mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-28 14:20:47 +00:00
Fix bill edit submission group thing.
This commit is contained in:
@@ -89,23 +89,23 @@ class BillUpdateService
|
||||
// new values
|
||||
$data['transaction_currency_name'] = $currency->name;
|
||||
|
||||
if (isset($data['name']) && '' !== (string) $data['name']) {
|
||||
if (isset($data['name']) && '' !== (string)$data['name']) {
|
||||
$bill->name = $data['name'];
|
||||
}
|
||||
|
||||
if (isset($data['amount_min']) && '' !== (string) $data['amount_min']) {
|
||||
if (isset($data['amount_min']) && '' !== (string)$data['amount_min']) {
|
||||
$bill->amount_min = $data['amount_min'];
|
||||
}
|
||||
if (isset($data['amount_max']) && '' !== (string) $data['amount_max']) {
|
||||
if (isset($data['amount_max']) && '' !== (string)$data['amount_max']) {
|
||||
$bill->amount_max = $data['amount_max'];
|
||||
}
|
||||
if (isset($data['date']) && '' !== (string) $data['date']) {
|
||||
if (isset($data['date']) && '' !== (string)$data['date']) {
|
||||
$bill->date = $data['date'];
|
||||
}
|
||||
if (isset($data['repeat_freq']) && '' !== (string) $data['repeat_freq']) {
|
||||
if (isset($data['repeat_freq']) && '' !== (string)$data['repeat_freq']) {
|
||||
$bill->repeat_freq = $data['repeat_freq'];
|
||||
}
|
||||
if (isset($data['skip']) && '' !== (string) $data['skip']) {
|
||||
if (isset($data['skip']) && '' !== (string)$data['skip']) {
|
||||
$bill->skip = $data['skip'];
|
||||
}
|
||||
if (isset($data['active']) && is_bool($data['active'])) {
|
||||
@@ -119,13 +119,13 @@ class BillUpdateService
|
||||
|
||||
// update note:
|
||||
if (isset($data['notes'])) {
|
||||
$this->updateNote($bill, (string) $data['notes']);
|
||||
$this->updateNote($bill, (string)$data['notes']);
|
||||
}
|
||||
|
||||
// update order.
|
||||
// update the order of the piggy bank:
|
||||
$oldOrder = (int) $bill->order;
|
||||
$newOrder = (int) ($data['order'] ?? $oldOrder);
|
||||
$oldOrder = (int)$bill->order;
|
||||
$newOrder = (int)($data['order'] ?? $oldOrder);
|
||||
if ($oldOrder !== $newOrder) {
|
||||
$this->updateOrder($bill, $oldOrder, $newOrder);
|
||||
}
|
||||
@@ -142,15 +142,27 @@ class BillUpdateService
|
||||
$bill->objectGroups()->sync([$objectGroup->id]);
|
||||
$bill->save();
|
||||
}
|
||||
return $bill;
|
||||
}
|
||||
// remove if name is empty. Should be overruled by ID.
|
||||
if ('' === $objectGroupTitle) {
|
||||
$bill->objectGroups()->sync([]);
|
||||
$bill->save();
|
||||
}
|
||||
|
||||
// try also with ID:
|
||||
$objectGroupId = (int) ($data['object_group_id'] ?? 0);
|
||||
$objectGroupId = (int)($data['object_group_id'] ?? 0);
|
||||
if (0 !== $objectGroupId) {
|
||||
$objectGroup = $this->findObjectGroupById($objectGroupId);
|
||||
if (null !== $objectGroup) {
|
||||
$bill->objectGroups()->sync([$objectGroup->id]);
|
||||
$bill->save();
|
||||
}
|
||||
return $bill;
|
||||
}
|
||||
if(0 === $objectGroupId) {
|
||||
$bill->objectGroups()->sync([]);
|
||||
$bill->save();
|
||||
}
|
||||
|
||||
return $bill;
|
||||
|
||||
Reference in New Issue
Block a user