This commit is contained in:
James Cole 2017-12-09 19:19:15 +01:00
parent 17684a3ab3
commit 1fec7d6271
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -36,10 +36,12 @@ $(function () {
Respond to changes in balance statements.
*/
$('input[type="number"]').on('change', function () {
console.log('On change number input.');
if (reconcileStarted) {
calculateBalanceDifference();
difference = balanceDifference - selectedAmount;
updateDifference();
}
changedBalances = true;
});
@ -48,6 +50,7 @@ $(function () {
Respond to changes in the date range.
*/
$('input[type="date"]').on('change', function () {
console.log('On change date input.');
if (reconcileStarted) {
// hide original instructions.
$('.select_transactions_instruction').hide();
@ -67,16 +70,19 @@ $(function () {
});
function storeReconcile() {
console.log('In storeReconcile.');
// get modal HTML:
var ids = [];
$.each($('.reconcile_checkbox:checked'), function (i, v) {
ids.push($(v).data('id'));
});
console.log('Ids is ' + ids);
var cleared = [];
$.each($('input[class="cleared"]'), function (i, v) {
var obj = $(v);
cleared.push(obj.data('id'));
});
console.log('Cleared is ' + ids);
var variables = {
startBalance: parseFloat($('input[name="start_balance"]').val()),
@ -86,13 +92,12 @@ function storeReconcile() {
transactions: ids,
cleared: cleared,
};
console.log
var uri = overviewUri.replace('%start%', $('input[name="start_date"]').val()).replace('%end%', $('input[name="end_date"]').val());
$.getJSON(uri, variables).done(function (data) {
if (data.is_zero === false) {
$('#defaultModal').empty().html(data.html).modal('show');
}
$('#defaultModal').empty().html(data.html).modal('show');
});
}
@ -101,6 +106,7 @@ function storeReconcile() {
* @param e
*/
function checkReconciledBox(e) {
console.log('In checkReconciledBox.');
var el = $(e.target);
var amount = parseFloat(el.val());
// if checked, add to selected amount
@ -120,6 +126,7 @@ function checkReconciledBox(e) {
* and put it in balanceDifference.
*/
function calculateBalanceDifference() {
console.log('In calculateBalanceDifference.');
var startBalance = parseFloat($('input[name="start_balance"]').val());
var endBalance = parseFloat($('input[name="end_balance"]').val());
balanceDifference = startBalance - endBalance;
@ -133,6 +140,7 @@ function calculateBalanceDifference() {
* This more or less resets the reconciliation.
*/
function getTransactionsForRange() {
console.log('In getTransactionsForRange.');
// clear out the box:
$('#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());
@ -147,6 +155,7 @@ function getTransactionsForRange() {
*
*/
function includeClearedTransactions() {
console.log('In includeClearedTransactions.');
$.each($('input[class="cleared"]'), function (i, v) {
var obj = $(v);
if (obj.data('younger') === false) {
@ -160,6 +169,7 @@ function includeClearedTransactions() {
* @param data
*/
function placeTransactions(data) {
console.log('In placeTransactions.');
$('#transactions_holder').empty().html(data.html);
selectedAmount = 0;
// update start + end balance when user has not touched them.
@ -191,7 +201,7 @@ function placeTransactions(data) {
* @returns {boolean}
*/
function startReconcile() {
console.log('In startReconcile.');
reconcileStarted = true;
// hide the start button.
@ -213,6 +223,7 @@ function startReconcile() {
}
function updateDifference() {
console.log('In updateDifference.');
var addClass = 'text-info';
if (difference > 0) {
addClass = 'text-success';