Merge pull request 'refs: #7108 weekends' (!2524) from 7108-exchange into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #2524
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Javi Gallego 2024-05-31 05:39:06 +00:00
commit d4c76ed20e
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}
);
}
}
}
}
}