mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
refactor: dynamic list to nestjs
This commit is contained in:
@@ -1,46 +1,48 @@
|
||||
// import { Inject, Injectable } from '@nestjs/common';
|
||||
// import { GetSaleInvoiceMailStateTransformer } from './GetSaleInvoiceMailState.transformer';
|
||||
// import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service';
|
||||
// import { SaleInvoice } from '../models/SaleInvoice';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service';
|
||||
import { GetSaleInvoiceMailStateTransformer } from './GetSaleInvoiceMailState.transformer';
|
||||
import { SendSaleInvoiceMailCommon } from '../commands/SendInvoiceInvoiceMailCommon.service';
|
||||
import { SaleInvoice } from '../models/SaleInvoice';
|
||||
import { SaleInvoiceMailState } from '../SaleInvoice.types';
|
||||
|
||||
// @Injectable()
|
||||
// export class GetSaleInvoiceMailState {
|
||||
// constructor(
|
||||
// private transformer: TransformerInjectable,
|
||||
// // private invoiceMail: SendSaleInvoiceMailCommon,
|
||||
@Injectable()
|
||||
export class GetSaleInvoiceMailState {
|
||||
constructor(
|
||||
private transformer: TransformerInjectable,
|
||||
private invoiceMail: SendSaleInvoiceMailCommon,
|
||||
|
||||
// @Inject(SaleInvoice.name)
|
||||
// private saleInvoiceModel: typeof SaleInvoice,
|
||||
// ) {}
|
||||
@Inject(SaleInvoice.name)
|
||||
private saleInvoiceModel: typeof SaleInvoice,
|
||||
) {}
|
||||
|
||||
// /**
|
||||
// * Retrieves the invoice mail state of the given sale invoice.
|
||||
// * Invoice mail state includes the mail options, branding attributes and the invoice details.
|
||||
// * @param {number} saleInvoiceId - Sale invoice id.
|
||||
// * @returns {Promise<SaleInvoiceMailState>}
|
||||
// */
|
||||
// async getInvoiceMailState(
|
||||
// saleInvoiceId: number,
|
||||
// ): Promise<SaleInvoiceMailState> {
|
||||
// const saleInvoice = await this.saleInvoiceModel
|
||||
// .query()
|
||||
// .findById(saleInvoiceId)
|
||||
// .withGraphFetched('customer')
|
||||
// .withGraphFetched('entries.item')
|
||||
// .withGraphFetched('pdfTemplate')
|
||||
// .throwIfNotFound();
|
||||
/**
|
||||
* Retrieves the invoice mail state of the given sale invoice.
|
||||
* Invoice mail state includes the mail options, branding attributes and the invoice details.
|
||||
* @param {number} saleInvoiceId - Sale invoice id.
|
||||
* @returns {Promise<SaleInvoiceMailState>}
|
||||
*/
|
||||
public async getInvoiceMailState(
|
||||
saleInvoiceId: number,
|
||||
): Promise<SaleInvoiceMailState> {
|
||||
const saleInvoice = await this.saleInvoiceModel
|
||||
.query()
|
||||
.findById(saleInvoiceId)
|
||||
.withGraphFetched('customer')
|
||||
.withGraphFetched('entries.item')
|
||||
.withGraphFetched('pdfTemplate')
|
||||
.throwIfNotFound();
|
||||
|
||||
// const mailOptions =
|
||||
// await this.invoiceMail.getInvoiceMailOptions(saleInvoiceId);
|
||||
const mailOptions =
|
||||
await this.invoiceMail.getInvoiceMailOptions(saleInvoiceId);
|
||||
|
||||
// // Transforms the sale invoice mail state.
|
||||
// const transformed = await this.transformer.transform(
|
||||
// saleInvoice,
|
||||
// new GetSaleInvoiceMailStateTransformer(),
|
||||
// {
|
||||
// mailOptions,
|
||||
// },
|
||||
// );
|
||||
// return transformed;
|
||||
// }
|
||||
// }
|
||||
// Transforms the sale invoice mail state.
|
||||
const transformed = await this.transformer.transform(
|
||||
saleInvoice,
|
||||
new GetSaleInvoiceMailStateTransformer(),
|
||||
{
|
||||
mailOptions,
|
||||
},
|
||||
);
|
||||
return transformed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user