mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 07:45:44 +00:00
feat(BE): implement expense tracking for stock transfers and enhance related services
This commit is contained in:
@@ -71,9 +71,11 @@ type TransferDetailDTO struct {
|
||||
}
|
||||
|
||||
type TransferDetailItemDTO struct {
|
||||
Id uint64 `json:"id"`
|
||||
Product ProductSimpleDTO `json:"product"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
Id uint64 `json:"id"`
|
||||
Product ProductSimpleDTO `json:"product"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
TransportPerItem *float64 `json:"transport_per_item,omitempty"` // Biaya ekspedisi per item
|
||||
ExpeditionVendor *SupplierSimpleDTO `json:"expedition_vendor,omitempty"` // Vendor ekspedisi
|
||||
}
|
||||
|
||||
type TransferDeliveryDTO struct {
|
||||
@@ -153,14 +155,30 @@ func ToTransferListDTO(e entity.StockTransfer) TransferListDTO {
|
||||
|
||||
var details []TransferDetailItemDTO
|
||||
for _, d := range e.Details {
|
||||
details = append(details, TransferDetailItemDTO{
|
||||
detailDTO := TransferDetailItemDTO{
|
||||
Id: d.Id,
|
||||
Product: ProductSimpleDTO{
|
||||
Id: d.Product.Id,
|
||||
Name: d.Product.Name,
|
||||
},
|
||||
Quantity: d.UsageQty + d.PendingQty, // Total actual quantity allocated
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
if d.ExpenseNonstock != nil {
|
||||
priceCopy := d.ExpenseNonstock.Price
|
||||
detailDTO.TransportPerItem = &priceCopy
|
||||
|
||||
if d.ExpenseNonstock.Expense != nil && d.ExpenseNonstock.Expense.Supplier != nil && d.ExpenseNonstock.Expense.Supplier.Id != 0 {
|
||||
exp := d.ExpenseNonstock.Expense
|
||||
detailDTO.ExpeditionVendor = &SupplierSimpleDTO{
|
||||
Id: exp.Supplier.Id,
|
||||
Name: exp.Supplier.Name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
details = append(details, detailDTO)
|
||||
}
|
||||
|
||||
var deliveries []TransferDeliveryDTO
|
||||
@@ -223,14 +241,30 @@ func ToTransferListDTOs(e []entity.StockTransfer) []TransferListDTO {
|
||||
func ToTransferDetailDTO(e entity.StockTransfer) TransferDetailDTO {
|
||||
var details []TransferDetailItemDTO
|
||||
for _, d := range e.Details {
|
||||
details = append(details, TransferDetailItemDTO{
|
||||
detailDTO := TransferDetailItemDTO{
|
||||
Id: d.Id,
|
||||
Product: ProductSimpleDTO{
|
||||
Id: d.Product.Id,
|
||||
Name: d.Product.Name,
|
||||
},
|
||||
Quantity: d.UsageQty + d.PendingQty, // Total actual quantity allocated
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
if d.ExpenseNonstock != nil {
|
||||
priceCopy := d.ExpenseNonstock.Price
|
||||
detailDTO.TransportPerItem = &priceCopy
|
||||
|
||||
if d.ExpenseNonstock.Expense != nil && d.ExpenseNonstock.Expense.Supplier != nil && d.ExpenseNonstock.Expense.Supplier.Id != 0 {
|
||||
exp := d.ExpenseNonstock.Expense
|
||||
detailDTO.ExpeditionVendor = &SupplierSimpleDTO{
|
||||
Id: exp.Supplier.Id,
|
||||
Name: exp.Supplier.Name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
details = append(details, detailDTO)
|
||||
}
|
||||
|
||||
var deliveries []TransferDeliveryDTO
|
||||
|
||||
Reference in New Issue
Block a user