mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some code for #736
This commit is contained in:
parent
7de512aff8
commit
644fa3027a
@ -259,6 +259,20 @@ class ReconcileController extends Controller
|
|||||||
return $this->redirectToOriginalAccount($account);
|
return $this->redirectToOriginalAccount($account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$startDate = clone $start;
|
||||||
|
$startDate->subDays(1);
|
||||||
|
|
||||||
|
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||||
|
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||||
|
$currencyId = intval($account->getMeta('currency_id'));
|
||||||
|
$currency = $currencyRepos->find($currencyId);
|
||||||
|
if (0 === $currencyId) {
|
||||||
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
|
}
|
||||||
|
|
||||||
|
$startBalance = round(app('steam')->balance($account, $startDate), $currency->decimal_places);
|
||||||
|
$endBalance = round(app('steam')->balance($account, $end), $currency->decimal_places);
|
||||||
|
|
||||||
// get the transactions
|
// get the transactions
|
||||||
$selectionStart = clone $start;
|
$selectionStart = clone $start;
|
||||||
$selectionStart->subDays(3);
|
$selectionStart->subDays(3);
|
||||||
@ -273,6 +287,6 @@ class ReconcileController extends Controller
|
|||||||
$transactions = $collector->getJournals();
|
$transactions = $collector->getJournals();
|
||||||
$html = view('accounts.reconcile.transactions', compact('account', 'transactions', 'start', 'end', 'selectionStart', 'selectionEnd'))->render();
|
$html = view('accounts.reconcile.transactions', compact('account', 'transactions', 'start', 'end', 'selectionStart', 'selectionEnd'))->render();
|
||||||
|
|
||||||
return Response::json(['html' => $html]);
|
return Response::json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
public/js/ff/accounts/reconcile.js
vendored
22
public/js/ff/accounts/reconcile.js
vendored
@ -22,6 +22,7 @@ var balanceDifference = 0;
|
|||||||
var difference = 0;
|
var difference = 0;
|
||||||
var selectedAmount = 0;
|
var selectedAmount = 0;
|
||||||
var reconcileStarted = false;
|
var reconcileStarted = false;
|
||||||
|
var changedBalances = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -38,6 +39,7 @@ $(function () {
|
|||||||
difference = balanceDifference - selectedAmount;
|
difference = balanceDifference - selectedAmount;
|
||||||
updateDifference();
|
updateDifference();
|
||||||
}
|
}
|
||||||
|
changedBalances = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -111,19 +113,8 @@ function checkReconciledBox(e) {
|
|||||||
}
|
}
|
||||||
difference = balanceDifference - selectedAmount;
|
difference = balanceDifference - selectedAmount;
|
||||||
updateDifference();
|
updateDifference();
|
||||||
allowReconcile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function allowReconcile() {
|
|
||||||
var count = $('.reconcile_checkbox:checked').length;
|
|
||||||
console.log('Count checkboxes is ' + count);
|
|
||||||
if (count > 0) {
|
|
||||||
$('.store_reconcile').prop('disabled', false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the difference between given start and end balance
|
* Calculate the difference between given start and end balance
|
||||||
@ -171,7 +162,12 @@ function includeClearedTransactions() {
|
|||||||
*/
|
*/
|
||||||
function placeTransactions(data) {
|
function placeTransactions(data) {
|
||||||
$('#transactions_holder').empty().html(data.html);
|
$('#transactions_holder').empty().html(data.html);
|
||||||
|
selectedAmount = 0;
|
||||||
|
// update start + end balance when user has not touched them.
|
||||||
|
if (!changedBalances) {
|
||||||
|
$('input[name="start_balance"]').val(data.startBalance);
|
||||||
|
$('input[name="end_balance"]').val(data.endBalance);
|
||||||
|
}
|
||||||
|
|
||||||
// as long as the dates are equal, changing the balance does not matter.
|
// as long as the dates are equal, changing the balance does not matter.
|
||||||
calculateBalanceDifference();
|
calculateBalanceDifference();
|
||||||
@ -187,6 +183,8 @@ function placeTransactions(data) {
|
|||||||
|
|
||||||
// show the other instruction:
|
// show the other instruction:
|
||||||
$('.select_transactions_instruction').show();
|
$('.select_transactions_instruction').show();
|
||||||
|
|
||||||
|
$('.store_reconcile').prop('disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user