This commit is contained in:
aditya.siregar
2025-07-18 20:10:29 +07:00
parent 1bceae010b
commit 4f5950543e
511 changed files with 24132 additions and 34137 deletions
+59
View File
@@ -0,0 +1,59 @@
package models
import (
"time"
"github.com/google/uuid"
)
type Inventory struct {
ID uuid.UUID
OutletID uuid.UUID
ProductID uuid.UUID
Quantity int
ReorderLevel int
UpdatedAt time.Time
}
type CreateInventoryRequest struct {
OutletID uuid.UUID
ProductID uuid.UUID
Quantity int
ReorderLevel int
}
type UpdateInventoryRequest struct {
Quantity *int
ReorderLevel *int
}
type InventoryAdjustmentRequest struct {
Delta int
Reason string
}
type InventoryResponse struct {
ID uuid.UUID
OutletID uuid.UUID
ProductID uuid.UUID
Quantity int
ReorderLevel int
IsLowStock bool
UpdatedAt time.Time
}
func (i *Inventory) IsLowStock() bool {
return i.Quantity <= i.ReorderLevel
}
func (i *Inventory) CanFulfillOrder(requestedQuantity int) bool {
return i.Quantity >= requestedQuantity
}
func (i *Inventory) AdjustQuantity(delta int) int {
newQuantity := i.Quantity + delta
if newQuantity < 0 {
newQuantity = 0
}
return newQuantity
}