feat(BE-115,116,117): implement chickin CRUD, approve logic, and stock availabilit

This commit is contained in:
aguhh18
2025-10-20 06:01:16 +07:00
parent 68a670a2bd
commit 83c3e61113
34 changed files with 558 additions and 199 deletions
@@ -57,17 +57,17 @@ type TransferDetailDTO struct {
// Detail produk
type TransferDetailItemDTO struct {
Id uint64 `json:"id"`
Product *ProductDTO `json:"product,omitempty"`
Quantity float64 `json:"quantity"`
BeforeQuantity float64 `json:"before_quantity"`
AfterQuantity float64 `json:"after_quantity"`
Id uint64 `json:"id"`
ProductId uint64 `json:"product_id"`
Quantity float64 `json:"quantity"`
BeforeQuantity float64 `json:"before_quantity"`
AfterQuantity float64 `json:"after_quantity"`
}
// Delivery ekspedisi
type TransferDeliveryDTO struct {
Id uint64 `json:"id"`
Supplier *SupplierDTO `json:"supplier,omitempty"`
SupplierId uint64 `json:"supplier_id"`
VehiclePlate string `json:"vehicle_plate"`
DriverName string `json:"driver_name"`
DocumentNumber string `json:"document_number"`
@@ -83,16 +83,6 @@ 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 {
@@ -124,26 +114,6 @@ 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
@@ -172,19 +142,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,
Product: toProductDTO(d.Product),
Quantity: d.Quantity,
Id: d.Id,
ProductId: d.ProductId,
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{
@@ -195,8 +165,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,
@@ -228,9 +198,9 @@ func ToTransferDetailDTO(e entity.StockTransfer) TransferDetailDTO {
var details []TransferDetailItemDTO
for _, d := range e.Details {
details = append(details, TransferDetailItemDTO{
Id: d.Id,
Product: toProductDTO(d.Product),
Quantity: d.Quantity,
Id: d.Id,
ProductId: d.ProductId,
Quantity: d.Quantity,
})
}
// Map deliveries
@@ -238,7 +208,7 @@ func ToTransferDetailDTO(e entity.StockTransfer) TransferDetailDTO {
for _, del := range e.Deliveries {
deliveries = append(deliveries, TransferDeliveryDTO{
Id: del.Id,
Supplier: toSupplierDTO(del.Supplier),
SupplierId: del.SupplierId,
VehiclePlate: del.VehiclePlate,
DriverName: del.DriverName,
DocumentNumber: del.DocumentNumber,
@@ -9,7 +9,7 @@ import (
rStockTransfer "gitlab.com/mbugroup/lti-api.git/internal/modules/inventory/transfers/repositories"
sTransfer "gitlab.com/mbugroup/lti-api.git/internal/modules/inventory/transfers/services"
rSupplier "gitlab.com/mbugroup/lti-api.git/internal/modules/master/suppliers/repositories"
rStockLogs "gitlab.com/mbugroup/lti-api.git/internal/modules/shared/stock-logs/repositories"
rStockLogs "gitlab.com/mbugroup/lti-api.git/internal/modules/shared/repositories"
rUser "gitlab.com/mbugroup/lti-api.git/internal/modules/users/repositories"
sUser "gitlab.com/mbugroup/lti-api.git/internal/modules/users/services"
)
@@ -10,7 +10,7 @@ import (
rStockTransfer "gitlab.com/mbugroup/lti-api.git/internal/modules/inventory/transfers/repositories"
validation "gitlab.com/mbugroup/lti-api.git/internal/modules/inventory/transfers/validations"
rSupplier "gitlab.com/mbugroup/lti-api.git/internal/modules/master/suppliers/repositories"
rStockLogs "gitlab.com/mbugroup/lti-api.git/internal/modules/shared/stock-logs/repositories"
rStockLogs "gitlab.com/mbugroup/lti-api.git/internal/modules/shared/repositories"
"gitlab.com/mbugroup/lti-api.git/internal/utils"
"github.com/go-playground/validator/v10"
@@ -60,8 +60,6 @@ func (s transferService) withRelations(db *gorm.DB) *gorm.DB {
Preload("ToWarehouse.Location").
Preload("ToWarehouse.Area").
Preload("Details").
Preload("Details.Product").
Preload("Deliveries.Supplier").
Preload("Deliveries.Items")
}