shift expire date to next month, when deposit happens on the last day of month

This commit is contained in:
2020-10-05 16:14:53 +02:00
parent 1eda10d11e
commit 78d9afd187

View File

@@ -97,9 +97,13 @@
if (pdata['l_expire_type'] == '1') {
//var today = new Date();
var today = new Date($('#mod_date').val());
var today = new Date($('#mod_date').val() + " 00:00:00");
//var nextMonthBeginning = new Date(today.getFullYear(), today.getMonth() + 1, 1);
var lastDayOfMonth = new Date(today.getFullYear(), today.getMonth()+1, 0);
//console.log(lastDayOfMonth, today, lastDayOfMonth.getTime() === today.getTime());
if (lastDayOfMonth.getTime() === today.getTime()) {
lastDayOfMonth = new Date(today.getFullYear(), today.getMonth()+2, 0);
}
$('#expire_date').html(lastDayOfMonth.getFullYear() + '-' + ('0' + (lastDayOfMonth.getMonth()+1)).slice(-2) + '-' + ('0' + lastDayOfMonth.getDate()).slice(-2));
$('#mod_expire_date').val(lastDayOfMonth.getFullYear() + '-' + ('0' + (lastDayOfMonth.getMonth()+1)).slice(-2) + '-' + ('0' + lastDayOfMonth.getDate()).slice(-2));