mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Can edit and set location for accounts.
This commit is contained in:
@@ -79,6 +79,15 @@ class CreateController extends Controller
|
||||
$subTitle = (string)trans(sprintf('firefly.make_new_%s_account', $objectType));
|
||||
$roles = $this->getRoles();
|
||||
$liabilityTypes = $this->getLiabilityTypes();
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$locations = [
|
||||
'location' => [
|
||||
'latitude' => $hasOldInput ? old('location_latitude') : config('firefly.default_location.latitude'),
|
||||
'longitude' => $hasOldInput ? old('location_longitude') : config('firefly.default_location.longitude'),
|
||||
'zoom_level' => $hasOldInput ? old('location_zoom_level') : config('firefly.default_location.zoom_level'),
|
||||
'has_location' => $hasOldInput ? 'true' === old('location_has_location') : false,
|
||||
],
|
||||
];
|
||||
|
||||
// interest calculation periods:
|
||||
$interestPeriods = [
|
||||
@@ -88,7 +97,6 @@ class CreateController extends Controller
|
||||
];
|
||||
|
||||
// pre fill some data
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$request->session()->flash(
|
||||
'preFilled', [
|
||||
'currency_id' => $defaultCurrency->id,
|
||||
@@ -103,7 +111,7 @@ class CreateController extends Controller
|
||||
$request->session()->forget('accounts.create.fromStore');
|
||||
Log::channel('audit')->info('Creating new account.');
|
||||
|
||||
return view('accounts.create', compact('subTitleIcon', 'objectType', 'interestPeriods', 'subTitle', 'roles', 'liabilityTypes'));
|
||||
return view('accounts.create', compact('subTitleIcon', 'locations', 'objectType', 'interestPeriods', 'subTitle', 'roles', 'liabilityTypes'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +123,6 @@ class CreateController extends Controller
|
||||
*/
|
||||
public function store(AccountFormRequest $request)
|
||||
{
|
||||
|
||||
$data = $request->getAccountData();
|
||||
$account = $this->repository->store($data);
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
|
||||
|
@@ -87,6 +87,19 @@ class EditController extends Controller
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||
$roles = $this->getRoles();
|
||||
$liabilityTypes = $this->getLiabilityTypes();
|
||||
$location = $repository->getLocation($account);
|
||||
$latitude = $location ? $location->latitude : config('firefly.default_location.latitude');
|
||||
$longitude = $location ? $location->longitude : config('firefly.default_location.longitude');
|
||||
$zoomLevel = $location ? $location->zoom_level : config('firefly.default_location.zoom_level');
|
||||
$hasLocation = null !== $location;
|
||||
$locations = [
|
||||
'location' => [
|
||||
'latitude' => old('location_latitude') ?? $latitude,
|
||||
'longitude' => old('location_longitude') ?? $longitude,
|
||||
'zoom_level' => old('location_zoom_level') ?? $zoomLevel,
|
||||
'has_location' => $hasLocation || 'true' === old('location_has_location'),
|
||||
],
|
||||
];
|
||||
|
||||
// interest calculation periods:
|
||||
$interestPeriods = [
|
||||
@@ -132,7 +145,9 @@ class EditController extends Controller
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
||||
return view(
|
||||
'accounts.edit', compact('account', 'currency', 'subTitle', 'subTitleIcon', 'objectType', 'roles', 'preFilled', 'liabilityTypes', 'interestPeriods')
|
||||
'accounts.edit', compact(
|
||||
'account', 'currency', 'subTitle', 'subTitleIcon', 'locations', 'objectType', 'roles', 'preFilled', 'liabilityTypes', 'interestPeriods'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -155,6 +155,7 @@ class IndexController extends Controller
|
||||
$account->interest = round($this->repository->getMetaValue($account, 'interest'), 6);
|
||||
$account->interestPeriod = (string)trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));
|
||||
$account->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type));
|
||||
$account->location = $this->repository->getLocation($account);
|
||||
}
|
||||
);
|
||||
|
||||
|
@@ -99,7 +99,7 @@ class ShowController extends Controller
|
||||
if ($end < $start) {
|
||||
[$start, $end] = [$end, $start]; // @codeCoverageIgnore
|
||||
}
|
||||
$location = $account->locations()->first();
|
||||
$location = $this->repository->getLocation($account);
|
||||
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
|
||||
$today = new Carbon;
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
|
||||
@@ -147,6 +147,7 @@ class ShowController extends Controller
|
||||
return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$location = $this->repository->getLocation($account);
|
||||
$isLiability = $this->repository->isLiability($account);
|
||||
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
|
||||
$end = new Carbon;
|
||||
@@ -168,8 +169,10 @@ class ShowController extends Controller
|
||||
|
||||
return view(
|
||||
'accounts.show',
|
||||
compact('account', 'showAll', 'objectType', 'isLiability', 'currency', 'today',
|
||||
'chartUri', 'periods', 'subTitleIcon', 'groups', 'subTitle', 'start', 'end')
|
||||
compact(
|
||||
'account', 'showAll', 'location', 'objectType', 'isLiability', 'currency', 'today',
|
||||
'chartUri', 'periods', 'subTitleIcon', 'groups', 'subTitle', 'start', 'end'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user