mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
refactor: wip to nestjs
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
import {
|
||||
IPaymentReceivedCreateDTO,
|
||||
IPaymentReceivedEditDTO,
|
||||
IPaymentReceivedSmsDetails,
|
||||
// IPaymentsReceivedFilter,
|
||||
// ISystemUser,
|
||||
// PaymentReceiveMailOptsDTO,
|
||||
} from './types/PaymentReceived.types';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreatePaymentReceivedService } from './commands/CreatePaymentReceived.serivce';
|
||||
import { EditPaymentReceived } from './commands/EditPaymentReceived.service';
|
||||
import { DeletePaymentReceived } from './commands/DeletePaymentReceived.service';
|
||||
// import { GetPaymentReceives } from './queries/GetPaymentsReceived.service';
|
||||
import { GetPaymentReceived } from './queries/GetPaymentReceived.service';
|
||||
import { GetPaymentReceivedInvoices } from './queries/GetPaymentReceivedInvoices.service';
|
||||
// import { PaymentReceiveNotifyBySms } from './PaymentReceivedSmsNotify';
|
||||
import GetPaymentReceivedPdf from './queries/GetPaymentReceivedPdf.service';
|
||||
// import { SendPaymentReceiveMailNotification } from './PaymentReceivedMailNotification';
|
||||
import { GetPaymentReceivedState } from './queries/GetPaymentReceivedState.service';
|
||||
|
||||
@Injectable()
|
||||
export class PaymentReceivesApplication {
|
||||
constructor(
|
||||
private createPaymentReceivedService: CreatePaymentReceivedService,
|
||||
private editPaymentReceivedService: EditPaymentReceived,
|
||||
private deletePaymentReceivedService: DeletePaymentReceived,
|
||||
// private getPaymentsReceivedService: GetPaymentReceives,
|
||||
private getPaymentReceivedService: GetPaymentReceived,
|
||||
private getPaymentReceiveInvoicesService: GetPaymentReceivedInvoices,
|
||||
// private paymentSmsNotify: PaymentReceiveNotifyBySms,
|
||||
// private paymentMailNotify: SendPaymentReceiveMailNotification,
|
||||
private getPaymentReceivePdfService: GetPaymentReceivedPdf,
|
||||
private getPaymentReceivedStateService: GetPaymentReceivedState,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates a new payment receive.
|
||||
* @param {IPaymentReceivedCreateDTO} paymentReceiveDTO
|
||||
* @returns
|
||||
*/
|
||||
public createPaymentReceived(paymentReceiveDTO: IPaymentReceivedCreateDTO) {
|
||||
return this.createPaymentReceivedService.createPaymentReceived(
|
||||
paymentReceiveDTO,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit details the given payment receive with associated entries.
|
||||
* @param {number} tenantId
|
||||
* @param {number} paymentReceiveId
|
||||
* @param {IPaymentReceivedEditDTO} paymentReceiveDTO
|
||||
* @param {ISystemUser} authorizedUser
|
||||
* @returns
|
||||
*/
|
||||
public editPaymentReceive(
|
||||
paymentReceiveId: number,
|
||||
paymentReceiveDTO: IPaymentReceivedEditDTO,
|
||||
) {
|
||||
return this.editPaymentReceivedService.editPaymentReceive(
|
||||
paymentReceiveId,
|
||||
paymentReceiveDTO,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the given payment receive.
|
||||
* @param {number} paymentReceiveId - Payment received id.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public deletePaymentReceive(paymentReceiveId: number) {
|
||||
return this.deletePaymentReceivedService.deletePaymentReceive(
|
||||
paymentReceiveId,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve payment receives paginated and filterable.
|
||||
* @param {number} tenantId
|
||||
* @param {IPaymentsReceivedFilter} filterDTO
|
||||
* @returns
|
||||
*/
|
||||
// public async getPaymentReceives(
|
||||
// tenantId: number,
|
||||
// filterDTO: IPaymentsReceivedFilter,
|
||||
// ): Promise<{
|
||||
// paymentReceives: IPaymentReceived[];
|
||||
// pagination: IPaginationMeta;
|
||||
// filterMeta: IFilterMeta;
|
||||
// }> {
|
||||
// return this.getPaymentsReceivedService.getPaymentReceives(
|
||||
// tenantId,
|
||||
// filterDTO,
|
||||
// );
|
||||
// }
|
||||
|
||||
/**
|
||||
* Retrieves the given payment receive.
|
||||
* @param {number} paymentReceiveId
|
||||
* @returns {Promise<IPaymentReceived>}
|
||||
*/
|
||||
public async getPaymentReceive(paymentReceiveId: number) {
|
||||
return this.getPaymentReceivedService.getPaymentReceive(paymentReceiveId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves associated sale invoices of the given payment receive.
|
||||
* @param {number} paymentReceiveId
|
||||
* @returns
|
||||
*/
|
||||
public getPaymentReceiveInvoices(paymentReceiveId: number) {
|
||||
return this.getPaymentReceiveInvoicesService.getPaymentReceiveInvoices(
|
||||
paymentReceiveId,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify customer via sms about payment receive details.
|
||||
* @param {number} tenantId - Tenant id.
|
||||
* @param {number} paymentReceiveid - Payment receive id.
|
||||
*/
|
||||
// public notifyPaymentBySms(tenantId: number, paymentReceiveid: number) {
|
||||
// return this.paymentSmsNotify.notifyBySms(tenantId, paymentReceiveid);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Retrieve the SMS details of the given invoice.
|
||||
* @param {number} tenantId - Tenant id.
|
||||
* @param {number} paymentReceiveid - Payment receive id.
|
||||
*/
|
||||
// public getPaymentSmsDetails = async (
|
||||
// tenantId: number,
|
||||
// paymentReceiveId: number,
|
||||
// ): Promise<IPaymentReceivedSmsDetails> => {
|
||||
// return this.paymentSmsNotify.smsDetails(tenantId, paymentReceiveId);
|
||||
// };
|
||||
|
||||
/**
|
||||
* Notify customer via mail about payment receive details.
|
||||
* @param {number} tenantId
|
||||
* @param {number} paymentReceiveId
|
||||
* @param {IPaymentReceiveMailOpts} messageOpts
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
// public notifyPaymentByMail(
|
||||
// tenantId: number,
|
||||
// paymentReceiveId: number,
|
||||
// messageOpts: PaymentReceiveMailOptsDTO,
|
||||
// ): Promise<void> {
|
||||
// return this.paymentMailNotify.triggerMail(
|
||||
// tenantId,
|
||||
// paymentReceiveId,
|
||||
// messageOpts,
|
||||
// );
|
||||
// }
|
||||
|
||||
/**
|
||||
* Retrieves the default mail options of the given payment transaction.
|
||||
* @param {number} tenantId
|
||||
* @param {number} paymentReceiveId
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
// public getPaymentMailOptions(tenantId: number, paymentReceiveId: number) {
|
||||
// return this.paymentMailNotify.getMailOptions(tenantId, paymentReceiveId);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Retrieve pdf content of the given payment receive.
|
||||
* @param {number} tenantId
|
||||
* @param {PaymentReceive} paymentReceive
|
||||
* @returns
|
||||
*/
|
||||
public getPaymentReceivePdf = (
|
||||
tenantId: number,
|
||||
paymentReceiveId: number,
|
||||
) => {
|
||||
return this.getPaymentReceivePdfService.getPaymentReceivePdf(
|
||||
paymentReceiveId,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the create/edit initial state of the payment received.
|
||||
* @returns {Promise<IPaymentReceivedState>}
|
||||
*/
|
||||
public getPaymentReceivedState = () => {
|
||||
return this.getPaymentReceivedStateService.getPaymentReceivedState();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user