mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 06:45:43 +00:00
feat[BE]: refine customer payment report structure by removing unused fields and enhancing query logic for better performance
This commit is contained in:
@@ -19,9 +19,7 @@ type CustomerPaymentReportRow struct {
|
||||
Weight float64 `json:"weight"`
|
||||
AverageWeight float64 `json:"average_weight"`
|
||||
Price float64 `json:"price"`
|
||||
CreditNote float64 `json:"credit_note"`
|
||||
FinalPrice float64 `json:"final_price"`
|
||||
PPN float64 `json:"ppn"`
|
||||
TotalPrice float64 `json:"total_price"`
|
||||
PaymentAmount float64 `json:"payment_amount"`
|
||||
AccountsReceivable float64 `json:"accounts_receivable"`
|
||||
@@ -35,10 +33,7 @@ type CustomerPaymentReportRow struct {
|
||||
type CustomerPaymentReportSummary struct {
|
||||
TotalQty float64 `json:"total_qty"`
|
||||
TotalWeight float64 `json:"total_weight"`
|
||||
TotalInitialAmount float64 `json:"total_initial_amount"`
|
||||
TotalCreditNote float64 `json:"total_credit_note"`
|
||||
TotalFinalAmount float64 `json:"total_final_amount"`
|
||||
TotalPPN float64 `json:"total_ppn"`
|
||||
TotalGrandAmount float64 `json:"total_grand_amount"`
|
||||
TotalPayment float64 `json:"total_payment"`
|
||||
TotalAccountsReceivable float64 `json:"total_accounts_receivable"`
|
||||
@@ -66,9 +61,7 @@ func ToCustomerPaymentReportRow(tx repportRepo.CustomerPaymentTransaction) Custo
|
||||
Weight: tx.Weight,
|
||||
AverageWeight: tx.AverageWeight,
|
||||
Price: tx.Price,
|
||||
CreditNote: tx.CreditNote,
|
||||
FinalPrice: tx.FinalPrice,
|
||||
PPN: tx.PPN,
|
||||
TotalPrice: tx.TotalPrice,
|
||||
PaymentAmount: tx.PaymentAmount,
|
||||
VehicleNumbers: parseStringSlice(tx.VehicleNumbers),
|
||||
@@ -101,11 +94,8 @@ func CalculateCustomerPaymentSummary(rows []CustomerPaymentReportRow, initialBal
|
||||
for _, row := range rows {
|
||||
summary.TotalQty += row.Qty
|
||||
summary.TotalWeight += row.Weight
|
||||
summary.TotalCreditNote += row.CreditNote
|
||||
summary.TotalPPN += row.PPN
|
||||
|
||||
if row.TransactionType == "SALES" {
|
||||
summary.TotalInitialAmount += row.TotalPrice
|
||||
summary.TotalFinalAmount += row.FinalPrice
|
||||
summary.TotalGrandAmount += row.TotalPrice
|
||||
} else if row.TransactionType == "PAYMENT" {
|
||||
@@ -113,10 +103,7 @@ func CalculateCustomerPaymentSummary(rows []CustomerPaymentReportRow, initialBal
|
||||
}
|
||||
}
|
||||
|
||||
// Formula: Total AR = Initial Balance - Total Sales + Total Payment
|
||||
// - Initial balance: positive (customer deposit)
|
||||
// - Sales: reduces balance (customer debt)
|
||||
// - Payment: increases balance (customer pays)
|
||||
// Total AR = Initial Balance - Total Sales + Total Payment
|
||||
summary.TotalAccountsReceivable = initialBalance - summary.TotalGrandAmount + summary.TotalPayment
|
||||
|
||||
return summary
|
||||
|
||||
Reference in New Issue
Block a user