feat: add money request cronjob, and edit money request entity

This commit is contained in:
Abdalhamid Alhamad
2025-01-02 11:22:33 +03:00
parent 557ef4cd33
commit aefa866ae7
12 changed files with 187 additions and 9 deletions

View File

@ -84,7 +84,13 @@ export class Allowance {
const calculateNextDate = (unit: moment.unitOfTime.Diff) => {
const diff = now.diff(startDate, unit);
const nextDate = startDate.clone().add(diff, unit);
return nextDate.isSameOrAfter(now) ? nextDate.toDate() : nextDate.add('1', unit).toDate();
const adjustedDate = nextDate.isSameOrAfter(now) ? nextDate : nextDate.add('1', unit);
if (endDate && adjustedDate.isAfter(endDate)) {
return null;
}
return adjustedDate.toDate();
};
switch (this.frequency) {