mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'fix/pay' into 'development'
[FIX][BE]: adjust calculate total price marketing ayam pullet See merge request mbugroup/lti-api!533
This commit is contained in:
@@ -770,7 +770,12 @@ func (s salesOrdersService) Approval(c *fiber.Ctx, req *validation.Approve) ([]e
|
|||||||
|
|
||||||
func (s *salesOrdersService) createMarketingProductWithDelivery(ctx context.Context, marketingId uint, marketingType string, rp validation.CreateMarketingProduct, marketingProductRepo repository.MarketingProductRepository, invDeliveryRepo repository.MarketingDeliveryProductRepository) error {
|
func (s *salesOrdersService) createMarketingProductWithDelivery(ctx context.Context, marketingId uint, marketingType string, rp validation.CreateMarketingProduct, marketingProductRepo repository.MarketingProductRepository, invDeliveryRepo repository.MarketingDeliveryProductRepository) error {
|
||||||
|
|
||||||
totalWeight, totalPrice := s.calculatePriceByMarketingType(
|
var totalWeight, totalPrice float64
|
||||||
|
if rp.TotalPrice != nil {
|
||||||
|
totalWeight = math.Round(rp.Qty*rp.AvgWeight*100) / 100
|
||||||
|
totalPrice = *rp.TotalPrice
|
||||||
|
} else {
|
||||||
|
totalWeight, totalPrice = s.calculatePriceByMarketingType(
|
||||||
marketingType,
|
marketingType,
|
||||||
rp.Qty,
|
rp.Qty,
|
||||||
rp.AvgWeight,
|
rp.AvgWeight,
|
||||||
@@ -779,6 +784,7 @@ func (s *salesOrdersService) createMarketingProductWithDelivery(ctx context.Cont
|
|||||||
rp.ConvertionUnit,
|
rp.ConvertionUnit,
|
||||||
rp.WeightPerConvertion,
|
rp.WeightPerConvertion,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
marketingProduct := &entity.MarketingProduct{
|
marketingProduct := &entity.MarketingProduct{
|
||||||
MarketingId: marketingId,
|
MarketingId: marketingId,
|
||||||
@@ -821,7 +827,7 @@ func (s *salesOrdersService) calculatePriceByMarketingType(marketingType string,
|
|||||||
totalPrice = math.Round(qty*unitPrice*100) / 100
|
totalPrice = math.Round(qty*unitPrice*100) / 100
|
||||||
} else if marketingType == string(utils.MarketingTypeAyamPullet) && week != nil && *week > 0 {
|
} else if marketingType == string(utils.MarketingTypeAyamPullet) && week != nil && *week > 0 {
|
||||||
totalWeight = math.Round(qty*avgWeight*100) / 100
|
totalWeight = math.Round(qty*avgWeight*100) / 100
|
||||||
totalPrice = math.Round(unitPrice*float64(*week)*qty*100) / 100
|
totalPrice = math.Round(totalWeight*unitPrice*100) / 100
|
||||||
} else {
|
} else {
|
||||||
totalWeight = math.Round(qty*avgWeight*100) / 100
|
totalWeight = math.Round(qty*avgWeight*100) / 100
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type CreateMarketingProduct struct {
|
|||||||
UnitPrice float64 `json:"unit_price" validate:"required,gt=0"`
|
UnitPrice float64 `json:"unit_price" validate:"required,gt=0"`
|
||||||
Qty float64 `json:"qty" validate:"required,gt=0"`
|
Qty float64 `json:"qty" validate:"required,gt=0"`
|
||||||
AvgWeight float64 `json:"avg_weight" validate:"omitempty,gt=0"`
|
AvgWeight float64 `json:"avg_weight" validate:"omitempty,gt=0"`
|
||||||
|
TotalPrice *float64 `json:"total_price" validate:"omitempty,gt=0"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Update struct {
|
type Update struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user