implement bop for expedition must recheck and qty in staff purchase need info

This commit is contained in:
ragilap
2025-12-05 14:08:54 +07:00
parent c064fb1765
commit ee2db748ea
15 changed files with 1062 additions and 292 deletions
@@ -19,10 +19,9 @@ type PurchaseRepository interface {
repository.BaseRepository[entity.Purchase]
CreateWithItems(ctx context.Context, purchase *entity.Purchase, items []*entity.PurchaseItem) error
CreateItems(ctx context.Context, purchaseID uint, items []*entity.PurchaseItem) error
UpdatePricing(ctx context.Context, purchaseID uint, updates []PurchasePricingUpdate, grandTotal float64) error
UpdatePricing(ctx context.Context, purchaseID uint, updates []PurchasePricingUpdate) error
UpdateReceivingDetails(ctx context.Context, purchaseID uint, updates []PurchaseReceivingUpdate) error
DeleteItems(ctx context.Context, purchaseID uint, itemIDs []uint) error
UpdateGrandTotal(ctx context.Context, purchaseID uint, grandTotal float64) error
NextPrNumber(ctx context.Context, tx *gorm.DB) (string, error)
NextPoNumber(ctx context.Context, tx *gorm.DB) (string, error)
}
@@ -99,7 +98,6 @@ func (r *PurchaseRepositoryImpl) UpdatePricing(
ctx context.Context,
purchaseID uint,
updates []PurchasePricingUpdate,
grandTotal float64,
) error {
if len(updates) == 0 {
return errors.New("pricing updates cannot be empty")
@@ -133,14 +131,6 @@ func (r *PurchaseRepositoryImpl) UpdatePricing(
}
}
if err := db.Model(&entity.Purchase{}).
Where("id = ?", purchaseID).
Updates(map[string]interface{}{
"grand_total": grandTotal,
}).Error; err != nil {
return err
}
return nil
}
@@ -201,20 +191,6 @@ func (r *PurchaseRepositoryImpl) UpdateReceivingDetails(
return nil
}
func (r *PurchaseRepositoryImpl) UpdateGrandTotal(
ctx context.Context,
purchaseID uint,
grandTotal float64,
) error {
return r.DB().WithContext(ctx).
Model(&entity.Purchase{}).
Where("id = ?", purchaseID).
Updates(map[string]interface{}{
"grand_total": grandTotal,
"updated_at": gorm.Expr("NOW()"),
}).Error
}
func (r *PurchaseRepositoryImpl) DeleteItems(ctx context.Context, purchaseID uint, itemIDs []uint) error {
if len(itemIDs) == 0 {
return errors.New("itemIDs cannot be empty")