diff --git a/internal/modules/production/transfer_layings/services/transfer_laying.service.go b/internal/modules/production/transfer_layings/services/transfer_laying.service.go index 3d291b6d..7994727f 100644 --- a/internal/modules/production/transfer_layings/services/transfer_laying.service.go +++ b/internal/modules/production/transfer_layings/services/transfer_laying.service.go @@ -294,7 +294,7 @@ func (s *transferLayingService) CreateOne(c *fiber.Ctx, req *validation.Create) return fiber.NewError(fiber.StatusInternalServerError, "Failed to reduce project flock population") } - if err := productWarehouseRepoTx.PatchOne(c.Context(), productWarehouseId, map[string]any{"quantity": gorm.Expr("quantity - ?", sourceDetail.Quantity)}, nil); err != nil { + if err := productWarehouseRepoTx.PatchOne(c.Context(), productWarehouseId, map[string]any{"quantity": gorm.Expr("qty - ?", sourceDetail.Quantity)}, nil); err != nil { return fiber.NewError(fiber.StatusInternalServerError, "Failed to update source warehouse quantity") } } @@ -388,7 +388,7 @@ func (s transferLayingService) UpdateOne(c *fiber.Ctx, req *validation.Update, i if oldSource.ProductWarehouseId != nil && oldSource.Qty > 0 { if err := productWarehouseRepoTx.PatchOne(c.Context(), *oldSource.ProductWarehouseId, map[string]any{ - "quantity": gorm.Expr("quantity + ?", oldSource.Qty), + "quantity": gorm.Expr("qty + ?", oldSource.Qty), }, nil); err != nil { return fiber.NewError(fiber.StatusInternalServerError, "Failed to restore warehouse quantity") } @@ -466,7 +466,7 @@ func (s transferLayingService) UpdateOne(c *fiber.Ctx, req *validation.Update, i return err } - if err := productWarehouseRepoTx.PatchOne(c.Context(), productWarehouseId, map[string]any{"quantity": gorm.Expr("quantity - ?", sourceDetail.Quantity)}, nil); err != nil { + if err := productWarehouseRepoTx.PatchOne(c.Context(), productWarehouseId, map[string]any{"quantity": gorm.Expr("qty - ?", sourceDetail.Quantity)}, nil); err != nil { return fiber.NewError(fiber.StatusInternalServerError, "Failed to update source warehouse quantity") } } @@ -544,7 +544,7 @@ func (s transferLayingService) DeleteOne(c *fiber.Ctx, id uint) error { if source.ProductWarehouseId != nil && source.Qty > 0 { if err := productWarehouseRepoTx.PatchOne(c.Context(), *source.ProductWarehouseId, map[string]any{ - "quantity": gorm.Expr("quantity + ?", source.Qty), + "quantity": gorm.Expr("qty + ?", source.Qty), }, nil); err != nil { return fiber.NewError(fiber.StatusInternalServerError, "Failed to restore source warehouse quantity") } @@ -766,7 +766,7 @@ func (s *transferLayingService) getOrCreateProductWarehouse(ctx context.Context, existing, err := productWarehouseRepoTx.GetProductWarehouseByProductAndWarehouseID(ctx, productID, warehouseID) if err == nil && existing != nil { - if err := productWarehouseRepoTx.PatchOne(ctx, existing.Id, map[string]any{"quantity": gorm.Expr("quantity + ?", quantity)}, nil); err != nil { + if err := productWarehouseRepoTx.PatchOne(ctx, existing.Id, map[string]any{"quantity": gorm.Expr("qty + ?", quantity)}, nil); err != nil { return nil, err } return existing, nil