mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Some experimental fixes for #3011
This commit is contained in:
78
public/v1/js/ff/accounts/reconcile.js
vendored
78
public/v1/js/ff/accounts/reconcile.js
vendored
@@ -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() {
|
function storeReconcile() {
|
||||||
console.log('in storeReconcile()');
|
console.log('in storeReconcile()');
|
||||||
// get modal HTML:
|
// get modal HTML:
|
||||||
@@ -116,15 +154,19 @@ function checkReconciledBox(e) {
|
|||||||
|
|
||||||
var el = $(e.target);
|
var el = $(e.target);
|
||||||
var amount = parseFloat(el.val());
|
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 amount
|
// if checked, add to selected amount
|
||||||
if (el.prop('checked') === true && el.data('younger') === false) {
|
if (el.prop('checked') === true && el.data('younger') === false) {
|
||||||
selectedAmount = selectedAmount - amount;
|
selectedAmount = selectedAmount - amount;
|
||||||
console.log('checked = true and younger = false so selected amount = ' + selectedAmount);
|
console.log('checked = true and younger = false so selected amount = ' + selectedAmount);
|
||||||
|
localStorage.setItem(identifier, 'true');
|
||||||
}
|
}
|
||||||
if (el.prop('checked') === false && el.data('younger') === false) {
|
if (el.prop('checked') === false && el.data('younger') === false) {
|
||||||
selectedAmount = selectedAmount + amount;
|
selectedAmount = selectedAmount + amount;
|
||||||
console.log('checked = false and younger = false so selected amount = ' + selectedAmount);
|
console.log('checked = false and younger = false so selected amount = ' + selectedAmount);
|
||||||
|
localStorage.setItem(identifier, 'false');
|
||||||
}
|
}
|
||||||
difference = balanceDifference - selectedAmount;
|
difference = balanceDifference - selectedAmount;
|
||||||
console.log('Difference is now ' + difference);
|
console.log('Difference is now ' + difference);
|
||||||
@@ -198,6 +240,10 @@ function includeClearedTransactions() {
|
|||||||
function placeTransactions(data) {
|
function placeTransactions(data) {
|
||||||
console.log('in placeTransactions()');
|
console.log('in placeTransactions()');
|
||||||
$('#transactions_holder').empty().html(data.html);
|
$('#transactions_holder').empty().html(data.html);
|
||||||
|
|
||||||
|
// add checkbox thing
|
||||||
|
$('.check_all_btn').click(selectAllReconcile);
|
||||||
|
|
||||||
selectedAmount = 0;
|
selectedAmount = 0;
|
||||||
// update start + end balance when user has not touched them.
|
// update start + end balance when user has not touched them.
|
||||||
if (!changedBalances) {
|
if (!changedBalances) {
|
||||||
@@ -214,6 +260,10 @@ function placeTransactions(data) {
|
|||||||
difference = balanceDifference - selectedAmount;
|
difference = balanceDifference - selectedAmount;
|
||||||
updateDifference();
|
updateDifference();
|
||||||
|
|
||||||
|
// loop al placed checkboxes and check them if necessary.
|
||||||
|
restoreFromLocalStorage();
|
||||||
|
|
||||||
|
|
||||||
// enable the check buttons:
|
// enable the check buttons:
|
||||||
$('.reconcile_checkbox').prop('disabled', false).unbind('change').change(checkReconciledBox);
|
$('.reconcile_checkbox').prop('disabled', false).unbind('change').change(checkReconciledBox);
|
||||||
|
|
||||||
@@ -223,6 +273,30 @@ function placeTransactions(data) {
|
|||||||
$('.store_reconcile').prop('disabled', false);
|
$('.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}
|
* @returns {boolean}
|
||||||
@@ -259,4 +333,4 @@ function updateDifference() {
|
|||||||
addClass = 'text-danger';
|
addClass = 'text-danger';
|
||||||
}
|
}
|
||||||
$('#difference').addClass(addClass).text(accounting.formatMoney(difference));
|
$('#difference').addClass(addClass).text(accounting.formatMoney(difference));
|
||||||
}
|
}
|
||||||
|
@@ -20,9 +20,12 @@
|
|||||||
{# start marker #}
|
{# start marker #}
|
||||||
{% if journal.date < start and startSet == false %}
|
{% if journal.date < start and startSet == false %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5">
|
<td colspan="4">
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" class="check_all_btn">
|
||||||
|
</td>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<span class="label label-default">
|
<span class="label label-default">
|
||||||
{{ trans('firefly.start_of_reconcile_period', {period: start.formatLocalized(monthAndDayFormat) }) }}
|
{{ trans('firefly.start_of_reconcile_period', {period: start.formatLocalized(monthAndDayFormat) }) }}
|
||||||
@@ -38,9 +41,12 @@
|
|||||||
{# end marker #}
|
{# end marker #}
|
||||||
{% if journal.date <= end and endSet == false %}
|
{% if journal.date <= end and endSet == false %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5">
|
<td colspan="4">
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" class="check_all_btn">
|
||||||
|
</td>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<span class="label label-default">
|
<span class="label label-default">
|
||||||
{{ trans('firefly.end_of_reconcile_period', {period: end.formatLocalized(monthAndDayFormat) }) }}
|
{{ trans('firefly.end_of_reconcile_period', {period: end.formatLocalized(monthAndDayFormat) }) }}
|
||||||
|
Reference in New Issue
Block a user