mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
refactor: dynamic list to nestjs
This commit is contained in:
@@ -13,10 +13,13 @@ import { PaymentReceivesApplication } from './PaymentReceived.application';
|
||||
import {
|
||||
IPaymentReceivedCreateDTO,
|
||||
IPaymentReceivedEditDTO,
|
||||
IPaymentsReceivedFilter,
|
||||
} from './types/PaymentReceived.types';
|
||||
import { PublicRoute } from '../Auth/Jwt.guard';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('payments-received')
|
||||
@ApiTags('payments-received')
|
||||
@PublicRoute()
|
||||
export class PaymentReceivesController {
|
||||
constructor(private paymentReceivesApplication: PaymentReceivesApplication) {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
DEFAULT_PAYMENT_MAIL_CONTENT,
|
||||
DEFAULT_PAYMENT_MAIL_SUBJECT,
|
||||
} from '../constants';
|
||||
import { transformPaymentReceivedToMailDataArgs } from './utils';
|
||||
import { transformPaymentReceivedToMailDataArgs } from '../utils';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { events } from '@/common/events/events';
|
||||
import { ContactMailNotification } from '@/modules/MailNotification/ContactMailNotification';
|
||||
@@ -14,16 +14,19 @@ import { PaymentReceiveMailOptsDTO } from '../types/PaymentReceived.types';
|
||||
import { PaymentReceiveMailOpts } from '../types/PaymentReceived.types';
|
||||
import { PaymentReceiveMailPresendEvent } from '../types/PaymentReceived.types';
|
||||
import { SendInvoiceMailDTO } from '@/modules/SaleInvoices/SaleInvoice.types';
|
||||
import { Mail } from '@/modules/Mail/Mail';
|
||||
import { MailTransporter } from '@/modules/Mail/MailTransporter.service';
|
||||
|
||||
@Injectable()
|
||||
export class SendPaymentReceiveMailNotification {
|
||||
constructor(
|
||||
private getPaymentService: GetPaymentReceivedService,
|
||||
private contactMailNotification: ContactMailNotification,
|
||||
private eventEmitter: EventEmitter2,
|
||||
private readonly getPaymentService: GetPaymentReceivedService,
|
||||
private readonly contactMailNotification: ContactMailNotification,
|
||||
private readonly eventEmitter: EventEmitter2,
|
||||
private readonly mailTransport: MailTransporter,
|
||||
|
||||
@Inject(PaymentReceived.name)
|
||||
private paymentReceiveModel: typeof PaymentReceived,
|
||||
private readonly paymentReceiveModel: typeof PaymentReceived,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -148,7 +151,7 @@ export class SendPaymentReceiveMailNotification {
|
||||
events.paymentReceive.onMailSend,
|
||||
eventPayload,
|
||||
);
|
||||
await mail.send();
|
||||
await this.mailTransport.send(mail);
|
||||
|
||||
// Triggers `onPaymentReceiveMailSent` event.
|
||||
await this.eventEmitter.emitAsync(
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
import { Model, mixin } from 'objection';
|
||||
// import TenantModel from 'models/TenantModel';
|
||||
// import ModelSetting from './ModelSetting';
|
||||
// import PaymentReceiveSettings from './PaymentReceive.Settings';
|
||||
// import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
// import { DEFAULT_VIEWS } from '@/services/Sales/PaymentReceived/constants';
|
||||
// import ModelSearchable from './ModelSearchable';
|
||||
import { BaseModel } from '@/models/Model';
|
||||
import { Model } from 'objection';
|
||||
import { PaymentReceivedEntry } from './PaymentReceivedEntry';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
|
||||
export class PaymentReceived extends BaseModel {
|
||||
export class PaymentReceived extends TenantBaseModel {
|
||||
customerId: number;
|
||||
paymentDate: string;
|
||||
amount: number;
|
||||
@@ -69,7 +63,9 @@ export class PaymentReceived extends BaseModel {
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const { PaymentReceivedEntry } = require('./PaymentReceivedEntry');
|
||||
const { AccountTransaction } = require('../../Accounts/models/AccountTransaction.model');
|
||||
const {
|
||||
AccountTransaction,
|
||||
} = require('../../Accounts/models/AccountTransaction.model');
|
||||
const { Customer } = require('../../Customers/models/Customer');
|
||||
const { Account } = require('../../Accounts/models/Account.model');
|
||||
const { Branch } = require('../../Branches/models/Branch.model');
|
||||
|
||||
@@ -31,7 +31,7 @@ export class GetPaymentsReceivedService {
|
||||
|
||||
// Dynamic list service.
|
||||
const dynamicList = await this.dynamicListService.dynamicList(
|
||||
PaymentReceive,
|
||||
PaymentReceived,
|
||||
filter,
|
||||
);
|
||||
const { results, pagination } = await this.paymentReceivedModel
|
||||
|
||||
Reference in New Issue
Block a user