Discounts are now at the beginning of a month

This commit is contained in:
Senad Uka
2019-10-04 19:55:59 +02:00
parent 4de9e1d9a0
commit 790b72f764

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().subtract(1, 'month').startOf('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,