Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Some experimental fixes for #3011
James Cole173e196bc8a5
diff --git a/public/v1/js/ff/accounts/reconcile.js b/public/v1/js/ff/accounts/reconcile.jsindex 3cd50df687..45aafed7ed 100644--- a/public/v1/js/ff/accounts/reconcile.js+++ b/public/v1/js/ff/accounts/reconcile.js@@ -71,6 +71,44 @@ $(function () {});+function selectAllReconcile(e) {+ // loop all, check.+ var el = $(e.target);+ var doCheck = true;+ if (el.prop('checked') === true) {+ $('.check_all_btn').prop('checked', true);+ }+ if (el.prop('checked') === false) {+ $('.check_all_btn').prop('checked', false);+ doCheck = false;+ }++ $('.reconcile_checkbox').each(function (i, v) {+ var check = $(v);+ var amount = parseFloat(check.val());+ var journalId = parseInt(check.data('id'));+ var identifier = 'checked_' + journalId;+ console.log('in selectAllReconcile(' + journalId + ') with amount ' + amount + ' and selected amount ' + selectedAmount);++ check.prop('checked', doCheck);+ // if checked, add to selected amount+ if (doCheck === true && check.data('younger') === false) {+ selectedAmount = selectedAmount - amount;+ console.log('checked = true and younger = false so selected amount = ' + selectedAmount);+ localStorage.setItem(identifier, 'true');+ }+ if (doCheck === false && check.data('younger') === false) {+ selectedAmount = selectedAmount + amount;+ console.log('checked = false and younger = false so selected amount = ' + selectedAmount);+ localStorage.setItem(identifier, 'false');+ }+ difference = balanceDifference - selectedAmount;+ console.log('Difference is now ' + difference);+ });++ updateDifference();+}+function storeReconcile() {console.log('in storeReconcile()');// get modal HTML:@@ -116,15 +154,19 @@ function checkReconciledBox(e) {var el = $(e.target);var amount = parseFloat(el.val());- console.log('in checkReconciledBox() with amount ' + amount + ' and selected amount ' + selectedAmount);+ var journalId = parseInt(el.data('id'));+ var identifier = 'checked_' + journalId;+ console.log('in checkReconciledBox(' + journalId + ') with amount ' + amount + ' and selected amount ' + selectedAmount);// if checked, add to selected amountif (el.prop('checked') === true && el.data('younger') === false) {selectedAmount = selectedAmount - amount;console.log('checked = true and younger = false so selected amount = ' + selectedAmount);+ localStorage.setItem(identifier, 'true');}if (el.prop('checked') === false && el.data('younger') === false) {selectedAmount = selectedAmount + amount;console.log('checked = false and younger = false so selected amount = ' + selectedAmount);+ localStorage.setItem(identifier, 'false');}difference = balanceDifference - selectedAmount;console.log('Difference is now ' + difference);@@ -198,6 +240,10 @@ function includeClearedTransactions() {function placeTransactions(data) {console.log('in placeTransactions()');$('#transactions_holder').empty().html(data.html);++ // add checkbox thing+ $('.check_all_btn').click(selectAllReconcile);+selectedAmount = 0;// update start + end balance when user has not touched them.if (!changedBalances) {@@ -214,6 +260,10 @@ function placeTransactions(data) {difference = balanceDifference - selectedAmount;updateDifference();+ // loop al placed checkboxes and check them if necessary.+ restoreFromLocalStorage();++// enable the check buttons:$('.reconcile_checkbox').prop('disabled', false).unbind('change').change(checkReconciledBox);@@ -223,6 +273,30 @@ function placeTransactions(data) {$('.store_reconcile').prop('disabled', false);}+function restoreFromLocalStorage() {+ $('.reconcile_checkbox').each(function (i, v) {+ var el = $(v);+ var journalId = el.data('id')+ var identifier = 'checked_' + journalId;+ var amount = parseFloat(el.val());+ if (localStorage.getItem(identifier) === 'true') {+ el.prop('checked', true);+ // do balance thing:+ console.log('in restoreFromLocalStorage(' + journalId + ') with amount ' + amount + ' and selected amount ' + selectedAmount);+ // if checked, add to selected amount+ if (el.data('younger') === false) {+ selectedAmount = selectedAmount - amount;+ console.log('checked = true and younger = false so selected amount = ' + selectedAmount);+ localStorage.setItem(identifier, 'true');+ }+ difference = balanceDifference - selectedAmount;+ console.log('Difference is now ' + difference);+ }++ });+ updateDifference();+}+/**** @returns {boolean}@@ -259,4 +333,4 @@ function updateDifference() {addClass = 'text-danger';}$('#difference').addClass(addClass).text(accounting.formatMoney(difference));-}\ No newline at end of file+}diff --git a/resources/views/v1/accounts/reconcile/transactions.twig b/resources/views/v1/accounts/reconcile/transactions.twigindex 73944ce267..81ab7a1786 100644--- a/resources/views/v1/accounts/reconcile/transactions.twig+++ b/resources/views/v1/accounts/reconcile/transactions.twig@@ -20,9 +20,12 @@{# start marker #}{% if journal.date < start and startSet == false %}<tr>- <td colspan="5">+ <td colspan="4"> </td>+ <td>+ <input type="checkbox" class="check_all_btn">+ </td><td colspan="3"><span class="label label-default">{{ trans('firefly.start_of_reconcile_period', {period: start.formatLocalized(monthAndDayFormat) }) }}@@ -38,9 +41,12 @@{# end marker #}{% if journal.date <= end and endSet == false %}<tr>- <td colspan="5">+ <td colspan="4"> </td>+ <td>+ <input type="checkbox" class="check_all_btn">+ </td><td colspan="3"><span class="label label-default">{{ trans('firefly.end_of_reconcile_period', {period: end.formatLocalized(monthAndDayFormat) }) }}