From 92ddc1bf38e08a397abe556555ae0a8bc5b723aa Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Mon, 26 Oct 2020 12:48:26 +0200 Subject: [PATCH] fix: missed send_to_email column in sale estimate. --- server/src/api/controllers/Sales/SalesEstimates.ts | 6 ++++-- .../20200713192127_create_sales_estimates_table.js | 2 +- server/src/interfaces/SaleEstimate.ts | 3 ++- server/src/services/Sales/SalesEstimate.ts | 4 +++- server/src/subscribers/paymentReceives.ts | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/server/src/api/controllers/Sales/SalesEstimates.ts b/server/src/api/controllers/Sales/SalesEstimates.ts index 15ce01f3a..2006cd970 100644 --- a/server/src/api/controllers/Sales/SalesEstimates.ts +++ b/server/src/api/controllers/Sales/SalesEstimates.ts @@ -23,8 +23,9 @@ export default class SalesEstimatesController extends BaseController { const router = Router(); router.post( - '/', - this.estimateValidationSchema, + '/', [ + ...this.estimateValidationSchema, + ], this.validationResult, asyncMiddleware(this.newEstimate.bind(this)), this.handleServiceErrors, @@ -85,6 +86,7 @@ export default class SalesEstimatesController extends BaseController { check('note').optional().trim().escape(), check('terms_conditions').optional().trim().escape(), + check('send_to_email').optional().trim().escape(), ]; } diff --git a/server/src/database/migrations/20200713192127_create_sales_estimates_table.js b/server/src/database/migrations/20200713192127_create_sales_estimates_table.js index 82d2d3ebe..646d61550 100644 --- a/server/src/database/migrations/20200713192127_create_sales_estimates_table.js +++ b/server/src/database/migrations/20200713192127_create_sales_estimates_table.js @@ -10,7 +10,7 @@ exports.up = function(knex) { table.string('estimate_number').index(); table.text('note'); table.text('terms_conditions'); - + table.text('send_to_email'); table.integer('user_id').unsigned().index(); table.timestamps(); }); diff --git a/server/src/interfaces/SaleEstimate.ts b/server/src/interfaces/SaleEstimate.ts index edef799c0..89eb8dbe1 100644 --- a/server/src/interfaces/SaleEstimate.ts +++ b/server/src/interfaces/SaleEstimate.ts @@ -11,7 +11,7 @@ export interface ISaleEstimate { termsConditions: string, userId: number, entries: IItemEntry[], - + sendToEmail: string, createdAt?: Date, }; export interface ISaleEstimateDTO { @@ -22,6 +22,7 @@ export interface ISaleEstimateDTO { entries: IItemEntry[], note: string, termsConditions: string, + sendToEmail: string, }; export interface ISalesEstimatesFilter extends IDynamicListFilterDTO { diff --git a/server/src/services/Sales/SalesEstimate.ts b/server/src/services/Sales/SalesEstimate.ts index 54146ea40..8ade46b2d 100644 --- a/server/src/services/Sales/SalesEstimate.ts +++ b/server/src/services/Sales/SalesEstimate.ts @@ -120,7 +120,9 @@ export default class SaleEstimateService { }); this.logger.info('[sale_estimate] insert sale estimated success.'); - await this.eventDispatcher.dispatch(events.saleEstimate.onCreated); + await this.eventDispatcher.dispatch(events.saleEstimate.onCreated, { + tenantId, saleEstimate, saleEstimateId: saleEstimate.id, + }); return saleEstimate; } diff --git a/server/src/subscribers/paymentReceives.ts b/server/src/subscribers/paymentReceives.ts index ba19bd4fb..746eb24da 100644 --- a/server/src/subscribers/paymentReceives.ts +++ b/server/src/subscribers/paymentReceives.ts @@ -43,7 +43,7 @@ export default class PaymentReceivesSubscriber { } /** - * Handle + * Handle revert invoices payment amount once payment receive deleted. */ @On(events.paymentReceive.onDeleted) async handleInvoiceDecrementPaymentAmount({ tenantId, paymentReceiveId, oldPaymentReceive }) {