mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 15:55:44 +00:00
fix(BE): add missing product json in transfer get all & support flag param filter in product warehouses
This commit is contained in:
@@ -57,17 +57,17 @@ type TransferDetailDTO struct {
|
||||
|
||||
// Detail produk
|
||||
type TransferDetailItemDTO struct {
|
||||
Id uint64 `json:"id"`
|
||||
ProductId uint64 `json:"product_id"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
BeforeQuantity float64 `json:"before_quantity"`
|
||||
AfterQuantity float64 `json:"after_quantity"`
|
||||
Id uint64 `json:"id"`
|
||||
Product *ProductDTO `json:"product,omitempty"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
BeforeQuantity float64 `json:"before_quantity"`
|
||||
AfterQuantity float64 `json:"after_quantity"`
|
||||
}
|
||||
|
||||
// Delivery ekspedisi
|
||||
type TransferDeliveryDTO struct {
|
||||
Id uint64 `json:"id"`
|
||||
SupplierId uint64 `json:"supplier_id"`
|
||||
Supplier *SupplierDTO `json:"supplier,omitempty"`
|
||||
VehiclePlate string `json:"vehicle_plate"`
|
||||
DriverName string `json:"driver_name"`
|
||||
DocumentNumber string `json:"document_number"`
|
||||
@@ -83,6 +83,16 @@ type TransferDeliveryItemDTO struct {
|
||||
Quantity float64 `json:"quantity"`
|
||||
}
|
||||
|
||||
type ProductDTO struct {
|
||||
Id uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type SupplierDTO struct {
|
||||
Id uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// === Mapper Functions ===
|
||||
|
||||
func ToTransferBaseDTO(e entity.StockTransfer) TransferBaseDTO {
|
||||
@@ -114,6 +124,26 @@ func toAreaDTO(a *entity.Area) *AreaDTO {
|
||||
}
|
||||
}
|
||||
|
||||
func toProductDTO(p *entity.Product) *ProductDTO {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return &ProductDTO{
|
||||
Id: uint64(p.Id),
|
||||
Name: p.Name,
|
||||
}
|
||||
}
|
||||
|
||||
func toSupplierDTO(s *entity.Supplier) *SupplierDTO {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
return &SupplierDTO{
|
||||
Id: uint64(s.Id),
|
||||
Name: s.Name,
|
||||
}
|
||||
}
|
||||
|
||||
func toLocationDTO(l *entity.Location) *LocationDTO {
|
||||
if l == nil {
|
||||
return nil
|
||||
@@ -142,19 +172,19 @@ func ToTransferListDTO(e entity.StockTransfer) TransferListDTO {
|
||||
mapped := userDTO.ToUserBaseDTO(*e.CreatedUser)
|
||||
createdUser = &mapped
|
||||
}
|
||||
// Map details
|
||||
|
||||
var details []TransferDetailItemDTO
|
||||
for _, d := range e.Details {
|
||||
details = append(details, TransferDetailItemDTO{
|
||||
Id: d.Id,
|
||||
ProductId: d.ProductId,
|
||||
Quantity: d.Quantity,
|
||||
Id: d.Id,
|
||||
Product: toProductDTO(d.Product),
|
||||
Quantity: d.Quantity,
|
||||
})
|
||||
}
|
||||
// Map deliveries
|
||||
|
||||
var deliveries []TransferDeliveryDTO
|
||||
for _, del := range e.Deliveries {
|
||||
// Map delivery items
|
||||
|
||||
var items []TransferDeliveryItemDTO
|
||||
for _, item := range del.Items {
|
||||
items = append(items, TransferDeliveryItemDTO{
|
||||
@@ -165,8 +195,8 @@ func ToTransferListDTO(e entity.StockTransfer) TransferListDTO {
|
||||
}
|
||||
deliveries = append(deliveries, TransferDeliveryDTO{
|
||||
Id: del.Id,
|
||||
SupplierId: del.SupplierId,
|
||||
VehiclePlate: del.VehiclePlate,
|
||||
Supplier: toSupplierDTO(del.Supplier),
|
||||
DriverName: del.DriverName,
|
||||
DocumentNumber: del.DocumentNumber,
|
||||
DocumentPath: del.DocumentPath,
|
||||
@@ -198,9 +228,9 @@ func ToTransferDetailDTO(e entity.StockTransfer) TransferDetailDTO {
|
||||
var details []TransferDetailItemDTO
|
||||
for _, d := range e.Details {
|
||||
details = append(details, TransferDetailItemDTO{
|
||||
Id: d.Id,
|
||||
ProductId: d.ProductId,
|
||||
Quantity: d.Quantity,
|
||||
Id: d.Id,
|
||||
Product: toProductDTO(d.Product),
|
||||
Quantity: d.Quantity,
|
||||
})
|
||||
}
|
||||
// Map deliveries
|
||||
@@ -208,7 +238,7 @@ func ToTransferDetailDTO(e entity.StockTransfer) TransferDetailDTO {
|
||||
for _, del := range e.Deliveries {
|
||||
deliveries = append(deliveries, TransferDeliveryDTO{
|
||||
Id: del.Id,
|
||||
SupplierId: del.SupplierId,
|
||||
Supplier: toSupplierDTO(del.Supplier),
|
||||
VehiclePlate: del.VehiclePlate,
|
||||
DriverName: del.DriverName,
|
||||
DocumentNumber: del.DocumentNumber,
|
||||
|
||||
Reference in New Issue
Block a user