add discount on first day of the month

This commit is contained in:
Bilal Catic
2019-10-04 19:41:51 +02:00
parent 5a07b74ae2
commit ef932ed36b

View File

@@ -228,9 +228,9 @@ const createNegativeFeeForDiscount = (memberData, dateRange) => {
const { totalBookedHours, totalChargedHours, totalBookingChargedFee } = bookingData; const { totalBookedHours, totalChargedHours, totalBookingChargedFee } = bookingData;
const { memberId, officeId } = member; const { memberId, officeId } = member;
let endDate = moment.utc().endOf('day').toISOString(); let dateForDiscount = moment.utc().startOf('day').subtract(1, 'month').toISOString();
if (dateRange.endDate){ if (dateRange.startDate){
endDate = moment.utc(dateRange.endDate, DEFAULT_DATE_FORMAT).endOf('day').toISOString(); dateForDiscount = moment.utc(dateRange.startDate, DEFAULT_DATE_FORMAT).startOf('month').toISOString();
} }
let membershipFeeForDiscount = 0; let membershipFeeForDiscount = 0;
@@ -269,7 +269,7 @@ const createNegativeFeeForDiscount = (memberData, dateRange) => {
name: formattedName, name: formattedName,
price: -discount.toFixed(2), price: -discount.toFixed(2),
quantity: 1, quantity: 1,
date: endDate, date: dateForDiscount,
member: memberId, member: memberId,
team: null, team: null,
office: officeId, office: officeId,