mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-25 08:21:08 -06:00
Cleaning up and bug fixing.
This commit is contained in:
parent
ad2aebb54d
commit
b1af6bab28
31
app/Events/JournalCreated.php
Normal file
31
app/Events/JournalCreated.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\Events\Event;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class JournalCreated extends Event {
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
public $journal;
|
||||
public $piggyBankId;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal, $piggyBankId)
|
||||
{
|
||||
//
|
||||
$this->journal = $journal;
|
||||
$this->piggyBankId = $piggyBankId;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
85
app/Handlers/Events/ConnectJournalToPiggyBank.php
Normal file
85
app/Handlers/Events/ConnectJournalToPiggyBank.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php namespace FireflyIII\Handlers\Events;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Events\JournalCreated;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ConnectJournalToPiggyBank
|
||||
*
|
||||
* @package FireflyIII\Handlers\Events
|
||||
*/
|
||||
class ConnectJournalToPiggyBank
|
||||
{
|
||||
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event when journal is saved.
|
||||
*
|
||||
* @param JournalCreated $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(JournalCreated $event)
|
||||
{
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $event->journal;
|
||||
$piggyBankId = $event->piggyBankId;
|
||||
|
||||
Log::debug('JournalCreated event: ' . $journal->id . ', ' . $piggyBankId);
|
||||
|
||||
/** @var PiggyBank $piggyBank */
|
||||
$piggyBank = Auth::user()->piggybanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
|
||||
|
||||
if (is_null($piggyBank) || $journal->transactionType->type != 'Transfer') {
|
||||
return;
|
||||
}
|
||||
Log::debug('Found a piggy bank');
|
||||
$amount = 0;
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
if ($transaction->account_id === $piggyBank->account_id) {
|
||||
// this transaction is the relevant one.
|
||||
$amount = floatval($transaction->amount);
|
||||
}
|
||||
}
|
||||
Log::debug('Amount: ' . $amount);
|
||||
if ($amount == 0) {
|
||||
return;
|
||||
}
|
||||
// update piggy bank rep for date of transaction journal.
|
||||
$repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();
|
||||
if (is_null($repetition)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log::debug('Found rep! ' . $repetition->id);
|
||||
$repetition->currentamount += $amount;
|
||||
$repetition->save();
|
||||
|
||||
PiggyBankEvent::create(
|
||||
[
|
||||
'piggy_bank_id' => $piggyBank->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'date' => $journal->date,
|
||||
'amount' => $amount
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
64
app/Handlers/Events/UpdateJournalConnection.php
Normal file
64
app/Handlers/Events/UpdateJournalConnection.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php namespace FireflyIII\Handlers\Events;
|
||||
|
||||
use FireflyIII\Events\JournalSaved;
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
class UpdateJournalConnection
|
||||
{
|
||||
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param JournalSaved $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(JournalSaved $event)
|
||||
{
|
||||
$journal = $event->journal;
|
||||
|
||||
// get the event connected to this journal:
|
||||
/** @var PiggyBankEvent $event */
|
||||
$event = PiggyBankEvent::where('transaction_journal_id', $journal->id)->first();
|
||||
$piggyBank = $event->piggyBank()->first();
|
||||
$repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();
|
||||
|
||||
if (is_null($repetition)) {
|
||||
return;
|
||||
}
|
||||
$amount = 0;
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
if ($transaction->account_id === $piggyBank->account_id) {
|
||||
// this transaction is the relevant one.
|
||||
$amount = floatval($transaction->amount);
|
||||
}
|
||||
}
|
||||
|
||||
// update current repetition:
|
||||
$diff = $amount - $event->amount;
|
||||
|
||||
$repetition->currentamount += $diff;
|
||||
if($repetition->currentamount < 0) {
|
||||
$repetition->currentamount = 0;
|
||||
}
|
||||
$repetition->save();
|
||||
|
||||
|
||||
$event->amount = $amount;
|
||||
$event->save();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
<?php namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use App;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
@ -128,7 +127,7 @@ class AccountController extends Controller
|
||||
['accountmeta' => function ($query) {
|
||||
$query->where('name', 'accountRole');
|
||||
}]
|
||||
)->accountTypeIn($types)->take($size)->offset($offset)->orderBy('accounts.name','ASC')->get(['accounts.*']);
|
||||
)->accountTypeIn($types)->take($size)->offset($offset)->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||
$total = Auth::user()->accounts()->accountTypeIn($types)->count();
|
||||
|
||||
// last activity:
|
||||
@ -148,7 +147,7 @@ class AccountController extends Controller
|
||||
);
|
||||
|
||||
$accounts = new LengthAwarePaginator($set, $total, $size, $page);
|
||||
$accounts->setPath(route('accounts.index',$what));
|
||||
$accounts->setPath(route('accounts.index', $what));
|
||||
|
||||
|
||||
return view('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
|
||||
@ -156,22 +155,19 @@ class AccountController extends Controller
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param string $range
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
* @return View
|
||||
*/
|
||||
public function show(Account $account, $range = 'session')
|
||||
public function show(Account $account, AccountRepositoryInterface $repository)
|
||||
{
|
||||
/** @var \FireflyIII\Repositories\Account\AccountRepositoryInterface $repository */
|
||||
$repository = App::make('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||
$subTitleIcon = Config::get('firefly.subTitlesByIdentifier.' . $account->accountType->type);
|
||||
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||
$journals = $repository->getJournals($account, $page, $range);
|
||||
$journals = $repository->getJournals($account, $page);
|
||||
$subTitle = 'Details for ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"';
|
||||
|
||||
return view('accounts.show', compact('account', 'what', 'range', 'subTitleIcon', 'journals', 'subTitle'));
|
||||
return view('accounts.show', compact('account', 'what', 'subTitleIcon', 'journals', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,6 +193,10 @@ class AccountController extends Controller
|
||||
|
||||
Session::flash('success', 'New account "' . $account->name . '" stored!');
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
return Redirect::route('accounts.create', $request->input('what'));
|
||||
}
|
||||
|
||||
return Redirect::route('accounts.index', $request->input('what'));
|
||||
|
||||
}
|
||||
@ -225,6 +225,10 @@ class AccountController extends Controller
|
||||
|
||||
Session::flash('success', 'Account "' . $account->name . '" updated.');
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
return Redirect::route('accounts.edit', $account->id);
|
||||
}
|
||||
|
||||
return Redirect::route('accounts.index', $what);
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ use Redirect;
|
||||
use Session;
|
||||
use View;
|
||||
use Cache;
|
||||
use Input;
|
||||
|
||||
|
||||
/**
|
||||
* Class CurrencyController
|
||||
@ -145,6 +147,10 @@ class CurrencyController extends Controller
|
||||
|
||||
Session::flash('success', 'Currency "' . $currency->name . '" created');
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
return Redirect::route('currency.create');
|
||||
}
|
||||
|
||||
return Redirect::route('currency.index');
|
||||
|
||||
|
||||
@ -163,7 +169,12 @@ class CurrencyController extends Controller
|
||||
$currency->name = $request->get('name');
|
||||
$currency->save();
|
||||
|
||||
Session::flash('success', 'Currency "' . e($currency->namename) . '" updated.');
|
||||
Session::flash('success', 'Currency "' . e($currency->name) . '" updated.');
|
||||
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
return Redirect::route('currency.edit', $currency->id);
|
||||
}
|
||||
|
||||
return Redirect::route('currency.index');
|
||||
|
||||
|
@ -42,27 +42,14 @@ class GoogleChartController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function accountBalanceChart(Account $account, $view = 'session', GChart $chart)
|
||||
public function accountBalanceChart(Account $account, GChart $chart)
|
||||
{
|
||||
$chart->addColumn('Day of month', 'date');
|
||||
$chart->addColumn('Balance for ' . $account->name, 'number');
|
||||
$chart->addCertainty(1);
|
||||
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$count = $account->transactions()->count();
|
||||
|
||||
if ($view == 'all' && $count > 0) {
|
||||
$first = $account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy(
|
||||
'date', 'ASC'
|
||||
)->first(['transaction_journals.date']);
|
||||
$last = $account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy(
|
||||
'date', 'DESC'
|
||||
)->first(['transaction_journals.date']);
|
||||
$start = new Carbon($first->date);
|
||||
$end = new Carbon($last->date);
|
||||
}
|
||||
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$current = clone $start;
|
||||
|
||||
while ($end >= $current) {
|
||||
|
@ -273,7 +273,7 @@ class PiggyBankController extends Controller
|
||||
$piggyBankData = [
|
||||
'repeats' => false,
|
||||
'name' => $request->get('name'),
|
||||
'startdate' => new Carbon,
|
||||
'startdate' => null,
|
||||
'account_id' => intval($request->get('account_id')),
|
||||
'targetamount' => floatval($request->get('targetamount')),
|
||||
'targetdate' => strlen($request->get('targetdate')) > 0 ? new Carbon($request->get('targetdate')) : null,
|
||||
|
@ -3,6 +3,7 @@
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use ExpandedForm;
|
||||
use FireflyIII\Events\JournalCreated;
|
||||
use FireflyIII\Events\JournalSaved;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\JournalFormRequest;
|
||||
@ -144,7 +145,7 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
if ($journal->piggyBankEvents()->count() > 0) {
|
||||
$preFilled['piggy_bank_id'] = $journal->piggyBankEvents()->first()->piggy_bank_id;
|
||||
$preFilled['piggy_bank_id'] = $journal->piggyBankEvents()->orderBy('date', 'DESC')->first()->piggy_bank_id;
|
||||
}
|
||||
|
||||
$preFilled['amount'] = 0;
|
||||
@ -266,8 +267,10 @@ class TransactionController extends Controller
|
||||
$journal = $repository->store($journalData);
|
||||
|
||||
event(new JournalSaved($journal));
|
||||
event(new JournalCreated($journal, intval($request->get('piggy_bank_id'))));
|
||||
|
||||
Session::flash('success', 'New transaction "' . $journal->description . '" stored!');
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
return Redirect::route('transactions.create', $request->input('what'));
|
||||
}
|
||||
@ -307,6 +310,7 @@ class TransactionController extends Controller
|
||||
$repository->update($journal, $journalData);
|
||||
|
||||
event(new JournalSaved($journal));
|
||||
// update, get events by date and sort DESC
|
||||
|
||||
Session::flash('success', 'Transaction "' . e($journalData['description']) . '" updated.');
|
||||
|
||||
|
@ -10,6 +10,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class PiggyBankEvent extends Model
|
||||
{
|
||||
|
||||
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php namespace FireflyIII\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Carbon\Carbon;
|
||||
/**
|
||||
* Class PiggyBankRepetition
|
||||
*
|
||||
@ -26,4 +27,25 @@ class PiggyBankRepetition extends Model
|
||||
return $this->belongsTo('FireflyIII\Models\PiggyBank');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeRelevantOnDate(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
return $query->where(
|
||||
function($q) use ($date) {
|
||||
$q->where('startdate', '>=', $date->format('Y-m-d 00:00:00'));
|
||||
$q->orWhereNull('startdate');
|
||||
})
|
||||
|
||||
->where(function($q) use ($date) {
|
||||
|
||||
$q->where('targetdate', '<=', $date->format('Y-m-d 00:00:00'));
|
||||
$q->orWhereNull('targetdate');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,12 @@ class EventServiceProvider extends ServiceProvider
|
||||
= [
|
||||
'FireflyIII\Events\JournalSaved' => [
|
||||
'FireflyIII\Handlers\Events\RescanJournal',
|
||||
'FireflyIII\Handlers\Events\UpdateJournalConnection',
|
||||
|
||||
],
|
||||
'FireflyIII\Events\JournalCreated' => [
|
||||
'FireflyIII\Handlers\Events\ConnectJournalToPiggyBank',
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
@ -73,8 +78,8 @@ class EventServiceProvider extends ServiceProvider
|
||||
function (PiggyBank $piggyBank) {
|
||||
$repetition = new PiggyBankRepetition;
|
||||
$repetition->piggyBank()->associate($piggyBank);
|
||||
$repetition->startdate = $piggyBank->startdate;
|
||||
$repetition->targetdate = $piggyBank->targetdate;
|
||||
$repetition->startdate = is_null($piggyBank->startdate) ? null : $piggyBank->startdate;
|
||||
$repetition->targetdate = is_null($piggyBank->targetdate) ? null : $piggyBank->targetdate;
|
||||
$repetition->currentamount = 0;
|
||||
$repetition->save();
|
||||
}
|
||||
|
@ -40,11 +40,10 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param int $page
|
||||
* @param string $range
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getJournals(Account $account, $page, $range = 'session')
|
||||
public function getJournals(Account $account, $page)
|
||||
{
|
||||
$offset = ($page - 1) * 50;
|
||||
$query = Auth::user()
|
||||
@ -54,10 +53,8 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
->where('transactions.account_id', $account->id)
|
||||
->orderBy('date', 'DESC');
|
||||
|
||||
if ($range == 'session') {
|
||||
$query->before(Session::get('end', Carbon::now()->endOfMonth()));
|
||||
$query->after(Session::get('start', Carbon::now()->startOfMonth()));
|
||||
}
|
||||
$query->before(Session::get('end', Carbon::now()->endOfMonth()));
|
||||
$query->after(Session::get('start', Carbon::now()->startOfMonth()));
|
||||
$count = $query->count();
|
||||
$set = $query->take(50)->offset($offset)->get(['transaction_journals.*']);
|
||||
$paginator = new LengthAwarePaginator($set, $count, 50, $page);
|
||||
@ -296,32 +293,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param TransactionJournal $journal
|
||||
* @param array $data
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
protected function _updateInitialBalance(Account $account, TransactionJournal $journal, array $data)
|
||||
{
|
||||
$journal->date = $data['openingBalanceDate'];
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
if ($account->id == $transaction->account_id) {
|
||||
$transaction->amount = $data['openingBalance'];
|
||||
$transaction->save();
|
||||
}
|
||||
if ($account->id != $transaction->account_id) {
|
||||
$transaction->amount = $data['openingBalance'] * -1;
|
||||
$transaction->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $journal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
@ -355,4 +326,30 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param TransactionJournal $journal
|
||||
* @param array $data
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
protected function _updateInitialBalance(Account $account, TransactionJournal $journal, array $data)
|
||||
{
|
||||
$journal->date = $data['openingBalanceDate'];
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
if ($account->id == $transaction->account_id) {
|
||||
$transaction->amount = $data['openingBalance'];
|
||||
$transaction->save();
|
||||
}
|
||||
if ($account->id != $transaction->account_id) {
|
||||
$transaction->amount = $data['openingBalance'] * -1;
|
||||
$transaction->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $journal;
|
||||
}
|
||||
}
|
@ -21,12 +21,11 @@ interface AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param int $page
|
||||
* @param string $range
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getJournals(Account $account, $page, $range = 'session');
|
||||
public function getJournals(Account $account, $page);
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
|
@ -8,6 +8,7 @@ use Illuminate\Support\MessageBag;
|
||||
use Input;
|
||||
use Session;
|
||||
use View;
|
||||
use Amount;
|
||||
|
||||
/**
|
||||
* Class ExpandedForm
|
||||
@ -17,46 +18,6 @@ use View;
|
||||
class ExpandedForm
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function integer($name, $value = null, array $options = [])
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = '1';
|
||||
$html = \View::make('form.integer', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function tags($name, $value = null, array $options = [])
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['data-role'] = 'tagsinput';
|
||||
$html = \View::make('form.tags', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
@ -91,9 +52,19 @@ class ExpandedForm
|
||||
if (isset($options['label'])) {
|
||||
return $options['label'];
|
||||
}
|
||||
$labels = ['amount_min' => 'Amount (min)', 'amount_max' => 'Amount (max)', 'match' => 'Matches on', 'repeat_freq' => 'Repetition',
|
||||
'account_from_id' => 'Account from', 'account_to_id' => 'Account to', 'account_id' => 'Asset account', 'budget_id' => 'Budget'
|
||||
, 'piggy_bank_id' => 'Piggy bank'];
|
||||
$labels = [
|
||||
'amount_min' => 'Amount (min)',
|
||||
'amount_max' => 'Amount (max)',
|
||||
'match' => 'Matches on',
|
||||
'repeat_freq' => 'Repetition',
|
||||
'account_from_id' => 'Account from',
|
||||
'account_to_id' => 'Account to',
|
||||
'account_id' => 'Asset account',
|
||||
'budget_id' => 'Budget',
|
||||
'openingBalance' => 'Opening balance',
|
||||
'accountRole' => 'Account role',
|
||||
'openingBalanceDate' => 'Opening balance date',
|
||||
'piggy_bank_id' => 'Piggy bank'];
|
||||
|
||||
|
||||
return isset($labels[$name]) ? $labels[$name] : str_replace('_', ' ', ucfirst($name));
|
||||
@ -229,6 +200,26 @@ class ExpandedForm
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function integer($name, $value = null, array $options = [])
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = '1';
|
||||
$html = \View::make('form.integer', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
*
|
||||
@ -296,6 +287,25 @@ class ExpandedForm
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function tags($name, $value = null, array $options = [])
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['data-role'] = 'tagsinput';
|
||||
$html = \View::make('form.tags', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
|
@ -1,7 +1,7 @@
|
||||
$(function () {
|
||||
|
||||
if (typeof(googleLineChart) === "function" && typeof accountID !== 'undefined' && typeof view !== 'undefined') {
|
||||
googleLineChart('chart/account/' + accountID + '/' + view, 'overview-chart');
|
||||
if (typeof(googleLineChart) === "function" && typeof accountID !== 'undefined') {
|
||||
googleLineChart('chart/account/' + accountID, 'overview-chart');
|
||||
}
|
||||
|
||||
});
|
@ -2,7 +2,7 @@
|
||||
@section('content')
|
||||
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) !!}
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-md-6 col-sm-12">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-fw {{$subTitleIcon}} fa-fw"></i> {{{$account->name}}}
|
||||
@ -27,24 +27,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-6 col-sm-12">
|
||||
<!-- time based navigation -->
|
||||
@include('partials.date_nav')
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-clock-o fa-fw"></i> View options for {{{$account->name}}}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
@if($range == 'all')
|
||||
<a href="{{route('accounts.show',$account->id)}}/session" class="btn btn-default">Stick to date-range</a>
|
||||
@else
|
||||
<a href="{{route('accounts.show',$account->id)}}/all" class="btn btn-default">Show all transactions</a>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -66,7 +48,6 @@
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var accountID = {{{$account->id}}};
|
||||
var view = '{{{$range}}}';
|
||||
var currencyCode = '{{Amount::getCurrencyCode()}}';
|
||||
</script>
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
|
@ -5,7 +5,7 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">Update (expected) income for {{Session::get('start', \Carbon\Carbon::now()->startOfMonth())->format('F Y')}}</h4>
|
||||
<h4 class="modal-title" id="myModalLabel">Update (expected) available amount for {{Session::get('start', \Carbon\Carbon::now()->startOfMonth())->format('F Y')}}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="input-group">
|
||||
|
@ -13,7 +13,7 @@
|
||||
<small>Budgeted: <span id="budgetedAmount" data-value="300">{{Amount::format(300)}}</span></small>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-4 col-sm-3" style="text-align:right;">
|
||||
<small>Income {{Session::get('start', \Carbon\Carbon::now()->startOfMonth())->format('F Y')}}:
|
||||
<small>Available in {{Session::get('start', \Carbon\Carbon::now()->startOfMonth())->format('F Y')}}:
|
||||
<a href="#" class="updateIncome"><span id="totalAmount" data-value="{{$amount}}">{!! Amount::format($amount) !!}</span></a></small>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -20,6 +20,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-5">
|
||||
@if(count($limits) == 1)
|
||||
<p class="small text-center"><a href="{{route('budgets.show',$budget->id)}}">Show everything</a></p>
|
||||
@endif
|
||||
|
||||
@foreach($limits as $limit)
|
||||
@foreach($limit->limitrepetitions as $rep)
|
||||
<div class="panel panel-default">
|
||||
@ -64,6 +68,9 @@
|
||||
@endforeach
|
||||
@endforeach
|
||||
|
||||
@if(count($limits) == 1)
|
||||
<p class="small text-center"><a href="{{route('budgets.show',$budget->id)}}">Show everything</a></p>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,7 +3,7 @@
|
||||
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName()) !!}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-sm-12 col-md-12">
|
||||
<div class="col-lg-12 col-sm-12 col-md-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Currencies
|
||||
@ -14,23 +14,34 @@
|
||||
</p>
|
||||
<ul>
|
||||
@if(count($currencies) > 0)
|
||||
<table class="table table-striped table-bordered">
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th colspan="2">Currency</th>
|
||||
</tr>
|
||||
@foreach($currencies as $currency)
|
||||
<li>
|
||||
<a href="{{route('currency.edit',$currency->id)}}"><i class="fa fa-fw fa-pencil"></i></a>
|
||||
<a href="{{route('currency.delete',$currency->id)}}"><i class="fa fa-fw fa-trash"></i></a>
|
||||
{{{$currency->name}}} ({{{$currency->code}}}) ({{{$currency->symbol}}})
|
||||
<tr>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a class="btn btn-default" href="{{route('currency.edit',$currency->id)}}"><i class="fa fa-fw fa-pencil"></i></a>
|
||||
<a class="btn btn-default" href="{{route('currency.delete',$currency->id)}}"><i class="fa fa-fw fa-trash"></i></a>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{{$currency->name}}} ({{{$currency->code}}}) ({{{$currency->symbol}}})</td>
|
||||
<td>
|
||||
@if($currency->id == $defaultCurrency->id)
|
||||
<span class="label label-success">default</span>
|
||||
@else
|
||||
<span class="label label-default"><a style="color:#fff" href="{{route('currency.default',$currency->id)}}">make default</a></span>
|
||||
|
||||
<a class="btn btn-info" href="{{route('currency.default',$currency->id)}}">make default</a>
|
||||
@endif
|
||||
</li>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@endforeach
|
||||
</table>
|
||||
@endif
|
||||
<li><a href="{{route('currency.create')}}"><i class="fa fa-fw fa-plus-circle"></i> Add another currency</a></li>
|
||||
</ul>
|
||||
<p><a class="btn btn-success" href="{{route('currency.create')}}"><i class="fa fa-fw fa-plus-circle"></i> Add another currency</a></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user