mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 14:55:42 +00:00
adjust export format purchase and filter
This commit is contained in:
@@ -32,12 +32,15 @@ type PurchaseListDTO struct {
|
||||
RequesterName string `json:"requester_name"`
|
||||
PoExpedition []PoExpeditionDTO `json:"po_expedition"`
|
||||
Items []PurchaseItemDTO `json:"items"`
|
||||
Products []productDTO.ProductRelationDTO `json:"products"`
|
||||
Location *locationDTO.LocationRelationDTO `json:"location"`
|
||||
Area *areaDTO.AreaRelationDTO `json:"area"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
LatestApproval *approvalDTO.ApprovalRelationDTO `json:"latest_approval"`
|
||||
Products []productDTO.ProductRelationDTO `json:"products"`
|
||||
Location *locationDTO.LocationRelationDTO `json:"location"`
|
||||
Area *areaDTO.AreaRelationDTO `json:"area"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
LatestApproval *approvalDTO.ApprovalRelationDTO `json:"latest_approval"`
|
||||
ProductsTotal float64 `json:"products_total"`
|
||||
ExpeditionTotal float64 `json:"expedition_total"`
|
||||
GrandTotalAll float64 `json:"grand_total_all"`
|
||||
}
|
||||
|
||||
type PurchaseDetailDTO struct {
|
||||
@@ -69,6 +72,8 @@ type PurchaseItemDTO struct {
|
||||
VehicleNumber *string `json:"vehicle_number"`
|
||||
TransportPerItem *float64 `json:"transport_per_item,omitempty"`
|
||||
ExpeditionVendor *supplierDTO.SupplierRelationDTO `json:"expedition_vendor,omitempty"`
|
||||
ExpeditionQty float64 `json:"expedition_qty"`
|
||||
ExpeditionTotal float64 `json:"expedition_total"`
|
||||
HasChickin bool `json:"has_chickin"`
|
||||
}
|
||||
|
||||
@@ -127,6 +132,8 @@ func ToPurchaseItemDTO(item entity.PurchaseItem) PurchaseItemDTO {
|
||||
if item.ExpenseNonstock != nil {
|
||||
priceCopy := item.ExpenseNonstock.Price
|
||||
dto.TransportPerItem = &priceCopy
|
||||
dto.ExpeditionQty = item.ExpenseNonstock.Qty
|
||||
dto.ExpeditionTotal = item.ExpenseNonstock.Qty * item.ExpenseNonstock.Price
|
||||
|
||||
if item.ExpenseNonstock.Expense != nil {
|
||||
exp := item.ExpenseNonstock.Expense
|
||||
@@ -173,15 +180,21 @@ func ToPurchaseListDTO(p entity.Purchase) PurchaseListDTO {
|
||||
}
|
||||
|
||||
var (
|
||||
poExpedition = make([]PoExpeditionDTO, 0)
|
||||
location *locationDTO.LocationRelationDTO
|
||||
area *areaDTO.AreaRelationDTO
|
||||
receivedDate *time.Time
|
||||
poExpedition = make([]PoExpeditionDTO, 0)
|
||||
location *locationDTO.LocationRelationDTO
|
||||
area *areaDTO.AreaRelationDTO
|
||||
receivedDate *time.Time
|
||||
productsTotal float64
|
||||
expeditionTotal float64
|
||||
)
|
||||
productMap := make(map[uint]productDTO.ProductRelationDTO)
|
||||
expeditionRefSet := make(map[uint64]struct{})
|
||||
for i := range p.Items {
|
||||
item := p.Items[i]
|
||||
productsTotal += item.TotalPrice
|
||||
if item.ExpenseNonstock != nil {
|
||||
expeditionTotal += item.ExpenseNonstock.Qty * item.ExpenseNonstock.Price
|
||||
}
|
||||
if item.Product != nil && item.Product.Id != 0 {
|
||||
if _, exists := productMap[item.Product.Id]; !exists {
|
||||
productMap[item.Product.Id] = productDTO.ToProductRelationDTO(*item.Product)
|
||||
@@ -235,6 +248,9 @@ func ToPurchaseListDTO(p entity.Purchase) PurchaseListDTO {
|
||||
CreatedAt: p.CreatedAt,
|
||||
UpdatedAt: p.UpdatedAt,
|
||||
LatestApproval: latestApproval,
|
||||
ProductsTotal: productsTotal,
|
||||
ExpeditionTotal: expeditionTotal,
|
||||
GrandTotalAll: productsTotal + expeditionTotal,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user