mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 21:41:55 +00:00
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:
@@ -154,7 +154,7 @@ func ToMarketingDeliveryProductDTO(e entity.MarketingDeliveryProduct) MarketingD
|
||||
return MarketingDeliveryProductDTO{
|
||||
Id: e.Id,
|
||||
MarketingProductId: e.MarketingProductId,
|
||||
Qty: e.UsageQty,
|
||||
Qty: e.UsageQty + e.PendingQty,
|
||||
UnitPrice: e.UnitPrice,
|
||||
TotalWeight: e.TotalWeight,
|
||||
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
|
||||
if err := tx.WithContext(ctx).
|
||||
Table("marketing_delivery_products").
|
||||
Select("usage_qty").
|
||||
Select("usage_qty + pending_qty").
|
||||
Where("id = ?", deliveryProductID).
|
||||
Scan(&usageQty).Error; err != nil {
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user