More stuff for splits.

This commit is contained in:
James Cole
2016-04-30 19:50:42 +02:00
parent c05c6e72c0
commit 9c5292962f
8 changed files with 37 additions and 17 deletions

View File

@@ -18,6 +18,7 @@ use FireflyIII\Http\Requests\SplitJournalFormRequest;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Log;
use Session;
@@ -41,12 +42,15 @@ class SplitController extends Controller
/** @var BudgetRepositoryInterface $budgetRepository */
$budgetRepository = app(BudgetRepositoryInterface::class);
/** @var PiggyBankRepositoryInterface $piggyBankRepository */
$piggyBankRepository = app(PiggyBankRepositoryInterface::class);
// expect data to be in session or in post?
$journalData = session('temporary_split_data');
$journalData = session('temporary_split_data');
$currencies = ExpandedForm::makeSelectList($currencyRepository->get());
$assetAccounts = ExpandedForm::makeSelectList($accountRepository->getAccounts(['Default account', 'Asset account']));
$budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
$piggyBanks = ExpandedForm::makeSelectListWithEmpty($piggyBankRepository->getPiggyBanks());
if (!is_array($journalData)) {
throw new FireflyException('Could not find transaction data in your session. Please go back and try again.'); // translate me.
}
@@ -54,7 +58,7 @@ class SplitController extends Controller
Log::debug('Journal data', $journalData);
return view('split.journals.from-store', compact('currencies', 'assetAccounts', 'budgets'))->with('data', $journalData);
return view('split.journals.from-store', compact('currencies', 'piggyBanks', 'assetAccounts', 'budgets'))->with('data', $journalData);
}

View File

@@ -55,7 +55,9 @@ class SplitJournalFormRequest extends Request
'category' => $this->get('category')[$index] ?? '',
'source_account_id' => intval($this->get('source_account_id')),
'source_account_name' => $this->get('source_account_name'),
'destination_account_id' => $this->get('destination_account_id')[$index] ? intval($this->get('destination_account_id')[$index]) : 0,
'destination_account_id' => isset($this->get('destination_account_id')[$index])
? intval($this->get('destination_account_id')[$index])
: intval($this->get('destination_account_id')),
'destination_account_name' => $this->get('destination_account_name')[$index] ?? '',
];
$data['transactions'][] = $transaction;