feat: add inventory transaction details to product entity and response, and update repository preload logic
Deploy Application / deploy (push) Successful in 26s Details

This commit is contained in:
Habib Fatkhul Rohman 2025-11-21 13:55:58 +07:00
parent f7eab339b6
commit 15dce0f540
3 changed files with 59 additions and 45 deletions

View File

@ -51,6 +51,7 @@ type MProductEntity struct {
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
} }

View File

@ -137,6 +137,7 @@ type (
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"`
}
) )

View File

@ -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
} }