mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Covered transaction controller.
This commit is contained in:
@@ -12,12 +12,12 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Input;
|
||||
use Log;
|
||||
use Redirect;
|
||||
use Response;
|
||||
use Session;
|
||||
use URL;
|
||||
use View;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class TransactionController
|
||||
@@ -263,7 +263,6 @@ class TransactionController extends Controller
|
||||
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
|
||||
{
|
||||
|
||||
|
||||
$journalData = $request->getJournalData();
|
||||
$journal = $repository->store($journalData);
|
||||
|
||||
@@ -272,11 +271,7 @@ class TransactionController extends Controller
|
||||
// ConnectJournalToPiggyBank
|
||||
event(new JournalCreated($journal, intval($request->get('piggy_bank_id'))));
|
||||
|
||||
if (intval($request->get('reminder_id')) > 0) {
|
||||
$reminder = Auth::user()->reminders()->find($request->get('reminder_id'));
|
||||
$reminder->active = 0;
|
||||
$reminder->save();
|
||||
}
|
||||
$repository->deactivateReminder($request->get('reminder_id'));
|
||||
|
||||
Session::flash('success', 'New transaction "' . $journal->description . '" stored!');
|
||||
|
||||
@@ -292,6 +287,8 @@ class TransactionController extends Controller
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param JournalFormRequest $request
|
||||
* @param JournalRepositoryInterface $repository
|
||||
|
||||
@@ -57,7 +57,7 @@ class JournalFormRequest extends Request
|
||||
|
||||
$rules = [
|
||||
'description' => 'required|min:1,max:255',
|
||||
'what' => 'required|in:withdrawal,deposit,transfer|exists:transaction_types,type',
|
||||
'what' => 'required|in:withdrawal,deposit,transfer',
|
||||
'amount' => 'numeric|required|min:0.01',
|
||||
'date' => 'required|date',
|
||||
'reminder_id' => 'numeric|exists:reminders,id',
|
||||
|
||||
@@ -26,6 +26,21 @@ use Log;
|
||||
class JournalRepository implements JournalRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deactivateReminder($id)
|
||||
{
|
||||
$reminder = Auth::user()->reminders()->find($id);
|
||||
if ($reminder) {
|
||||
$reminder->active = 0;
|
||||
$reminder->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
@@ -69,7 +84,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
->where('transaction_journals.order', '>=', $journal->order)
|
||||
->where('transaction_journals.id', '!=', $journal->id)
|
||||
->sum('transactions.amount')
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,13 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface JournalRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deactivateReminder($id);
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
@@ -30,14 +37,6 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function first();
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function getWithDate($id, Carbon $date);
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param Transaction $transaction
|
||||
@@ -69,6 +68,14 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function getTransactionType($type);
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function getWithDate($id, Carbon $date);
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param array $array
|
||||
|
||||
Reference in New Issue
Block a user