refs: #7108 weekends #2524

Merged
jgallego merged 2 commits from 7108-exchange into dev 2024-05-31 05:39:07 +00:00
1 changed files with 14 additions and 0 deletions

View File

@ -54,6 +54,20 @@ module.exports = Self => {
value: rate
});
}
const monday = 1;
if (xmlDateWithoutTime.getDay() === monday) {
const saturday = new Date(xmlDateWithoutTime);
saturday.setDate(xmlDateWithoutTime.getDate() - 2);
const sunday = new Date(xmlDateWithoutTime);
sunday.setDate(xmlDateWithoutTime.getDate() - 1);
for (const date of [saturday, sunday]) {
await models.ReferenceRate.upsertWithWhere(
{currencyFk: currency.id, dated: date},
{currencyFk: currency.id, dated: date, value: rate}
);
}
}
}
}
}