added info message #315
This commit is contained in:
parent
17758a24cc
commit
0efd3721f6
@ -71,9 +71,7 @@ class RecurringCheck extends Command
|
||||
$recurring = $company->recurring();
|
||||
|
||||
foreach ($recurring as $recur) {
|
||||
$schedule = $this->schedule($recur);
|
||||
|
||||
$current = Date::parse($schedule->current()->getStart());
|
||||
$current = Date::parse($recur->schedule()->current()->getStart()->format('Y-m-d'));
|
||||
|
||||
// Check if should recur today
|
||||
if ($this->today->ne($current)) {
|
||||
@ -183,27 +181,4 @@ class RecurringCheck extends Command
|
||||
$user->notify(new BillNotification($clone));
|
||||
}
|
||||
}
|
||||
|
||||
protected function schedule($recur)
|
||||
{
|
||||
$config = new ArrayTransformerConfig();
|
||||
$config->enableLastDayOfMonthFix();
|
||||
|
||||
$transformer = new ArrayTransformer();
|
||||
$transformer->setConfig($config);
|
||||
|
||||
return $transformer->transform($this->rule($recur));
|
||||
}
|
||||
|
||||
protected function rule($recur)
|
||||
{
|
||||
$rule = (new Rule())
|
||||
->setStartDate($recur->started_at)
|
||||
->setTimezone(setting('general.timezone'))
|
||||
->setFreq(strtoupper($recur->frequency))
|
||||
->setInterval($recur->interval)
|
||||
->setCount($recur->count);
|
||||
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,11 @@
|
||||
namespace App\Models\Common;
|
||||
|
||||
use App\Models\Model;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Recurr\Rule;
|
||||
use Recurr\Transformer\ArrayTransformer;
|
||||
use Recurr\Transformer\ArrayTransformerConfig;
|
||||
|
||||
class Recurring extends Model
|
||||
{
|
||||
@ -24,4 +29,30 @@ class Recurring extends Model
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function schedule()
|
||||
{
|
||||
$config = new ArrayTransformerConfig();
|
||||
$config->enableLastDayOfMonthFix();
|
||||
|
||||
$transformer = new ArrayTransformer();
|
||||
$transformer->setConfig($config);
|
||||
|
||||
return $transformer->transform($this->rule());
|
||||
}
|
||||
|
||||
public function rule()
|
||||
{
|
||||
// 0 means infinite
|
||||
$count = ($this->count == 0) ? 999 : $this->count;
|
||||
|
||||
$rule = (new Rule())
|
||||
->setStartDate(new DateTime($this->started_at, new DateTimeZone(setting('general.timezone'))))
|
||||
->setTimezone(setting('general.timezone'))
|
||||
->setFreq(strtoupper($this->frequency))
|
||||
->setInterval($this->interval)
|
||||
->setCount($count);
|
||||
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,6 @@ return [
|
||||
'weeks' => 'Week(s)',
|
||||
'months' => 'Month(s)',
|
||||
'years' => 'Year(s)',
|
||||
'message' => 'This is a recurring :type and the next :type will be automatically generated at :date',
|
||||
|
||||
];
|
||||
|
@ -3,6 +3,18 @@
|
||||
@section('title', trans_choice('general.bills', 1) . ': ' . $bill->bill_number)
|
||||
|
||||
@section('content')
|
||||
@if ($bill->recurring()->count())
|
||||
<div class="callout callout-info">
|
||||
<h4>{{ trans('recurring.recurring') }}</h4>
|
||||
|
||||
<p>{{ trans('recurring.message', [
|
||||
'type' => mb_strtolower(trans_choice('general.bills', 1)),
|
||||
'date' => $bill->recurring->schedule()->next()->getStart()->format($date_format)
|
||||
]) }}
|
||||
</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="box box-success">
|
||||
<div class="bill">
|
||||
<span class="badge bg-aqua">{{ $bill->status->name }}</span>
|
||||
|
@ -3,6 +3,18 @@
|
||||
@section('title', trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]))
|
||||
|
||||
@section('content')
|
||||
@if ($payment->recurring()->count())
|
||||
<div class="callout callout-info">
|
||||
<h4>{{ trans('recurring.recurring') }}</h4>
|
||||
|
||||
<p>{{ trans('recurring.message', [
|
||||
'type' => mb_strtolower(trans_choice('general.payments', 1)),
|
||||
'date' => $payment->recurring->schedule()->next()->getStart()->format($date_format)
|
||||
]) }}
|
||||
</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Default box -->
|
||||
<div class="box box-success">
|
||||
{!! Form::model($payment, [
|
||||
|
@ -3,6 +3,18 @@
|
||||
@section('title', trans_choice('general.invoices', 1) . ': ' . $invoice->invoice_number)
|
||||
|
||||
@section('content')
|
||||
@if ($invoice->recurring()->count())
|
||||
<div class="callout callout-info">
|
||||
<h4>{{ trans('recurring.recurring') }}</h4>
|
||||
|
||||
<p>{{ trans('recurring.message', [
|
||||
'type' => mb_strtolower(trans_choice('general.invoices', 1)),
|
||||
'date' => $invoice->recurring->schedule()->next()->getStart()->format($date_format)
|
||||
]) }}
|
||||
</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="box box-success">
|
||||
<section class="invoice">
|
||||
<span class="badge bg-aqua">{{ $invoice->status->name }}</span>
|
||||
|
@ -3,6 +3,18 @@
|
||||
@section('title', trans('general.title.edit', ['type' => trans_choice('general.revenues', 1)]))
|
||||
|
||||
@section('content')
|
||||
@if ($revenue->recurring()->count())
|
||||
<div class="callout callout-info">
|
||||
<h4>{{ trans('recurring.recurring') }}</h4>
|
||||
|
||||
<p>{{ trans('recurring.message', [
|
||||
'type' => mb_strtolower(trans_choice('general.revenues', 1)),
|
||||
'date' => $revenue->recurring->schedule()->next()->getStart()->format($date_format)
|
||||
]) }}
|
||||
</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Default box -->
|
||||
<div class="box box-success">
|
||||
{!! Form::model($revenue, [
|
||||
|
Loading…
x
Reference in New Issue
Block a user