mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 06:45:43 +00:00
fix(BE-273): add object nonstock and supplier in response get one and fix name base to relation in dto
This commit is contained in:
@@ -13,52 +13,52 @@ import (
|
||||
)
|
||||
|
||||
type PurchaseListItemDTO struct {
|
||||
Id uint64 `json:"id"`
|
||||
PrNumber string `json:"pr_number"`
|
||||
PoNumber *string `json:"po_number"`
|
||||
Supplier *supplierDTO.SupplierBaseDTO `json:"supplier"`
|
||||
CreditTerm *int `json:"credit_term"`
|
||||
DueDate *time.Time `json:"due_date"`
|
||||
PoDate *time.Time `json:"po_date"`
|
||||
GrandTotal float64 `json:"grand_total"`
|
||||
Notes *string `json:"notes"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Approval *approvalDTO.ApprovalBaseDTO `json:"approval"`
|
||||
Id uint64 `json:"id"`
|
||||
PrNumber string `json:"pr_number"`
|
||||
PoNumber *string `json:"po_number"`
|
||||
Supplier *supplierDTO.SupplierRelationDTO `json:"supplier"`
|
||||
CreditTerm *int `json:"credit_term"`
|
||||
DueDate *time.Time `json:"due_date"`
|
||||
PoDate *time.Time `json:"po_date"`
|
||||
GrandTotal float64 `json:"grand_total"`
|
||||
Notes *string `json:"notes"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Approval *approvalDTO.ApprovalRelationDTO `json:"approval"`
|
||||
}
|
||||
|
||||
type PurchaseDetailDTO struct {
|
||||
Id uint64 `json:"id"`
|
||||
PrNumber string `json:"pr_number"`
|
||||
PoNumber *string `json:"po_number"`
|
||||
Supplier *supplierDTO.SupplierBaseDTO `json:"supplier"`
|
||||
CreditTerm *int `json:"credit_term"`
|
||||
DueDate *time.Time `json:"due_date"`
|
||||
PoDate *time.Time `json:"po_date"`
|
||||
GrandTotal float64 `json:"grand_total"`
|
||||
Notes *string `json:"notes"`
|
||||
Items []PurchaseItemDTO `json:"items"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Approval *approvalDTO.ApprovalBaseDTO `json:"approval"`
|
||||
Id uint64 `json:"id"`
|
||||
PrNumber string `json:"pr_number"`
|
||||
PoNumber *string `json:"po_number"`
|
||||
Supplier *supplierDTO.SupplierRelationDTO `json:"supplier"`
|
||||
CreditTerm *int `json:"credit_term"`
|
||||
DueDate *time.Time `json:"due_date"`
|
||||
PoDate *time.Time `json:"po_date"`
|
||||
GrandTotal float64 `json:"grand_total"`
|
||||
Notes *string `json:"notes"`
|
||||
Items []PurchaseItemDTO `json:"items"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Approval *approvalDTO.ApprovalRelationDTO `json:"approval"`
|
||||
}
|
||||
|
||||
type PurchaseItemDTO struct {
|
||||
Id uint64 `json:"id"`
|
||||
ProductID uint64 `json:"product_id"`
|
||||
Product *productDTO.ProductBaseDTO `json:"product"`
|
||||
WarehouseID uint64 `json:"warehouse_id"`
|
||||
Warehouse *warehouseDTO.WarehouseBaseDTO `json:"warehouse"`
|
||||
ProductWarehouseID *uint64 `json:"product_warehouse_id"`
|
||||
SubQty float64 `json:"sub_qty"`
|
||||
TotalQty float64 `json:"total_qty"`
|
||||
TotalUsed float64 `json:"total_used"`
|
||||
Price float64 `json:"price"`
|
||||
TotalPrice float64 `json:"total_price"`
|
||||
ReceivedDate *time.Time `json:"received_date"`
|
||||
TravelNumber *string `json:"travel_number"`
|
||||
TravelDocumentPath *string `json:"travel_document_path"`
|
||||
VehicleNumber *string `json:"vehicle_number"`
|
||||
Id uint64 `json:"id"`
|
||||
ProductID uint64 `json:"product_id"`
|
||||
Product *productDTO.ProductRelationDTO `json:"product"`
|
||||
WarehouseID uint64 `json:"warehouse_id"`
|
||||
Warehouse *warehouseDTO.WarehouseRelationDTO `json:"warehouse"`
|
||||
ProductWarehouseID *uint64 `json:"product_warehouse_id"`
|
||||
SubQty float64 `json:"sub_qty"`
|
||||
TotalQty float64 `json:"total_qty"`
|
||||
TotalUsed float64 `json:"total_used"`
|
||||
Price float64 `json:"price"`
|
||||
TotalPrice float64 `json:"total_price"`
|
||||
ReceivedDate *time.Time `json:"received_date"`
|
||||
TravelNumber *string `json:"travel_number"`
|
||||
TravelDocumentPath *string `json:"travel_document_path"`
|
||||
VehicleNumber *string `json:"vehicle_number"`
|
||||
}
|
||||
|
||||
func ToPurchaseItemDTO(item entity.PurchaseItem) PurchaseItemDTO {
|
||||
@@ -78,17 +78,17 @@ func ToPurchaseItemDTO(item entity.PurchaseItem) PurchaseItemDTO {
|
||||
VehicleNumber: item.VehicleNumber,
|
||||
}
|
||||
if item.Product != nil && item.Product.Id != 0 {
|
||||
summary := productDTO.ToProductBaseDTO(*item.Product)
|
||||
summary := productDTO.ToProductRelationDTO(*item.Product)
|
||||
dto.Product = &summary
|
||||
}
|
||||
if item.Warehouse != nil && item.Warehouse.Id != 0 {
|
||||
summary := warehouseDTO.ToWarehouseBaseDTO(*item.Warehouse)
|
||||
summary := warehouseDTO.ToWarehouseRelationDTO(*item.Warehouse)
|
||||
if item.Warehouse.Area.Id != 0 {
|
||||
areaSummary := areaDTO.ToAreaBaseDTO(item.Warehouse.Area)
|
||||
areaSummary := areaDTO.ToAreaRelationDTO(item.Warehouse.Area)
|
||||
summary.Area = &areaSummary
|
||||
}
|
||||
if item.Warehouse.Location != nil && item.Warehouse.Location.Id != 0 {
|
||||
locationSummary := locationDTO.ToLocationBaseDTO(*item.Warehouse.Location)
|
||||
locationSummary := locationDTO.ToLocationRelationDTO(*item.Warehouse.Location)
|
||||
summary.Location = &locationSummary
|
||||
}
|
||||
dto.Warehouse = &summary
|
||||
@@ -145,11 +145,11 @@ func ToPurchaseListDTO(p entity.Purchase) PurchaseListItemDTO {
|
||||
return dto
|
||||
}
|
||||
|
||||
func mapSupplier(s entity.Supplier) *supplierDTO.SupplierBaseDTO {
|
||||
func mapSupplier(s entity.Supplier) *supplierDTO.SupplierRelationDTO {
|
||||
if s.Id == 0 {
|
||||
return nil
|
||||
}
|
||||
summary := supplierDTO.ToSupplierBaseDTO(s)
|
||||
summary := supplierDTO.ToSupplierRelationDTO(s)
|
||||
return &summary
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ func ToPurchaseListDTOs(items []entity.Purchase) []PurchaseListItemDTO {
|
||||
return result
|
||||
}
|
||||
|
||||
func toPurchaseApprovalDTO(p entity.Purchase) *approvalDTO.ApprovalBaseDTO {
|
||||
func toPurchaseApprovalDTO(p entity.Purchase) *approvalDTO.ApprovalRelationDTO {
|
||||
if p.LatestApproval == nil || p.LatestApproval.Id == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user