add kolom lokasi to export

This commit is contained in:
giovanni
2026-04-23 13:49:51 +07:00
parent c744043321
commit 151edf578e
2 changed files with 57 additions and 28 deletions
@@ -79,10 +79,11 @@ func setPurchaseExportColumns(file *excelize.File, sheet string) error {
"B": 16,
"C": 14,
"D": 22,
"E": 18,
"E": 22,
"F": 18,
"G": 52,
"H": 24,
"G": 18,
"H": 52,
"I": 24,
}
for col, width := range columnWidths {
@@ -103,6 +104,7 @@ func setPurchaseExportHeaders(file *excelize.File, sheet string) error {
"PO Number",
"Tanggal PO",
"Supplier",
"Lokasi",
"Status",
"Grand Total",
"Products",
@@ -134,7 +136,7 @@ func setPurchaseExportHeaders(file *excelize.File, sheet string) error {
return err
}
return file.SetCellStyle(sheet, "A1", "H1", headerStyle)
return file.SetCellStyle(sheet, "A1", "I1", headerStyle)
}
func setPurchaseExportRows(file *excelize.File, sheet string, items []dto.PurchaseListDTO, grandTotals map[uint]float64) error {
@@ -156,16 +158,19 @@ func setPurchaseExportRows(file *excelize.File, sheet string, items []dto.Purcha
if err := file.SetCellValue(sheet, "D"+row, safePurchaseSupplierName(item)); err != nil {
return err
}
if err := file.SetCellValue(sheet, "E"+row, formatPurchaseExportStatus(item)); err != nil {
if err := file.SetCellValue(sheet, "E"+row, safePurchaseLocationName(item)); err != nil {
return err
}
if err := file.SetCellValue(sheet, "F"+row, formatPurchaseRupiah(grandTotals[item.Id])); err != nil {
if err := file.SetCellValue(sheet, "F"+row, formatPurchaseExportStatus(item)); err != nil {
return err
}
if err := file.SetCellValue(sheet, "G"+row, formatPurchaseProducts(item)); err != nil {
if err := file.SetCellValue(sheet, "G"+row, formatPurchaseRupiah(grandTotals[item.Id])); err != nil {
return err
}
if err := file.SetCellValue(sheet, "H"+row, safePurchaseExportPointerText(item.Notes)); err != nil {
if err := file.SetCellValue(sheet, "H"+row, formatPurchaseProducts(item)); err != nil {
return err
}
if err := file.SetCellValue(sheet, "I"+row, safePurchaseExportPointerText(item.Notes)); err != nil {
return err
}
}
@@ -187,7 +192,7 @@ func setPurchaseExportRows(file *excelize.File, sheet string, items []dto.Purcha
if err != nil {
return err
}
if err := file.SetCellStyle(sheet, "A2", "H"+strconv.Itoa(lastRow), dataStyle); err != nil {
if err := file.SetCellStyle(sheet, "A2", "I"+strconv.Itoa(lastRow), dataStyle); err != nil {
return err
}
@@ -207,7 +212,7 @@ func setPurchaseExportRows(file *excelize.File, sheet string, items []dto.Purcha
return err
}
return file.SetCellStyle(sheet, "F2", "F"+strconv.Itoa(lastRow), moneyStyle)
return file.SetCellStyle(sheet, "G2", "G"+strconv.Itoa(lastRow), moneyStyle)
}
func buildPurchaseGrandTotalMap(items []entity.Purchase) map[uint]float64 {
@@ -229,6 +234,13 @@ func safePurchaseSupplierName(item dto.PurchaseListDTO) string {
return safePurchaseExportText(item.Supplier.Name)
}
func safePurchaseLocationName(item dto.PurchaseListDTO) string {
if item.Location == nil {
return "-"
}
return safePurchaseExportText(item.Location.Name)
}
func formatPurchaseExportStatus(item dto.PurchaseListDTO) string {
if item.LatestApproval == nil {
return "-"