Feat(BE-334):Fixing dto closing hpp expedisi

This commit is contained in:
ragilap
2025-12-18 16:02:57 +07:00
parent 3bfc401206
commit 14a4d9e944
4 changed files with 1 additions and 16 deletions
@@ -3,10 +3,7 @@ package dto
// ExpeditionCostItemDTO merepresentasikan biaya ekspedisi per vendor.
type ExpeditionCostItemDTO struct {
Id uint64 `json:"id"`
ExpeditionVendorID uint64 `json:"expedition_vendor_id"`
ExpeditionVendorName string `json:"expedition_vendor_name"`
Qty float64 `json:"qty"`
UnitPrice float64 `json:"unit_price"`
HPPAmount float64 `json:"hpp_amount"`
}
@@ -15,4 +12,3 @@ type ExpeditionHPPDTO struct {
ExpeditionCosts []ExpeditionCostItemDTO `json:"expedition_costs"`
TotalHPPAmount float64 `json:"total_hpp_amount"`
}
@@ -55,9 +55,7 @@ type SapronakRow struct {
}
type ExpeditionHPPRow struct {
SupplierID uint64 `gorm:"column:supplier_id"`
SupplierName string `gorm:"column:supplier_name"`
Qty float64 `gorm:"column:qty"`
TotalAmount float64 `gorm:"column:total_amount"`
}
@@ -147,7 +145,6 @@ func (r *ClosingRepositoryImpl) GetExpeditionHPP(ctx context.Context, projectFlo
Select(
"e.supplier_id AS supplier_id, " +
"s.name AS supplier_name, " +
"SUM(er.qty) AS qty, " +
"SUM(er.qty * er.price) AS total_amount",
).
Group("e.supplier_id, s.name").
@@ -645,4 +642,4 @@ func (r *ClosingRepositoryImpl) FetchSapronakTransfers(ctx context.Context, kand
return fmt.Sprintf("TRF-%d", row.ID)
})
return in, out, nil
}
}
@@ -398,17 +398,9 @@ func (s closingService) GetExpeditionHPP(c *fiber.Ctx, projectFlockID uint, proj
var totalHPP float64
for idx, row := range rows {
unitPrice := 0.0
if row.Qty > 0 {
unitPrice = row.TotalAmount / row.Qty
}
expeditionCosts = append(expeditionCosts, dto.ExpeditionCostItemDTO{
Id: uint64(idx + 1),
ExpeditionVendorID: row.SupplierID,
ExpeditionVendorName: row.SupplierName,
Qty: row.Qty,
UnitPrice: unitPrice,
HPPAmount: row.TotalAmount,
})