mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-06-09 15:07:49 +00:00
fix: use soDate instead of deliveryDate for Delivery Order rows in marketing export
In the Excel export, Delivery Order rows were writing `group.DeliveryDate`
(the actual delivery date) to column B ("Tanggal"), while the web UI always
shows `so_date` for every row. This caused a visible mismatch — e.g. DO-01954
displayed "31 Mei 2026" on the web but "01-06-2026" in the exported file.
Changes:
- Remove the `doDate` variable from the DO branch; both the empty-deliveries
fallback row and each per-delivery row now write `soDate` to column B,
consistent with what the web shows
- Fix a pre-existing nil pointer dereference: `prod.ProductWarehouse.Warehouse`
was accessed without a nil guard in the SO branch
- Update the export test to match the current 17-column layout (headers and
row assertions were stale), and add a regression case that explicitly
asserts a DO row with soDate=2026-05-31 / deliveryDate=2026-06-01 produces
"31-05-2026" in column B
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -201,11 +201,6 @@ func setMarketingExportRows(file *excelize.File, sheet string, items []dto.Marke
|
||||
for _, group := range item.DeliveryOrder {
|
||||
doNumber := safeMarketingExportText(group.DoNumber)
|
||||
|
||||
doDate := "-"
|
||||
if group.DeliveryDate != nil {
|
||||
doDate = formatMarketingExportDate(*group.DeliveryDate)
|
||||
}
|
||||
|
||||
gudang := "-"
|
||||
if group.Warehouse != nil {
|
||||
gudang = safeMarketingExportText(group.Warehouse.Name)
|
||||
@@ -215,7 +210,7 @@ func setMarketingExportRows(file *excelize.File, sheet string, items []dto.Marke
|
||||
row++
|
||||
r := strconv.Itoa(row)
|
||||
vals := map[string]interface{}{
|
||||
"A": doNumber, "B": doDate, "C": status, "D": customer, "E": salesPerson,
|
||||
"A": doNumber, "B": soDate, "C": status, "D": customer, "E": salesPerson,
|
||||
"F": "-", "G": "-", "H": gudang, "I": "-", "J": "-", "K": "-",
|
||||
"L": "-", "M": "-", "N": "-", "O": "-",
|
||||
"P": grandTotal, "Q": notes,
|
||||
@@ -251,7 +246,7 @@ func setMarketingExportRows(file *excelize.File, sheet string, items []dto.Marke
|
||||
if err := file.SetCellValue(sheet, "A"+r, doNumber); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := file.SetCellValue(sheet, "B"+r, doDate); err != nil {
|
||||
if err := file.SetCellValue(sheet, "B"+r, soDate); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := file.SetCellValue(sheet, "C"+r, status); err != nil {
|
||||
@@ -347,7 +342,7 @@ func setMarketingExportRows(file *excelize.File, sheet string, items []dto.Marke
|
||||
}
|
||||
|
||||
gudang := "-"
|
||||
if prod.ProductWarehouse != nil {
|
||||
if prod.ProductWarehouse != nil && prod.ProductWarehouse.Warehouse != nil {
|
||||
gudang = safeMarketingExportText(prod.ProductWarehouse.Warehouse.Name)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user