fix(server): Revert the paid amount to bill transaction after editing bill payment amount

This commit is contained in:
Ahmed Bouhuolia
2024-02-05 18:50:34 +02:00
parent ba3ea93a2d
commit 7b5287ee80
6 changed files with 15 additions and 44 deletions

View File

@@ -1,6 +1,5 @@
import { Knex } from 'knex';
import UnitOfWork from '@/services/UnitOfWork';
import { BillPaymentValidators } from './BillPaymentValidators';
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
import HasTenancyService from '@/services/Tenancy/TenancyService';
import { Inject, Service } from 'typedi';
@@ -21,9 +20,6 @@ export class DeleteBillPayment {
@Inject()
private uow: UnitOfWork;
@Inject()
private validators: BillPaymentValidators;
/**
* Deletes the bill payment and associated transactions.
* @param {number} tenantId - Tenant id.
@@ -36,10 +32,8 @@ export class DeleteBillPayment {
// Retrieve the bill payment or throw not found service error.
const oldBillPayment = await BillPayment.query()
.withGraphFetched('entries')
.findById(billPaymentId);
// Validates the bill payment existance.
this.validators.validateBillPaymentExistance(oldBillPayment);
.findById(billPaymentId)
.throwIfNotFound();
// Deletes the bill transactions with associated transactions under
// unit-of-work envirement.