From a56a6df557bd34578784f385a8b20ddf01b8aebd Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 5 Feb 2022 08:53:45 +0100 Subject: [PATCH] Final changes to bills --- app/Http/Controllers/Bill/IndexController.php | 1 + app/Http/Requests/BillStoreRequest.php | 2 +- app/Http/Requests/BillUpdateRequest.php | 2 +- app/Transformers/BillTransformer.php | 3 +++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.php index d8d7e2d9f2..f5cb3bf78e 100644 --- a/app/Http/Controllers/Bill/IndexController.php +++ b/app/Http/Controllers/Bill/IndexController.php @@ -203,6 +203,7 @@ class IndexController extends Controller 'quarterly' => '4', 'monthly' => '12', 'weekly' => '52.17', + 'daily' => '365.24', ]; $yearAmount = bcmul($avg, bcdiv($multiplies[$bill['repeat_freq']], (string)($bill['skip'] + 1))); Log::debug(sprintf('Amount per year is %s (%s * %s / %s)', $yearAmount, $avg, $multiplies[$bill['repeat_freq']], (string)($bill['skip'] + 1))); diff --git a/app/Http/Requests/BillStoreRequest.php b/app/Http/Requests/BillStoreRequest.php index 39f01d8d22..aec73c412a 100644 --- a/app/Http/Requests/BillStoreRequest.php +++ b/app/Http/Requests/BillStoreRequest.php @@ -68,7 +68,7 @@ class BillStoreRequest extends FormRequest 'amount_max' => 'required|numeric|gt:0|max:1000000000', 'transaction_currency_id' => 'required|exists:transaction_currencies,id', 'date' => 'required|date', - 'repeat_freq' => 'required|in:weekly,monthly,quarterly,half-year,yearly', + 'repeat_freq' => sprintf('required|in:%s', join(',', config('firefly.bill_periods'))), 'skip' => 'required|integer|gte:0|lte:31', 'active' => 'boolean', ]; diff --git a/app/Http/Requests/BillUpdateRequest.php b/app/Http/Requests/BillUpdateRequest.php index 4e6a4bd066..259fe629d3 100644 --- a/app/Http/Requests/BillUpdateRequest.php +++ b/app/Http/Requests/BillUpdateRequest.php @@ -72,7 +72,7 @@ class BillUpdateRequest extends FormRequest 'amount_max' => 'required|numeric|gt:0|max:1000000000', 'transaction_currency_id' => 'required|exists:transaction_currencies,id', 'date' => 'required|date', - 'repeat_freq' => 'required|in:weekly,monthly,quarterly,half-year,yearly', + 'repeat_freq' => sprintf('required|in:%s', join(',', config('firefly.bill_periods'))), 'skip' => 'required|integer|gte:0|lte:31', 'active' => 'boolean', ]; diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php index 995dd48de9..b56417b7ce 100644 --- a/app/Transformers/BillTransformer.php +++ b/app/Transformers/BillTransformer.php @@ -267,6 +267,9 @@ class BillTransformer extends AbstractTransformer $nextExpectedMatch->addDay(); $currentStart = clone $nextExpectedMatch; $loop++; + if($loop > 4) { + break; + } } $simple = $set->map( static function (Carbon $date) {