Update payment

This commit is contained in:
Aditya Siregar
2025-08-13 23:14:26 +07:00
parent 451697b783
commit ccb0458189
10 changed files with 849 additions and 308 deletions
@@ -19,6 +19,7 @@ type InventoryMovementRepository interface {
GetByPaymentID(ctx context.Context, paymentID uuid.UUID) ([]*entities.InventoryMovement, error)
Count(ctx context.Context, filters map[string]interface{}) (int64, error)
CreateWithTransaction(tx *gorm.DB, movement *entities.InventoryMovement) error
CreateInBatches(ctx context.Context, movements []*entities.InventoryMovement, batchSize int) error
}
type InventoryMovementRepositoryImpl struct {
@@ -39,6 +40,13 @@ func (r *InventoryMovementRepositoryImpl) CreateWithTransaction(tx *gorm.DB, mov
return tx.Create(movement).Error
}
func (r *InventoryMovementRepositoryImpl) CreateInBatches(ctx context.Context, movements []*entities.InventoryMovement, batchSize int) error {
if len(movements) == 0 {
return nil
}
return r.db.WithContext(ctx).CreateInBatches(movements, batchSize).Error
}
func (r *InventoryMovementRepositoryImpl) GetByID(ctx context.Context, id uuid.UUID) (*entities.InventoryMovement, error) {
var movement entities.InventoryMovement
err := r.db.WithContext(ctx).First(&movement, "id = ?", id).Error