From 29aeb58fc09ba563e37e66876d3d3e37ceee65f7 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 8 Jun 2026 12:30:39 +0700 Subject: [PATCH] Fix formatting --- internal/contract/account_request.go | 42 ++++++++-------- .../ingredient_unit_converter_contract.go | 1 - internal/contract/inventory_contract.go | 12 ++--- internal/contract/product_recipe_contract.go | 50 +++++++++---------- .../entities/ingredient_unit_converter.go | 1 - .../entities/order_ingredient_transaction.go | 14 +++--- internal/entities/product_ingredient.go | 18 +++---- internal/entities/product_recipe.go | 2 +- .../handler/chart_of_account_type_handler.go | 2 +- .../ingredient_unit_converter_handler.go | 1 - internal/handler/product_recipe_handler.go | 2 +- internal/mappers/product_ingredient_mapper.go | 44 ++++++++-------- internal/models/account.go | 12 ++--- internal/models/customer.go | 22 ++++---- internal/models/ingredient_unit_converter.go | 1 - .../models/order_ingredient_transaction.go | 18 +++---- internal/models/product_ingredient.go | 36 ++++++------- internal/models/product_recipe.go | 2 +- internal/service/account_service.go | 12 ++--- .../service/chart_of_account_type_service.go | 4 +- .../ingredient_unit_converter_service.go | 1 - internal/service/product_recipe_service.go | 2 +- .../ingredient_unit_converter_transformer.go | 1 - internal/util/waste_util.go | 4 +- .../ingredient_unit_converter_validator.go | 1 - 25 files changed, 149 insertions(+), 156 deletions(-) diff --git a/internal/contract/account_request.go b/internal/contract/account_request.go index b77dcdb..e794d6b 100644 --- a/internal/contract/account_request.go +++ b/internal/contract/account_request.go @@ -5,12 +5,12 @@ import ( ) type CreateAccountRequest struct { - ChartOfAccountID uuid.UUID `json:"chart_of_account_id" validate:"required"` - Name string `json:"name" validate:"required,min=1,max=255"` - Number string `json:"number" validate:"required,min=1,max=50"` - AccountType string `json:"account_type" validate:"required,oneof=cash wallet bank credit debit asset liability equity revenue expense"` - OpeningBalance float64 `json:"opening_balance"` - Description *string `json:"description"` + ChartOfAccountID uuid.UUID `json:"chart_of_account_id" validate:"required"` + Name string `json:"name" validate:"required,min=1,max=255"` + Number string `json:"number" validate:"required,min=1,max=50"` + AccountType string `json:"account_type" validate:"required,oneof=cash wallet bank credit debit asset liability equity revenue expense"` + OpeningBalance float64 `json:"opening_balance"` + Description *string `json:"description"` } type UpdateAccountRequest struct { @@ -24,21 +24,21 @@ type UpdateAccountRequest struct { } type AccountResponse struct { - ID uuid.UUID `json:"id"` - OrganizationID uuid.UUID `json:"organization_id"` - OutletID *uuid.UUID `json:"outlet_id"` - ChartOfAccountID uuid.UUID `json:"chart_of_account_id"` - Name string `json:"name"` - Number string `json:"number"` - AccountType string `json:"account_type"` - OpeningBalance float64 `json:"opening_balance"` - CurrentBalance float64 `json:"current_balance"` - Description *string `json:"description"` - IsActive bool `json:"is_active"` - IsSystem bool `json:"is_system"` - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` - ChartOfAccount *ChartOfAccountResponse `json:"chart_of_account,omitempty"` + ID uuid.UUID `json:"id"` + OrganizationID uuid.UUID `json:"organization_id"` + OutletID *uuid.UUID `json:"outlet_id"` + ChartOfAccountID uuid.UUID `json:"chart_of_account_id"` + Name string `json:"name"` + Number string `json:"number"` + AccountType string `json:"account_type"` + OpeningBalance float64 `json:"opening_balance"` + CurrentBalance float64 `json:"current_balance"` + Description *string `json:"description"` + IsActive bool `json:"is_active"` + IsSystem bool `json:"is_system"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + ChartOfAccount *ChartOfAccountResponse `json:"chart_of_account,omitempty"` } type ListAccountsRequest struct { diff --git a/internal/contract/ingredient_unit_converter_contract.go b/internal/contract/ingredient_unit_converter_contract.go index de37f8a..9741814 100644 --- a/internal/contract/ingredient_unit_converter_contract.go +++ b/internal/contract/ingredient_unit_converter_contract.go @@ -81,4 +81,3 @@ type IngredientUnitsResponse struct { BaseUnitName string `json:"base_unit_name"` Units []*UnitResponse `json:"units"` } - diff --git a/internal/contract/inventory_contract.go b/internal/contract/inventory_contract.go index 0b1f642..1dbc76d 100644 --- a/internal/contract/inventory_contract.go +++ b/internal/contract/inventory_contract.go @@ -26,9 +26,9 @@ type AdjustInventoryRequest struct { } type RestockInventoryRequest struct { - OutletID uuid.UUID `json:"outlet_id" validate:"required"` + OutletID uuid.UUID `json:"outlet_id" validate:"required"` Items []RestockItem `json:"items" validate:"required,min=1,dive"` - Reason string `json:"reason" validate:"required,min=1,max=255"` + Reason string `json:"reason" validate:"required,min=1,max=255"` } type RestockItem struct { @@ -82,10 +82,10 @@ type InventoryAdjustmentResponse struct { } type RestockInventoryResponse struct { - OutletID uuid.UUID `json:"outlet_id"` - Items []RestockItemResult `json:"items"` - Reason string `json:"reason"` - RestockedAt time.Time `json:"restocked_at"` + OutletID uuid.UUID `json:"outlet_id"` + Items []RestockItemResult `json:"items"` + Reason string `json:"reason"` + RestockedAt time.Time `json:"restocked_at"` } type RestockItemResult struct { diff --git a/internal/contract/product_recipe_contract.go b/internal/contract/product_recipe_contract.go index 9df640c..cc73de2 100644 --- a/internal/contract/product_recipe_contract.go +++ b/internal/contract/product_recipe_contract.go @@ -34,34 +34,34 @@ type BulkCreateProductRecipeRequest struct { // Response structures type ProductRecipeResponse struct { - ID uuid.UUID `json:"id"` - OrganizationID uuid.UUID `json:"organization_id"` - OutletID *uuid.UUID `json:"outlet_id"` - ProductID uuid.UUID `json:"product_id"` - VariantID *uuid.UUID `json:"variant_id"` - IngredientID uuid.UUID `json:"ingredient_id"` - Quantity float64 `json:"quantity"` - WastePercentage float64 `json:"waste_percentage"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` - Product *ProductResponse `json:"product,omitempty"` - ProductVariant *ProductVariantResponse `json:"product_variant,omitempty"` + ID uuid.UUID `json:"id"` + OrganizationID uuid.UUID `json:"organization_id"` + OutletID *uuid.UUID `json:"outlet_id"` + ProductID uuid.UUID `json:"product_id"` + VariantID *uuid.UUID `json:"variant_id"` + IngredientID uuid.UUID `json:"ingredient_id"` + Quantity float64 `json:"quantity"` + WastePercentage float64 `json:"waste_percentage"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + Product *ProductResponse `json:"product,omitempty"` + ProductVariant *ProductVariantResponse `json:"product_variant,omitempty"` Ingredient *ProductRecipeIngredientResponse `json:"ingredient,omitempty"` } type ProductRecipeIngredientResponse struct { - ID uuid.UUID `json:"id"` - OrganizationID uuid.UUID `json:"organization_id"` - OutletID *uuid.UUID `json:"outlet_id"` - Name string `json:"name"` - UnitID uuid.UUID `json:"unit_id"` - Cost float64 `json:"cost"` - Stock float64 `json:"stock"` - IsSemiFinished bool `json:"is_semi_finished"` - IsActive bool `json:"is_active"` - Metadata map[string]interface{} `json:"metadata"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + ID uuid.UUID `json:"id"` + OrganizationID uuid.UUID `json:"organization_id"` + OutletID *uuid.UUID `json:"outlet_id"` + Name string `json:"name"` + UnitID uuid.UUID `json:"unit_id"` + Cost float64 `json:"cost"` + Stock float64 `json:"stock"` + IsSemiFinished bool `json:"is_semi_finished"` + IsActive bool `json:"is_active"` + Metadata map[string]interface{} `json:"metadata"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` Unit *ProductRecipeUnitResponse `json:"unit,omitempty"` } @@ -71,4 +71,4 @@ type ProductRecipeUnitResponse struct { Symbol string `json:"symbol"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` -} \ No newline at end of file +} diff --git a/internal/entities/ingredient_unit_converter.go b/internal/entities/ingredient_unit_converter.go index d2a3465..ad9650e 100644 --- a/internal/entities/ingredient_unit_converter.go +++ b/internal/entities/ingredient_unit_converter.go @@ -39,4 +39,3 @@ func (iuc *IngredientUnitConverter) BeforeCreate() error { } return nil } - diff --git a/internal/entities/order_ingredient_transaction.go b/internal/entities/order_ingredient_transaction.go index 38b9917..5a50ccf 100644 --- a/internal/entities/order_ingredient_transaction.go +++ b/internal/entities/order_ingredient_transaction.go @@ -26,14 +26,14 @@ type OrderIngredientTransaction struct { UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` // Relations - Organization Organization `gorm:"foreignKey:OrganizationID" json:"organization,omitempty"` - Outlet *Outlet `gorm:"foreignKey:OutletID" json:"outlet,omitempty"` - Order Order `gorm:"foreignKey:OrderID" json:"order,omitempty"` - OrderItem *OrderItem `gorm:"foreignKey:OrderItemID" json:"order_item,omitempty"` - Product Product `gorm:"foreignKey:ProductID" json:"product,omitempty"` + Organization Organization `gorm:"foreignKey:OrganizationID" json:"organization,omitempty"` + Outlet *Outlet `gorm:"foreignKey:OutletID" json:"outlet,omitempty"` + Order Order `gorm:"foreignKey:OrderID" json:"order,omitempty"` + OrderItem *OrderItem `gorm:"foreignKey:OrderItemID" json:"order_item,omitempty"` + Product Product `gorm:"foreignKey:ProductID" json:"product,omitempty"` ProductVariant *ProductVariant `gorm:"foreignKey:ProductVariantID" json:"product_variant,omitempty"` - Ingredient Ingredient `gorm:"foreignKey:IngredientID" json:"ingredient,omitempty"` - CreatedByUser User `gorm:"foreignKey:CreatedBy" json:"created_by_user,omitempty"` + Ingredient Ingredient `gorm:"foreignKey:IngredientID" json:"ingredient,omitempty"` + CreatedByUser User `gorm:"foreignKey:CreatedBy" json:"created_by_user,omitempty"` } func (oit *OrderIngredientTransaction) BeforeCreate(tx *gorm.DB) error { diff --git a/internal/entities/product_ingredient.go b/internal/entities/product_ingredient.go index 5d9bb46..20d869c 100644 --- a/internal/entities/product_ingredient.go +++ b/internal/entities/product_ingredient.go @@ -7,15 +7,15 @@ import ( ) type ProductIngredient struct { - ID uuid.UUID `json:"id" db:"id"` - OrganizationID uuid.UUID `json:"organization_id" db:"organization_id"` - OutletID *uuid.UUID `json:"outlet_id" db:"outlet_id"` - ProductID uuid.UUID `json:"product_id" db:"product_id"` - IngredientID uuid.UUID `json:"ingredient_id" db:"ingredient_id"` - Quantity float64 `json:"quantity" db:"quantity"` - WastePercentage float64 `json:"waste_percentage" db:"waste_percentage"` - CreatedAt time.Time `json:"created_at" db:"created_at"` - UpdatedAt time.Time `json:"updated_at" db:"updated_at"` + ID uuid.UUID `json:"id" db:"id"` + OrganizationID uuid.UUID `json:"organization_id" db:"organization_id"` + OutletID *uuid.UUID `json:"outlet_id" db:"outlet_id"` + ProductID uuid.UUID `json:"product_id" db:"product_id"` + IngredientID uuid.UUID `json:"ingredient_id" db:"ingredient_id"` + Quantity float64 `json:"quantity" db:"quantity"` + WastePercentage float64 `json:"waste_percentage" db:"waste_percentage"` + CreatedAt time.Time `json:"created_at" db:"created_at"` + UpdatedAt time.Time `json:"updated_at" db:"updated_at"` // Relations Product *Product `json:"product,omitempty"` diff --git a/internal/entities/product_recipe.go b/internal/entities/product_recipe.go index d178f2b..7292fe4 100644 --- a/internal/entities/product_recipe.go +++ b/internal/entities/product_recipe.go @@ -34,4 +34,4 @@ func (pr *ProductRecipe) BeforeCreate(tx *gorm.DB) error { func (ProductRecipe) TableName() string { return "product_recipes" -} \ No newline at end of file +} diff --git a/internal/handler/chart_of_account_type_handler.go b/internal/handler/chart_of_account_type_handler.go index a9cc3ff..43300cb 100644 --- a/internal/handler/chart_of_account_type_handler.go +++ b/internal/handler/chart_of_account_type_handler.go @@ -99,7 +99,7 @@ func (h *ChartOfAccountTypeHandler) DeleteChartOfAccountType(c *gin.Context) { func (h *ChartOfAccountTypeHandler) ListChartOfAccountTypes(c *gin.Context) { // Parse query parameters filters := make(map[string]interface{}) - + if isActive := c.Query("is_active"); isActive != "" { if isActiveBool, err := strconv.ParseBool(isActive); err == nil { filters["is_active"] = isActiveBool diff --git a/internal/handler/ingredient_unit_converter_handler.go b/internal/handler/ingredient_unit_converter_handler.go index e78346b..4dd642e 100644 --- a/internal/handler/ingredient_unit_converter_handler.go +++ b/internal/handler/ingredient_unit_converter_handler.go @@ -275,4 +275,3 @@ func (h *IngredientUnitConverterHandler) GetUnitsByIngredientID(c *gin.Context) util.HandleResponse(c.Writer, c.Request, unitsResponse, "IngredientUnitConverterHandler::GetUnitsByIngredientID") } - diff --git a/internal/handler/product_recipe_handler.go b/internal/handler/product_recipe_handler.go index 15066f1..8078203 100644 --- a/internal/handler/product_recipe_handler.go +++ b/internal/handler/product_recipe_handler.go @@ -219,4 +219,4 @@ func (h *ProductRecipeHandler) BulkCreate(c *gin.Context) { } c.JSON(http.StatusCreated, contract.BuildSuccessResponse(recipes)) -} \ No newline at end of file +} diff --git a/internal/mappers/product_ingredient_mapper.go b/internal/mappers/product_ingredient_mapper.go index b7c99cb..f5dc1bc 100644 --- a/internal/mappers/product_ingredient_mapper.go +++ b/internal/mappers/product_ingredient_mapper.go @@ -11,17 +11,17 @@ func MapProductIngredientEntityToModel(entity *entities.ProductIngredient) *mode } return &models.ProductIngredient{ - ID: entity.ID, - OrganizationID: entity.OrganizationID, - OutletID: entity.OutletID, - ProductID: entity.ProductID, - IngredientID: entity.IngredientID, - Quantity: entity.Quantity, - WastePercentage: entity.WastePercentage, - CreatedAt: entity.CreatedAt, - UpdatedAt: entity.UpdatedAt, - Product: ProductEntityToModel(entity.Product), - Ingredient: MapIngredientEntityToModel(entity.Ingredient), + ID: entity.ID, + OrganizationID: entity.OrganizationID, + OutletID: entity.OutletID, + ProductID: entity.ProductID, + IngredientID: entity.IngredientID, + Quantity: entity.Quantity, + WastePercentage: entity.WastePercentage, + CreatedAt: entity.CreatedAt, + UpdatedAt: entity.UpdatedAt, + Product: ProductEntityToModel(entity.Product), + Ingredient: MapIngredientEntityToModel(entity.Ingredient), } } @@ -31,17 +31,17 @@ func MapProductIngredientModelToEntity(model *models.ProductIngredient) *entitie } return &entities.ProductIngredient{ - ID: model.ID, - OrganizationID: model.OrganizationID, - OutletID: model.OutletID, - ProductID: model.ProductID, - IngredientID: model.IngredientID, - Quantity: model.Quantity, - WastePercentage: model.WastePercentage, - CreatedAt: model.CreatedAt, - UpdatedAt: model.UpdatedAt, - Product: ProductModelToEntity(model.Product), - Ingredient: MapIngredientModelToEntity(model.Ingredient), + ID: model.ID, + OrganizationID: model.OrganizationID, + OutletID: model.OutletID, + ProductID: model.ProductID, + IngredientID: model.IngredientID, + Quantity: model.Quantity, + WastePercentage: model.WastePercentage, + CreatedAt: model.CreatedAt, + UpdatedAt: model.UpdatedAt, + Product: ProductModelToEntity(model.Product), + Ingredient: MapIngredientModelToEntity(model.Ingredient), } } diff --git a/internal/models/account.go b/internal/models/account.go index 8c943d6..07259bd 100644 --- a/internal/models/account.go +++ b/internal/models/account.go @@ -25,12 +25,12 @@ type AccountResponse struct { } type CreateAccountRequest struct { - ChartOfAccountID uuid.UUID `json:"chart_of_account_id" validate:"required"` - Name string `json:"name" validate:"required,min=1,max=255"` - Number string `json:"number" validate:"required,min=1,max=50"` - AccountType string `json:"account_type" validate:"required,oneof=cash wallet bank credit debit asset liability equity revenue expense"` - OpeningBalance float64 `json:"opening_balance"` - Description *string `json:"description"` + ChartOfAccountID uuid.UUID `json:"chart_of_account_id" validate:"required"` + Name string `json:"name" validate:"required,min=1,max=255"` + Number string `json:"number" validate:"required,min=1,max=50"` + AccountType string `json:"account_type" validate:"required,oneof=cash wallet bank credit debit asset liability equity revenue expense"` + OpeningBalance float64 `json:"opening_balance"` + Description *string `json:"description"` } type UpdateAccountRequest struct { diff --git a/internal/models/customer.go b/internal/models/customer.go index b873198..2b9e388 100644 --- a/internal/models/customer.go +++ b/internal/models/customer.go @@ -23,17 +23,17 @@ type UpdateCustomerRequest struct { } type CustomerResponse struct { - ID uuid.UUID `json:"id"` - OrganizationID uuid.UUID `json:"organization_id"` - Name string `json:"name"` - Email *string `json:"email,omitempty"` - Phone *string `json:"phone,omitempty"` - Address *string `json:"address,omitempty"` - IsDefault bool `json:"is_default"` - IsActive bool `json:"is_active"` - Metadata entities.Metadata `json:"metadata"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + ID uuid.UUID `json:"id"` + OrganizationID uuid.UUID `json:"organization_id"` + Name string `json:"name"` + Email *string `json:"email,omitempty"` + Phone *string `json:"phone,omitempty"` + Address *string `json:"address,omitempty"` + IsDefault bool `json:"is_default"` + IsActive bool `json:"is_active"` + Metadata entities.Metadata `json:"metadata"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` } // ListCustomersQuery represents query parameters for listing customers diff --git a/internal/models/ingredient_unit_converter.go b/internal/models/ingredient_unit_converter.go index 3413a7c..af14c0c 100644 --- a/internal/models/ingredient_unit_converter.go +++ b/internal/models/ingredient_unit_converter.go @@ -101,4 +101,3 @@ type IngredientUnitsResponse struct { BaseUnitName string `json:"base_unit_name"` Units []*UnitResponse `json:"units"` } - diff --git a/internal/models/order_ingredient_transaction.go b/internal/models/order_ingredient_transaction.go index b8706fa..7c9f1ab 100644 --- a/internal/models/order_ingredient_transaction.go +++ b/internal/models/order_ingredient_transaction.go @@ -52,8 +52,8 @@ type UpdateOrderIngredientTransactionRequest struct { GrossQty *float64 `json:"gross_qty,omitempty" validate:"omitempty,gt=0"` NetQty *float64 `json:"net_qty,omitempty" validate:"omitempty,gt=0"` WasteQty *float64 `json:"waste_qty,omitempty" validate:"min=0"` - Unit *string `json:"unit,omitempty" validate:"omitempty,max=50"` - TransactionDate *time.Time `json:"transaction_date,omitempty"` + Unit *string `json:"unit,omitempty" validate:"omitempty,max=50"` + TransactionDate *time.Time `json:"transaction_date,omitempty"` } type OrderIngredientTransactionResponse struct { @@ -98,11 +98,11 @@ type ListOrderIngredientTransactionsRequest struct { } type OrderIngredientTransactionSummary struct { - IngredientID uuid.UUID `json:"ingredient_id"` - IngredientName string `json:"ingredient_name"` - TotalGrossQty float64 `json:"total_gross_qty"` - TotalNetQty float64 `json:"total_net_qty"` - TotalWasteQty float64 `json:"total_waste_qty"` - WastePercentage float64 `json:"waste_percentage"` - Unit string `json:"unit"` + IngredientID uuid.UUID `json:"ingredient_id"` + IngredientName string `json:"ingredient_name"` + TotalGrossQty float64 `json:"total_gross_qty"` + TotalNetQty float64 `json:"total_net_qty"` + TotalWasteQty float64 `json:"total_waste_qty"` + WastePercentage float64 `json:"waste_percentage"` + Unit string `json:"unit"` } diff --git a/internal/models/product_ingredient.go b/internal/models/product_ingredient.go index 3c3d9de..6466f1e 100644 --- a/internal/models/product_ingredient.go +++ b/internal/models/product_ingredient.go @@ -7,15 +7,15 @@ import ( ) type ProductIngredient struct { - ID uuid.UUID `json:"id"` - OrganizationID uuid.UUID `json:"organization_id"` - OutletID *uuid.UUID `json:"outlet_id"` - ProductID uuid.UUID `json:"product_id"` - IngredientID uuid.UUID `json:"ingredient_id"` - Quantity float64 `json:"quantity"` - WastePercentage float64 `json:"waste_percentage"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + ID uuid.UUID `json:"id"` + OrganizationID uuid.UUID `json:"organization_id"` + OutletID *uuid.UUID `json:"outlet_id"` + ProductID uuid.UUID `json:"product_id"` + IngredientID uuid.UUID `json:"ingredient_id"` + Quantity float64 `json:"quantity"` + WastePercentage float64 `json:"waste_percentage"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` // Relations Product *Product `json:"product,omitempty"` @@ -37,15 +37,15 @@ type UpdateProductIngredientRequest struct { } type ProductIngredientResponse struct { - ID uuid.UUID `json:"id"` - OrganizationID uuid.UUID `json:"organization_id"` - OutletID *uuid.UUID `json:"outlet_id"` - ProductID uuid.UUID `json:"product_id"` - IngredientID uuid.UUID `json:"ingredient_id"` - Quantity float64 `json:"quantity"` - WastePercentage float64 `json:"waste_percentage"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + ID uuid.UUID `json:"id"` + OrganizationID uuid.UUID `json:"organization_id"` + OutletID *uuid.UUID `json:"outlet_id"` + ProductID uuid.UUID `json:"product_id"` + IngredientID uuid.UUID `json:"ingredient_id"` + Quantity float64 `json:"quantity"` + WastePercentage float64 `json:"waste_percentage"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` // Relations Product *Product `json:"product,omitempty"` diff --git a/internal/models/product_recipe.go b/internal/models/product_recipe.go index 5df109c..a9832ea 100644 --- a/internal/models/product_recipe.go +++ b/internal/models/product_recipe.go @@ -56,4 +56,4 @@ type ProductRecipeResponse struct { Product *Product `json:"product,omitempty"` ProductVariant *ProductVariant `json:"product_variant,omitempty"` Ingredient *Ingredient `json:"ingredient,omitempty"` -} \ No newline at end of file +} diff --git a/internal/service/account_service.go b/internal/service/account_service.go index 83a5c9f..43c4f00 100644 --- a/internal/service/account_service.go +++ b/internal/service/account_service.go @@ -60,12 +60,12 @@ func (s *AccountServiceImpl) ListAccounts(ctx context.Context, req *contract.Lis if err != nil { return nil, 0, err } - + contractResp := make([]contract.AccountResponse, len(modelResp)) for i, resp := range modelResp { contractResp[i] = *mappers.ModelToContractAccountResponse(&resp) } - + return contractResp, total, nil } @@ -74,12 +74,12 @@ func (s *AccountServiceImpl) GetAccountsByOrganization(ctx context.Context, orga if err != nil { return nil, err } - + contractResp := make([]contract.AccountResponse, len(modelResp)) for i, resp := range modelResp { contractResp[i] = *mappers.ModelToContractAccountResponse(&resp) } - + return contractResp, nil } @@ -88,12 +88,12 @@ func (s *AccountServiceImpl) GetAccountsByChartOfAccount(ctx context.Context, ch if err != nil { return nil, err } - + contractResp := make([]contract.AccountResponse, len(modelResp)) for i, resp := range modelResp { contractResp[i] = *mappers.ModelToContractAccountResponse(&resp) } - + return contractResp, nil } diff --git a/internal/service/chart_of_account_type_service.go b/internal/service/chart_of_account_type_service.go index a4085d9..9f3c66b 100644 --- a/internal/service/chart_of_account_type_service.go +++ b/internal/service/chart_of_account_type_service.go @@ -59,11 +59,11 @@ func (s *ChartOfAccountTypeServiceImpl) ListChartOfAccountTypes(ctx context.Cont if err != nil { return nil, 0, err } - + contractResp := make([]contract.ChartOfAccountTypeResponse, len(modelResp)) for i, resp := range modelResp { contractResp[i] = *mappers.ModelToContractChartOfAccountTypeResponse(&resp) } - + return contractResp, total, nil } diff --git a/internal/service/ingredient_unit_converter_service.go b/internal/service/ingredient_unit_converter_service.go index 7d7d0a4..3432056 100644 --- a/internal/service/ingredient_unit_converter_service.go +++ b/internal/service/ingredient_unit_converter_service.go @@ -160,4 +160,3 @@ func (s *IngredientUnitConverterServiceImpl) GetUnitsByIngredientID(ctx context. contractResponse := transformer.IngredientUnitsModelResponseToResponse(unitsResponse) return contract.BuildSuccessResponse(contractResponse) } - diff --git a/internal/service/product_recipe_service.go b/internal/service/product_recipe_service.go index bfaf76d..fe0c5b6 100644 --- a/internal/service/product_recipe_service.go +++ b/internal/service/product_recipe_service.go @@ -111,4 +111,4 @@ func (s *ProductRecipeServiceImpl) BulkCreate(ctx context.Context, organizationI } return s.processor.BulkCreate(ctx, req.Recipes, organizationID) -} \ No newline at end of file +} diff --git a/internal/transformer/ingredient_unit_converter_transformer.go b/internal/transformer/ingredient_unit_converter_transformer.go index e3512b0..2d64c49 100644 --- a/internal/transformer/ingredient_unit_converter_transformer.go +++ b/internal/transformer/ingredient_unit_converter_transformer.go @@ -175,4 +175,3 @@ func IngredientUnitsModelResponseToResponse(model *models.IngredientUnitsRespons return response } - diff --git a/internal/util/waste_util.go b/internal/util/waste_util.go index 696fafc..a627365 100644 --- a/internal/util/waste_util.go +++ b/internal/util/waste_util.go @@ -20,11 +20,11 @@ func CalculateWasteQuantities(productIngredients []*entities.ProductIngredient, for _, pi := range productIngredients { // Calculate net quantity (actual quantity needed for the product) netQty := pi.Quantity * quantity - + // Calculate gross quantity (including waste) wasteMultiplier := 1 + (pi.WastePercentage / 100) grossQty := netQty * wasteMultiplier - + // Calculate waste quantity wasteQty := grossQty - netQty diff --git a/internal/validator/ingredient_unit_converter_validator.go b/internal/validator/ingredient_unit_converter_validator.go index f2a0499..a5ae6e9 100644 --- a/internal/validator/ingredient_unit_converter_validator.go +++ b/internal/validator/ingredient_unit_converter_validator.go @@ -119,4 +119,3 @@ func (v *IngredientUnitConverterValidatorImpl) ValidateConvertUnitRequest(req *c return nil, "" } -