mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Cleanup in preparation of an overhaul.
This commit is contained in:
parent
18f46676fd
commit
9eec6641dd
@ -140,8 +140,7 @@ class AccountController extends BaseController
|
|||||||
{
|
{
|
||||||
$subTitle = $this->_subTitlesByIdentifier[$what];
|
$subTitle = $this->_subTitlesByIdentifier[$what];
|
||||||
$subTitleIcon = $this->_subIconsByIdentifier[$what];
|
$subTitleIcon = $this->_subIconsByIdentifier[$what];
|
||||||
|
$accounts = $this->_repository->getAccountsByType($this->_accountTypesByIdentifier[$what]);
|
||||||
$accounts = $this->_repository->getAccountsByType($this->_accountTypesByIdentifier[$what]);
|
|
||||||
|
|
||||||
return View::make('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
|
return View::make('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
|
||||||
}
|
}
|
||||||
@ -169,21 +168,23 @@ class AccountController extends BaseController
|
|||||||
public function store()
|
public function store()
|
||||||
{
|
{
|
||||||
|
|
||||||
$data = Input::except('_token');
|
/*
|
||||||
|
* always validate using the account validator:
|
||||||
// always validate:
|
* TODO move to constructor.
|
||||||
$messages = $this->_repository->validate($data);
|
*/
|
||||||
|
/** @var \FireflyIII\Validation\Account $validator */
|
||||||
|
$validator = App::make('FireflyIII\Validation\Account');
|
||||||
|
$data = Input::except('_token', 'post_submit_action');
|
||||||
|
$errors = $validator->store($data);
|
||||||
|
|
||||||
// flash messages:
|
// flash messages:
|
||||||
Session::flash('warnings', $messages['warnings']);
|
Session::flash('errors', $errors);
|
||||||
Session::flash('successes', $messages['successes']);
|
if ($errors->count() > 0) {
|
||||||
Session::flash('errors', $messages['errors']);
|
Session::flash('error', 'Could not store account: ' . $errors->first());
|
||||||
if ($messages['errors']->count() > 0) {
|
|
||||||
Session::flash('error', 'Could not store account: ' . $messages['errors']->first());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return to create screen:
|
// return to create screen:
|
||||||
if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {
|
if ($data['post_submit_action'] == 'validate_only' || $errors->count() > 0) {
|
||||||
return Redirect::route('accounts.create', e($data['what']))->withInput();
|
return Redirect::route('accounts.create', e($data['what']))->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,23 +206,24 @@ class AccountController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function update(Account $account)
|
public function update(Account $account)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* always validate using the account validator:
|
||||||
|
* TODO move to constructor.
|
||||||
|
*/
|
||||||
|
/** @var \FireflyIII\Validation\Account $validator */
|
||||||
|
$validator = App::make('FireflyIII\Validation\Account');
|
||||||
$data = Input::except('_token');
|
$data = Input::except('_token');
|
||||||
$data['what'] = $this->_shortNamesByFullName[$account->accountType->type];
|
$data['what'] = $this->_shortNamesByFullName[$account->accountType->type];
|
||||||
|
$errors = $validator->update($data, $account);
|
||||||
|
|
||||||
// always validate:
|
|
||||||
$messages = $this->_repository->validate($data);
|
|
||||||
|
|
||||||
// flash messages:
|
// flash messages:
|
||||||
Session::flash('warnings', $messages['warnings']);
|
Session::flash('errors', $errors);
|
||||||
Session::flash('successes', $messages['successes']);
|
if ($errors->count() > 0) {
|
||||||
Session::flash('errors', $messages['errors']);
|
Session::flash('error', 'Could not update account: ' . $errors->first());
|
||||||
if ($messages['errors']->count() > 0) {
|
|
||||||
Session::flash('error', 'Could not update account: ' . $messages['errors']->first());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return to update screen:
|
// return to update screen:
|
||||||
if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {
|
if ($data['post_submit_action'] == 'validate_only' || $errors->count() > 0) {
|
||||||
return Redirect::route('accounts.edit', $account->id)->withInput();
|
return Redirect::route('accounts.edit', $account->id)->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class GoogleChartController extends BaseController
|
|||||||
|
|
||||||
/** @var \FireflyIII\Database\Account\Account $acct */
|
/** @var \FireflyIII\Database\Account\Account $acct */
|
||||||
$acct = App::make('FireflyIII\Database\Account\Account');
|
$acct = App::make('FireflyIII\Database\Account\Account');
|
||||||
$accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAssetAccounts();
|
$accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAccountsByType(['Default account', 'Asset account']);
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
|
@ -33,7 +33,7 @@ class HomeController extends BaseController
|
|||||||
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
|
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
|
||||||
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
|
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
|
||||||
|
|
||||||
$count = $acct->countAssetAccounts();
|
$count = $acct->countAccountsByType(['Default account', 'Asset account']);
|
||||||
|
|
||||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||||
@ -42,7 +42,7 @@ class HomeController extends BaseController
|
|||||||
// get the preference for the home accounts to show:
|
// get the preference for the home accounts to show:
|
||||||
$frontPage = $preferences->get('frontPageAccounts', []);
|
$frontPage = $preferences->get('frontPageAccounts', []);
|
||||||
if ($frontPage->data == []) {
|
if ($frontPage->data == []) {
|
||||||
$accounts = $acct->getAssetAccounts();
|
$accounts = $acct->getAccountsByType(['Default account', 'Asset account']);
|
||||||
} else {
|
} else {
|
||||||
$accounts = $acct->getByIds($frontPage->data);
|
$accounts = $acct->getByIds($frontPage->data);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class JsonController extends BaseController
|
|||||||
{
|
{
|
||||||
/** @var \FireflyIII\Database\Account\Account $accounts */
|
/** @var \FireflyIII\Database\Account\Account $accounts */
|
||||||
$accounts = App::make('FireflyIII\Database\Account\Account');
|
$accounts = App::make('FireflyIII\Database\Account\Account');
|
||||||
$list = $accounts->getExpenseAccounts();
|
$list = $accounts->getAccountsByType(['Expense account', 'Beneficiary account']);
|
||||||
$return = [];
|
$return = [];
|
||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
$return[] = $entry->name;
|
$return[] = $entry->name;
|
||||||
@ -53,7 +53,7 @@ class JsonController extends BaseController
|
|||||||
{
|
{
|
||||||
/** @var \FireflyIII\Database\Account\Account $accounts */
|
/** @var \FireflyIII\Database\Account\Account $accounts */
|
||||||
$accounts = App::make('FireflyIII\Database\Account\Account');
|
$accounts = App::make('FireflyIII\Database\Account\Account');
|
||||||
$list = $accounts->getRevenueAccounts();
|
$list = $accounts->getAccountsByType(['Revenue account']);
|
||||||
$return = [];
|
$return = [];
|
||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
$return[] = $entry->name;
|
$return[] = $entry->name;
|
||||||
|
@ -62,7 +62,7 @@ class PiggyBankController extends BaseController
|
|||||||
$acct = App::make('FireflyIII\Database\Account\Account');
|
$acct = App::make('FireflyIII\Database\Account\Account');
|
||||||
|
|
||||||
$periods = Config::get('firefly.piggy_bank_periods');
|
$periods = Config::get('firefly.piggy_bank_periods');
|
||||||
$accounts = FFForm::makeSelectList($acct->getAssetAccounts());
|
$accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
|
||||||
$subTitle = 'Create new piggy bank';
|
$subTitle = 'Create new piggy bank';
|
||||||
$subTitleIcon = 'fa-plus';
|
$subTitleIcon = 'fa-plus';
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ class PiggyBankController extends BaseController
|
|||||||
$acct = App::make('FireflyIII\Database\Account\Account');
|
$acct = App::make('FireflyIII\Database\Account\Account');
|
||||||
|
|
||||||
$periods = Config::get('firefly.piggy_bank_periods');
|
$periods = Config::get('firefly.piggy_bank_periods');
|
||||||
$accounts = FFForm::makeSelectList($acct->getAssetAccounts());
|
$accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
|
||||||
$subTitle = 'Edit piggy bank "' . e($piggyBank->name) . '"';
|
$subTitle = 'Edit piggy bank "' . e($piggyBank->name) . '"';
|
||||||
$subTitleIcon = 'fa-pencil';
|
$subTitleIcon = 'fa-pencil';
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class PreferencesController extends BaseController
|
|||||||
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
|
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
|
||||||
$preferences = App::make('FireflyIII\Shared\Preferences\Preferences');
|
$preferences = App::make('FireflyIII\Shared\Preferences\Preferences');
|
||||||
|
|
||||||
$accounts = $acct->getAssetAccounts();
|
$accounts = $acct->getAccountsByType(['Default account', 'Asset account']);
|
||||||
$viewRange = $preferences->get('viewRange', '1M');
|
$viewRange = $preferences->get('viewRange', '1M');
|
||||||
$viewRangeValue = $viewRange->data;
|
$viewRangeValue = $viewRange->data;
|
||||||
$frontPage = $preferences->get('frontPageAccounts', []);
|
$frontPage = $preferences->get('frontPageAccounts', []);
|
||||||
|
@ -34,7 +34,7 @@ class RepeatedExpenseController extends BaseController
|
|||||||
/** @var \FireflyIII\Database\Account\Account $acct */
|
/** @var \FireflyIII\Database\Account\Account $acct */
|
||||||
$acct = App::make('FireflyIII\Database\Account\Account');
|
$acct = App::make('FireflyIII\Database\Account\Account');
|
||||||
$periods = Config::get('firefly.piggy_bank_periods');
|
$periods = Config::get('firefly.piggy_bank_periods');
|
||||||
$accounts = FFForm::makeSelectList($acct->getAssetAccounts());
|
$accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
|
||||||
|
|
||||||
return View::make('repeatedExpense.create', compact('accounts', 'periods'))->with('subTitle', 'Create new repeated expense')->with(
|
return View::make('repeatedExpense.create', compact('accounts', 'periods'))->with('subTitle', 'Create new repeated expense')->with(
|
||||||
'subTitleIcon', 'fa-plus'
|
'subTitleIcon', 'fa-plus'
|
||||||
@ -79,7 +79,7 @@ class RepeatedExpenseController extends BaseController
|
|||||||
$acct = App::make('FireflyIII\Database\Account\Account');
|
$acct = App::make('FireflyIII\Database\Account\Account');
|
||||||
|
|
||||||
$periods = Config::get('firefly.piggy_bank_periods');
|
$periods = Config::get('firefly.piggy_bank_periods');
|
||||||
$accounts = FFForm::makeSelectList($acct->getAssetAccounts());
|
$accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
|
||||||
$subTitle = 'Edit repeated expense "' . e($repeatedExpense->name) . '"';
|
$subTitle = 'Edit repeated expense "' . e($repeatedExpense->name) . '"';
|
||||||
$subTitleIcon = 'fa-pencil';
|
$subTitleIcon = 'fa-pencil';
|
||||||
|
|
||||||
|
@ -6,12 +6,11 @@ use Carbon\Carbon;
|
|||||||
use FireflyIII\Database\CommonDatabaseCallsInterface;
|
use FireflyIII\Database\CommonDatabaseCallsInterface;
|
||||||
use FireflyIII\Database\CUDInterface;
|
use FireflyIII\Database\CUDInterface;
|
||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\DeprecatedException;
|
||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Database\Query\Builder as QueryBuilder;
|
use Illuminate\Database\Query\Builder as QueryBuilder;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Account
|
* Class Account
|
||||||
@ -41,47 +40,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
return $this->getUser()->accounts()->accountTypeIn($types)->count();
|
return $this->getUser()->accounts()->accountTypeIn($types)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function countAssetAccounts()
|
|
||||||
{
|
|
||||||
return $this->countAccountsByType(['Default account', 'Asset account']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function countExpenseAccounts()
|
|
||||||
{
|
|
||||||
return $this->countAccountsByType(['Expense account', 'Beneficiary account']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Counts the number of total revenue accounts. Useful for DataTables.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function countRevenueAccounts()
|
|
||||||
{
|
|
||||||
return $this->countAccountsByType(['Revenue account']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Account $account
|
|
||||||
*
|
|
||||||
* @return \Account|null
|
|
||||||
*/
|
|
||||||
public function findInitialBalanceAccount(\Account $account)
|
|
||||||
{
|
|
||||||
/** @var \FireflyIII\Database\AccountType\AccountType $acctType */
|
|
||||||
$acctType = \App::make('FireflyIII\Database\AccountType\AccountType');
|
|
||||||
|
|
||||||
$accountType = $acctType->findByWhat('initial');
|
|
||||||
|
|
||||||
return $this->getUser()->accounts()->where('account_type_id', $accountType->id)->where('name', 'LIKE', $account->name . '%')->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*
|
*
|
||||||
@ -92,14 +50,11 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
/*
|
/*
|
||||||
* Basic query:
|
* Basic query:
|
||||||
*/
|
*/
|
||||||
$query = $this->getUser()->accounts()->accountTypeIn($types)->withMeta()->orderBy('name', 'ASC');;
|
$query = $this->getUser()->accounts()->accountTypeIn($types)->orderBy('name', 'ASC');;
|
||||||
$set = $query->get(['accounts.*']);
|
$set = $query->get(['accounts.*','account_role.data as account_role']);
|
||||||
|
|
||||||
$set->each(
|
$set->each(
|
||||||
function (\Account $account) {
|
function (\Account $account) {
|
||||||
/*
|
|
||||||
* Get last activity date.
|
|
||||||
*/
|
|
||||||
$account->lastActivityDate = $this->getLastActivity($account);
|
$account->lastActivityDate = $this->getLastActivity($account);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -107,57 +62,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all asset accounts. Optional JSON based parameters.
|
|
||||||
*
|
|
||||||
* @param array $metaFilter
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getAssetAccounts($metaFilter = [])
|
|
||||||
{
|
|
||||||
$list = $this->getAccountsByType(['Default account', 'Asset account']);
|
|
||||||
$list->each(
|
|
||||||
function (\Account $account) {
|
|
||||||
|
|
||||||
// get accountRole:
|
|
||||||
|
|
||||||
/** @var \AccountMeta $entry */
|
|
||||||
$accountRole = $account->accountmeta()->whereName('accountRole')->first();
|
|
||||||
if (!$accountRole) {
|
|
||||||
$accountRole = new \AccountMeta;
|
|
||||||
$accountRole->account_id = $account->id;
|
|
||||||
$accountRole->name = 'accountRole';
|
|
||||||
$accountRole->data = 'defaultExpense';
|
|
||||||
$accountRole->save();
|
|
||||||
|
|
||||||
}
|
|
||||||
$account->accountRole = $accountRole->data;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return $list;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getExpenseAccounts()
|
|
||||||
{
|
|
||||||
return $this->getAccountsByType(['Expense account', 'Beneficiary account']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all revenue accounts.
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getRevenueAccounts()
|
|
||||||
{
|
|
||||||
return $this->getAccountsByType(['Revenue account']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Account $account
|
* @param \Account $account
|
||||||
*
|
*
|
||||||
@ -184,8 +88,8 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
/*
|
/*
|
||||||
* Create a journal from opposing to account or vice versa.
|
* Create a journal from opposing to account or vice versa.
|
||||||
*/
|
*/
|
||||||
$balance = floatval($data['openingbalance']);
|
$balance = floatval($data['openingBalance']);
|
||||||
$date = new Carbon($data['openingbalancedate']);
|
$date = new Carbon($data['openingBalanceDate']);
|
||||||
/** @var \FireflyIII\Database\TransactionJournal\TransactionJournal $tj */
|
/** @var \FireflyIII\Database\TransactionJournal\TransactionJournal $tj */
|
||||||
$tj = \App::make('FireflyIII\Database\TransactionJournal\TransactionJournal');
|
$tj = \App::make('FireflyIII\Database\TransactionJournal\TransactionJournal');
|
||||||
if ($balance < 0) {
|
if ($balance < 0) {
|
||||||
@ -339,7 +243,7 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
\App::abort(500);
|
\App::abort(500);
|
||||||
}
|
}
|
||||||
$account->save();
|
$account->save();
|
||||||
if (isset($data['openingbalance']) && floatval($data['openingbalance']) != 0) {
|
if (isset($data['openingBalance']) && floatval($data['openingBalance']) != 0) {
|
||||||
$this->storeInitialBalance($account, $data);
|
$this->storeInitialBalance($account, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,78 +309,18 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates a model. Returns an array containing MessageBags
|
* Validates an array. Returns an array containing MessageBags
|
||||||
* errors/warnings/successes.
|
* errors/warnings/successes.
|
||||||
*
|
*
|
||||||
* @param array $model
|
* @param array $model
|
||||||
*
|
*
|
||||||
|
* @throws DeprecatedException
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function validate(array $model)
|
public function validate(array $model)
|
||||||
{
|
{
|
||||||
$warnings = new MessageBag;
|
throw new DeprecatedException;
|
||||||
$successes = new MessageBag;
|
|
||||||
$errors = new MessageBag;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Name validation:
|
|
||||||
*/
|
|
||||||
if (!isset($model['name'])) {
|
|
||||||
$errors->add('name', 'Name is mandatory');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($model['name']) && strlen($model['name']) == 0) {
|
|
||||||
$errors->add('name', 'Name is too short');
|
|
||||||
}
|
|
||||||
if (isset($model['name']) && strlen($model['name']) > 100) {
|
|
||||||
$errors->add('name', 'Name is too long');
|
|
||||||
}
|
|
||||||
$validator = \Validator::make([$model], \Account::$rules);
|
|
||||||
if ($validator->invalid()) {
|
|
||||||
$errors->merge($errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($model['account_role']) && !in_array($model['account_role'], array_keys(\Config::get('firefly.accountRoles')))) {
|
|
||||||
$errors->add('account_role', 'Invalid account role');
|
|
||||||
} else {
|
|
||||||
$successes->add('account_role', 'OK');
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* type validation.
|
|
||||||
*/
|
|
||||||
if (!isset($model['what'])) {
|
|
||||||
$errors->add('name', 'Internal error: need to know type of account!');
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Opening balance and opening balance date.
|
|
||||||
*/
|
|
||||||
if (isset($model['what']) && $model['what'] == 'asset') {
|
|
||||||
if (isset($model['openingbalance']) && strlen($model['openingbalance']) > 0 && !is_numeric($model['openingbalance'])) {
|
|
||||||
$errors->add('openingbalance', 'This is not a number.');
|
|
||||||
}
|
|
||||||
if (isset($model['openingbalancedate']) && strlen($model['openingbalancedate']) > 0) {
|
|
||||||
try {
|
|
||||||
new Carbon($model['openingbalancedate']);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$errors->add('openingbalancedate', 'This date is invalid.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!$errors->has('name')) {
|
|
||||||
$successes->add('name', 'OK');
|
|
||||||
}
|
|
||||||
if (!$errors->has('openingbalance')) {
|
|
||||||
$successes->add('openingbalance', 'OK');
|
|
||||||
}
|
|
||||||
if (!$errors->has('openingbalancedate')) {
|
|
||||||
$successes->add('openingbalancedate', 'OK');
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -492,25 +336,30 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
|
||||||
|
*
|
||||||
* @param $what
|
* @param $what
|
||||||
*
|
*
|
||||||
* @throws NotImplementedException
|
* @throws DeprecatedException
|
||||||
|
*
|
||||||
* @return \AccountType|null
|
* @return \AccountType|null
|
||||||
*/
|
*/
|
||||||
public function findByWhat($what)
|
public function findByWhat($what)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
throw new DeprecatedException;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all objects.
|
* Returns all objects.
|
||||||
*
|
*
|
||||||
|
* @throws DeprecatedException
|
||||||
|
*
|
||||||
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
* @throws NotImplementedException
|
|
||||||
*/
|
*/
|
||||||
public function get()
|
public function get()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
throw new DeprecatedException;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -571,32 +420,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Account $account
|
|
||||||
* @param int $limit
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Pagination\Paginator
|
|
||||||
*/
|
|
||||||
public function getAllTransactionJournals(\Account $account, $limit = 50)
|
|
||||||
{
|
|
||||||
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
|
|
||||||
$set = $this->getUser()->transactionJournals()->withRelevantData()->leftJoin(
|
|
||||||
'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
|
|
||||||
)->where('transactions.account_id', $account->id)->take($limit)->offset($offset)->orderBy('date', 'DESC')->get(
|
|
||||||
['transaction_journals.*']
|
|
||||||
);
|
|
||||||
$count = $this->getUser()->transactionJournals()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
|
||||||
->orderBy('date', 'DESC')->where('transactions.account_id', $account->id)->count();
|
|
||||||
$items = [];
|
|
||||||
foreach ($set as $entry) {
|
|
||||||
$items[] = $entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
return \Paginator::make($items, $count, $limit);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Account $account
|
* @param \Account $account
|
||||||
*
|
*
|
||||||
@ -655,25 +478,4 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Account $account
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Pagination\Paginator
|
|
||||||
*/
|
|
||||||
public function getTransactionJournalsInRange(\Account $account, Carbon $start, Carbon $end)
|
|
||||||
{
|
|
||||||
$set = $this->getUser()->transactionJournals()->transactionTypes(['Withdrawal'])->withRelevantData()->leftJoin(
|
|
||||||
'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
|
|
||||||
)->where('transactions.account_id', $account->id)->before($end)->after($start)->orderBy('date', 'DESC')->get(
|
|
||||||
['transaction_journals.*']
|
|
||||||
);
|
|
||||||
|
|
||||||
return $set;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,34 +21,6 @@ interface AccountInterface
|
|||||||
*/
|
*/
|
||||||
public function countAccountsByType(array $types);
|
public function countAccountsByType(array $types);
|
||||||
|
|
||||||
/**
|
|
||||||
* Counts the number of total asset accounts. Useful for DataTables.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function countAssetAccounts();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Counts the number of total expense accounts. Useful for DataTables.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function countExpenseAccounts();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Counts the number of total revenue accounts. Useful for DataTables.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function countRevenueAccounts();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Account $account
|
|
||||||
*
|
|
||||||
* @return \Account|null
|
|
||||||
*/
|
|
||||||
public function findInitialBalanceAccount(\Account $account);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all accounts of the selected types. Is also capable of handling DataTables' parameters.
|
* Get all accounts of the selected types. Is also capable of handling DataTables' parameters.
|
||||||
*
|
*
|
||||||
@ -58,24 +30,6 @@ interface AccountInterface
|
|||||||
*/
|
*/
|
||||||
public function getAccountsByType(array $types);
|
public function getAccountsByType(array $types);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all asset accounts. The parameters are optional and are provided by the DataTables plugin.
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getAssetAccounts();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getExpenseAccounts();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all revenue accounts.
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getRevenueAccounts();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Account $account
|
* @param \Account $account
|
||||||
|
66
app/lib/FireflyIII/Database/AccountMeta/AccountMeta.php
Normal file
66
app/lib/FireflyIII/Database/AccountMeta/AccountMeta.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Database\AccountMeta;
|
||||||
|
|
||||||
|
use FireflyIII\Database\CUDInterface;
|
||||||
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AccountMeta
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Database\AccountMeta
|
||||||
|
*/
|
||||||
|
class AccountMeta implements CUDInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Eloquent $model
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function destroy(Eloquent $model)
|
||||||
|
{
|
||||||
|
// TODO: Implement destroy() method.
|
||||||
|
throw new NotImplementedException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Eloquent
|
||||||
|
*/
|
||||||
|
public function store(array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement store() method.
|
||||||
|
throw new NotImplementedException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Eloquent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Eloquent $model, array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
throw new NotImplementedException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates an array. Returns an array containing MessageBags
|
||||||
|
* errors/warnings/successes.
|
||||||
|
*
|
||||||
|
* @param array $model
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function validate(array $model)
|
||||||
|
{
|
||||||
|
$model = new \AccountMeta($model);
|
||||||
|
$model->isValid();
|
||||||
|
|
||||||
|
return ['errors' => $model->getErrors()];
|
||||||
|
}
|
||||||
|
}
|
52
app/lib/FireflyIII/Database/Scope/AccountScope.php
Normal file
52
app/lib/FireflyIII/Database/Scope/AccountScope.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Database\Scope;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\ScopeInterface;
|
||||||
|
use Illuminate\Database\Query\JoinClause;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AccountScope
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Database\Scope
|
||||||
|
*/
|
||||||
|
class AccountScope implements ScopeInterface
|
||||||
|
{
|
||||||
|
static public $fields = ['accountRole' => 'account_role'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply the scope to a given Eloquent query builder.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $builder
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function apply(Builder $builder)
|
||||||
|
{
|
||||||
|
foreach (self::$fields as $name => $field) {
|
||||||
|
$builder->leftJoin(
|
||||||
|
'account_meta AS ' . $field, function (JoinClause $join) use ($field, $name) {
|
||||||
|
$join->on($field . '.account_id', '=', 'accounts.id')->where($field . '.name', '=', $name);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//$builder->whereNull($model->getQualifiedDeletedAtColumn());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the scope from the given Eloquent query builder.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $builder
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function remove(Builder $builder)
|
||||||
|
{
|
||||||
|
foreach ($builder->joins as $join) {
|
||||||
|
var_dump($join);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
app/lib/FireflyIII/Database/Scope/AccountScopeTrait.php
Normal file
22
app/lib/FireflyIII/Database/Scope/AccountScopeTrait.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Database\Scope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AccountScopeTrait
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Database\Scope
|
||||||
|
*/
|
||||||
|
trait AccountScopeTrait
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Boot the soft deleting trait for a model.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function bootAccountScopeTrait()
|
||||||
|
{
|
||||||
|
static::addGlobalScope(new AccountScope);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
13
app/lib/FireflyIII/Exception/DeprecatedException.php
Normal file
13
app/lib/FireflyIII/Exception/DeprecatedException.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace FireflyIII\Exception;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DeprecatedException
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Exception
|
||||||
|
*/
|
||||||
|
class DeprecatedException extends \Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -49,7 +49,7 @@ class Helper implements HelperInterface
|
|||||||
/** @var \FireflyIII\Database\Account\Account $accountRepository */
|
/** @var \FireflyIII\Database\Account\Account $accountRepository */
|
||||||
$accountRepository = \App::make('FireflyIII\Database\Account\Account');
|
$accountRepository = \App::make('FireflyIII\Database\Account\Account');
|
||||||
|
|
||||||
return $accountRepository->getAssetAccounts();
|
return $accountRepository->getAccountsByType(['Default account', 'Asset account']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -387,7 +387,7 @@ class Report implements ReportInterface
|
|||||||
$sharedAccounts[] = $account->id;
|
$sharedAccounts[] = $account->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$accounts = $this->_accounts->getAssetAccounts()->filter(
|
$accounts = $this->_accounts->getAccountsByType(['Default account', 'Asset account'])->filter(
|
||||||
function (\Account $account) use ($sharedAccounts) {
|
function (\Account $account) use ($sharedAccounts) {
|
||||||
if (!in_array($account->id, $sharedAccounts)) {
|
if (!in_array($account->id, $sharedAccounts)) {
|
||||||
return $account;
|
return $account;
|
||||||
|
62
app/lib/FireflyIII/Validation/Account.php
Normal file
62
app/lib/FireflyIII/Validation/Account.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Validation;
|
||||||
|
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Account
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Validation
|
||||||
|
*/
|
||||||
|
class Account implements Validation
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Every time a new [object or set of objects] is created through
|
||||||
|
* the Firefly III website, the data submitted will be validated using
|
||||||
|
* this method. This method does not check for valid models but rather if the information
|
||||||
|
* in the array can be used to create the [object or set of objects] that the user wants to.
|
||||||
|
*
|
||||||
|
* For example, to create a new asset account with an opening balance, the user does not have to
|
||||||
|
* submit an account_type or transaction_type because we know what to do.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return MessageBag
|
||||||
|
*/
|
||||||
|
public function store(array $data = [])
|
||||||
|
{
|
||||||
|
$meta = join(',', array_keys(\Config::get('firefly.accountRoles')));
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
'what' => 'required|in:asset,expense,revenue',
|
||||||
|
'name' => 'required|between:1,100',
|
||||||
|
'openingBalance' => 'numeric',
|
||||||
|
'openingBalanceDate' => 'date',
|
||||||
|
'active' => 'required|boolean',
|
||||||
|
'account_role' => 'in:' . $meta,
|
||||||
|
];
|
||||||
|
$validator = \Validator::make($data, $rules);
|
||||||
|
$validator->valid();
|
||||||
|
|
||||||
|
return $validator->messages();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Every time an [object or set of objects] is updated this method will validate the new
|
||||||
|
* values in the context of the existing object (or set of objects). Since most forms
|
||||||
|
* only have one [object] to validate and at least always one main [object] to validate
|
||||||
|
* this method will accept an array of data to validate and an optional model to validate
|
||||||
|
* against.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param \Eloquent $model
|
||||||
|
*
|
||||||
|
* @return MessageBag
|
||||||
|
*/
|
||||||
|
public function update(array $data = [], \Eloquent $model = null)
|
||||||
|
{
|
||||||
|
// this method simply returns the validation done by "store":
|
||||||
|
return $this->store($data);
|
||||||
|
}
|
||||||
|
}
|
44
app/lib/FireflyIII/Validation/Validation.php
Normal file
44
app/lib/FireflyIII/Validation/Validation.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Validation;
|
||||||
|
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface Validation
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Validation
|
||||||
|
*/
|
||||||
|
interface Validation
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Every time a new [object or set of objects] is created through
|
||||||
|
* the Firefly III website, the data submitted will be validated using
|
||||||
|
* this method. This method does not check for valid models but rather if the information
|
||||||
|
* in the array can be used to create the [object or set of objects] that the user wants to.
|
||||||
|
*
|
||||||
|
* For example, to create a new asset account with an opening balance, the user does not have to
|
||||||
|
* submit an account_type or transaction_type because we know what to do.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return MessageBag
|
||||||
|
*/
|
||||||
|
public function store(array $data = []);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Every time an [object or set of objects] is updated this method will validate the new
|
||||||
|
* values in the context of the existing object (or set of objects). Since most forms
|
||||||
|
* only have one [object] to validate and at least always one main [object] to validate
|
||||||
|
* this method will accept an array of data to validate and an optional model to validate
|
||||||
|
* against.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param \Eloquent $model
|
||||||
|
*
|
||||||
|
* @return MessageBag
|
||||||
|
*/
|
||||||
|
public function update(array $data = [], Model $model = null);
|
||||||
|
|
||||||
|
}
|
@ -1,23 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use FireflyIII\Database\Scope\AccountScopeTrait;
|
||||||
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
|
||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Account
|
* Class Account
|
||||||
*/
|
*/
|
||||||
class Account extends Eloquent
|
class Account extends Eloquent
|
||||||
{
|
{
|
||||||
use SoftDeletingTrait, ValidatingTrait;
|
use SoftDeletingTrait, ValidatingTrait, AccountScopeTrait;
|
||||||
|
protected $dates = ['deleted_at', 'created_at', 'updated_at'];
|
||||||
|
protected $fillable = ['name', 'user_id', 'account_type_id', 'active'];
|
||||||
/**
|
/**
|
||||||
* Validation rules.
|
* Validation rules.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $rules
|
protected $rules
|
||||||
= [
|
= [
|
||||||
'name' => ['required', 'between:1,100'],
|
'name' => ['required', 'between:1,100'],
|
||||||
'user_id' => 'required|exists:users,id',
|
'user_id' => 'required|exists:users,id',
|
||||||
@ -25,8 +27,6 @@ class Account extends Eloquent
|
|||||||
'active' => 'required|boolean'
|
'active' => 'required|boolean'
|
||||||
|
|
||||||
];
|
];
|
||||||
protected $dates = ['deleted_at', 'created_at', 'updated_at'];
|
|
||||||
protected $fillable = ['name', 'user_id', 'account_type_id', 'active'];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account type.
|
* Account type.
|
||||||
@ -67,7 +67,7 @@ class Account extends Eloquent
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param EloquentBuilder $query
|
* @param EloquentBuilder $query
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*/
|
*/
|
||||||
public function scopeAccountTypeIn(EloquentBuilder $query, array $types)
|
public function scopeAccountTypeIn(EloquentBuilder $query, array $types)
|
||||||
{
|
{
|
||||||
@ -97,6 +97,16 @@ class Account extends Eloquent
|
|||||||
return $this->hasMany('Transaction');
|
return $this->hasMany('Transaction');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $value
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getAccountRoleAttribute($value)
|
||||||
|
{
|
||||||
|
return json_decode($value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $fieldName
|
* @param $fieldName
|
||||||
* @param $fieldValue
|
* @param $fieldValue
|
||||||
|
@ -10,16 +10,16 @@ class AccountMeta extends Eloquent
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $rules
|
protected $rules
|
||||||
= [
|
= [
|
||||||
'account_id' => 'numeric|required|exists:accounts,id',
|
'account_id' => 'numeric|exists:accounts,id',
|
||||||
'name' => 'required|between:1,250',
|
'name' => 'required|between:1,250',
|
||||||
'data' => 'required'
|
'data' => 'required'
|
||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $fillable = ['account_id', 'name', 'date'];
|
protected $fillable = ['account_id', 'name', 'data'];
|
||||||
protected $table = 'account_meta';
|
protected $table = 'account_meta';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@if($what == 'asset')
|
@if($what == 'asset')
|
||||||
{{Form::ffBalance('openingbalance')}}
|
{{Form::ffBalance('openingBalance')}}
|
||||||
{{Form::ffDate('openingbalancedate', date('Y-m-d'))}}
|
{{Form::ffDate('openingBalanceDate', date('Y-m-d'))}}
|
||||||
@endif
|
@endif
|
||||||
{{Form::ffCheckbox('active','1',true)}}
|
{{Form::ffCheckbox('active','1',true)}}
|
||||||
{{Form::ffSelect('account_role',Config::get('firefly.accountRoles'))}}
|
{{Form::ffSelect('account_role',Config::get('firefly.accountRoles'))}}
|
||||||
|
Loading…
Reference in New Issue
Block a user