mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 23:05:44 +00:00
FIX[BE] : fixing typografical error on report marketing
This commit is contained in:
@@ -1,12 +1,16 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||||
marketingDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/marketing/dto"
|
marketingDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/marketing/dto"
|
||||||
customerDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/customers/dto"
|
customerDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/customers/dto"
|
||||||
|
productCategoryDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/product-categories/dto"
|
||||||
productDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/products/dto"
|
productDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/products/dto"
|
||||||
|
supplierDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/suppliers/dto"
|
||||||
|
uomDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/uoms/dto"
|
||||||
warehouseDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/warehouses/dto"
|
warehouseDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/warehouses/dto"
|
||||||
userDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/users/dto"
|
userDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/users/dto"
|
||||||
"gitlab.com/mbugroup/lti-api.git/internal/utils"
|
"gitlab.com/mbugroup/lti-api.git/internal/utils"
|
||||||
@@ -22,7 +26,7 @@ type RepportMarketingItemDTO struct {
|
|||||||
DoNumber string `json:"do_number"`
|
DoNumber string `json:"do_number"`
|
||||||
Sales *userDTO.UserRelationDTO `json:"sales,omitempty"`
|
Sales *userDTO.UserRelationDTO `json:"sales,omitempty"`
|
||||||
VehicleNumber string `json:"vehicle_number"`
|
VehicleNumber string `json:"vehicle_number"`
|
||||||
Product *productDTO.ProductRelationDTO `json:"product,omitempty"`
|
Product *ProductRelationDTOFixed `json:"product,omitempty"`
|
||||||
MarketingType string `json:"marketing_type"`
|
MarketingType string `json:"marketing_type"`
|
||||||
Qty float64 `json:"qty"`
|
Qty float64 `json:"qty"`
|
||||||
AverageWeightKg float64 `json:"average_weight_kg"`
|
AverageWeightKg float64 `json:"average_weight_kg"`
|
||||||
@@ -46,6 +50,12 @@ type RepportMarketingResponseDTO struct {
|
|||||||
Total *Summary `json:"total,omitempty"`
|
Total *Summary `json:"total,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ProductRelationDTOFixed struct {
|
||||||
|
productDTO.ProductRelationDTO
|
||||||
|
ProductPrice float64 `json:"product_price"`
|
||||||
|
SellingPrice *float64 `json:"selling_price,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
func ToRepportMarketingItemDTO(mdp entity.MarketingDeliveryProduct, hppPricePerKg float64, category string) RepportMarketingItemDTO {
|
func ToRepportMarketingItemDTO(mdp entity.MarketingDeliveryProduct, hppPricePerKg float64, category string) RepportMarketingItemDTO {
|
||||||
soDate := time.Time{}
|
soDate := time.Time{}
|
||||||
agingDays := 0
|
agingDays := 0
|
||||||
@@ -106,7 +116,7 @@ func ToRepportMarketingItemDTO(mdp entity.MarketingDeliveryProduct, hppPricePerK
|
|||||||
|
|
||||||
if mdp.MarketingProduct.ProductWarehouse.ProductId != 0 {
|
if mdp.MarketingProduct.ProductWarehouse.ProductId != 0 {
|
||||||
mapped := productDTO.ToProductRelationDTO(mdp.MarketingProduct.ProductWarehouse.Product)
|
mapped := productDTO.ToProductRelationDTO(mdp.MarketingProduct.ProductWarehouse.Product)
|
||||||
item.Product = &mapped
|
item.Product = newProductRelationDTOFixedPtr(&mapped)
|
||||||
}
|
}
|
||||||
|
|
||||||
return item
|
return item
|
||||||
@@ -259,3 +269,39 @@ func ToRepportMarketingResponseDTO(mdps []entity.MarketingDeliveryProduct, hppPr
|
|||||||
Total: total,
|
Total: total,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newProductRelationDTOFixedPtr(original *productDTO.ProductRelationDTO) *ProductRelationDTOFixed {
|
||||||
|
if original == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
fixed := ProductRelationDTOFixed{
|
||||||
|
ProductRelationDTO: *original,
|
||||||
|
ProductPrice: original.ProductPrice,
|
||||||
|
SellingPrice: original.SellingPrice,
|
||||||
|
}
|
||||||
|
return &fixed
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p ProductRelationDTOFixed) MarshalJSON() ([]byte, error) {
|
||||||
|
type Alias struct {
|
||||||
|
Id uint `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
ProductPrice float64 `json:"product_price"`
|
||||||
|
SellingPrice *float64 `json:"selling_price"`
|
||||||
|
Uom *uomDTO.UomRelationDTO `json:"uom,omitempty"`
|
||||||
|
Flags *[]string `json:"flags,omitempty"`
|
||||||
|
ProductCategory *productCategoryDTO.ProductCategoryRelationDTO `json:"product_category,omitempty"`
|
||||||
|
Suppliers []supplierDTO.SupplierRelationDTO `json:"suppliers"`
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(&Alias{
|
||||||
|
Id: p.ProductRelationDTO.Id,
|
||||||
|
Name: p.ProductRelationDTO.Name,
|
||||||
|
ProductPrice: p.ProductPrice,
|
||||||
|
SellingPrice: p.SellingPrice,
|
||||||
|
Uom: p.ProductRelationDTO.Uom,
|
||||||
|
Flags: p.ProductRelationDTO.Flags,
|
||||||
|
ProductCategory: p.ProductRelationDTO.ProductCategory,
|
||||||
|
Suppliers: p.ProductRelationDTO.Suppliers,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user