mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 08:35:00 +00:00
This commit is contained in:
@@ -58,7 +58,7 @@ class CreateController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||||
app('view')->share('title', (string)trans('firefly.accounts'));
|
app('view')->share('title', (string) trans('firefly.accounts'));
|
||||||
|
|
||||||
$this->repository = app(AccountRepositoryInterface::class);
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
$this->attachments = app(AttachmentHelperInterface::class);
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
@@ -77,7 +77,7 @@ class CreateController extends Controller
|
|||||||
{
|
{
|
||||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||||
$subTitle = (string)trans(sprintf('firefly.make_new_%s_account', $objectType));
|
$subTitle = (string) trans(sprintf('firefly.make_new_%s_account', $objectType));
|
||||||
$roles = $this->getRoles();
|
$roles = $this->getRoles();
|
||||||
$liabilityTypes = $this->getLiabilityTypes();
|
$liabilityTypes = $this->getLiabilityTypes();
|
||||||
$hasOldInput = null !== $request->old('_token');
|
$hasOldInput = null !== $request->old('_token');
|
||||||
@@ -95,10 +95,10 @@ class CreateController extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
// interest calculation periods:
|
// interest calculation periods:
|
||||||
$interestPeriods = [
|
$interestPeriods = [
|
||||||
'daily' => (string)trans('firefly.interest_calc_daily'),
|
'daily' => (string) trans('firefly.interest_calc_daily'),
|
||||||
'monthly' => (string)trans('firefly.interest_calc_monthly'),
|
'monthly' => (string) trans('firefly.interest_calc_monthly'),
|
||||||
'yearly' => (string)trans('firefly.interest_calc_yearly'),
|
'yearly' => (string) trans('firefly.interest_calc_yearly'),
|
||||||
];
|
];
|
||||||
|
|
||||||
// pre fill some data
|
// pre fill some data
|
||||||
@@ -106,9 +106,15 @@ class CreateController extends Controller
|
|||||||
'preFilled',
|
'preFilled',
|
||||||
[
|
[
|
||||||
'currency_id' => $defaultCurrency->id,
|
'currency_id' => $defaultCurrency->id,
|
||||||
'include_net_worth' => $hasOldInput ? (bool)$request->old('include_net_worth') : true,
|
'include_net_worth' => $hasOldInput ? (bool) $request->old('include_net_worth') : true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
// issue #8321
|
||||||
|
$showNetWorth = true;
|
||||||
|
if ('liabilities' !== $objectType && 'asset' !== $objectType) {
|
||||||
|
$showNetWorth = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// put previous url in session if not redirect from store (not "create another").
|
// put previous url in session if not redirect from store (not "create another").
|
||||||
if (true !== session('accounts.create.fromStore')) {
|
if (true !== session('accounts.create.fromStore')) {
|
||||||
@@ -119,7 +125,7 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
return view(
|
return view(
|
||||||
'accounts.create',
|
'accounts.create',
|
||||||
compact('subTitleIcon', 'liabilityDirections', 'locations', 'objectType', 'interestPeriods', 'subTitle', 'roles', 'liabilityTypes')
|
compact('subTitleIcon', 'liabilityDirections', 'showNetWorth', 'locations', 'objectType', 'interestPeriods', 'subTitle', 'roles', 'liabilityTypes')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,9 +138,9 @@ class CreateController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(AccountFormRequest $request)
|
public function store(AccountFormRequest $request)
|
||||||
{
|
{
|
||||||
$data = $request->getAccountData();
|
$data = $request->getAccountData();
|
||||||
$account = $this->repository->store($data);
|
$account = $this->repository->store($data);
|
||||||
$request->session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
|
$request->session()->flash('success', (string) trans('firefly.stored_new_account', ['name' => $account->name]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
Log::channel('audit')->info('Stored new account.', $data);
|
Log::channel('audit')->info('Stored new account.', $data);
|
||||||
@@ -151,13 +157,13 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
// store attachment(s):
|
// store attachment(s):
|
||||||
/** @var null|array $files */
|
/** @var null|array $files */
|
||||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||||
}
|
}
|
||||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||||
Log::channel('audit')->info(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
Log::channel('audit')->info(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
@@ -165,8 +171,8 @@ class CreateController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// redirect to previous URL.
|
// redirect to previous URL.
|
||||||
$redirect = redirect($this->getPreviousUrl('accounts.create.url'));
|
$redirect = redirect($this->getPreviousUrl('accounts.create.url'));
|
||||||
if (1 === (int)$request->get('create_another')) {
|
if (1 === (int) $request->get('create_another')) {
|
||||||
// set value so create routine will not overwrite URL:
|
// set value so create routine will not overwrite URL:
|
||||||
$request->session()->put('accounts.create.fromStore', true);
|
$request->session()->put('accounts.create.fromStore', true);
|
||||||
|
|
||||||
|
@@ -80,17 +80,17 @@ class EditController extends Controller
|
|||||||
return $this->redirectAccountToAccount($account);
|
return $this->redirectAccountToAccount($account);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objectType = config('firefly.shortNamesByFullName')[$account->accountType->type];
|
$objectType = config('firefly.shortNamesByFullName')[$account->accountType->type];
|
||||||
$subTitle = (string) trans(sprintf('firefly.edit_%s_account', $objectType), ['name' => $account->name]);
|
$subTitle = (string) trans(sprintf('firefly.edit_%s_account', $objectType), ['name' => $account->name]);
|
||||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||||
$roles = $this->getRoles();
|
$roles = $this->getRoles();
|
||||||
$liabilityTypes = $this->getLiabilityTypes();
|
$liabilityTypes = $this->getLiabilityTypes();
|
||||||
$location = $repository->getLocation($account);
|
$location = $repository->getLocation($account);
|
||||||
$latitude = null !== $location ? $location->latitude : config('firefly.default_location.latitude');
|
$latitude = null !== $location ? $location->latitude : config('firefly.default_location.latitude');
|
||||||
$longitude = null !== $location ? $location->longitude : config('firefly.default_location.longitude');
|
$longitude = null !== $location ? $location->longitude : config('firefly.default_location.longitude');
|
||||||
$zoomLevel = null !== $location ? $location->zoom_level : config('firefly.default_location.zoom_level');
|
$zoomLevel = null !== $location ? $location->zoom_level : config('firefly.default_location.zoom_level');
|
||||||
$hasLocation = null !== $location;
|
$hasLocation = null !== $location;
|
||||||
$locations = [
|
$locations = [
|
||||||
'location' => [
|
'location' => [
|
||||||
'latitude' => null !== old('location_latitude') ? old('location_latitude') : $latitude,
|
'latitude' => null !== old('location_latitude') ? old('location_latitude') : $latitude,
|
||||||
'longitude' => null !== old('location_longitude') ? old('location_longitude') : $longitude,
|
'longitude' => null !== old('location_longitude') ? old('location_longitude') : $longitude,
|
||||||
@@ -99,13 +99,13 @@ class EditController extends Controller
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$liabilityDirections = [
|
$liabilityDirections = [
|
||||||
'debit' => trans('firefly.liability_direction_debit'),
|
'debit' => trans('firefly.liability_direction_debit'),
|
||||||
'credit' => trans('firefly.liability_direction_credit'),
|
'credit' => trans('firefly.liability_direction_credit'),
|
||||||
];
|
];
|
||||||
|
|
||||||
// interest calculation periods:
|
// interest calculation periods:
|
||||||
$interestPeriods = [
|
$interestPeriods = [
|
||||||
'daily' => (string) trans('firefly.interest_calc_daily'),
|
'daily' => (string) trans('firefly.interest_calc_daily'),
|
||||||
'monthly' => (string) trans('firefly.interest_calc_monthly'),
|
'monthly' => (string) trans('firefly.interest_calc_monthly'),
|
||||||
'yearly' => (string) trans('firefly.interest_calc_yearly'),
|
'yearly' => (string) trans('firefly.interest_calc_yearly'),
|
||||||
@@ -121,17 +121,23 @@ class EditController extends Controller
|
|||||||
if ('0' === $openingBalanceAmount) {
|
if ('0' === $openingBalanceAmount) {
|
||||||
$openingBalanceAmount = '';
|
$openingBalanceAmount = '';
|
||||||
}
|
}
|
||||||
$openingBalanceDate = $repository->getOpeningBalanceDate($account);
|
$openingBalanceDate = $repository->getOpeningBalanceDate($account);
|
||||||
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
||||||
|
|
||||||
// include this account in net-worth charts?
|
// include this account in net-worth charts?
|
||||||
$includeNetWorth = $repository->getMetaValue($account, 'include_net_worth');
|
$includeNetWorth = $repository->getMetaValue($account, 'include_net_worth');
|
||||||
$includeNetWorth = null === $includeNetWorth ? true : '1' === $includeNetWorth;
|
$includeNetWorth = null === $includeNetWorth ? true : '1' === $includeNetWorth;
|
||||||
|
|
||||||
|
// issue #8321
|
||||||
|
$showNetWorth = true;
|
||||||
|
if ('liabilities' !== $objectType && 'asset' !== $objectType) {
|
||||||
|
$showNetWorth = false;
|
||||||
|
}
|
||||||
|
|
||||||
// code to handle active-checkboxes
|
// code to handle active-checkboxes
|
||||||
$hasOldInput = null !== $request->old('_token');
|
$hasOldInput = null !== $request->old('_token');
|
||||||
$virtualBalance = null === $account->virtual_balance ? '0' : $account->virtual_balance;
|
$virtualBalance = null === $account->virtual_balance ? '0' : $account->virtual_balance;
|
||||||
$preFilled = [
|
$preFilled = [
|
||||||
'account_number' => $repository->getMetaValue($account, 'account_number'),
|
'account_number' => $repository->getMetaValue($account, 'account_number'),
|
||||||
'account_role' => $repository->getMetaValue($account, 'account_role'),
|
'account_role' => $repository->getMetaValue($account, 'account_role'),
|
||||||
'cc_type' => $repository->getMetaValue($account, 'cc_type'),
|
'cc_type' => $repository->getMetaValue($account, 'cc_type'),
|
||||||
@@ -155,7 +161,7 @@ class EditController extends Controller
|
|||||||
|
|
||||||
$request->session()->flash('preFilled', $preFilled);
|
$request->session()->flash('preFilled', $preFilled);
|
||||||
|
|
||||||
return view('accounts.edit', compact('account', 'currency', 'subTitle', 'subTitleIcon', 'locations', 'liabilityDirections', 'objectType', 'roles', 'preFilled', 'liabilityTypes', 'interestPeriods'));
|
return view('accounts.edit', compact('account', 'currency', 'showNetWorth', 'subTitle', 'subTitleIcon', 'locations', 'liabilityDirections', 'objectType', 'roles', 'preFilled', 'liabilityTypes', 'interestPeriods'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,14 +175,14 @@ class EditController extends Controller
|
|||||||
return $this->redirectAccountToAccount($account);
|
return $this->redirectAccountToAccount($account);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $request->getAccountData();
|
$data = $request->getAccountData();
|
||||||
$this->repository->update($account, $data);
|
$this->repository->update($account, $data);
|
||||||
Log::channel('audit')->info(sprintf('Updated account #%d.', $account->id), $data);
|
Log::channel('audit')->info(sprintf('Updated account #%d.', $account->id), $data);
|
||||||
$request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
|
$request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
|
||||||
|
|
||||||
// store new attachment(s):
|
// store new attachment(s):
|
||||||
/** @var null|array $files */
|
/** @var null|array $files */
|
||||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,9 @@
|
|||||||
{{ ExpandedForm.amountNoCurrency('virtual_balance') }}
|
{{ ExpandedForm.amountNoCurrency('virtual_balance') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{# only correct way to do active checkbox #}
|
{# only correct way to do active checkbox #}
|
||||||
{{ ExpandedForm.checkbox('include_net_worth', 1) }}
|
{% if showNetWorth %}
|
||||||
|
{{ ExpandedForm.checkbox('include_net_worth', 1) }}
|
||||||
|
{% endif %}
|
||||||
{{ ExpandedForm.textarea('notes',null,{helpText: trans('firefly.field_supports_markdown')}) }}
|
{{ ExpandedForm.textarea('notes',null,{helpText: trans('firefly.field_supports_markdown')}) }}
|
||||||
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
|
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
|
||||||
</div>
|
</div>
|
||||||
|
@@ -67,7 +67,9 @@
|
|||||||
{{ ExpandedForm.amountNoCurrency('virtual_balance',null) }}
|
{{ ExpandedForm.amountNoCurrency('virtual_balance',null) }}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ ExpandedForm.checkbox('include_net_worth', 1) }}
|
{% if showNetWorth %}
|
||||||
|
{{ ExpandedForm.checkbox('include_net_worth', 1) }}
|
||||||
|
{% endif %}
|
||||||
{{ ExpandedForm.textarea('notes',preFilled.notes,{helpText: trans('firefly.field_supports_markdown')}) }}
|
{{ ExpandedForm.textarea('notes',preFilled.notes,{helpText: trans('firefly.field_supports_markdown')}) }}
|
||||||
{# only correct way to do active checkbox #}
|
{# only correct way to do active checkbox #}
|
||||||
{{ ExpandedForm.checkbox('active', 1) }}
|
{{ ExpandedForm.checkbox('active', 1) }}
|
||||||
|
Reference in New Issue
Block a user