Make sure location data in request is processed in a unified way.

This commit is contained in:
James Cole
2020-01-01 14:27:43 +01:00
parent 414e8d7153
commit ca260387a2
4 changed files with 101 additions and 20 deletions

View File

@@ -59,12 +59,6 @@ class AccountUpdateRequest extends Request
if (null !== $this->get('include_net_worth')) {
$includeNetWorth = $this->boolean('include_net_worth');
}
$updateLocation = false;
if ($this->has('longitude') && $this->has('latitude') && $this->has('zoom_level')) {
$updateLocation = true;
}
$data = [
'name' => $this->nullableString('name'),
'active' => $active,
@@ -85,12 +79,10 @@ class AccountUpdateRequest extends Request
'notes' => $this->nullableNlString('notes'),
'interest' => $this->nullableString('interest'),
'interest_period' => $this->nullableString('interest_period'),
'has_location' => $updateLocation,
'longitude' => '' === $this->string('longitude') ? null : $this->string('longitude'),
'latitude' => '' === $this->string('latitude') ? null : $this->string('latitude'),
'zoom_level' => '' === $this->string('zoom_level') ? null : $this->integer('zoom_level'),
];
$data = $this->appendLocationData($data);
if ('liability' === $data['account_type']) {
$data['opening_balance'] = bcmul($this->nullableString('liability_amount'), '-1');
$data['opening_balance_date'] = $this->date('liability_start_date');