feat: expose received_date in laporan pembelian

This commit is contained in:
Adnan Zahir
2026-04-25 22:24:28 +07:00
parent af5f3dc7d4
commit 27d076b817
2 changed files with 27 additions and 13 deletions
@@ -27,6 +27,7 @@ type PurchaseListDTO struct {
PurchaseRelationDTO
Supplier *supplierDTO.SupplierRelationDTO `json:"supplier"`
DueDate *time.Time `json:"due_date"`
ReceivedDate *time.Time `json:"received_date"`
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
RequesterName string `json:"requester_name"`
PoExpedition []PoExpeditionDTO `json:"po_expedition"`
@@ -174,6 +175,7 @@ func ToPurchaseListDTO(p entity.Purchase) PurchaseListDTO {
poExpedition = make([]PoExpeditionDTO, 0)
location *locationDTO.LocationRelationDTO
area *areaDTO.AreaRelationDTO
receivedDate *time.Time
)
productMap := make(map[uint]productDTO.ProductRelationDTO)
expeditionRefSet := make(map[uint64]struct{})
@@ -205,6 +207,12 @@ func ToPurchaseListDTO(p entity.Purchase) PurchaseListDTO {
ar := areaDTO.ToAreaRelationDTO(item.Warehouse.Area)
area = &ar
}
if item.ReceivedDate != nil && !item.ReceivedDate.IsZero() {
if receivedDate == nil || item.ReceivedDate.Before(*receivedDate) {
t := *item.ReceivedDate
receivedDate = &t
}
}
}
products := make([]productDTO.ProductRelationDTO, 0, len(productMap))
for _, prod := range productMap {
@@ -215,6 +223,7 @@ func ToPurchaseListDTO(p entity.Purchase) PurchaseListDTO {
PurchaseRelationDTO: ToPurchaseRelationDTO(&p),
Supplier: supplier,
DueDate: p.DueDate,
ReceivedDate: receivedDate,
CreatedUser: createdUser,
RequesterName: requesterName,
PoExpedition: poExpedition,