mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 15:25:43 +00:00
[FEAT/BE] Add filter delivery order and adjust response purchase
This commit is contained in:
@@ -25,17 +25,17 @@ type PurchaseRelationDTO struct {
|
||||
|
||||
type PurchaseListDTO struct {
|
||||
PurchaseRelationDTO
|
||||
Supplier *supplierDTO.SupplierRelationDTO `json:"supplier"`
|
||||
DueDate *time.Time `json:"due_date"`
|
||||
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
|
||||
RequesterName string `json:"requester_name"`
|
||||
PoExpedition []string `json:"po_expedition"`
|
||||
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"`
|
||||
Supplier *supplierDTO.SupplierRelationDTO `json:"supplier"`
|
||||
DueDate *time.Time `json:"due_date"`
|
||||
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
|
||||
RequesterName string `json:"requester_name"`
|
||||
PoExpedition []PoExpeditionDTO `json:"po_expedition"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type PurchaseDetailDTO struct {
|
||||
@@ -69,6 +69,11 @@ type PurchaseItemDTO struct {
|
||||
ExpeditionVendor *supplierDTO.SupplierRelationDTO `json:"expedition_vendor,omitempty"`
|
||||
}
|
||||
|
||||
type PoExpeditionDTO struct {
|
||||
Id uint64 `json:"id"`
|
||||
Refrence string `json:"refrence"`
|
||||
}
|
||||
|
||||
func ToPurchaseRelationDTO(p *entity.Purchase) PurchaseRelationDTO {
|
||||
return PurchaseRelationDTO{
|
||||
Id: p.Id,
|
||||
@@ -164,12 +169,12 @@ func ToPurchaseListDTO(p entity.Purchase) PurchaseListDTO {
|
||||
}
|
||||
|
||||
var (
|
||||
poExpedition []string
|
||||
poExpedition = make([]PoExpeditionDTO, 0)
|
||||
location *locationDTO.LocationRelationDTO
|
||||
area *areaDTO.AreaRelationDTO
|
||||
)
|
||||
productMap := make(map[uint]productDTO.ProductRelationDTO)
|
||||
expeditionRefSet := make(map[string]struct{})
|
||||
expeditionRefSet := make(map[uint64]struct{})
|
||||
for i := range p.Items {
|
||||
item := p.Items[i]
|
||||
if item.Product != nil && item.Product.Id != 0 {
|
||||
@@ -178,11 +183,15 @@ func ToPurchaseListDTO(p entity.Purchase) PurchaseListDTO {
|
||||
}
|
||||
}
|
||||
if item.ExpenseNonstock != nil && item.ExpenseNonstock.Expense != nil {
|
||||
ref := strings.TrimSpace(item.ExpenseNonstock.Expense.ReferenceNumber)
|
||||
if ref != "" {
|
||||
if _, exists := expeditionRefSet[ref]; !exists {
|
||||
expeditionRefSet[ref] = struct{}{}
|
||||
poExpedition = append(poExpedition, ref)
|
||||
exp := item.ExpenseNonstock.Expense
|
||||
ref := strings.TrimSpace(exp.ReferenceNumber)
|
||||
if exp.Id != 0 && ref != "" {
|
||||
if _, exists := expeditionRefSet[exp.Id]; !exists {
|
||||
expeditionRefSet[exp.Id] = struct{}{}
|
||||
poExpedition = append(poExpedition, PoExpeditionDTO{
|
||||
Id: exp.Id,
|
||||
Refrence: ref,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user