From 5a252e28a0924350f2ccdf4210dd3205534cae86 Mon Sep 17 00:00:00 2001 From: Richard Toth Date: Tue, 6 Oct 2020 11:11:24 +0200 Subject: [PATCH] handle last deposit in month --- _class/class_user_kid.php | 7 ++++++- template/templates/money_deposit_create.tpl | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/_class/class_user_kid.php b/_class/class_user_kid.php index 045f333..e1a5353 100644 --- a/_class/class_user_kid.php +++ b/_class/class_user_kid.php @@ -667,8 +667,13 @@ class user_kid extends user_parent { $nonZero = $_de->get_de_money_deposit()->get_mod_non_zero(); $_de->set_de_transaction($_de->get_de_money_deposit()->get_mod_money_income()->get_mi_sum()); + $lastEntryInMonth = false; + if (isset($_de_obj_array[$i+1])) { + $lastEntryInMonth = date('m', strtotime($_de_obj_array[$i+1]->get_de_date())) !== date('m', strtotime($_de->get_de_date())); + } + //var_dump($i < (count($_de_obj_array) -1 ) || !$_de->get_de_expired() || !$lastEntryInMonth); //ha ez a befizetés az utolsó és lejárt, akkor ne adjuk hozzá a balancehoz - if ($i < (count($_de_obj_array) -1 ) || !$_de->get_de_expired()) { + if ($i < (count($_de_obj_array) -1 ) || !$_de->get_de_expired() || !$lastEntryInMonth) { $_de->set_de_balance($_de->get_de_balance()+$_de->get_de_transaction()); } diff --git a/template/templates/money_deposit_create.tpl b/template/templates/money_deposit_create.tpl index 52128ed..49bd38c 100644 --- a/template/templates/money_deposit_create.tpl +++ b/template/templates/money_deposit_create.tpl @@ -101,9 +101,6 @@ //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));