mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service';
|
||||
import { InvoicePaymentTransactionTransformer } from './InvoicePaymentTransaction.transformer';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { PaymentReceivedEntry } from '@/modules/PaymentReceived/models/PaymentReceivedEntry';
|
||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||
|
||||
@Injectable()
|
||||
export class GetInvoicePaymentsService {
|
||||
constructor(
|
||||
private readonly transformer: TransformerInjectable,
|
||||
|
||||
@Inject(PaymentReceivedEntry.name)
|
||||
private readonly paymentReceivedEntryModel: TenantModelProxy<
|
||||
typeof PaymentReceivedEntry
|
||||
>,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Retrieve the invoice associated payments transactions.
|
||||
* @param {number} tenantId - Tenant id.
|
||||
* @param {number} invoiceId - Invoice id.
|
||||
*/
|
||||
public getInvoicePayments = async (invoiceId: number) => {
|
||||
const paymentsEntries = await this.paymentReceivedEntryModel()
|
||||
.query()
|
||||
.where('invoiceId', invoiceId)
|
||||
.withGraphJoined('payment.depositAccount')
|
||||
.withGraphJoined('invoice')
|
||||
.orderBy('payment:paymentDate', 'ASC');
|
||||
|
||||
return this.transformer.transform(
|
||||
paymentsEntries,
|
||||
new InvoicePaymentTransactionTransformer(),
|
||||
);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user