Expand services.

This commit is contained in:
James Cole
2018-02-21 18:42:15 +01:00
parent 9f37bf5875
commit 81221038f0
10 changed files with 111 additions and 33 deletions

View File

@@ -334,17 +334,44 @@ class SingleController extends Controller
* @param JournalRepositoryInterface $repository
*
* @return \Illuminate\Http\RedirectResponse
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
{
$doSplit = 1 === intval($request->get('split_journal'));
$createAnother = 1 === intval($request->get('create_another'));
$data = $request->getJournalData();
$doSplit = 1 === intval($request->get('split_journal'));
$createAnother = 1 === intval($request->get('create_another'));
$data = $request->getJournalData();
$data['user'] = auth()->user()->id;
$data['bill_id'] = null;
$data['bill_name'] = null;
$data['piggy_bank_name'] = null;
$data['transactions'] = [
[
'amount' => $data['amount'],
'currency_id' => $data['currency_id'],
'description' => null,
'reconciled' => false,
'identifier' => 0,
'currency_code' => null,
'budget_id' => $data['budget_id'],
'budget_name' => null,
'category_id' => null,
'category_name' => $data['category'],
'source_id' => (int)$data['source_account_id'],
'source_name' => $data['source_account_name'],
'destination_id' => (int)$data['destination_account_id'],
'destination_name' => $data['destination_account_name'],
'foreign_currency_id' => null,
'foreign_currency_code' => null,
'foreign_amount' => null,
],
];
var_dump($data);exit;
// todo call factory instead of repository
/** @var TransactionJournalFactory $factory */
$factory = app(TransactionJournalFactory::class);
$factory->setUser(auth()->user());
$journal = $repository->store($data);
$journal = $factory->create($data);
//$journal = $repository->store($data);
if (null === $journal->id) {
// error!