mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-21 13:55:43 +00:00
adjust export format purchase and filter
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -2,7 +2,6 @@ package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -197,9 +196,9 @@ func setMarketingReportRows(file *excelize.File, items []dto.RepportMarketingIte
|
||||
item.Qty,
|
||||
item.AverageWeightKg,
|
||||
item.TotalWeightKg,
|
||||
formatMarketingRupiah(item.SalesPricePerKg),
|
||||
formatMarketingRupiah(item.HppPricePerKg),
|
||||
formatMarketingRupiah(item.SalesAmount),
|
||||
item.SalesPricePerKg,
|
||||
item.HppPricePerKg,
|
||||
item.SalesAmount,
|
||||
}
|
||||
|
||||
for colIdx, val := range values {
|
||||
@@ -229,13 +228,13 @@ func setMarketingReportRows(file *excelize.File, items []dto.RepportMarketingIte
|
||||
if err := file.SetCellValue(sheet, "N"+totalRow, summary.TotalWeightKg); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := file.SetCellValue(sheet, "O"+totalRow, formatMarketingRupiah(summary.AverageSalesPrice)); err != nil {
|
||||
if err := file.SetCellValue(sheet, "O"+totalRow, summary.AverageSalesPrice); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := file.SetCellValue(sheet, "P"+totalRow, formatMarketingRupiah(summary.TotalHppPricePerKg)); err != nil {
|
||||
if err := file.SetCellValue(sheet, "P"+totalRow, summary.TotalHppPricePerKg); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := file.SetCellValue(sheet, "Q"+totalRow, formatMarketingRupiah(float64(summary.TotalSalesAmount))); err != nil {
|
||||
if err := file.SetCellValue(sheet, "Q"+totalRow, float64(summary.TotalSalesAmount)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -333,30 +332,3 @@ func safeMarketingExportText(value string) string {
|
||||
return trimmed
|
||||
}
|
||||
|
||||
// formatMarketingRupiah formats a float64 as Indonesian Rupiah string.
|
||||
// e.g. 1000000 → "Rp 1.000.000"
|
||||
func formatMarketingRupiah(value float64) string {
|
||||
rounded := int64(math.Round(value))
|
||||
|
||||
negative := rounded < 0
|
||||
abs := rounded
|
||||
if negative {
|
||||
abs = -rounded
|
||||
}
|
||||
|
||||
numStr := strconv.FormatInt(abs, 10)
|
||||
n := len(numStr)
|
||||
|
||||
var b strings.Builder
|
||||
for i, c := range numStr {
|
||||
if i > 0 && (n-i)%3 == 0 {
|
||||
b.WriteByte('.')
|
||||
}
|
||||
b.WriteRune(c)
|
||||
}
|
||||
|
||||
if negative {
|
||||
return "Rp -" + b.String()
|
||||
}
|
||||
return "Rp " + b.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user