mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 05:21:57 +00:00
Feat[BE]: update update dto for transfer document
This commit is contained in:
@@ -85,7 +85,7 @@ type TransferDeliveryDTO struct {
|
||||
ShippingCostItem float64 `json:"shipping_cost_item"`
|
||||
ShippingCostTotal float64 `json:"shipping_cost_total"`
|
||||
Items []TransferDeliveryItemDTO `json:"items"`
|
||||
Documents []DocumentDTO `json:"documents"`
|
||||
Document *DocumentDTO `json:"document,omitempty"`
|
||||
}
|
||||
|
||||
type TransferDeliveryItemDTO struct {
|
||||
@@ -174,15 +174,16 @@ func ToTransferListDTO(e entity.StockTransfer) TransferListDTO {
|
||||
})
|
||||
}
|
||||
|
||||
var documents []DocumentDTO
|
||||
for _, doc := range del.Documents {
|
||||
documents = append(documents, DocumentDTO{
|
||||
var document *DocumentDTO
|
||||
if len(del.Documents) > 0 {
|
||||
doc := del.Documents[0] // Take first document
|
||||
document = &DocumentDTO{
|
||||
Id: doc.Id,
|
||||
Path: doc.Path,
|
||||
Name: doc.Name,
|
||||
Ext: doc.Ext,
|
||||
Size: doc.Size,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
deliveries = append(deliveries, TransferDeliveryDTO{
|
||||
@@ -197,7 +198,7 @@ func ToTransferListDTO(e entity.StockTransfer) TransferListDTO {
|
||||
ShippingCostItem: del.ShippingCostItem,
|
||||
ShippingCostTotal: del.ShippingCostTotal,
|
||||
Items: items,
|
||||
Documents: documents,
|
||||
Document: document,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -234,15 +235,16 @@ func ToTransferDetailDTO(e entity.StockTransfer) TransferDetailDTO {
|
||||
|
||||
var deliveries []TransferDeliveryDTO
|
||||
for _, del := range e.Deliveries {
|
||||
var documents []DocumentDTO
|
||||
for _, doc := range del.Documents {
|
||||
documents = append(documents, DocumentDTO{
|
||||
var document *DocumentDTO
|
||||
if len(del.Documents) > 0 {
|
||||
doc := del.Documents[0] // Take first document
|
||||
document = &DocumentDTO{
|
||||
Id: doc.Id,
|
||||
Path: doc.Path,
|
||||
Name: doc.Name,
|
||||
Ext: doc.Ext,
|
||||
Size: doc.Size,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
deliveries = append(deliveries, TransferDeliveryDTO{
|
||||
@@ -256,7 +258,7 @@ func ToTransferDetailDTO(e entity.StockTransfer) TransferDetailDTO {
|
||||
DocumentNumber: del.DocumentNumber,
|
||||
ShippingCostItem: del.ShippingCostItem,
|
||||
ShippingCostTotal: del.ShippingCostTotal,
|
||||
Documents: documents,
|
||||
Document: document,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user