feat: Added yearly and half-yearly billing periods

This commit is contained in:
IceToast 2022-07-22 04:00:23 +02:00
parent 78a6787607
commit 08208cab72
5 changed files with 26 additions and 2 deletions

View file

@ -61,6 +61,12 @@ class ChargeServers extends Command
// check if server is due to be charged by comparing its last_billed date with the current date and the billing period
$newBillingDate = null;
switch($billing_period) {
case 'yearly':
$newBillingDate = Carbon::parse($server->last_billed)->addYear();
break;
case 'half-yearly':
$newBillingDate = Carbon::parse($server->last_billed)->addMonths(6);
break;
case 'monthly':
$newBillingDate = Carbon::parse($server->last_billed)->addMonth();
break;

View file

@ -73,7 +73,7 @@ class ProductController extends Controller
"nodes.*" => "required|exists:nodes,id",
"eggs.*" => "required|exists:eggs,id",
"disabled" => "nullable",
"billing_period" => "required|in:hourly,daily,weekly,monthly",
"billing_period" => "required|in:hourly,daily,weekly,monthly,half-yearly,yearly",
]);
$disabled = !is_null($request->input('disabled'));
@ -140,7 +140,7 @@ class ProductController extends Controller
"nodes.*" => "required|exists:nodes,id",
"eggs.*" => "required|exists:eggs,id",
"disabled" => "nullable",
"billing_period" => "required|in:hourly,daily,weekly,monthly",
"billing_period" => "required|in:hourly,daily,weekly,monthly,half-yearly,yearly",
]);
$disabled = !is_null($request->input('disabled'));

View file

@ -183,6 +183,12 @@
<option value="monthly">
{{__('Monthly')}}
</option>
<option value="half-yearly">
{{__('Half Yearly')}}
</option>
<option value="yearly">
{{__('Yearly')}}
</option>
</select>
@error('billing_period')
<div class="invalid-feedback">

View file

@ -190,6 +190,14 @@
@endif>
{{__('Monthly')}}
</option>
<option value="half-yearly" @if ($product->billing_period == 'half-yearly') selected
@endif>
{{__('Half Yearly')}}
</option>
<option value="yearly" @if ($product->billing_period == 'yearly') selected
@endif>
{{__('Yearly')}}
</option>
</select>
@error('billing_period')
<div class="invalid-feedback">

View file

@ -162,6 +162,10 @@
<div class="text-muted">
@if($server->product->billing_period == 'monthly')
{{ __('per Month') }}
@elseif($server->product->billing_period == 'half-yearly')
{{ __('per 6 Months') }}
@elseif($server->product->billing_period == 'yearly')
{{ __('per Year') }}
@elseif($server->product->billing_period == 'weekly')
{{ __('per Week') }}
@elseif($server->product->billing_period == 'daily')