complete structure revamp

This commit is contained in:
2025-10-07 14:46:31 +03:00
parent 0d800e014e
commit 1081f2cca6
11 changed files with 1009 additions and 377 deletions

49
api/helpers.go Normal file
View File

@@ -0,0 +1,49 @@
package api
func NewReceiptRow(name string, cnt int, price float64, taxgrp string) ReceiptRow {
return ReceiptRow{
Name: name,
Cnt: cnt,
Price: price,
Taxgrp: taxgrp,
}
}
func NewReceiptPayCash(sum float64, comment string) ReceiptPay {
return ReceiptPay{
Type: PayTypeCash,
Sum: sum,
Comment: comment,
}
}
func NewReceiptPayCard(sum float64, cardmask, bankID, rrnCode, authCode string) ReceiptPay {
return ReceiptPay{
Type: PayTypeCard,
Sum: sum,
Paysys: PaySystemParkingPos,
Cardmask: cardmask,
BankID: bankID,
Rrn: rrnCode,
AuthCode: authCode,
}
}
func CalculateReceiptSum(rows []ReceiptRow) float64 {
sum := 0.0
for _, row := range rows {
sum += (row.Price - row.Disc) * float64(row.Cnt)
}
return sum
}
func NewReceipt(rows []ReceiptRow, pays []ReceiptPay) Receipt {
return Receipt{
Sum: CalculateReceiptSum(rows),
Round: 0.00,
Disc: 0,
DiscType: 0,
Rows: rows,
Pays: pays,
}
}