Merge branch 'codex/bulk-approve-marketings-expenses' into 'development'

fix: DTO mismatch marketings

See merge request mbugroup/lti-api!434
This commit is contained in:
Adnan Zahir
2026-04-22 11:49:44 +07:00
3 changed files with 24 additions and 2 deletions
@@ -154,7 +154,7 @@ func ToMarketingDeliveryProductDTO(e entity.MarketingDeliveryProduct) MarketingD
return MarketingDeliveryProductDTO{ return MarketingDeliveryProductDTO{
Id: e.Id, Id: e.Id,
MarketingProductId: e.MarketingProductId, MarketingProductId: e.MarketingProductId,
Qty: e.UsageQty, Qty: e.UsageQty + e.PendingQty,
UnitPrice: e.UnitPrice, UnitPrice: e.UnitPrice,
TotalWeight: e.TotalWeight, TotalWeight: e.TotalWeight,
AvgWeight: e.AvgWeight, AvgWeight: e.AvgWeight,
@@ -0,0 +1,22 @@
package dto
import (
"testing"
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
)
func TestToMarketingDeliveryProductDTOIncludesPendingQty(t *testing.T) {
input := entity.MarketingDeliveryProduct{
Id: 1,
MarketingProductId: 42,
UsageQty: 15,
PendingQty: 5,
}
got := ToMarketingDeliveryProductDTO(input)
if got.Qty != 20 {
t.Fatalf("expected qty to include pending quantity, got %.2f", got.Qty)
}
}
@@ -1303,7 +1303,7 @@ func (s deliveryOrdersService) resolveMarketingRequestedUsageQty(ctx context.Con
var usageQty float64 var usageQty float64
if err := tx.WithContext(ctx). if err := tx.WithContext(ctx).
Table("marketing_delivery_products"). Table("marketing_delivery_products").
Select("usage_qty"). Select("usage_qty + pending_qty").
Where("id = ?", deliveryProductID). Where("id = ?", deliveryProductID).
Scan(&usageQty).Error; err != nil { Scan(&usageQty).Error; err != nil {
return 0 return 0