feat/BE/US-304/TASK-292,293-restriction expense not finish and stock not used,add status project flock completed, fix dto purchase, fix dto nonstock supplier, purchase

This commit is contained in:
ragilap
2025-12-10 16:30:17 +07:00
parent 0fbf04fc1d
commit 2b6ba3a41d
4 changed files with 69 additions and 31 deletions
+16 -2
View File
@@ -42,7 +42,6 @@ type PurchaseDetailDTO struct {
LatestApproval *approvalDTO.ApprovalRelationDTO `json:"latest_approval"`
}
type PurchaseItemDTO struct {
Id uint `json:"id"`
ProductID uint `json:"product_id"`
@@ -59,9 +58,10 @@ type PurchaseItemDTO struct {
TravelNumber *string `json:"travel_number"`
TravelDocumentPath *string `json:"travel_document_path"`
VehicleNumber *string `json:"vehicle_number"`
TransportPerItem *float64 `json:"transport_per_item,omitempty"`
ExpeditionVendor *supplierDTO.SupplierRelationDTO `json:"expedition_vendor,omitempty"`
}
func ToPurchaseRelationDTO(p *entity.Purchase) PurchaseRelationDTO {
return PurchaseRelationDTO{
Id: p.Id,
@@ -107,6 +107,20 @@ func ToPurchaseItemDTO(item entity.PurchaseItem) PurchaseItemDTO {
dto.Warehouse = &summary
}
if item.ExpenseNonstock != nil {
priceCopy := item.ExpenseNonstock.Price
dto.TransportPerItem = &priceCopy
if item.ExpenseNonstock.Expense != nil {
exp := item.ExpenseNonstock.Expense
if exp.Supplier != nil && exp.Supplier.Id != 0 {
supplierSummary := supplierDTO.ToSupplierRelationDTO(*exp.Supplier)
dto.ExpeditionVendor = &supplierSummary
}
}
}
return dto
}