mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 15:55:44 +00:00
Feat(BE-334):Fixing dto closing hpp expedisi
This commit is contained in:
@@ -3,10 +3,7 @@ package dto
|
|||||||
// ExpeditionCostItemDTO merepresentasikan biaya ekspedisi per vendor.
|
// ExpeditionCostItemDTO merepresentasikan biaya ekspedisi per vendor.
|
||||||
type ExpeditionCostItemDTO struct {
|
type ExpeditionCostItemDTO struct {
|
||||||
Id uint64 `json:"id"`
|
Id uint64 `json:"id"`
|
||||||
ExpeditionVendorID uint64 `json:"expedition_vendor_id"`
|
|
||||||
ExpeditionVendorName string `json:"expedition_vendor_name"`
|
ExpeditionVendorName string `json:"expedition_vendor_name"`
|
||||||
Qty float64 `json:"qty"`
|
|
||||||
UnitPrice float64 `json:"unit_price"`
|
|
||||||
HPPAmount float64 `json:"hpp_amount"`
|
HPPAmount float64 `json:"hpp_amount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,4 +12,3 @@ type ExpeditionHPPDTO struct {
|
|||||||
ExpeditionCosts []ExpeditionCostItemDTO `json:"expedition_costs"`
|
ExpeditionCosts []ExpeditionCostItemDTO `json:"expedition_costs"`
|
||||||
TotalHPPAmount float64 `json:"total_hpp_amount"`
|
TotalHPPAmount float64 `json:"total_hpp_amount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,7 @@ type SapronakRow struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ExpeditionHPPRow struct {
|
type ExpeditionHPPRow struct {
|
||||||
SupplierID uint64 `gorm:"column:supplier_id"`
|
|
||||||
SupplierName string `gorm:"column:supplier_name"`
|
SupplierName string `gorm:"column:supplier_name"`
|
||||||
Qty float64 `gorm:"column:qty"`
|
|
||||||
TotalAmount float64 `gorm:"column:total_amount"`
|
TotalAmount float64 `gorm:"column:total_amount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +145,6 @@ func (r *ClosingRepositoryImpl) GetExpeditionHPP(ctx context.Context, projectFlo
|
|||||||
Select(
|
Select(
|
||||||
"e.supplier_id AS supplier_id, " +
|
"e.supplier_id AS supplier_id, " +
|
||||||
"s.name AS supplier_name, " +
|
"s.name AS supplier_name, " +
|
||||||
"SUM(er.qty) AS qty, " +
|
|
||||||
"SUM(er.qty * er.price) AS total_amount",
|
"SUM(er.qty * er.price) AS total_amount",
|
||||||
).
|
).
|
||||||
Group("e.supplier_id, s.name").
|
Group("e.supplier_id, s.name").
|
||||||
|
|||||||
@@ -398,17 +398,9 @@ func (s closingService) GetExpeditionHPP(c *fiber.Ctx, projectFlockID uint, proj
|
|||||||
var totalHPP float64
|
var totalHPP float64
|
||||||
|
|
||||||
for idx, row := range rows {
|
for idx, row := range rows {
|
||||||
unitPrice := 0.0
|
|
||||||
if row.Qty > 0 {
|
|
||||||
unitPrice = row.TotalAmount / row.Qty
|
|
||||||
}
|
|
||||||
|
|
||||||
expeditionCosts = append(expeditionCosts, dto.ExpeditionCostItemDTO{
|
expeditionCosts = append(expeditionCosts, dto.ExpeditionCostItemDTO{
|
||||||
Id: uint64(idx + 1),
|
Id: uint64(idx + 1),
|
||||||
ExpeditionVendorID: row.SupplierID,
|
|
||||||
ExpeditionVendorName: row.SupplierName,
|
ExpeditionVendorName: row.SupplierName,
|
||||||
Qty: row.Qty,
|
|
||||||
UnitPrice: unitPrice,
|
|
||||||
HPPAmount: row.TotalAmount,
|
HPPAmount: row.TotalAmount,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user