fix(server): rename term to

This commit is contained in:
Ahmed Bouhuolia
2024-08-13 13:41:09 +02:00
parent cd90fede54
commit 9991eebaaf
35 changed files with 89 additions and 93 deletions

View File

@@ -0,0 +1,46 @@
import { ServiceError } from '@/exceptions';
import { IPaymentReceive } from '@/interfaces';
import HasTenancyService from '@/services/Tenancy/TenancyService';
import { Inject, Service } from 'typedi';
import { ERRORS } from './constants';
import { PaymentReceiveTransfromer } from './PaymentReceivedTransformer';
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
@Service()
export class GetPaymentReceived {
@Inject()
private tenancy: HasTenancyService;
@Inject()
private transformer: TransformerInjectable;
/**
* Retrieve payment receive details.
* @param {number} tenantId - Tenant id.
* @param {number} paymentReceiveId - Payment receive id.
* @return {Promise<IPaymentReceive>}
*/
public async getPaymentReceive(
tenantId: number,
paymentReceiveId: number
): Promise<IPaymentReceive> {
const { PaymentReceive } = this.tenancy.models(tenantId);
const paymentReceive = await PaymentReceive.query()
.withGraphFetched('customer')
.withGraphFetched('depositAccount')
.withGraphFetched('entries.invoice')
.withGraphFetched('transactions')
.withGraphFetched('branch')
.findById(paymentReceiveId);
if (!paymentReceive) {
throw new ServiceError(ERRORS.PAYMENT_RECEIVE_NOT_EXISTS);
}
return this.transformer.transform(
tenantId,
paymentReceive,
new PaymentReceiveTransfromer()
);
}
}