mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-06 12:45:30 +00:00
Fix for #1825
This commit is contained in:
@@ -113,13 +113,41 @@ class ReconcileController extends Controller
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$amount = bcadd($amount, $transaction->amount);
|
||||
}
|
||||
// find the account and opposing account for this transaction
|
||||
$srcAccount = $this->accountRepos->findNull((int)$transaction->account_id);
|
||||
$dstAccount = $this->accountRepos->findNull((int)$transaction->opposing_account_id);
|
||||
$srcCurrency = (int)$this->accountRepos->getMetaValue($srcAccount, 'currency_id');
|
||||
$dstCurrency = (int)$this->accountRepos->getMetaValue($dstAccount, 'currency_id');
|
||||
|
||||
// is $account source or destination?
|
||||
if ($account->id === $srcAccount->id) {
|
||||
// source, and it matches the currency id or is 0
|
||||
if ($srcCurrency === $transaction->transaction_currency_id || 0 === $srcCurrency) {
|
||||
$amount = bcadd($amount, $transaction->transaction_amount);
|
||||
}
|
||||
// destination, and it matches the foreign currency ID.
|
||||
if ($srcCurrency === $transaction->foreign_currency_id) {
|
||||
$amount = bcadd($amount, $transaction->transaction_foreign_amount);
|
||||
}
|
||||
}
|
||||
|
||||
if ($account->id === $dstAccount->id) {
|
||||
// destination, and it matches the currency id or is 0
|
||||
if ($dstCurrency === $transaction->transaction_currency_id || 0 === $dstCurrency) {
|
||||
$amount = bcadd($amount, $transaction->transaction_amount);
|
||||
}
|
||||
// destination, and it matches the foreign currency ID.
|
||||
if ($dstCurrency === $transaction->foreign_currency_id) {
|
||||
$amount = bcadd($amount, $transaction->transaction_foreign_amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
// make sure amount is positive.
|
||||
$amount = app('steam')->positive($amount);
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($cleared as $transaction) {
|
||||
if ($transaction->transactionJournal->date <= $end) {
|
||||
$clearedAmount = bcadd($clearedAmount, $transaction->amount); // @codeCoverageIgnore
|
||||
if ($transaction->date <= $end) {
|
||||
$clearedAmount = bcadd($clearedAmount, $transaction->transaction_amount); // @codeCoverageIgnore
|
||||
++$countCleared;
|
||||
}
|
||||
}
|
||||
@@ -201,6 +229,7 @@ class ReconcileController extends Controller
|
||||
Log::debug(sprintf('Could not render: %s', $e->getMessage()));
|
||||
$html = 'Could not render accounts.reconcile.transactions';
|
||||
}
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return response()->json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]);
|
||||
|
Reference in New Issue
Block a user