mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 07:45:44 +00:00
FEAT[BE] :add marketing type field to delivery and sales order DTOs, enhance validation and service logic for consistent marketing type handling
This commit is contained in:
@@ -2,6 +2,7 @@ package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
@@ -79,6 +80,7 @@ type DeliveryMarketingProductDTO struct {
|
||||
Id uint `json:"id"`
|
||||
MarketingId uint `json:"marketing_id"`
|
||||
ProductWarehouseId uint `json:"product_warehouse_id"`
|
||||
MarketingType string `json:"marketing_type"`
|
||||
Qty float64 `json:"qty"`
|
||||
UnitPrice float64 `json:"unit_price"`
|
||||
AvgWeight float64 `json:"avg_weight"`
|
||||
@@ -111,7 +113,7 @@ func ToDeliveryMarketingProductDTO(e entity.MarketingProduct, marketingType stri
|
||||
// Calculate total_peti only for TELUR marketing type
|
||||
var totalPeti *float64
|
||||
if marketingType == "TELUR" && e.ConvertionUnit != nil && *e.ConvertionUnit == "PETI" && e.WeightPerConvertion != nil && *e.WeightPerConvertion > 0 {
|
||||
calculated := e.TotalWeight / *e.WeightPerConvertion
|
||||
calculated := math.Floor(e.TotalWeight / *e.WeightPerConvertion)
|
||||
totalPeti = &calculated
|
||||
}
|
||||
|
||||
@@ -119,6 +121,7 @@ func ToDeliveryMarketingProductDTO(e entity.MarketingProduct, marketingType stri
|
||||
Id: e.Id,
|
||||
MarketingId: e.MarketingId,
|
||||
ProductWarehouseId: e.ProductWarehouseId,
|
||||
MarketingType: marketingType,
|
||||
Qty: e.Qty,
|
||||
UnitPrice: e.UnitPrice,
|
||||
AvgWeight: e.AvgWeight,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
|
||||
type MarketingProductDTO struct {
|
||||
Id uint `json:"id"`
|
||||
MarketingType string `json:"marketing_type"`
|
||||
Qty float64 `json:"qty"`
|
||||
UnitPrice float64 `json:"unit_price"`
|
||||
AvgWeight float64 `json:"avg_weight"`
|
||||
@@ -44,12 +46,13 @@ func ToMarketingProductDTO(e entity.MarketingProduct, marketingType string) Mark
|
||||
// Calculate total_peti only for TELUR marketing type
|
||||
var totalPeti *float64
|
||||
if marketingType == "TELUR" && e.ConvertionUnit != nil && *e.ConvertionUnit == "PETI" && e.WeightPerConvertion != nil && *e.WeightPerConvertion > 0 {
|
||||
calculated := e.TotalWeight / *e.WeightPerConvertion
|
||||
calculated := math.Floor(e.TotalWeight / *e.WeightPerConvertion)
|
||||
totalPeti = &calculated
|
||||
}
|
||||
|
||||
return MarketingProductDTO{
|
||||
Id: e.Id,
|
||||
MarketingType: marketingType,
|
||||
Qty: e.Qty,
|
||||
UnitPrice: e.UnitPrice,
|
||||
AvgWeight: e.AvgWeight,
|
||||
|
||||
Reference in New Issue
Block a user