adjust export format purchase and filter

This commit is contained in:
giovanni
2026-05-21 11:48:24 +07:00
parent 71e80634b1
commit 495f5f5cc1
12 changed files with 679 additions and 264 deletions
@@ -214,8 +214,7 @@ func writeCustomerPaymentSheet(file *excelize.File, sheet string, item dto.Custo
}
// Row 2: saldo awal
initialFormatted := formatCPRupiah(item.InitialBalance)
if err := file.SetCellValue(sheet, "N2", initialFormatted); err != nil {
if err := file.SetCellValue(sheet, "N2", item.InitialBalance); err != nil {
return err
}
if item.InitialBalance < 0 {
@@ -248,14 +247,14 @@ func writeCustomerPaymentSheet(file *excelize.File, sheet string, item dto.Custo
totalRowNum := len(item.Rows) + 3
totalRowStr := fmt.Sprintf("%d", totalRowNum)
totalCells := map[string]string{
totalCells := map[string]interface{}{
"A": "Total",
"G": formatCPIDInteger(item.Summary.TotalQty),
"H": formatCPIDInteger(item.Summary.TotalWeight),
"K": formatCPRupiah(item.Summary.TotalFinalAmount),
"L": formatCPRupiah(item.Summary.TotalGrandAmount),
"M": formatCPRupiah(item.Summary.TotalPayment),
"N": formatCPRupiah(item.Summary.TotalAccountsReceivable),
"K": item.Summary.TotalFinalAmount,
"L": item.Summary.TotalGrandAmount,
"M": item.Summary.TotalPayment,
"N": item.Summary.TotalAccountsReceivable,
}
for col, val := range totalCells {
if err := file.SetCellValue(sheet, col+totalRowStr, val); err != nil {
@@ -369,8 +368,7 @@ func writeCustomerPaymentAllRows(file *excelize.File, sheet string, items []dto.
if err := file.SetCellValue(sheet, "A"+saldoStr, name); err != nil {
return err
}
initialFormatted := formatCPRupiah(item.InitialBalance)
if err := file.SetCellValue(sheet, "O"+saldoStr, initialFormatted); err != nil {
if err := file.SetCellValue(sheet, "O"+saldoStr, item.InitialBalance); err != nil {
return err
}
if err := file.SetCellStyle(sheet, "A"+saldoStr, lastHeaderCol+saldoStr, dataStyle); err != nil {
@@ -409,15 +407,15 @@ func writeCustomerPaymentAllRows(file *excelize.File, sheet string, items []dto.
// Total row
totalStr := fmt.Sprintf("%d", currentRow)
totalCells := map[string]string{
totalCells := map[string]interface{}{
"A": name,
"B": "Total",
"H": formatCPIDInteger(item.Summary.TotalQty),
"I": formatCPIDInteger(item.Summary.TotalWeight),
"L": formatCPRupiah(item.Summary.TotalFinalAmount),
"M": formatCPRupiah(item.Summary.TotalGrandAmount),
"N": formatCPRupiah(item.Summary.TotalPayment),
"O": formatCPRupiah(item.Summary.TotalAccountsReceivable),
"L": item.Summary.TotalFinalAmount,
"M": item.Summary.TotalGrandAmount,
"N": item.Summary.TotalPayment,
"O": item.Summary.TotalAccountsReceivable,
}
for col, val := range totalCells {
if err := file.SetCellValue(sheet, col+totalStr, val); err != nil {
@@ -453,11 +451,11 @@ func customerPaymentRowCells(row dto.CustomerPaymentReportRow, seq int) []interf
formatCPIDInteger(row.Qty),
formatCPIDInteger(row.Weight),
formatCPAvg(row.AverageWeight),
formatCPRupiah(row.UnitPrice),
formatCPRupiah(row.FinalPrice),
formatCPRupiah(row.TotalPrice),
formatCPRupiah(row.PaymentAmount),
formatCPRupiah(row.AccountsReceivable),
row.UnitPrice,
row.FinalPrice,
row.TotalPrice,
row.PaymentAmount,
row.AccountsReceivable,
safeCPText(row.Status),
joinCPStrings(row.PickupInfo),
safeCPText(row.SalesPerson),
@@ -546,13 +544,6 @@ func formatCPIDInteger(v float64) string {
return b.String()
}
func formatCPRupiah(v float64) string {
const nbsp = " "
if v < 0 {
return "-Rp" + nbsp + formatCPIDInteger(-v)
}
return "Rp" + nbsp + formatCPIDInteger(v)
}
func formatCPAvg(v float64) string {
if v == 0 {