This commit is contained in:
James Cole
2019-08-21 18:01:57 +02:00
parent c7931f2b72
commit 24a2238134
3 changed files with 727 additions and 714 deletions

View File

@@ -54,6 +54,7 @@ class BillController extends Controller
/**
* BillController constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
@@ -239,12 +240,23 @@ class BillController extends Controller
*/
public function rescan(Request $request, Bill $bill)
{
$total = 0;
if (false === $bill->active) {
$request->session()->flash('warning', (string)trans('firefly.cannot_scan_inactive_bill'));
return redirect(route('bills.show', [$bill->id]));
}
$set = new Collection;
if (true === $bill->active) {
$set = $this->billRepository->getRulesForBill($bill);
$total = 0;
}
if (0 === $set->count()) {
$request->session()->flash('error', (string)trans('firefly.no_rules_for_bill'));
return redirect(route('bills.show', [$bill->id]));
}
foreach ($set as $rule) {
// simply fire off all rules?
/** @var TransactionMatcher $matcher */
@@ -260,7 +272,6 @@ class BillController extends Controller
$request->session()->flash('success', (string)trans('firefly.rescanned_bill', ['total' => $total]));
app('preferences')->mark();
}
return redirect(route('bills.show', [$bill->id]));
}
@@ -325,6 +336,7 @@ class BillController extends Controller
}
);
}
// @codeCoverageIgnoreEnd

View File

@@ -551,7 +551,7 @@ class BillRepository implements BillRepositoryInterface
{
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
$journal = $transaction->transactionJournal;
$journal = $bill->user->transactionJournals()->find((int)$transaction['transaction_journal_id']);
$journal->bill_id = $bill->id;
$journal->save();
Log::debug(sprintf('Linked journal #%d to bill #%d', $journal->id, $bill->id));

View File

@@ -55,6 +55,7 @@ return [
'new_withdrawal' => 'New withdrawal',
'create_new_transaction' => 'Create new transaction',
'new_transaction' => 'New transaction',
'no_rules_for_bill' => 'This bill has no rules associated to it.',
'go_to_asset_accounts' => 'View your asset accounts',
'go_to_budgets' => 'Go to your budgets',
'go_to_categories' => 'Go to your categories',