fix(05): end of month installments

This commit is contained in:
puriphatt 2024-10-17 13:47:38 +07:00
parent 6ddf3a9030
commit b55437fa7e

View file

@ -165,10 +165,13 @@ function installmentsDate(date: Date | string) {
return pay;
}
// Create a new Date object to avoid mutating the original one
let updatedDate = new Date(firstPayDateObj);
updatedDate.setMonth(updatedDate.getMonth() + index);
if (updatedDate.getDate() !== firstPayDateObj.getDate()) {
updatedDate.setDate(0);
}
return {
...pay,
date: updatedDate.toISOString(),