mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 07:45:44 +00:00
fix perhitunga sapronak
This commit is contained in:
@@ -153,6 +153,20 @@ func ToSapronakProjectAggregatedFromReport(report *SapronakReportDTO, flag strin
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
normalizeCutOverToken := func(raw string) string {
|
||||
normalized := strings.ToUpper(strings.TrimSpace(raw))
|
||||
normalized = strings.ReplaceAll(normalized, "-", "")
|
||||
normalized = strings.ReplaceAll(normalized, " ", "")
|
||||
return normalized
|
||||
}
|
||||
containsCutOver := func(values ...string) bool {
|
||||
for _, value := range values {
|
||||
if strings.Contains(normalizeCutOverToken(value), "CUTOVER") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
filter := normalizeFlag(flag)
|
||||
|
||||
byFlag := map[string]**SapronakCategoryDTO{}
|
||||
@@ -258,6 +272,7 @@ func ToSapronakProjectAggregatedFromReport(report *SapronakReportDTO, flag strin
|
||||
UnitPrice: item.Harga,
|
||||
Notes: "-",
|
||||
}
|
||||
isCutOver := containsCutOver(baseRow.ProductCategory, baseRow.Description, item.ProductName)
|
||||
|
||||
row := getOrCreateRow(productKey, baseRow)
|
||||
|
||||
@@ -289,11 +304,21 @@ func ToSapronakProjectAggregatedFromReport(report *SapronakReportDTO, flag strin
|
||||
}
|
||||
row.QtyUsed += item.QtyKeluar
|
||||
row.TotalAmount += item.QtyKeluar * price
|
||||
case "adjustment keluar", "mutasi keluar", "penjualan":
|
||||
case "adjustment keluar":
|
||||
price := row.UnitPrice
|
||||
if price == 0 {
|
||||
price = item.Harga
|
||||
}
|
||||
if row.UnitPrice == 0 {
|
||||
row.UnitPrice = price
|
||||
}
|
||||
if isCutOver {
|
||||
row.QtyUsed += item.QtyKeluar
|
||||
row.TotalAmount += item.QtyKeluar * price
|
||||
continue
|
||||
}
|
||||
row.QtyOut += item.QtyKeluar
|
||||
case "mutasi keluar", "penjualan":
|
||||
row.QtyOut += item.QtyKeluar
|
||||
if strings.ToLower(item.JenisTransaksi) == "mutasi keluar" {
|
||||
ref := strings.ToUpper(strings.TrimSpace(item.NoReferensi))
|
||||
|
||||
Reference in New Issue
Block a user