feat: add inventory transaction details to product entity and response, and update repository preload logic
Deploy Application / deploy (push) Successful in 26s
Details
Deploy Application / deploy (push) Successful in 26s
Details
This commit is contained in:
parent
f7eab339b6
commit
15dce0f540
|
|
@ -40,17 +40,18 @@ type MProductEntity struct {
|
||||||
LeadTimeUomID *uuid.UUID `gorm:"type:uuid;index" json:"lead_time_uom_id"`
|
LeadTimeUomID *uuid.UUID `gorm:"type:uuid;index" json:"lead_time_uom_id"`
|
||||||
UomToUomID *uuid.UUID `gorm:"type:uuid;index" json:"uom_to_uom_id"`
|
UomToUomID *uuid.UUID `gorm:"type:uuid;index" json:"uom_to_uom_id"`
|
||||||
|
|
||||||
Client M_Client `gorm:"foreignKey:ClientID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
|
Client M_Client `gorm:"foreignKey:ClientID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
|
||||||
Category MCategoryEntity `gorm:"foreignKey:CategoryID;references:ID"`
|
Category MCategoryEntity `gorm:"foreignKey:CategoryID;references:ID"`
|
||||||
Uom MUomEntity `gorm:"foreignKey:UomID;references:ID"`
|
Uom MUomEntity `gorm:"foreignKey:UomID;references:ID"`
|
||||||
DimUom MUomEntity `gorm:"foreignKey:DimUomID;references:ID"`
|
DimUom MUomEntity `gorm:"foreignKey:DimUomID;references:ID"`
|
||||||
WeightUom MUomEntity `gorm:"foreignKey:WeightUomID;references:ID"`
|
WeightUom MUomEntity `gorm:"foreignKey:WeightUomID;references:ID"`
|
||||||
VolumeUom MUomEntity `gorm:"foreignKey:VolumeUomID;references:ID"`
|
VolumeUom MUomEntity `gorm:"foreignKey:VolumeUomID;references:ID"`
|
||||||
MinStockUom MUomEntity `gorm:"foreignKey:MinStockUomID;references:ID"`
|
MinStockUom MUomEntity `gorm:"foreignKey:MinStockUomID;references:ID"`
|
||||||
MaxStockUom MUomEntity `gorm:"foreignKey:MaxStockUomID;references:ID"`
|
MaxStockUom MUomEntity `gorm:"foreignKey:MaxStockUomID;references:ID"`
|
||||||
LeadTimeUom MUomEntity `gorm:"foreignKey:LeadTimeUomID;references:ID"`
|
LeadTimeUom MUomEntity `gorm:"foreignKey:LeadTimeUomID;references:ID"`
|
||||||
UomToUom MUomEntity `gorm:"foreignKey:UomToUomID;references:ID"`
|
UomToUom MUomEntity `gorm:"foreignKey:UomToUomID;references:ID"`
|
||||||
CrossReferences []MCrossReferenceEntity `gorm:"foreignKey:ProductID;references:ID"`
|
CrossReferences []MCrossReferenceEntity `gorm:"foreignKey:ProductID;references:ID"`
|
||||||
|
InventoryTransactions []InventoryTransactionEntity `gorm:"foreignKey:ProductID;references:ID"`
|
||||||
|
|
||||||
FullAuditTrail
|
FullAuditTrail
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,40 +103,41 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
ProductResponse struct {
|
ProductResponse struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
RefNumber string `json:"ref_number"`
|
RefNumber string `json:"ref_number"`
|
||||||
SKU string `json:"sku"`
|
SKU string `json:"sku"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
IsReturnable bool `json:"is_returnable"`
|
IsReturnable bool `json:"is_returnable"`
|
||||||
DimLength float64 `json:"dim_length"`
|
DimLength float64 `json:"dim_length"`
|
||||||
DimWidth float64 `json:"dim_width"`
|
DimWidth float64 `json:"dim_width"`
|
||||||
DimHeight float64 `json:"dim_height"`
|
DimHeight float64 `json:"dim_height"`
|
||||||
Weight float64 `json:"weight"`
|
Weight float64 `json:"weight"`
|
||||||
Volume float64 `json:"volume"`
|
Volume float64 `json:"volume"`
|
||||||
MaxStackHeight int `json:"max_stack_height"`
|
MaxStackHeight int `json:"max_stack_height"`
|
||||||
Temperature string `json:"temperature"`
|
Temperature string `json:"temperature"`
|
||||||
IsHazardous bool `json:"is_hazardous"`
|
IsHazardous bool `json:"is_hazardous"`
|
||||||
MinStock int `json:"min_stock"`
|
MinStock int `json:"min_stock"`
|
||||||
MaxStock int `json:"max_stock"`
|
MaxStock int `json:"max_stock"`
|
||||||
ReplenishType string `json:"replenish_type"`
|
ReplenishType string `json:"replenish_type"`
|
||||||
CycleCount string `json:"cycle_count"`
|
CycleCount string `json:"cycle_count"`
|
||||||
LotRules string `json:"lot_rules"`
|
LotRules string `json:"lot_rules"`
|
||||||
LeadTime int `json:"lead_time"`
|
LeadTime int `json:"lead_time"`
|
||||||
MultiplyRate string `json:"multiply_rate"`
|
MultiplyRate string `json:"multiply_rate"`
|
||||||
DivideRate float64 `json:"divide_rate"`
|
DivideRate float64 `json:"divide_rate"`
|
||||||
Client pkgdto.IdNameResponse `json:"client"`
|
Client pkgdto.IdNameResponse `json:"client"`
|
||||||
Category pkgdto.IdNameResponse `json:"category"`
|
Category pkgdto.IdNameResponse `json:"category"`
|
||||||
Uom pkgdto.IdNameResponse `json:"uom"`
|
Uom pkgdto.IdNameResponse `json:"uom"`
|
||||||
DimUom pkgdto.IdNameResponse `json:"dim_uom"`
|
DimUom pkgdto.IdNameResponse `json:"dim_uom"`
|
||||||
WeightUom pkgdto.IdNameResponse `json:"weight_uom"`
|
WeightUom pkgdto.IdNameResponse `json:"weight_uom"`
|
||||||
VolumeUom pkgdto.IdNameResponse `json:"volume_uom"`
|
VolumeUom pkgdto.IdNameResponse `json:"volume_uom"`
|
||||||
MinStockUom pkgdto.IdNameResponse `json:"min_stock_uom"`
|
MinStockUom pkgdto.IdNameResponse `json:"min_stock_uom"`
|
||||||
MaxStockUom pkgdto.IdNameResponse `json:"max_stock_uom"`
|
MaxStockUom pkgdto.IdNameResponse `json:"max_stock_uom"`
|
||||||
LeadTimeUom pkgdto.IdNameResponse `json:"lead_time_uom"`
|
LeadTimeUom pkgdto.IdNameResponse `json:"lead_time_uom"`
|
||||||
UomToUom pkgdto.IdNameResponse `json:"uom_to_uom"`
|
UomToUom pkgdto.IdNameResponse `json:"uom_to_uom"`
|
||||||
CrossReferences []ProductVendorResponse `json:"cross_references"`
|
CrossReferences []ProductVendorResponse `json:"cross_references"`
|
||||||
|
InvTransactions []ProductInventoryTransactionResponse `json:"inv_transactions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
CrossReferenceRequest struct {
|
CrossReferenceRequest struct {
|
||||||
|
|
@ -150,4 +151,9 @@ type (
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
ContactPerson string `json:"contact_person"`
|
ContactPerson string `json:"contact_person"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProductInventoryTransactionResponse struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
TransactionType string `json:"transaction_type"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,13 @@ func (r *productRepository) GetById(ctx context.Context, tx *gorm.DB, productId
|
||||||
Preload("UomToUom").
|
Preload("UomToUom").
|
||||||
Preload("CrossReferences").
|
Preload("CrossReferences").
|
||||||
Preload("CrossReferences.Vendor").
|
Preload("CrossReferences.Vendor").
|
||||||
|
Preload("InvTransactions").
|
||||||
|
Preload("InvTransactions.Product").
|
||||||
|
Preload("InvTransactions.Client").
|
||||||
|
Preload("InvTransactions.Aisle").
|
||||||
|
Preload("InvTransactions.InvReceipt").
|
||||||
|
Preload("InvTransactions.InvIssue").
|
||||||
|
Preload("InvTransactions.InvMove").
|
||||||
First(&product, "id = ?", productId).Error; err != nil {
|
First(&product, "id = ?", productId).Error; err != nil {
|
||||||
return product, err
|
return product, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue