fix(BE-78)change typedata in recording dto and validation for create and update

This commit is contained in:
ragilap
2025-11-04 12:05:04 +07:00
parent 98e0d56c64
commit f97d404121
3 changed files with 110 additions and 81 deletions
+4 -9
View File
@@ -13,16 +13,15 @@ func MapBodyWeights(recordingID uint, items []validation.BodyWeight) []entity.Re
result := make([]entity.RecordingBW, 0, len(items))
for _, item := range items {
totalWeight := item.TotalWeight
if totalWeight == nil {
calculated := item.AvgWeight * item.Qty
totalWeight = &calculated
if totalWeight <= 0 {
totalWeight = item.AvgWeight * item.Qty
}
result = append(result, entity.RecordingBW{
RecordingId: recordingID,
AvgWeight: item.AvgWeight,
Qty: item.Qty,
TotalWeight: *totalWeight,
TotalWeight: totalWeight,
})
}
return result
@@ -35,12 +34,8 @@ func MapStocks(recordingID uint, items []validation.Stock) []entity.RecordingSto
result := make([]entity.RecordingStock, 0, len(items))
for _, item := range items {
var usageAmount float64
if item.Qty != nil {
usageAmount = *item.Qty
}
usagePtr := new(float64)
*usagePtr = usageAmount
*usagePtr = item.Qty
pending := item.PendingQty
if pending == nil {
pending = new(float64)