Пример #1
0
 /**
  * @param JournalFormRequest         $request
  * @param JournalRepositoryInterface $repository
  *
  * @param AttachmentHelperInterface  $att
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att)
 {
     $journalData = $request->getJournalData();
     // if not withdrawal, unset budgetid.
     if ($journalData['what'] != strtolower(TransactionType::WITHDRAWAL)) {
         $journalData['budget_id'] = 0;
     }
     $journal = $repository->store($journalData);
     $att->saveAttachmentsForModel($journal);
     // flash errors
     if (count($att->getErrors()->get('attachments')) > 0) {
         Session::flash('error', $att->getErrors()->get('attachments'));
     }
     // flash messages
     if (count($att->getMessages()->get('attachments')) > 0) {
         Session::flash('info', $att->getMessages()->get('attachments'));
     }
     Log::debug('Before event. From account name is: ' . $journal->source_account->name);
     event(new TransactionJournalStored($journal, intval($request->get('piggy_bank_id'))));
     Session::flash('success', 'New transaction "' . $journal->description . '" stored!');
     Preferences::mark();
     if (intval(Input::get('create_another')) === 1) {
         // set value so create routine will not overwrite URL:
         Session::put('transactions.create.fromStore', true);
         return redirect(route('transactions.create', [$request->input('what')]))->withInput();
     }
     // redirect to previous URL.
     return redirect(Session::get('transactions.create.url'));
 }
 /**
  * @param JournalFormRequest         $request
  * @param JournalRepositoryInterface $repository
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
 {
     $att = app('FireflyIII\\Helpers\\Attachments\\AttachmentHelperInterface');
     $doSplit = intval($request->get('split_journal')) === 1;
     $journalData = $request->getJournalData();
     // store the journal only, flash the rest.
     if ($doSplit) {
         $journal = $repository->storeJournal($journalData);
         $journal->completed = false;
         $journal->save();
         // store attachments:
         $att->saveAttachmentsForModel($journal);
         // flash errors
         if (count($att->getErrors()->get('attachments')) > 0) {
             Session::flash('error', $att->getErrors()->get('attachments'));
         }
         // flash messages
         if (count($att->getMessages()->get('attachments')) > 0) {
             Session::flash('info', $att->getMessages()->get('attachments'));
         }
         Session::put('journal-data', $journalData);
         return redirect(route('split.journal.create', [$journal->id]));
     }
     // if not withdrawal, unset budgetid.
     if ($journalData['what'] != strtolower(TransactionType::WITHDRAWAL)) {
         $journalData['budget_id'] = 0;
     }
     $journal = $repository->store($journalData);
     $att->saveAttachmentsForModel($journal);
     // flash errors
     if (count($att->getErrors()->get('attachments')) > 0) {
         Session::flash('error', $att->getErrors()->get('attachments'));
     }
     // flash messages
     if (count($att->getMessages()->get('attachments')) > 0) {
         Session::flash('info', $att->getMessages()->get('attachments'));
     }
     event(new TransactionJournalStored($journal, intval($journalData['piggy_bank_id'])));
     Session::flash('success', strval(trans('firefly.stored_journal', ['description' => e($journal->description)])));
     Preferences::mark();
     if (intval($request->get('create_another')) === 1) {
         // set value so create routine will not overwrite URL:
         Session::put('transactions.create.fromStore', true);
         return redirect(route('transactions.create', [$request->input('what')]))->withInput();
     }
     // redirect to previous URL.
     return redirect(session('transactions.create.url'));
 }
Пример #3
0
 /**
  * @param JournalFormRequest         $request
  * @param JournalRepositoryInterface $repository
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att)
 {
     $journalData = $request->getJournalData();
     // if not withdrawal, unset budgetid.
     if ($journalData['what'] != 'withdrawal') {
         $journalData['budget_id'] = 0;
     }
     $journal = $repository->store($journalData);
     // save attachments:
     $att->saveAttachmentsForModel($journal);
     // flash errors
     if (count($att->getErrors()->get('attachments')) > 0) {
         Session::flash('error', $att->getErrors()->get('attachments'));
     }
     // flash messages
     if (count($att->getMessages()->get('attachments')) > 0) {
         Session::flash('info', $att->getMessages()->get('attachments'));
     }
     // rescan journal, UpdateJournalConnection
     event(new JournalSaved($journal));
     if ($journal->transactionType->type == 'Transfer' && intval($request->get('piggy_bank_id')) > 0) {
         event(new JournalCreated($journal, intval($request->get('piggy_bank_id'))));
     }
     Session::flash('success', 'New transaction "' . $journal->description . '" stored!');
     Preferences::mark();
     if (intval(Input::get('create_another')) === 1) {
         // set value so create routine will not overwrite URL:
         Session::put('transactions.create.fromStore', true);
         return redirect(route('transactions.create', [$request->input('what')]))->withInput();
     }
     // redirect to previous URL.
     return redirect(Session::get('transactions.create.url'));
 }
Пример #4
0
 /**
  * @param JournalFormRequest         $request
  * @param JournalRepositoryInterface $repository
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
 {
     $journalData = $request->getJournalData();
     $journal = $repository->store($journalData);
     // rescan journal, UpdateJournalConnection
     event(new JournalSaved($journal));
     // ConnectJournalToPiggyBank
     if ($journal->transactionType->type == 'Transfer' && intval($request->get('piggy_bank_id')) > 0) {
         event(new JournalCreated($journal, intval($request->get('piggy_bank_id'))));
     }
     Session::flash('success', 'New transaction "' . $journal->description . '" stored!');
     Preferences::mark();
     if (intval(Input::get('create_another')) === 1) {
         // set value so create routine will not overwrite URL:
         Session::put('transactions.create.fromStore', true);
         return Redirect::route('transactions.create', [$request->input('what')])->withInput();
     }
     // redirect to previous URL.
     return Redirect::to(Session::get('transactions.create.url'));
 }