feat(nestjs): migrate to NestJS

This commit is contained in:
Ahmed Bouhuolia
2025-04-07 11:51:24 +02:00
parent f068218a16
commit 55fcc908ef
3779 changed files with 631 additions and 195332 deletions

View File

@@ -0,0 +1,45 @@
import { Inject, Injectable } from '@nestjs/common';
import { ERRORS } from '../constants';
import { PaymentReceiveTransfromer } from './PaymentReceivedTransformer';
import { PaymentReceived } from '../models/PaymentReceived';
import { TransformerInjectable } from '../../Transformer/TransformerInjectable.service';
import { ServiceError } from '../../Items/ServiceError';
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
@Injectable()
export class GetPaymentReceivedService {
constructor(
private readonly transformer: TransformerInjectable,
@Inject(PaymentReceived.name)
private readonly paymentReceiveModel: TenantModelProxy<
typeof PaymentReceived
>,
) {}
/**
* Retrieve payment receive details.
* @param {number} paymentReceiveId - Payment receive id.
* @return {Promise<IPaymentReceived>}
*/
public async getPaymentReceive(
paymentReceiveId: number,
): Promise<PaymentReceived> {
const paymentReceive = await this.paymentReceiveModel()
.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(
paymentReceive,
new PaymentReceiveTransfromer(),
);
}
}