From ef932ed36be4381f1e7f93a55bb918bc881120b3 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Fri, 4 Oct 2019 19:41:51 +0200 Subject: [PATCH] add discount on first day of the month --- services/integration/invoiceIntegration.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/integration/invoiceIntegration.js b/services/integration/invoiceIntegration.js index e1f5a64..3cef4a0 100644 --- a/services/integration/invoiceIntegration.js +++ b/services/integration/invoiceIntegration.js @@ -228,9 +228,9 @@ const createNegativeFeeForDiscount = (memberData, dateRange) => { const { totalBookedHours, totalChargedHours, totalBookingChargedFee } = bookingData; const { memberId, officeId } = member; - let endDate = moment.utc().endOf('day').toISOString(); - if (dateRange.endDate){ - endDate = moment.utc(dateRange.endDate, DEFAULT_DATE_FORMAT).endOf('day').toISOString(); + let dateForDiscount = moment.utc().startOf('day').subtract(1, 'month').toISOString(); + if (dateRange.startDate){ + dateForDiscount = moment.utc(dateRange.startDate, DEFAULT_DATE_FORMAT).startOf('month').toISOString(); } let membershipFeeForDiscount = 0; @@ -269,7 +269,7 @@ const createNegativeFeeForDiscount = (memberData, dateRange) => { name: formattedName, price: -discount.toFixed(2), quantity: 1, - date: endDate, + date: dateForDiscount, member: memberId, team: null, office: officeId,