Add coa purchase and vendors
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
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 time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ChartOfAccount *ChartOfAccountResponse `json:"chart_of_account,omitempty"`
|
||||
}
|
||||
|
||||
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"`
|
||||
}
|
||||
|
||||
type UpdateAccountRequest struct {
|
||||
ChartOfAccountID *uuid.UUID `json:"chart_of_account_id"`
|
||||
Name *string `json:"name" validate:"omitempty,min=1,max=255"`
|
||||
Number *string `json:"number" validate:"omitempty,min=1,max=50"`
|
||||
AccountType *string `json:"account_type" validate:"omitempty,oneof=cash wallet bank credit debit asset liability equity revenue expense"`
|
||||
OpeningBalance *float64 `json:"opening_balance"`
|
||||
Description *string `json:"description"`
|
||||
IsActive *bool `json:"is_active"`
|
||||
}
|
||||
|
||||
type ListAccountsRequest struct {
|
||||
OrganizationID *uuid.UUID `form:"organization_id"`
|
||||
OutletID *uuid.UUID `form:"outlet_id"`
|
||||
ChartOfAccountID *uuid.UUID `form:"chart_of_account_id"`
|
||||
AccountType *string `form:"account_type"`
|
||||
IsActive *bool `form:"is_active"`
|
||||
IsSystem *bool `form:"is_system"`
|
||||
Page int `form:"page,default=1"`
|
||||
Limit int `form:"limit,default=10"`
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type ChartOfAccountResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id"`
|
||||
OutletID *uuid.UUID `json:"outlet_id"`
|
||||
ChartOfAccountTypeID uuid.UUID `json:"chart_of_account_type_id"`
|
||||
ParentID *uuid.UUID `json:"parent_id"`
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Description *string `json:"description"`
|
||||
IsActive bool `json:"is_active"`
|
||||
IsSystem bool `json:"is_system"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ChartOfAccountType *ChartOfAccountTypeResponse `json:"chart_of_account_type,omitempty"`
|
||||
Parent *ChartOfAccountResponse `json:"parent,omitempty"`
|
||||
Children []ChartOfAccountResponse `json:"children,omitempty"`
|
||||
}
|
||||
|
||||
type CreateChartOfAccountRequest struct {
|
||||
ChartOfAccountTypeID uuid.UUID `json:"chart_of_account_type_id" validate:"required"`
|
||||
ParentID *uuid.UUID `json:"parent_id"`
|
||||
Name string `json:"name" validate:"required,min=1,max=255"`
|
||||
Code string `json:"code" validate:"required,min=1,max=20"`
|
||||
Description *string `json:"description"`
|
||||
}
|
||||
|
||||
type UpdateChartOfAccountRequest struct {
|
||||
ChartOfAccountTypeID *uuid.UUID `json:"chart_of_account_type_id"`
|
||||
ParentID *uuid.UUID `json:"parent_id"`
|
||||
Name *string `json:"name" validate:"omitempty,min=1,max=255"`
|
||||
Code *string `json:"code" validate:"omitempty,min=1,max=20"`
|
||||
Description *string `json:"description"`
|
||||
IsActive *bool `json:"is_active"`
|
||||
}
|
||||
|
||||
type ListChartOfAccountsRequest struct {
|
||||
OrganizationID *uuid.UUID `form:"organization_id"`
|
||||
OutletID *uuid.UUID `form:"outlet_id"`
|
||||
ChartOfAccountTypeID *uuid.UUID `form:"chart_of_account_type_id"`
|
||||
ParentID *uuid.UUID `form:"parent_id"`
|
||||
IsActive *bool `form:"is_active"`
|
||||
IsSystem *bool `form:"is_system"`
|
||||
Page int `form:"page,default=1"`
|
||||
Limit int `form:"limit,default=10"`
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type ChartOfAccountTypeResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Description *string `json:"description"`
|
||||
IsActive bool `json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CreateChartOfAccountTypeRequest struct {
|
||||
Name string `json:"name" validate:"required,min=1,max=100"`
|
||||
Code string `json:"code" validate:"required,min=1,max=10"`
|
||||
Description *string `json:"description"`
|
||||
}
|
||||
|
||||
type UpdateChartOfAccountTypeRequest struct {
|
||||
Name *string `json:"name" validate:"omitempty,min=1,max=100"`
|
||||
Code *string `json:"code" validate:"omitempty,min=1,max=10"`
|
||||
Description *string `json:"description"`
|
||||
IsActive *bool `json:"is_active"`
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// IngredientUnitConverter represents the unit converter for ingredients
|
||||
type IngredientUnitConverter struct {
|
||||
ID uuid.UUID
|
||||
OrganizationID uuid.UUID
|
||||
IngredientID uuid.UUID
|
||||
FromUnitID uuid.UUID
|
||||
ToUnitID uuid.UUID
|
||||
ConversionFactor float64
|
||||
IsActive bool
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
CreatedBy uuid.UUID
|
||||
UpdatedBy uuid.UUID
|
||||
|
||||
// Related entities
|
||||
Ingredient *Ingredient
|
||||
FromUnit *Unit
|
||||
ToUnit *Unit
|
||||
}
|
||||
|
||||
// Request DTOs
|
||||
type CreateIngredientUnitConverterRequest struct {
|
||||
IngredientID uuid.UUID `validate:"required"`
|
||||
FromUnitID uuid.UUID `validate:"required"`
|
||||
ToUnitID uuid.UUID `validate:"required"`
|
||||
ConversionFactor float64 `validate:"required,gt=0"`
|
||||
IsActive *bool `validate:"omitempty"`
|
||||
}
|
||||
|
||||
type UpdateIngredientUnitConverterRequest struct {
|
||||
FromUnitID *uuid.UUID `validate:"omitempty"`
|
||||
ToUnitID *uuid.UUID `validate:"omitempty"`
|
||||
ConversionFactor *float64 `validate:"omitempty,gt=0"`
|
||||
IsActive *bool `validate:"omitempty"`
|
||||
}
|
||||
|
||||
type ListIngredientUnitConvertersRequest struct {
|
||||
IngredientID *uuid.UUID
|
||||
FromUnitID *uuid.UUID
|
||||
ToUnitID *uuid.UUID
|
||||
IsActive *bool
|
||||
Search string
|
||||
Page int `validate:"required,min=1"`
|
||||
Limit int `validate:"required,min=1,max=100"`
|
||||
}
|
||||
|
||||
type ConvertUnitRequest struct {
|
||||
IngredientID uuid.UUID `validate:"required"`
|
||||
FromUnitID uuid.UUID `validate:"required"`
|
||||
ToUnitID uuid.UUID `validate:"required"`
|
||||
Quantity float64 `validate:"required,gt=0"`
|
||||
}
|
||||
|
||||
// Response DTOs
|
||||
type IngredientUnitConverterResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id"`
|
||||
IngredientID uuid.UUID `json:"ingredient_id"`
|
||||
FromUnitID uuid.UUID `json:"from_unit_id"`
|
||||
ToUnitID uuid.UUID `json:"to_unit_id"`
|
||||
ConversionFactor float64 `json:"conversion_factor"`
|
||||
IsActive bool `json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
CreatedBy uuid.UUID `json:"created_by"`
|
||||
UpdatedBy uuid.UUID `json:"updated_by"`
|
||||
Ingredient *IngredientResponse `json:"ingredient,omitempty"`
|
||||
FromUnit *UnitResponse `json:"from_unit,omitempty"`
|
||||
ToUnit *UnitResponse `json:"to_unit,omitempty"`
|
||||
}
|
||||
|
||||
type ConvertUnitResponse struct {
|
||||
FromQuantity float64 `json:"from_quantity"`
|
||||
FromUnit *UnitResponse `json:"from_unit"`
|
||||
ToQuantity float64 `json:"to_quantity"`
|
||||
ToUnit *UnitResponse `json:"to_unit"`
|
||||
ConversionFactor float64 `json:"conversion_factor"`
|
||||
Ingredient *IngredientResponse `json:"ingredient,omitempty"`
|
||||
}
|
||||
|
||||
type ListIngredientUnitConvertersResponse struct {
|
||||
Converters []IngredientUnitConverterResponse `json:"converters"`
|
||||
TotalCount int `json:"total_count"`
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
TotalPages int `json:"total_pages"`
|
||||
}
|
||||
|
||||
@@ -26,5 +26,10 @@ func GetAllModelNames() []string {
|
||||
"PaymentMethod",
|
||||
"Payment",
|
||||
"Customer",
|
||||
"Vendor",
|
||||
"PurchaseOrder",
|
||||
"PurchaseOrderItem",
|
||||
"PurchaseOrderAttachment",
|
||||
"IngredientUnitConverter",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type PurchaseOrder struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id"`
|
||||
VendorID uuid.UUID `json:"vendor_id"`
|
||||
PONumber string `json:"po_number"`
|
||||
TransactionDate time.Time `json:"transaction_date"`
|
||||
DueDate time.Time `json:"due_date"`
|
||||
Reference *string `json:"reference"`
|
||||
Status string `json:"status"`
|
||||
Message *string `json:"message"`
|
||||
TotalAmount float64 `json:"total_amount"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type PurchaseOrderItem struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
PurchaseOrderID uuid.UUID `json:"purchase_order_id"`
|
||||
IngredientID uuid.UUID `json:"ingredient_id"`
|
||||
Description *string `json:"description"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
UnitID uuid.UUID `json:"unit_id"`
|
||||
Amount float64 `json:"amount"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type PurchaseOrderAttachment struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
PurchaseOrderID uuid.UUID `json:"purchase_order_id"`
|
||||
FileID uuid.UUID `json:"file_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type PurchaseOrderResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id"`
|
||||
VendorID uuid.UUID `json:"vendor_id"`
|
||||
PONumber string `json:"po_number"`
|
||||
TransactionDate time.Time `json:"transaction_date"`
|
||||
DueDate time.Time `json:"due_date"`
|
||||
Reference *string `json:"reference"`
|
||||
Status string `json:"status"`
|
||||
Message *string `json:"message"`
|
||||
TotalAmount float64 `json:"total_amount"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Vendor *VendorResponse `json:"vendor,omitempty"`
|
||||
Items []PurchaseOrderItemResponse `json:"items,omitempty"`
|
||||
Attachments []PurchaseOrderAttachmentResponse `json:"attachments,omitempty"`
|
||||
}
|
||||
|
||||
type PurchaseOrderItemResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
PurchaseOrderID uuid.UUID `json:"purchase_order_id"`
|
||||
IngredientID uuid.UUID `json:"ingredient_id"`
|
||||
Description *string `json:"description"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
UnitID uuid.UUID `json:"unit_id"`
|
||||
Amount float64 `json:"amount"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Ingredient *IngredientResponse `json:"ingredient,omitempty"`
|
||||
Unit *UnitResponse `json:"unit,omitempty"`
|
||||
}
|
||||
|
||||
type PurchaseOrderAttachmentResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
PurchaseOrderID uuid.UUID `json:"purchase_order_id"`
|
||||
FileID uuid.UUID `json:"file_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
File *FileResponse `json:"file,omitempty"`
|
||||
}
|
||||
|
||||
type CreatePurchaseOrderRequest struct {
|
||||
VendorID uuid.UUID `json:"vendor_id"`
|
||||
PONumber string `json:"po_number"`
|
||||
TransactionDate time.Time `json:"transaction_date"`
|
||||
DueDate time.Time `json:"due_date"`
|
||||
Reference *string `json:"reference,omitempty"`
|
||||
Status *string `json:"status,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
Items []CreatePurchaseOrderItemRequest `json:"items"`
|
||||
AttachmentFileIDs []uuid.UUID `json:"attachment_file_ids,omitempty"`
|
||||
}
|
||||
|
||||
type CreatePurchaseOrderItemRequest struct {
|
||||
IngredientID uuid.UUID `json:"ingredient_id"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
UnitID uuid.UUID `json:"unit_id"`
|
||||
Amount float64 `json:"amount"`
|
||||
}
|
||||
|
||||
type UpdatePurchaseOrderRequest struct {
|
||||
VendorID *uuid.UUID `json:"vendor_id,omitempty"`
|
||||
PONumber *string `json:"po_number,omitempty"`
|
||||
TransactionDate *time.Time `json:"transaction_date,omitempty"`
|
||||
DueDate *time.Time `json:"due_date,omitempty"`
|
||||
Reference *string `json:"reference,omitempty"`
|
||||
Status *string `json:"status,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
Items []UpdatePurchaseOrderItemRequest `json:"items,omitempty"`
|
||||
AttachmentFileIDs []uuid.UUID `json:"attachment_file_ids,omitempty"`
|
||||
}
|
||||
|
||||
type UpdatePurchaseOrderItemRequest struct {
|
||||
ID *uuid.UUID `json:"id,omitempty"` // For existing items
|
||||
IngredientID *uuid.UUID `json:"ingredient_id,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Quantity *float64 `json:"quantity,omitempty"`
|
||||
UnitID *uuid.UUID `json:"unit_id,omitempty"`
|
||||
Amount *float64 `json:"amount,omitempty"`
|
||||
}
|
||||
|
||||
type ListPurchaseOrdersRequest struct {
|
||||
Page int `json:"page" validate:"min=1"`
|
||||
Limit int `json:"limit" validate:"min=1,max=100"`
|
||||
Search string `json:"search,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
VendorID *uuid.UUID `json:"vendor_id,omitempty"`
|
||||
StartDate *time.Time `json:"start_date,omitempty"`
|
||||
EndDate *time.Time `json:"end_date,omitempty"`
|
||||
}
|
||||
|
||||
type ListPurchaseOrdersResponse struct {
|
||||
PurchaseOrders []PurchaseOrderResponse `json:"purchase_orders"`
|
||||
TotalCount int `json:"total_count"`
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
TotalPages int `json:"total_pages"`
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Vendor struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id"`
|
||||
Name string `json:"name"`
|
||||
Email *string `json:"email"`
|
||||
PhoneNumber *string `json:"phone_number"`
|
||||
Address *string `json:"address"`
|
||||
ContactPerson *string `json:"contact_person"`
|
||||
TaxNumber *string `json:"tax_number"`
|
||||
PaymentTerms *string `json:"payment_terms"`
|
||||
Notes *string `json:"notes"`
|
||||
IsActive bool `json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type VendorResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id"`
|
||||
Name string `json:"name"`
|
||||
Email *string `json:"email"`
|
||||
PhoneNumber *string `json:"phone_number"`
|
||||
Address *string `json:"address"`
|
||||
ContactPerson *string `json:"contact_person"`
|
||||
TaxNumber *string `json:"tax_number"`
|
||||
PaymentTerms *string `json:"payment_terms"`
|
||||
Notes *string `json:"notes"`
|
||||
IsActive bool `json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CreateVendorRequest struct {
|
||||
Name string `json:"name"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
PhoneNumber *string `json:"phone_number,omitempty"`
|
||||
Address *string `json:"address,omitempty"`
|
||||
ContactPerson *string `json:"contact_person,omitempty"`
|
||||
TaxNumber *string `json:"tax_number,omitempty"`
|
||||
PaymentTerms *string `json:"payment_terms,omitempty"`
|
||||
Notes *string `json:"notes,omitempty"`
|
||||
IsActive *bool `json:"is_active,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateVendorRequest struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
PhoneNumber *string `json:"phone_number,omitempty"`
|
||||
Address *string `json:"address,omitempty"`
|
||||
ContactPerson *string `json:"contact_person,omitempty"`
|
||||
TaxNumber *string `json:"tax_number,omitempty"`
|
||||
PaymentTerms *string `json:"payment_terms,omitempty"`
|
||||
Notes *string `json:"notes,omitempty"`
|
||||
IsActive *bool `json:"is_active,omitempty"`
|
||||
}
|
||||
|
||||
type ListVendorsRequest struct {
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
Search string `json:"search,omitempty"`
|
||||
IsActive *bool `json:"is_active,omitempty"`
|
||||
}
|
||||
|
||||
type ListVendorsResponse struct {
|
||||
Vendors []*VendorResponse `json:"vendors"`
|
||||
TotalCount int `json:"total_count"`
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
TotalPages int `json:"total_pages"`
|
||||
}
|
||||
Reference in New Issue
Block a user