mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-03 19:16:51 +00:00
Some attempts to fix #1673
This commit is contained in:
50
public/js/ff/accounts/reconcile.js
vendored
50
public/js/ff/accounts/reconcile.js
vendored
@@ -36,7 +36,9 @@ $(function () {
|
|||||||
Respond to changes in balance statements.
|
Respond to changes in balance statements.
|
||||||
*/
|
*/
|
||||||
$('input[type="number"]').on('change', function () {
|
$('input[type="number"]').on('change', function () {
|
||||||
|
console.log('On type=number change.');
|
||||||
if (reconcileStarted) {
|
if (reconcileStarted) {
|
||||||
|
console.log('Reconcile has started.');
|
||||||
calculateBalanceDifference();
|
calculateBalanceDifference();
|
||||||
difference = balanceDifference - selectedAmount;
|
difference = balanceDifference - selectedAmount;
|
||||||
updateDifference();
|
updateDifference();
|
||||||
@@ -49,7 +51,9 @@ $(function () {
|
|||||||
Respond to changes in the date range.
|
Respond to changes in the date range.
|
||||||
*/
|
*/
|
||||||
$('input[type="date"]').on('change', function () {
|
$('input[type="date"]').on('change', function () {
|
||||||
|
console.log('On type=date change.');
|
||||||
if (reconcileStarted) {
|
if (reconcileStarted) {
|
||||||
|
console.log('Reconcile has started.');
|
||||||
// hide original instructions.
|
// hide original instructions.
|
||||||
$('.select_transactions_instruction').hide();
|
$('.select_transactions_instruction').hide();
|
||||||
|
|
||||||
@@ -68,15 +72,24 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function storeReconcile() {
|
function storeReconcile() {
|
||||||
|
console.log('in storeReconcile()');
|
||||||
// get modal HTML:
|
// get modal HTML:
|
||||||
var ids = [];
|
var ids = [];
|
||||||
$.each($('.reconcile_checkbox:checked'), function (i, v) {
|
$.each($('.reconcile_checkbox:checked'), function (i, v) {
|
||||||
ids.push($(v).data('id'));
|
var obj = $(v);
|
||||||
|
if(obj.data('inrange') === true){
|
||||||
|
console.log('Added item with amount to list of checked ' + obj.val());
|
||||||
|
ids.push(obj.data('id'));
|
||||||
|
} else {
|
||||||
|
console.log('Ignored item with amount because is not in range ' + obj.val());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var cleared = [];
|
var cleared = [];
|
||||||
$.each($('input[class="cleared"]'), function (i, v) {
|
$.each($('input[class="cleared"]'), function (i, v) {
|
||||||
var obj = $(v);
|
var obj = $(v);
|
||||||
//cleared.push(obj.data('id'));
|
console.log('Added item with amount to list of cleared ' + obj.val());
|
||||||
|
// todo here we need to check previous transactions etc.
|
||||||
|
cleared.push(obj.data('id'));
|
||||||
});
|
});
|
||||||
|
|
||||||
var variables = {
|
var variables = {
|
||||||
@@ -100,16 +113,21 @@ function storeReconcile() {
|
|||||||
* @param e
|
* @param e
|
||||||
*/
|
*/
|
||||||
function checkReconciledBox(e) {
|
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);
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
difference = balanceDifference - selectedAmount;
|
difference = balanceDifference - selectedAmount;
|
||||||
|
console.log('Difference is now ' + difference);
|
||||||
updateDifference();
|
updateDifference();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +137,7 @@ function checkReconciledBox(e) {
|
|||||||
* and put it in balanceDifference.
|
* and put it in balanceDifference.
|
||||||
*/
|
*/
|
||||||
function calculateBalanceDifference() {
|
function calculateBalanceDifference() {
|
||||||
|
console.log('in calculateBalanceDifference()');
|
||||||
var startBalance = parseFloat($('input[name="start_balance"]').val());
|
var startBalance = parseFloat($('input[name="start_balance"]').val());
|
||||||
var endBalance = parseFloat($('input[name="end_balance"]').val());
|
var endBalance = parseFloat($('input[name="end_balance"]').val());
|
||||||
balanceDifference = startBalance - endBalance;
|
balanceDifference = startBalance - endBalance;
|
||||||
@@ -129,6 +148,7 @@ function calculateBalanceDifference() {
|
|||||||
* This more or less resets the reconciliation.
|
* This more or less resets the reconciliation.
|
||||||
*/
|
*/
|
||||||
function getTransactionsForRange() {
|
function getTransactionsForRange() {
|
||||||
|
console.log('in getTransactionsForRange()');
|
||||||
// clear out the box:
|
// clear out the box:
|
||||||
$('#transactions_holder').empty().append($('<p>').addClass('text-center').html('<i class="fa fa-fw fa-spin fa-spinner"></i>'));
|
$('#transactions_holder').empty().append($('<p>').addClass('text-center').html('<i class="fa fa-fw fa-spin fa-spinner"></i>'));
|
||||||
var uri = transactionsUri.replace('%start%', $('input[name="start_date"]').val()).replace('%end%', $('input[name="end_date"]').val());
|
var uri = transactionsUri.replace('%start%', $('input[name="start_date"]').val()).replace('%end%', $('input[name="end_date"]').val());
|
||||||
@@ -138,16 +158,35 @@ function getTransactionsForRange() {
|
|||||||
$.getJSON(uri).done(placeTransactions);
|
$.getJSON(uri).done(placeTransactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Loop over all transactions that have already been cleared (in the range)
|
||||||
|
// * and add this to the selectedAmount.
|
||||||
|
// *
|
||||||
|
// */
|
||||||
|
// function includeClearedTransactions() {
|
||||||
|
// $.each($('input[class="cleared"]'), function (i, v) {
|
||||||
|
// var obj = $(v);
|
||||||
|
// if (obj.data('younger') === false) {
|
||||||
|
// //selectedAmount = selectedAmount - parseFloat(obj.val());
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loop over all transactions that have already been cleared (in the range)
|
* Loop over all transactions that have already been cleared (in the range)
|
||||||
* and add this to the selectedAmount.
|
* and add this to the selectedAmount.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function includeClearedTransactions() {
|
function includeClearedTransactions() {
|
||||||
|
console.log('in includeClearedTransactions()');
|
||||||
$.each($('input[class="cleared"]'), function (i, v) {
|
$.each($('input[class="cleared"]'), function (i, v) {
|
||||||
var obj = $(v);
|
var obj = $(v);
|
||||||
if (obj.data('younger') === false) {
|
var amount = parseFloat(obj.val());
|
||||||
//selectedAmount = selectedAmount - parseFloat(obj.val());
|
if (obj.data('inrange') === true) {
|
||||||
|
console.log('Amount is ' + amount + ' and inrange = true');
|
||||||
|
selectedAmount = selectedAmount - amount;
|
||||||
|
} else {
|
||||||
|
console.log('Amount is ' + amount + ' but inrange = FALSE so ignore.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -157,6 +196,7 @@ function includeClearedTransactions() {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
function placeTransactions(data) {
|
function placeTransactions(data) {
|
||||||
|
console.log('in placeTransactions()');
|
||||||
$('#transactions_holder').empty().html(data.html);
|
$('#transactions_holder').empty().html(data.html);
|
||||||
selectedAmount = 0;
|
selectedAmount = 0;
|
||||||
// update start + end balance when user has not touched them.
|
// update start + end balance when user has not touched them.
|
||||||
@@ -188,6 +228,7 @@ function placeTransactions(data) {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
function startReconcile() {
|
function startReconcile() {
|
||||||
|
console.log('in startReconcile()');
|
||||||
reconcileStarted = true;
|
reconcileStarted = true;
|
||||||
|
|
||||||
// hide the start button.
|
// hide the start button.
|
||||||
@@ -209,6 +250,7 @@ function startReconcile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateDifference() {
|
function updateDifference() {
|
||||||
|
console.log('in updateDifference()');
|
||||||
var addClass = 'text-info';
|
var addClass = 'text-info';
|
||||||
if (difference > 0) {
|
if (difference > 0) {
|
||||||
addClass = 'text-success';
|
addClass = 'text-success';
|
||||||
|
@@ -91,10 +91,12 @@
|
|||||||
{% if transaction.reconciled %}
|
{% if transaction.reconciled %}
|
||||||
{{ transaction|transactionReconciled }}
|
{{ transaction|transactionReconciled }}
|
||||||
<input type="hidden" name="cleared[]" data-younger="{% if transaction.date < start %}true{% else %}false{% endif %}"
|
<input type="hidden" name="cleared[]" data-younger="{% if transaction.date < start %}true{% else %}false{% endif %}"
|
||||||
|
data-inrange="{% if transaction.date >= start and transaction.date <= end %}true{% else %}false"{% endif %}"
|
||||||
class="cleared" data-id="{{ transaction.id }}" value="{{ transactionAmount }}">
|
class="cleared" data-id="{{ transaction.id }}" value="{{ transactionAmount }}">
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="checkbox" name="reconciled[]"
|
<input type="checkbox" name="reconciled[]"
|
||||||
data-younger="{% if transaction.date < start %}true{% else %}false{% endif %}"
|
data-younger="{% if transaction.date < start %}true{% else %}false{% endif %}"
|
||||||
|
data-inrange="{% if transaction.date >= start and transaction.date <= end %}true{% else %}false"{% endif %}"
|
||||||
value="{{ transactionAmount }}" data-id="{{ transaction.id }}" disabled class="reconcile_checkbox">
|
value="{{ transactionAmount }}" data-id="{{ transaction.id }}" disabled class="reconcile_checkbox">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
Reference in New Issue
Block a user