mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
refactor: e2e test cases
This commit is contained in:
@@ -1,24 +1,19 @@
|
||||
import {
|
||||
IPaymentReceivedCreateDTO,
|
||||
IPaymentReceivedEditDTO,
|
||||
IPaymentReceivedSmsDetails,
|
||||
IPaymentsReceivedFilter,
|
||||
// IPaymentsReceivedFilter,
|
||||
// ISystemUser,
|
||||
// PaymentReceiveMailOptsDTO,
|
||||
PaymentReceiveMailOptsDTO,
|
||||
} from './types/PaymentReceived.types';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreatePaymentReceivedService } from './commands/CreatePaymentReceived.serivce';
|
||||
import { EditPaymentReceivedService } from './commands/EditPaymentReceived.service';
|
||||
import { DeletePaymentReceivedService } from './commands/DeletePaymentReceived.service';
|
||||
// import { GetPaymentReceives } from './queries/GetPaymentsReceived.service';
|
||||
import { GetPaymentReceivedService } from './queries/GetPaymentReceived.service';
|
||||
import { GetPaymentReceivedInvoices } from './queries/GetPaymentReceivedInvoices.service';
|
||||
// import { PaymentReceiveNotifyBySms } from './PaymentReceivedSmsNotify';
|
||||
import { GetPaymentReceivedPdfService } from './queries/GetPaymentReceivedPdf.service';
|
||||
// import { SendPaymentReceiveMailNotification } from './PaymentReceivedMailNotification';
|
||||
import { GetPaymentReceivedStateService } from './queries/GetPaymentReceivedState.service';
|
||||
import { GetPaymentsReceivedService } from './queries/GetPaymentsReceived.service';
|
||||
import { SendPaymentReceiveMailNotification } from './commands/PaymentReceivedMailNotification';
|
||||
|
||||
@Injectable()
|
||||
export class PaymentReceivesApplication {
|
||||
@@ -29,8 +24,7 @@ export class PaymentReceivesApplication {
|
||||
private getPaymentsReceivedService: GetPaymentsReceivedService,
|
||||
private getPaymentReceivedService: GetPaymentReceivedService,
|
||||
private getPaymentReceiveInvoicesService: GetPaymentReceivedInvoices,
|
||||
// private paymentSmsNotify: PaymentReceiveNotifyBySms,
|
||||
// private paymentMailNotify: SendPaymentReceiveMailNotification,
|
||||
private sendPaymentReceiveMailNotification: SendPaymentReceiveMailNotification,
|
||||
private getPaymentReceivePdfService: GetPaymentReceivedPdfService,
|
||||
private getPaymentReceivedStateService: GetPaymentReceivedStateService,
|
||||
) {}
|
||||
@@ -103,55 +97,32 @@ export class PaymentReceivesApplication {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param {PaymentReceiveMailOptsDTO} messageOpts
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
// public notifyPaymentByMail(
|
||||
// tenantId: number,
|
||||
// paymentReceiveId: number,
|
||||
// messageOpts: PaymentReceiveMailOptsDTO,
|
||||
// ): Promise<void> {
|
||||
// return this.paymentMailNotify.triggerMail(
|
||||
// tenantId,
|
||||
// paymentReceiveId,
|
||||
// messageOpts,
|
||||
// );
|
||||
// }
|
||||
public notifyPaymentByMail(
|
||||
paymentReceiveId: number,
|
||||
messageOpts: PaymentReceiveMailOptsDTO,
|
||||
): Promise<void> {
|
||||
return this.sendPaymentReceiveMailNotification.triggerMail(
|
||||
paymentReceiveId,
|
||||
messageOpts,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the default mail options of the given payment transaction.
|
||||
* @param {number} tenantId
|
||||
* @param {number} paymentReceiveId
|
||||
* @param {number} paymentReceiveId - Payment receive id.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
// public getPaymentMailOptions(tenantId: number, paymentReceiveId: number) {
|
||||
// return this.paymentMailNotify.getMailOptions(tenantId, paymentReceiveId);
|
||||
// }
|
||||
public getPaymentMailOptions(paymentReceiveId: number) {
|
||||
return this.sendPaymentReceiveMailNotification.getMailOptions(
|
||||
paymentReceiveId,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve pdf content of the given payment receive.
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Post,
|
||||
@@ -14,9 +15,10 @@ import {
|
||||
IPaymentReceivedCreateDTO,
|
||||
IPaymentReceivedEditDTO,
|
||||
IPaymentsReceivedFilter,
|
||||
PaymentReceiveMailOptsDTO,
|
||||
} from './types/PaymentReceived.types';
|
||||
import { PublicRoute } from '../Auth/Jwt.guard';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('payments-received')
|
||||
@ApiTags('payments-received')
|
||||
@@ -24,7 +26,38 @@ import { ApiTags } from '@nestjs/swagger';
|
||||
export class PaymentReceivesController {
|
||||
constructor(private paymentReceivesApplication: PaymentReceivesApplication) {}
|
||||
|
||||
@Post(':id/mail')
|
||||
@HttpCode(200)
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The payment receive mail has been successfully sent.',
|
||||
})
|
||||
public sendPaymentReceiveMail(
|
||||
@Param('id', ParseIntPipe) paymentReceiveId: number,
|
||||
@Body() messageOpts: PaymentReceiveMailOptsDTO,
|
||||
) {
|
||||
return this.paymentReceivesApplication.notifyPaymentByMail(
|
||||
paymentReceiveId,
|
||||
messageOpts,
|
||||
);
|
||||
}
|
||||
|
||||
@Get(':id/mail')
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description:
|
||||
'The payment receive mail options have been successfully retrieved.',
|
||||
})
|
||||
public getPaymentReceiveMailOptions(
|
||||
@Param('id', ParseIntPipe) paymentReceiveId: number,
|
||||
) {
|
||||
return this.paymentReceivesApplication.getPaymentMailOptions(
|
||||
paymentReceiveId,
|
||||
);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new payment received.' })
|
||||
public createPaymentReceived(
|
||||
@Body() paymentReceiveDTO: IPaymentReceivedCreateDTO,
|
||||
) {
|
||||
@@ -34,6 +67,7 @@ export class PaymentReceivesController {
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
@ApiOperation({ summary: 'Edit the given payment received.' })
|
||||
public editPaymentReceive(
|
||||
@Param('id', ParseIntPipe) paymentReceiveId: number,
|
||||
@Body() paymentReceiveDTO: IPaymentReceivedEditDTO,
|
||||
@@ -45,6 +79,7 @@ export class PaymentReceivesController {
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'Delete the given payment received.' })
|
||||
public deletePaymentReceive(
|
||||
@Param('id', ParseIntPipe) paymentReceiveId: number,
|
||||
) {
|
||||
@@ -54,16 +89,27 @@ export class PaymentReceivesController {
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Retrieves the payment received list.' })
|
||||
public getPaymentsReceived(@Query() filterDTO: IPaymentsReceivedFilter) {
|
||||
return this.paymentReceivesApplication.getPaymentsReceived(filterDTO);
|
||||
}
|
||||
|
||||
@Get('state')
|
||||
@ApiOperation({ summary: 'Retrieves the payment received state.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The payment received state has been successfully retrieved.',
|
||||
})
|
||||
public getPaymentReceivedState() {
|
||||
return this.paymentReceivesApplication.getPaymentReceivedState();
|
||||
}
|
||||
|
||||
@Get(':id/invoices')
|
||||
@ApiOperation({ summary: 'Retrieves the payment received invoices.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The payment received invoices have been successfully retrieved.',
|
||||
})
|
||||
public getPaymentReceiveInvoices(
|
||||
@Param('id', ParseIntPipe) paymentReceiveId: number,
|
||||
) {
|
||||
@@ -73,6 +119,11 @@ export class PaymentReceivesController {
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Retrieves the payment received details.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The payment received details have been successfully retrieved.',
|
||||
})
|
||||
public getPaymentReceive(
|
||||
@Param('id', ParseIntPipe) paymentReceiveId: number,
|
||||
) {
|
||||
@@ -80,6 +131,11 @@ export class PaymentReceivesController {
|
||||
}
|
||||
|
||||
@Get(':id/pdf')
|
||||
@ApiOperation({ summary: 'Retrieves the payment received pdf.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The payment received pdf has been successfully retrieved.',
|
||||
})
|
||||
public getPaymentReceivePdf(
|
||||
@Param('id', ParseIntPipe) paymentReceivedId: number,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user