mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 06:32:40 +01:00
allow cancellation under specific conditions
This commit is contained in:
parent
b25f79f4e1
commit
08b317f7b8
@ -61,27 +61,28 @@ class RecurringInvoiceController extends Controller
|
|||||||
|
|
||||||
public function requestCancellation(Request $request, RecurringInvoice $recurring_invoice)
|
public function requestCancellation(Request $request, RecurringInvoice $recurring_invoice)
|
||||||
{
|
{
|
||||||
//todo double check the user is able to request a cancellation
|
if (is_null($recurring_invoice->subscription_id) || optional($recurring_invoice->subscription)->allow_cancellation) {
|
||||||
//can add locale specific by chaining ->locale();
|
$nmo = new NinjaMailerObject;
|
||||||
|
$nmo->mailable = (new NinjaMailer((new ClientContactRequestCancellationObject($recurring_invoice, auth()->user()))->build()));
|
||||||
$nmo = new NinjaMailerObject;
|
$nmo->company = $recurring_invoice->company;
|
||||||
$nmo->mailable = (new NinjaMailer((new ClientContactRequestCancellationObject($recurring_invoice, auth()->user()))->build()));
|
$nmo->settings = $recurring_invoice->company->settings;
|
||||||
$nmo->company = $recurring_invoice->company;
|
|
||||||
$nmo->settings = $recurring_invoice->company->settings;
|
|
||||||
|
|
||||||
$notifiable_users = $this->filterUsersByPermissions($recurring_invoice->company->company_users, $recurring_invoice, ['recurring_cancellation']);
|
$notifiable_users = $this->filterUsersByPermissions($recurring_invoice->company->company_users, $recurring_invoice, ['recurring_cancellation']);
|
||||||
|
|
||||||
$notifiable_users->each(function ($company_user) use($nmo){
|
$notifiable_users->each(function ($company_user) use($nmo){
|
||||||
|
|
||||||
$nmo->to_user = $company_user->user;
|
$nmo->to_user = $company_user->user;
|
||||||
NinjaMailerJob::dispatch($nmo);
|
NinjaMailerJob::dispatch($nmo);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//$recurring_invoice->user->notify(new ClientContactRequestCancellation($recurring_invoice, auth()->user()));
|
//$recurring_invoice->user->notify(new ClientContactRequestCancellation($recurring_invoice, auth()->user()));
|
||||||
|
|
||||||
return $this->render('recurring_invoices.cancellation.index', [
|
return $this->render('recurring_invoices.cancellation.index', [
|
||||||
'invoice' => $recurring_invoice,
|
'invoice' => $recurring_invoice,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ class RecurringInvoice extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->morphMany(Document::class, 'documentable');
|
return $this->morphMany(Document::class, 'documentable');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatusAttribute()
|
public function getStatusAttribute()
|
||||||
{
|
{
|
||||||
if ($this->status_id == self::STATUS_ACTIVE && Carbon::parse($this->next_send_date)->isFuture()) {
|
if ($this->status_id == self::STATUS_ACTIVE && Carbon::parse($this->next_send_date)->isFuture()) {
|
||||||
@ -394,9 +394,9 @@ class RecurringInvoice extends BaseModel
|
|||||||
if ($this->remaining_cycles == -1) {
|
if ($this->remaining_cycles == -1) {
|
||||||
$iterations = 10;
|
$iterations = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
if (!Carbon::parse($this->next_send_date)) {
|
if (!Carbon::parse($this->next_send_date)) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@ -407,7 +407,7 @@ class RecurringInvoice extends BaseModel
|
|||||||
// we don't add the days... we calc the day of the month!!
|
// we don't add the days... we calc the day of the month!!
|
||||||
$next_due_date = $this->calculateDueDate($next_send_date->copy()->format('Y-m-d'));
|
$next_due_date = $this->calculateDueDate($next_send_date->copy()->format('Y-m-d'));
|
||||||
$next_due_date_string = $next_due_date ? $next_due_date->format('Y-m-d') : '';
|
$next_due_date_string = $next_due_date ? $next_due_date->format('Y-m-d') : '';
|
||||||
|
|
||||||
$next_send_date = Carbon::parse($next_send_date);
|
$next_send_date = Carbon::parse($next_send_date);
|
||||||
|
|
||||||
$data[] = [
|
$data[] = [
|
||||||
@ -420,7 +420,7 @@ class RecurringInvoice extends BaseModel
|
|||||||
|
|
||||||
/*If no due date is set - unset the due_date value */
|
/*If no due date is set - unset the due_date value */
|
||||||
// if(!$this->due_date_days || $this->due_date_days == 0){
|
// if(!$this->due_date_days || $this->due_date_days == 0){
|
||||||
|
|
||||||
// foreach($data as $key => $value)
|
// foreach($data as $key => $value)
|
||||||
// $data[$key]['due_date'] = '';
|
// $data[$key]['due_date'] = '';
|
||||||
|
|
||||||
@ -468,4 +468,9 @@ class RecurringInvoice extends BaseModel
|
|||||||
{
|
{
|
||||||
return new RecurringService($this);
|
return new RecurringService($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function subscription(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Subscription::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,31 +55,35 @@
|
|||||||
{{ \App\Utils\Number::formatMoney($invoice->amount, $invoice->client) }}
|
{{ \App\Utils\Number::formatMoney($invoice->amount, $invoice->client) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bg-white shadow sm:rounded-lg mb-4 mt-4">
|
@if(is_null($invoice->subscription_id) || optional($invoice->subscription)->allow_cancellation)
|
||||||
<div class="px-4 py-5 sm:p-6">
|
<div class="bg-white shadow sm:rounded-lg mb-4 mt-4">
|
||||||
<div class="sm:flex sm:items-start sm:justify-between">
|
<div class="px-4 py-5 sm:p-6">
|
||||||
<div>
|
<div class="sm:flex sm:items-start sm:justify-between">
|
||||||
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
<div>
|
||||||
{{ ctrans('texts.cancellation') }}
|
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
||||||
</h3>
|
{{ ctrans('texts.cancellation') }}
|
||||||
<div class="mt-2 max-w-xl text-sm leading-5 text-gray-500">
|
</h3>
|
||||||
<p translate>
|
<div class="mt-2 max-w-xl text-sm leading-5 text-gray-500">
|
||||||
{{ ctrans('texts.about_cancellation') }}
|
<p translate>
|
||||||
</p>
|
{{ ctrans('texts.about_cancellation') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="mt-5 sm:mt-0 sm:ml-6 sm:flex-shrink-0 sm:flex sm:items-center">
|
||||||
<div class="mt-5 sm:mt-0 sm:ml-6 sm:flex-shrink-0 sm:flex sm:items-center">
|
<div class="inline-flex rounded-md shadow-sm" x-data="{ open: false }">
|
||||||
<div class="inline-flex rounded-md shadow-sm" x-data="{ open: false }">
|
<button class="button button-danger" translate @click="open = true">Request Cancellation
|
||||||
<button class="button button-danger" translate @click="open = true">Request Cancellation
|
</button>
|
||||||
</button>
|
@include('portal.ninja2020.recurring_invoices.includes.modals.cancellation')
|
||||||
@include('portal.ninja2020.recurring_invoices.includes.modals.cancellation')
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
Loading…
Reference in New Issue
Block a user