Skip to content

Firefly III: a personal finances manager

Update frontend to facilitate bills.

James Cole217a382616e0
diff --git a/app/Api/V1/Requests/Models/Bill/StoreRequest.php b/app/Api/V1/Requests/Models/Bill/StoreRequest.php
index 88560c1077..d4ea90da3a 100644
--- a/app/Api/V1/Requests/Models/Bill/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/Bill/StoreRequest.php
@@ -55,6 +55,8 @@ class StoreRequest extends FormRequest
'currency_id' => ['currency_id', 'integer'],
'currency_code' => ['currency_code', 'string'],
'date' => ['date', 'date'],
+ 'end_date' => ['end_date', 'date'],
+ 'extension_date' => ['extension_date', 'date'],
'repeat_freq' => ['repeat_freq', 'string'],
'skip' => ['skip', 'integer'],
'active' => ['active', 'boolean'],
@@ -75,16 +77,18 @@ class StoreRequest extends FormRequest
public function rules(): array
{
return [
- 'name' => 'between:1,255|uniqueObjectForUser:bills,name',
- 'amount_min' => 'numeric|gt:0',
- 'amount_max' => 'numeric|gt:0',
- 'currency_id' => 'numeric|exists:transaction_currencies,id',
- 'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
- 'date' => 'date',
- 'repeat_freq' => 'in:weekly,monthly,quarterly,half-year,yearly',
- 'skip' => 'between:0,31',
- 'active' => [new IsBoolean],
- 'notes' => 'between:1,65536',
+ 'name' => 'between:1,255|uniqueObjectForUser:bills,name',
+ 'amount_min' => 'numeric|gt:0|required',
+ 'amount_max' => 'numeric|gt:0|required',
+ 'currency_id' => 'numeric|exists:transaction_currencies,id',
+ 'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
+ 'date' => 'date|required',
+ 'end_date' => 'date|after:date',
+ 'extension_date' => 'date|after:date',
+ 'repeat_freq' => 'in:weekly,monthly,quarterly,half-year,yearly|required',
+ 'skip' => 'between:0,31',
+ 'active' => [new IsBoolean],
+ 'notes' => 'between:1,65536',
];
}
diff --git a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php
index 2a4a89e555..5a3fbc91ef 100644
--- a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php
@@ -53,6 +53,8 @@ class UpdateRequest extends FormRequest
'currency_id' => ['currency_id', 'integer'],
'currency_code' => ['currency_code', 'string'],
'date' => ['date', 'date'],
+ 'end_date' => ['end_date', 'date'],
+ 'extension_date' => ['extension_date', 'date'],
'repeat_freq' => ['repeat_freq', 'string'],
'skip' => ['skip', 'integer'],
'active' => ['active', 'boolean'],
@@ -75,16 +77,18 @@ class UpdateRequest extends FormRequest
$bill = $this->route()->parameter('bill');
return [
- 'name' => sprintf('between:1,255|uniqueObjectForUser:bills,name,%d', $bill->id),
- 'amount_min' => 'numeric|gt:0',
- 'amount_max' => 'numeric|gt:0',
- 'currency_id' => 'numeric|exists:transaction_currencies,id',
- 'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
- 'date' => 'date',
- 'repeat_freq' => 'in:weekly,monthly,quarterly,half-year,yearly',
- 'skip' => 'between:0,31',
- 'active' => [new IsBoolean],
- 'notes' => 'between:1,65536',
+ 'name' => sprintf('between:1,255|uniqueObjectForUser:bills,name,%d', $bill->id),
+ 'amount_min' => 'numeric|gt:0',
+ 'amount_max' => 'numeric|gt:0',
+ 'currency_id' => 'numeric|exists:transaction_currencies,id',
+ 'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
+ 'date' => 'date',
+ 'end_date' => 'date|after:date',
+ 'extension_date' => 'date|after:date',
+ 'repeat_freq' => 'in:weekly,monthly,quarterly,half-year,yearly',
+ 'skip' => 'between:0,31',
+ 'active' => [new IsBoolean],
+ 'notes' => 'between:1,65536',
];
}
diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.php
index 417f72660d..8bde75a9ea 100644
--- a/app/Factory/BillFactory.php
+++ b/app/Factory/BillFactory.php
@@ -67,6 +67,8 @@ class BillFactory
'transaction_currency_id' => $currency->id,
'amount_max' => $data['amount_max'],
'date' => $data['date'],
+ 'end_date' => $data['end_date'] ?? null,
+ 'extension_date' => $data['extension_date'] ?? null,
'repeat_freq' => $data['repeat_freq'],
'skip' => $skip,
'automatch' => true,
diff --git a/app/Http/Middleware/InterestingMessage.php b/app/Http/Middleware/InterestingMessage.php
index 0d199782dc..944df6c67c 100644
--- a/app/Http/Middleware/InterestingMessage.php
+++ b/app/Http/Middleware/InterestingMessage.php
@@ -25,6 +25,7 @@ namespace FireflyIII\Http\Middleware;
use Closure;
use FireflyIII\Models\Account;
+use FireflyIII\Models\Bill;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Http\Request;
@@ -58,6 +59,10 @@ class InterestingMessage
Preferences::mark();
$this->handleAccountMessage($request);
}
+ if ($this->billMessage($request)) {
+ Preferences::mark();
+ $this->handleBillMessage($request);
+ }
return $next($request);
}
@@ -88,11 +93,12 @@ class InterestingMessage
/**
* @param Request $request
*/
- private function handleAccountMessage(Request $request): void {
+ private function handleAccountMessage(Request $request): void
+ {
// get parameters from request.
$accountId = $request->get('account_id');
- $message = $request->get('message');
+ $message = $request->get('message');
/** @var Account $account */
$account = auth()->user()->accounts()->withTrashed()->find($accountId);
@@ -103,10 +109,35 @@ class InterestingMessage
if ('deleted' === $message) {
session()->flash('success', (string)trans('firefly.account_deleted', ['name' => $account->name]));
}
- if('created' === $message) {
+ if ('created' === $message) {
session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
}
}
+
+ /**
+ * @param Request $request
+ */
+ private function handleBillMessage(Request $request): void
+ {
+
+ // get parameters from request.
+ $billId = $request->get('bill_id');
+ $message = $request->get('message');
+
+ /** @var Bill $bill */
+ $bill = auth()->user()->bills()->withTrashed()->find($billId);
+
+ if (null === $bill) {
+ return;
+ }
+ if ('deleted' === $message) {
+ session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $bill->name]));
+ }
+ if ('created' === $message) {
+ session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));
+ }
+ }
+
/**
* @param Request $request
*/
@@ -162,4 +193,18 @@ class InterestingMessage
return null !== $accountId && null !== $message;
}
+
+ /**
+ * @param Request $request
+ *
+ * @return bool
+ */
+ private function billMessage(Request $request): bool
+ {
+ // get parameters from request.
+ $billId = $request->get('bill_id');
+ $message = $request->get('message');
+
+ return null !== $billId && null !== $message;
+ }
}
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index 7f05a8f9ef..34fd41804d 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -122,7 +122,7 @@ class Bill extends Model
/** @var array Fields that can be filled */
protected $fillable
= ['name', 'match', 'amount_min', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
- 'automatch', 'active', 'transaction_currency_id'];
+ 'automatch', 'active', 'transaction_currency_id', 'end_date', 'extension_date'];
/** @var array Hidden from view */
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
diff --git a/app/Support/Binder/EitherConfigKey.php b/app/Support/Binder/EitherConfigKey.php
index 93b0fa4fd2..fc6bd59057 100644
--- a/app/Support/Binder/EitherConfigKey.php
+++ b/app/Support/Binder/EitherConfigKey.php
@@ -38,6 +38,7 @@ class EitherConfigKey
'firefly.accountRoles',
'firefly.valid_liabilities',
'firefly.interest_periods',
+ 'firefly.bill_periods',
'firefly.enable_external_map',
'firefly.expected_source_types',
'app.timezone',
diff --git a/changelog.md b/changelog.md
index 8fd6251160..8b1b210468 100644
--- a/changelog.md
+++ b/changelog.md
@@ -23,7 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
-- #4894 Bad number comparison
+- [Issue 4894](https://github.com/firefly-iii/firefly-iii/issues/4894) Bad number comparison
- Various Sonarqube issues, thanks @hazma-fadil!
- Correct menu display, thanks @vonsogt!
diff --git a/frontend/src/components/accounts/Currency.vue b/frontend/src/components/form/GenericCurrency.vue
similarity index 100%
rename from frontend/src/components/accounts/Currency.vue
rename to frontend/src/components/form/GenericCurrency.vue