init
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type InventoryMovementType string
|
||||
|
||||
const (
|
||||
InventoryMovementTypeSale InventoryMovementType = "sale"
|
||||
InventoryMovementTypePurchase InventoryMovementType = "purchase"
|
||||
InventoryMovementTypeAdjustment InventoryMovementType = "adjustment"
|
||||
InventoryMovementTypeReturn InventoryMovementType = "return"
|
||||
InventoryMovementTypeRefund InventoryMovementType = "refund"
|
||||
InventoryMovementTypeVoid InventoryMovementType = "void"
|
||||
InventoryMovementTypeTransferIn InventoryMovementType = "transfer_in"
|
||||
InventoryMovementTypeTransferOut InventoryMovementType = "transfer_out"
|
||||
InventoryMovementTypeDamage InventoryMovementType = "damage"
|
||||
InventoryMovementTypeExpiry InventoryMovementType = "expiry"
|
||||
)
|
||||
|
||||
type InventoryMovementReferenceType string
|
||||
|
||||
const (
|
||||
InventoryMovementReferenceTypeOrder InventoryMovementReferenceType = "order"
|
||||
InventoryMovementReferenceTypePayment InventoryMovementReferenceType = "payment"
|
||||
InventoryMovementReferenceTypeRefund InventoryMovementReferenceType = "refund"
|
||||
InventoryMovementReferenceTypeVoid InventoryMovementReferenceType = "void"
|
||||
InventoryMovementReferenceTypeManual InventoryMovementReferenceType = "manual"
|
||||
InventoryMovementReferenceTypeTransfer InventoryMovementReferenceType = "transfer"
|
||||
InventoryMovementReferenceTypePurchaseOrder InventoryMovementReferenceType = "purchase_order"
|
||||
)
|
||||
|
||||
type InventoryMovement struct {
|
||||
ID uuid.UUID
|
||||
OrganizationID uuid.UUID
|
||||
OutletID uuid.UUID
|
||||
ProductID uuid.UUID
|
||||
MovementType InventoryMovementType
|
||||
Quantity int
|
||||
PreviousQuantity int
|
||||
NewQuantity int
|
||||
UnitCost float64
|
||||
TotalCost float64
|
||||
ReferenceType *InventoryMovementReferenceType
|
||||
ReferenceID *uuid.UUID
|
||||
OrderID *uuid.UUID
|
||||
PaymentID *uuid.UUID
|
||||
UserID uuid.UUID
|
||||
Reason *string
|
||||
Notes *string
|
||||
Metadata map[string]interface{}
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type CreateInventoryMovementRequest struct {
|
||||
OrganizationID uuid.UUID
|
||||
OutletID uuid.UUID
|
||||
ProductID uuid.UUID
|
||||
MovementType InventoryMovementType
|
||||
Quantity int
|
||||
UnitCost float64
|
||||
ReferenceType *InventoryMovementReferenceType
|
||||
ReferenceID *uuid.UUID
|
||||
OrderID *uuid.UUID
|
||||
PaymentID *uuid.UUID
|
||||
UserID uuid.UUID
|
||||
Reason *string
|
||||
Notes *string
|
||||
Metadata map[string]interface{}
|
||||
}
|
||||
|
||||
type InventoryMovementResponse struct {
|
||||
ID uuid.UUID
|
||||
OrganizationID uuid.UUID
|
||||
OutletID uuid.UUID
|
||||
ProductID uuid.UUID
|
||||
MovementType InventoryMovementType
|
||||
Quantity int
|
||||
PreviousQuantity int
|
||||
NewQuantity int
|
||||
UnitCost float64
|
||||
TotalCost float64
|
||||
ReferenceType *InventoryMovementReferenceType
|
||||
ReferenceID *uuid.UUID
|
||||
OrderID *uuid.UUID
|
||||
PaymentID *uuid.UUID
|
||||
UserID uuid.UUID
|
||||
Reason *string
|
||||
Notes *string
|
||||
Metadata map[string]interface{}
|
||||
CreatedAt time.Time
|
||||
MovementDescription string
|
||||
}
|
||||
|
||||
type ListInventoryMovementsRequest struct {
|
||||
OrganizationID *uuid.UUID
|
||||
OutletID *uuid.UUID
|
||||
ProductID *uuid.UUID
|
||||
MovementType *InventoryMovementType
|
||||
ReferenceType *InventoryMovementReferenceType
|
||||
ReferenceID *uuid.UUID
|
||||
OrderID *uuid.UUID
|
||||
PaymentID *uuid.UUID
|
||||
UserID *uuid.UUID
|
||||
DateFrom *time.Time
|
||||
DateTo *time.Time
|
||||
Page int
|
||||
Limit int
|
||||
}
|
||||
|
||||
type ListInventoryMovementsResponse struct {
|
||||
Movements []InventoryMovementResponse
|
||||
TotalCount int
|
||||
Page int
|
||||
Limit int
|
||||
TotalPages int
|
||||
}
|
||||
|
||||
func (im *InventoryMovement) IsPositiveMovement() bool {
|
||||
return im.Quantity > 0
|
||||
}
|
||||
|
||||
func (im *InventoryMovement) IsNegativeMovement() bool {
|
||||
return im.Quantity < 0
|
||||
}
|
||||
|
||||
func (im *InventoryMovement) GetMovementDescription() string {
|
||||
switch im.MovementType {
|
||||
case InventoryMovementTypeSale:
|
||||
return "Sale"
|
||||
case InventoryMovementTypePurchase:
|
||||
return "Purchase"
|
||||
case InventoryMovementTypeAdjustment:
|
||||
return "Manual Adjustment"
|
||||
case InventoryMovementTypeReturn:
|
||||
return "Return"
|
||||
case InventoryMovementTypeRefund:
|
||||
return "Refund"
|
||||
case InventoryMovementTypeVoid:
|
||||
return "Void"
|
||||
case InventoryMovementTypeTransferIn:
|
||||
return "Transfer In"
|
||||
case InventoryMovementTypeTransferOut:
|
||||
return "Transfer Out"
|
||||
case InventoryMovementTypeDamage:
|
||||
return "Damage"
|
||||
case InventoryMovementTypeExpiry:
|
||||
return "Expiry"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ type Product struct {
|
||||
Price float64
|
||||
Cost float64
|
||||
BusinessType constants.BusinessType
|
||||
ImageURL *string
|
||||
PrinterType string
|
||||
Metadata map[string]interface{}
|
||||
IsActive bool
|
||||
CreatedAt time.Time
|
||||
@@ -43,6 +45,8 @@ type CreateProductRequest struct {
|
||||
Price float64 `validate:"required,min=0"`
|
||||
Cost float64 `validate:"min=0"`
|
||||
BusinessType constants.BusinessType `validate:"required"`
|
||||
ImageURL *string `validate:"omitempty,max=500"`
|
||||
PrinterType *string `validate:"omitempty,max=50"`
|
||||
Metadata map[string]interface{}
|
||||
Variants []CreateProductVariantRequest `validate:"omitempty,dive"`
|
||||
// Stock management fields
|
||||
@@ -58,6 +62,8 @@ type UpdateProductRequest struct {
|
||||
Description *string `validate:"omitempty,max=1000"`
|
||||
Price *float64 `validate:"omitempty,min=0"`
|
||||
Cost *float64 `validate:"omitempty,min=0"`
|
||||
ImageURL *string `validate:"omitempty,max=500"`
|
||||
PrinterType *string `validate:"omitempty,max=50"`
|
||||
Metadata map[string]interface{}
|
||||
IsActive *bool
|
||||
// Stock management fields
|
||||
@@ -89,6 +95,8 @@ type ProductResponse struct {
|
||||
Price float64
|
||||
Cost float64
|
||||
BusinessType constants.BusinessType
|
||||
ImageURL *string
|
||||
PrinterType string
|
||||
Metadata map[string]interface{}
|
||||
IsActive bool
|
||||
CreatedAt time.Time
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"apskel-pos-be/internal/constants"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Table struct {
|
||||
ID uuid.UUID
|
||||
OrganizationID uuid.UUID
|
||||
OutletID uuid.UUID
|
||||
TableName string
|
||||
StartTime *time.Time
|
||||
Status constants.TableStatus
|
||||
OrderID *uuid.UUID
|
||||
PaymentAmount float64
|
||||
PositionX float64
|
||||
PositionY float64
|
||||
Capacity int
|
||||
IsActive bool
|
||||
Metadata map[string]interface{}
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type CreateTableRequest struct {
|
||||
OutletID uuid.UUID `validate:"required"`
|
||||
TableName string `validate:"required,max=100"`
|
||||
PositionX float64 `validate:"required"`
|
||||
PositionY float64 `validate:"required"`
|
||||
Capacity int `validate:"required,min=1,max=20"`
|
||||
Metadata map[string]interface{}
|
||||
}
|
||||
|
||||
type UpdateTableRequest struct {
|
||||
TableName *string `validate:"omitempty,max=100"`
|
||||
Status *constants.TableStatus `validate:"omitempty"`
|
||||
PositionX *float64 `validate:"omitempty"`
|
||||
PositionY *float64 `validate:"omitempty"`
|
||||
Capacity *int `validate:"omitempty,min=1,max=20"`
|
||||
IsActive *bool `validate:"omitempty"`
|
||||
Metadata map[string]interface{}
|
||||
}
|
||||
|
||||
type OccupyTableRequest struct {
|
||||
OrderID uuid.UUID `validate:"required"`
|
||||
StartTime time.Time `validate:"required"`
|
||||
}
|
||||
|
||||
type ReleaseTableRequest struct {
|
||||
PaymentAmount float64 `validate:"required,min=0"`
|
||||
}
|
||||
|
||||
type TableResponse struct {
|
||||
ID uuid.UUID
|
||||
OrganizationID uuid.UUID
|
||||
OutletID uuid.UUID
|
||||
TableName string
|
||||
StartTime *time.Time
|
||||
Status constants.TableStatus
|
||||
OrderID *uuid.UUID
|
||||
PaymentAmount float64
|
||||
PositionX float64
|
||||
PositionY float64
|
||||
Capacity int
|
||||
IsActive bool
|
||||
Metadata map[string]interface{}
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Order *OrderResponse
|
||||
}
|
||||
|
||||
type ListTablesRequest struct {
|
||||
OrganizationID *uuid.UUID
|
||||
OutletID *uuid.UUID
|
||||
Status *constants.TableStatus
|
||||
IsActive *bool
|
||||
Search string
|
||||
Page int `validate:"required,min=1"`
|
||||
Limit int `validate:"required,min=1,max=100"`
|
||||
}
|
||||
|
||||
type ListTablesResponse struct {
|
||||
Tables []TableResponse
|
||||
TotalCount int
|
||||
Page int
|
||||
Limit int
|
||||
TotalPages int
|
||||
}
|
||||
|
||||
func (t *Table) IsAvailable() bool {
|
||||
return t.Status == constants.TableStatusAvailable
|
||||
}
|
||||
|
||||
func (t *Table) IsOccupied() bool {
|
||||
return t.Status == constants.TableStatusOccupied
|
||||
}
|
||||
|
||||
func (t *Table) CanBeOccupied() bool {
|
||||
return t.Status == constants.TableStatusAvailable || t.Status == constants.TableStatusCleaning
|
||||
}
|
||||
@@ -44,6 +44,10 @@ type ChangePasswordRequest struct {
|
||||
NewPassword string `validate:"required,min=6"`
|
||||
}
|
||||
|
||||
type UpdateUserOutletRequest struct {
|
||||
OutletID uuid.UUID `validate:"required"`
|
||||
}
|
||||
|
||||
type UserResponse struct {
|
||||
ID uuid.UUID
|
||||
OrganizationID uuid.UUID
|
||||
|
||||
Reference in New Issue
Block a user