FIX[BE]: fix logic on Chickin Laying not convert to layer but still Pullet, and inisiate laying transfer migration and base basic API

This commit is contained in:
aguhh18
2025-11-04 08:24:38 +07:00
parent c72db5bd18
commit 8220e34302
22 changed files with 587 additions and 163 deletions
@@ -41,12 +41,12 @@ type KandangCustomDTO struct {
type ProductWarehouseDTO struct {
Id uint `json:"id"`
Quantity float64 `json:"quantity"`
Product *productDTO.ProductBaseDTO `json:"product,omitempty"`
Warehouse *warehouseDTO.WarehouseBaseDTO `json:"warehouse,omitempty"`
}
type AvailableQtyDTO struct {
AvailableQty float64 `json:"available_qty"`
ProductWarehouse *ProductWarehouseDTO `json:"product_warehouse,omitempty"`
}
@@ -171,10 +171,6 @@ func buildProductWarehouseFromMap(pwData map[string]interface{}) *ProductWarehou
dto.Id = id
}
if qty, ok := pwData["quantity"].(float64); ok {
dto.Quantity = qty
}
if pData, ok := pwData["product"].(map[string]interface{}); ok {
dto.Product = buildProductFromMap(pData)
}
@@ -276,8 +272,7 @@ func buildAvailableQtys(chickins []entity.ProjectChickin) []AvailableQtyDTO {
}
pwDTO := &ProductWarehouseDTO{
Id: ch.ProductWarehouse.Id,
Quantity: ch.ProductWarehouse.Quantity,
Id: ch.ProductWarehouse.Id,
}
if ch.ProductWarehouse.Product.Id != 0 {
@@ -324,7 +319,13 @@ func buildAvailableQtysFromRaw(availableQtysRaw []map[string]interface{}) []Avai
}
pwDTO := buildProductWarehouseFromMap(pwData)
availableQty := 0.0
if qty, ok := v["available_qty"].(float64); ok {
availableQty = qty
}
result[i] = AvailableQtyDTO{
AvailableQty: availableQty,
ProductWarehouse: pwDTO,
}
}