refactor: e2e tests for payment received

This commit is contained in:
Ahmed Bouhuolia
2024-12-30 20:58:56 +02:00
parent 515a984714
commit b046edf337
19 changed files with 237 additions and 76 deletions

View File

@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
import { Inject, Injectable } from '@nestjs/common';
import { ERRORS } from '../constants';
import { PaymentReceiveTransfromer } from './PaymentReceivedTransformer';
import { PaymentReceived } from '../models/PaymentReceived';
@@ -6,10 +6,12 @@ import { TransformerInjectable } from '../../Transformer/TransformerInjectable.s
import { ServiceError } from '../../Items/ServiceError';
@Injectable()
export class GetPaymentReceived {
export class GetPaymentReceivedService {
constructor(
private readonly paymentReceiveModel: typeof PaymentReceived,
private readonly transformer: TransformerInjectable,
@Inject(PaymentReceived.name)
private readonly paymentReceiveModel: typeof PaymentReceived,
) {}
/**

View File

@@ -8,6 +8,10 @@ export class GetPaymentReceivedInvoices {
constructor(
@Inject(PaymentReceived.name)
private paymentReceiveModel: typeof PaymentReceived,
@Inject(SaleInvoice.name)
private saleInvoiceModel: typeof SaleInvoice,
private validators: PaymentReceivedValidators,
) {}
@@ -28,10 +32,10 @@ export class GetPaymentReceivedInvoices {
const paymentReceiveInvoicesIds = paymentReceive.entries.map(
(entry) => entry.invoiceId,
);
const saleInvoices = await SaleInvoice.query().whereIn(
'id',
paymentReceiveInvoicesIds,
);
const saleInvoices = await this.saleInvoiceModel
.query()
.whereIn('id', paymentReceiveInvoicesIds);
return saleInvoices;
}
}

View File

@@ -1,5 +1,5 @@
import { Inject, Injectable } from '@nestjs/common';
import { GetPaymentReceived } from './GetPaymentReceived.service';
import { GetPaymentReceivedService } from './GetPaymentReceived.service';
import { PaymentReceivedBrandingTemplate } from './PaymentReceivedBrandingTemplate.service';
import { transformPaymentReceivedToPdfTemplate } from '../utils';
@@ -16,7 +16,7 @@ export default class GetPaymentReceivedPdf {
constructor(
private chromiumlyTenancy: ChromiumlyTenancy,
private templateInjectable: TemplateInjectable,
private getPaymentService: GetPaymentReceived,
private getPaymentService: GetPaymentReceivedService,
private paymentBrandingTemplateService: PaymentReceivedBrandingTemplate,
private eventPublisher: EventEmitter2,

View File

@@ -1,10 +1,13 @@
import { PdfTemplateModel } from '@/modules/PdfTemplate/models/PdfTemplate';
import { Injectable } from '@nestjs/common';
import { Inject, Injectable } from '@nestjs/common';
import { IPaymentReceivedState } from '../types/PaymentReceived.types';
@Injectable()
export class GetPaymentReceivedState {
constructor(private pdfTemplateModel: typeof PdfTemplateModel) {}
export class GetPaymentReceivedStateService {
constructor(
@Inject(PdfTemplateModel.name)
private pdfTemplateModel: typeof PdfTemplateModel,
) {}
/**
* Retrieves the create/edit initial state of the payment received.