Merge pull request #1382 from denisdulici/master

Cancel invoice/bill
This commit is contained in:
Denis Duliçi 2020-03-28 17:55:54 +03:00 committed by GitHub
commit 616983441d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 445 additions and 104 deletions

View File

@ -22,7 +22,7 @@ abstract class DocumentModel extends Model
public function scopeAccrued($query)
{
return $query->where('status', '<>', 'draft');
return $query->whereNotIn('status', ['draft', 'cancelled']);
}
public function scopePaid($query)
@ -146,6 +146,9 @@ abstract class DocumentModel extends Model
case 'viewed':
$label = 'warning';
break;
case 'cancelled':
$label = 'darker';
break;
default:
$label = 'primary';
break;

View File

@ -3,6 +3,8 @@
namespace App\BulkActions\Purchases;
use App\Abstracts\BulkAction;
use App\Events\Purchase\BillCancelled;
use App\Events\Purchase\BillReceived;
use App\Exports\Purchases\Bills as Export;
use App\Jobs\Purchase\CreateBillHistory;
use App\Jobs\Purchase\DeleteBill;
@ -18,6 +20,11 @@ class Bills extends BulkAction
'message' => 'bulk_actions.message.received',
'permission' => 'update-purchases-bills',
],
'cancelled' => [
'name' => 'general.cancel',
'message' => 'bulk_actions.message.cancelled',
'permission' => 'update-purchases-bills',
],
'delete' => [
'name' => 'general.delete',
'message' => 'bulk_actions.message.delete',
@ -34,12 +41,16 @@ class Bills extends BulkAction
$bills = $this->getSelectedRecords($request);
foreach ($bills as $bill) {
$bill->status = 'received';
$bill->save();
event(new BillReceived($bill));
}
}
$description = trans('bills.mark_recevied');
public function cancelled($request)
{
$bills = $this->getSelectedRecords($request);
$this->dispatch(new CreateBillHistory($bill, 0, $description));
foreach ($bills as $bill) {
event(new BillCancelled($bill));
}
}

View File

@ -3,6 +3,7 @@
namespace App\BulkActions\Sales;
use App\Abstracts\BulkAction;
use App\Events\Sale\InvoiceCancelled;
use App\Events\Sale\InvoiceCreated;
use App\Events\Sale\InvoiceSent;
use App\Events\Sale\PaymentReceived;
@ -25,6 +26,11 @@ class Invoices extends BulkAction
'message' => 'bulk_actions.message.sent',
'permission' => 'update-sales-invoices',
],
'cancelled' => [
'name' => 'general.cancel',
'message' => 'bulk_actions.message.cancelled',
'permission' => 'update-sales-invoices',
],
'delete' => [
'name' => 'general.delete',
'message' => 'bulk_actions.message.delete',
@ -54,6 +60,15 @@ class Invoices extends BulkAction
}
}
public function cancelled($request)
{
$invoices = $this->getSelectedRecords($request);
foreach ($invoices as $invoice) {
event(new InvoiceCancelled($invoice));
}
}
public function duplicate($request)
{
$invoices = $this->getSelectedRecords($request);

View File

@ -0,0 +1,22 @@
<?php
namespace App\Events\Purchase;
use Illuminate\Queue\SerializesModels;
class BillCancelled
{
use SerializesModels;
public $bill;
/**
* Create a new event instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Events\Sale;
use Illuminate\Queue\SerializesModels;
class InvoiceCancelled
{
use SerializesModels;
public $invoice;
/**
* Create a new event instance.
*
* @param $invoice
*/
public function __construct($invoice)
{
$this->invoice = $invoice;
}
}

View File

@ -284,7 +284,25 @@ class Bills extends Controller
{
event(new \App\Events\Purchase\BillReceived($bill));
$message = trans('bills.messages.received');
$message = trans('bills.messages.marked_received');
flash($message)->success();
return redirect()->back();
}
/**
* Mark the bill as cancelled.
*
* @param Bill $bill
*
* @return Response
*/
public function markCancelled(Bill $bill)
{
event(new \App\Events\Purchase\BillCancelled($bill));
$message = trans('bills.messages.marked_cancelled');
flash($message)->success();

View File

@ -294,6 +294,24 @@ class Invoices extends Controller
return redirect()->back();
}
/**
* Mark the invoice as cancelled.
*
* @param Invoice $invoice
*
* @return Response
*/
public function markCancelled(Invoice $invoice)
{
event(new \App\Events\Sale\InvoiceCancelled($invoice));
$message = trans('invoices.messages.marked_cancelled');
flash($message)->success();
return redirect()->back();
}
/**
* Download the PDF file of invoice.
*

View File

@ -0,0 +1,38 @@
<?php
namespace App\Jobs\Purchase;
use App\Abstracts\Job;
use App\Models\Purchase\Bill;
class CancelBill extends Job
{
protected $bill;
/**
* Create a new job instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
/**
* Execute the job.
*
* @return Bill
*/
public function handle()
{
$this->deleteRelationships($this->bill, [
'transactions', 'recurring'
]);
$this->bill->status = 'cancelled';
$this->bill->save();
return true;
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace App\Jobs\Sale;
use App\Abstracts\Job;
use App\Models\Sale\Invoice;
class CancelInvoice extends Job
{
protected $invoice;
/**
* Create a new job instance.
*
* @param $invoice
*/
public function __construct($invoice)
{
$this->invoice = $invoice;
}
/**
* Execute the job.
*
* @return Invoice
*/
public function handle()
{
$this->deleteRelationships($this->invoice, [
'transactions', 'recurring'
]);
$this->invoice->status = 'cancelled';
$this->invoice->save();
return true;
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Listeners\Purchase;
use App\Events\Purchase\BillCancelled as Event;
use App\Jobs\Purchase\CancelBill;
use App\Jobs\Purchase\CreateBillHistory;
use App\Traits\Jobs;
class MarkBillCancelled
{
use Jobs;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
$this->dispatch(new CancelBill($event->bill));
$this->dispatch(new CreateBillHistory($event->bill, 0, trans('bills.messages.marked_cancelled')));
}
}

View File

@ -24,6 +24,6 @@ class MarkBillReceived
$event->bill->save();
}
$this->dispatch(new CreateBillHistory($event->bill, 0, trans('bills.mark_received')));
$this->dispatch(new CreateBillHistory($event->bill, 0, trans('bills.messages.marked_received')));
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Listeners\Sale;
use App\Events\Sale\InvoiceCancelled as Event;
use App\Jobs\Sale\CancelInvoice;
use App\Jobs\Sale\CreateInvoiceHistory;
use App\Traits\Jobs;
class MarkInvoiceCancelled
{
use Jobs;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
$this->dispatch(new CancelInvoice($event->invoice));
$this->dispatch(new CreateInvoiceHistory($event->invoice, 0, trans('invoices.messages.marked_cancelled')));
}
}

View File

@ -24,6 +24,6 @@ class MarkInvoiceSent
$event->invoice->save();
}
$this->dispatch(new CreateInvoiceHistory($event->invoice, 0, trans('invoices.mark_sent')));
$this->dispatch(new CreateInvoiceHistory($event->invoice, 0, trans('invoices.messages.marked_sent')));
}
}

View File

@ -29,6 +29,6 @@ class MarkInvoiceViewed
$invoice->status = 'viewed';
$invoice->save();
$this->dispatch(new CreateInvoiceHistory($event->invoice, 0, trans('invoices.mark_viewed')));
$this->dispatch(new CreateInvoiceHistory($event->invoice, 0, trans('invoices.messages.marked_viewed')));
}
}

View File

@ -33,6 +33,9 @@ class Event extends Provider
'App\Events\Purchase\BillReceived' => [
'App\Listeners\Purchase\MarkBillReceived',
],
'App\Events\Purchase\BillCancelled' => [
'App\Listeners\Purchase\MarkBillCancelled',
],
'App\Events\Purchase\BillRecurring' => [
'App\Listeners\Purchase\SendBillRecurringNotification',
],
@ -47,6 +50,9 @@ class Event extends Provider
'App\Events\Sale\InvoiceSent' => [
'App\Listeners\Sale\MarkInvoiceSent',
],
'App\Events\Sale\InvoiceCancelled' => [
'App\Listeners\Sale\MarkInvoiceCancelled',
],
'App\Events\Sale\InvoiceViewed' => [
'App\Listeners\Sale\MarkInvoiceViewed',
],

View File

@ -45,6 +45,7 @@ trait Purchases
'paid',
'overdue',
'unpaid',
'cancelled',
];
$statuses = collect($list)->each(function ($code) {

View File

@ -47,6 +47,7 @@ trait Sales
'paid',
'overdue',
'unpaid',
'cancelled',
];
$statuses = collect($list)->each(function ($code) {

View File

@ -1,5 +1,6 @@
<?php
use App\Events\Purchase\BillCancelled;
use App\Events\Purchase\BillCreated;
use App\Events\Purchase\BillReceived;
use App\Jobs\Banking\CreateDocumentTransaction;
@ -32,7 +33,7 @@ $factory->define(Bill::class, function (Faker $faker) use ($company) {
$contact = factory(Contact::class)->states('enabled', 'vendor')->create();
}
$statuses = ['draft', 'received', 'partial', 'paid'];
$statuses = ['draft', 'received', 'partial', 'paid', 'cancelled'];
return [
'company_id' => $company->id,
@ -62,6 +63,8 @@ $factory->state(Bill::class, 'partial', ['status' => 'partial']);
$factory->state(Bill::class, 'paid', ['status' => 'paid']);
$factory->state(Bill::class, 'cancelled', ['status' => 'cancelled']);
$factory->state(Bill::class, 'recurring', function (Faker $faker) {
$frequencies = ['monthly', 'weekly'];
@ -175,6 +178,10 @@ $factory->afterCreating(Bill::class, function ($bill, $faker) use ($company) {
$transaction = dispatch_now(new CreateDocumentTransaction($updated_bill, $payment_request));
break;
case 'cancelled':
event(new BillCancelled($updated_bill));
break;
}
});

View File

@ -1,5 +1,6 @@
<?php
use App\Events\Sale\InvoiceCancelled;
use App\Events\Sale\InvoiceCreated;
use App\Events\Sale\InvoiceSent;
use App\Events\Sale\InvoiceViewed;
@ -33,7 +34,7 @@ $factory->define(Invoice::class, function (Faker $faker) use ($company) {
$contact = factory(Contact::class)->states('enabled', 'customer')->create();
}
$statuses = ['draft', 'sent', 'viewed', 'partial', 'paid'];
$statuses = ['draft', 'sent', 'viewed', 'partial', 'paid', 'cancelled'];
return [
'company_id' => $company->id,
@ -65,6 +66,8 @@ $factory->state(Invoice::class, 'partial', ['status' => 'partial']);
$factory->state(Invoice::class, 'paid', ['status' => 'paid']);
$factory->state(Invoice::class, 'cancelled', ['status' => 'cancelled']);
$factory->state(Invoice::class, 'recurring', function (Faker $faker) {
$frequencies = ['monthly', 'weekly'];
@ -184,6 +187,10 @@ $factory->afterCreating(Invoice::class, function ($invoice, $faker) use ($compan
event(new PaymentReceived($updated_invoice, $payment_request));
break;
case 'cancelled':
event(new InvoiceCancelled($updated_invoice));
break;
}
});

View File

@ -480,6 +480,32 @@ a.text-yellow:focus
background-color: #bf8003;
}
/*--Warning Color Finish--*/
/*--Dark Color--*/
.badge-dark
{
color: #fff;
background-color: #6a7783;
}
.badge-dark[href]:hover,
.badge-dark[href]:focus
{
color: #fff;
background-color: #060607;
}
/*--Dark Color Finish--*/
/*--Darker Color--*/
.badge-darker
{
color: #fff;
background-color: #525252;
}
.badge-darker[href]:hover,
.badge-darker[href]:focus
{
color: #fff;
background-color: #000;
}
/*--Darker Color Finish--*/
/*--------Badge Colors Finish--------*/
/*--------Background Colors--------*/
@ -1897,6 +1923,20 @@ button.bg-yellow:focus
background-image: linear-gradient(to right, #ffffff , #efad32);
}
/*--Viewed Color Finish--*/
/*--Dark Color--*/
.status-dark
{
background-image: linear-gradient(to right, #ffffff , #6a7783);
}
/*--Dark Color Finish--*/
/*--Darker Color--*/
.status-darker
{
background-image: linear-gradient(to right, #ffffff , #525252);
}
/*--Darker Color Finish--*/
/*--------Transaction Status Colors Finish--------*/

View File

@ -31,6 +31,7 @@ return [
'add_payment' => 'Add Payment',
'mark_paid' => 'Mark Paid',
'mark_received' => 'Mark Received',
'mark_cancelled' => 'Mark Cancelled',
'download_pdf' => 'Download PDF',
'send_mail' => 'Send Email',
'create_bill' => 'Create Bill',
@ -44,11 +45,13 @@ return [
'paid' => 'Paid',
'overdue' => 'Overdue',
'unpaid' => 'Unpaid',
'cancelled' => 'Cancelled',
],
'messages' => [
'received' => 'Bill marked as received successfully!',
'marked_received' => 'Bill marked as received!',
'marked_paid' => 'Bill marked as paid!',
'marked_cancelled' => 'Bill marked as cancelled!',
'draft' => 'This is a <b>DRAFT</b> bill and will be reflected to charts after it gets received.',
'status' => [

View File

@ -15,6 +15,7 @@ return [
'paid' => 'Are you sure you want to mark selected invoice as <b>paid</b>?|Are you sure you want to mark selected invoices as <b>paid</b>?',
'sent' => 'Are you sure you want to mark selected invoice as <b>sent</b>?|Are you sure you want to mark selected invoices as <b>sent</b>?',
'received' => 'Are you sure you want to mark selected bill as <b>received</b>?|Are you sure you want to mark selected bills as <b>received</b>?',
'cancelled' => 'Are you sure you want to <b>cancel</b> selected invoice/bill?|Are you sure you want to <b>cancel</b> selected invoices/bills?',
],
];

View File

@ -31,6 +31,7 @@ return [
'mark_paid' => 'Mark Paid',
'mark_sent' => 'Mark Sent',
'mark_viewed' => 'Mark Viewed',
'mark_cancelled' => 'Mark Cancelled',
'download_pdf' => 'Download PDF',
'send_mail' => 'Send Email',
'all_invoices' => 'Login to view all invoices',
@ -48,12 +49,15 @@ return [
'paid' => 'Paid',
'overdue' => 'Overdue',
'unpaid' => 'Unpaid',
'cancelled' => 'Cancelled',
],
'messages' => [
'email_sent' => 'Invoice email has been sent!',
'marked_sent' => 'Invoice marked as sent!',
'marked_paid' => 'Invoice marked as paid!',
'marked_viewed' => 'Invoice marked as viewed!',
'marked_cancelled' => 'Invoice marked as cancelled!',
'email_required' => 'No email address for this customer!',
'draft' => 'This is a <b>DRAFT</b> invoice and will be reflected to charts after it gets sent.',

View File

@ -273,8 +273,7 @@
<div class="card-footer">
<div class="row">
<div class="col-xs-12 col-sm-6">
@if($invoice->status != 'paid')
@if ($payment_methods)
@if (!empty($payment_methods) && !in_array($invoice->status, ['paid', 'cancelled']))
{!! Form::open([
'id' => 'invoice-payment',
'role' => 'form',
@ -285,7 +284,6 @@
{{ Form::selectGroup('payment_method', '', 'money el-icon-money', $payment_methods, '', ['change' => 'onChangePaymentMethod', 'id' => 'payment-method', 'class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.payment_methods', 1)])], 'col-sm-12') }}
{!! Form::hidden('invoice_id', $invoice->id, ['v-model' => 'form.invoice_id']) !!}
{!! Form::close() !!}
@endif
@endif
</div>
<div class="col-xs-12 col-sm-6 text-right">

View File

@ -219,19 +219,17 @@
<div class="card-footer">
<div class="row">
<div class="col-md-4">
@if($invoice->status != 'paid')
@if ($payment_methods)
{!! Form::open([
'id' => 'invoice-payment',
'role' => 'form',
'autocomplete' => "off",
'novalidate' => 'true',
'class' => 'mb-0',
]) !!}
{{ Form::selectGroup('payment_method', '', 'fas fa-wallet', $payment_methods, '', ['change' => 'onChangePaymentMethodSigned', 'id' => 'payment-method', 'class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.payment_methods', 1)])], 'mb-0') }}
{!! Form::hidden('invoice_id', $invoice->id, ['v-model' => 'form.invoice_id']) !!}
{!! Form::close() !!}
@endif
@if (!empty($payment_methods) && !in_array($invoice->status, ['paid', 'cancelled']))
{!! Form::open([
'id' => 'invoice-payment',
'role' => 'form',
'autocomplete' => "off",
'novalidate' => 'true',
'class' => 'mb-0',
]) !!}
{{ Form::selectGroup('payment_method', '', 'fas fa-wallet', $payment_methods, '', ['change' => 'onChangePaymentMethodSigned', 'id' => 'payment-method', 'class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.payment_methods', 1)])], 'mb-0') }}
{!! Form::hidden('invoice_id', $invoice->id, ['v-model' => 'form.invoice_id']) !!}
{!! Form::close() !!}
@endif
</div>

View File

@ -70,9 +70,17 @@
<a class="dropdown-item" href="{{ route('bills.edit', $item->id) }}">{{ trans('general.edit') }}</a>
@endif
<div class="dropdown-divider"></div>
@permission('create-purchases-bills')
<a class="dropdown-item" href="{{ route('bills.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
@endpermission
@if ($item->status != 'cancelled')
@permission('create-purchases-bills')
<a class="dropdown-item" href="{{ route('bills.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
@endpermission
@permission('update-purchases-bills')
<a class="dropdown-item" href="{{ route('bills.cancelled', $item->id) }}">{{ trans('general.cancel') }}</a>
@endpermission
@endif
@permission('delete-purchases-bills')
<div class="dropdown-divider"></div>
@if (!$item->reconciled)

View File

@ -48,7 +48,7 @@
@stack('status_message_end')
@stack('timeline_start')
@if ($bill->status != 'paid')
@if (!in_array($bill->status, ['paid', 'cancelled']))
@stack('timeline_body_start')
<div class="card">
<div class="card-body">
@ -472,40 +472,50 @@
<div class="dropup header-drop-top">
<button type="button" class="btn btn-primary header-button-top" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-chevron-up"></i>&nbsp; {{ trans('general.more_actions') }}</button>
<div class="dropdown-menu" role="menu">
@stack('button_pay_start')
@if($bill->status != 'paid')
@if ($bill->status != 'cancelled')
@stack('button_pay_start')
@if($bill->status != 'paid')
@permission('update-purchases-bills')
<a class="dropdown-item" href="{{ route('bills.paid', $bill->id) }}">{{ trans('bills.mark_paid') }}</a>
@endpermission
@if(empty($bill->paid) || ($bill->paid != $bill->amount))
<button class="dropdown-item" id="button-payment" @click="onPayment">{{ trans('bills.add_payment') }}</button>
@endif
<div class="dropdown-divider"></div>
@endif
@stack('button_pay_end')
@stack('button_received_start')
@permission('update-purchases-bills')
<a class="dropdown-item" href="{{ route('bills.paid', $bill->id) }}">{{ trans('bills.mark_paid') }}</a>
@if($bill->status == 'draft')
<a class="dropdown-item" href="{{ route('bills.received', $bill->id) }}">{{ trans('bills.mark_received') }}</a></a>
@else
<button type="button" class="dropdown-item" disabled="disabled">{{ trans('bills.mark_received') }}</button>
@endif
@endpermission
@if(empty($bill->paid) || ($bill->paid != $bill->amount))
<button class="dropdown-item" id="button-payment" @click="onPayment">{{ trans('bills.add_payment') }}</button>
@endif
<div class="dropdown-divider"></div>
@endif
@stack('button_pay_end')
@stack('button_received_start')
@permission('update-purchases-bills')
@if($bill->status == 'draft')
<a class="dropdown-item" href="{{ route('bills.received', $bill->id) }}">{{ trans('bills.mark_received') }}</a></a>
@else
<button type="button" class="dropdown-item" disabled="disabled">{{ trans('bills.mark_received') }}</button>
@endif
@endpermission
@stack('button_received_end')
@stack('button_received_end')
@endif
@stack('button_pdf_start')
<a class="dropdown-item" href="{{ route('bills.pdf', $bill->id) }}">{{ trans('bills.download_pdf') }}</a>
@stack('button_pdf_end')
@stack('button_delete_start')
@permission('delete-purchases-bills')
@if(!$bill->reconciled)
{!! Form::deleteLink($bill, 'purchases/bills') !!}
@endif
@endpermission
@stack('button_delete_end')
@permission('update-purchases-bills')
@if ($bill->status != 'cancelled')
@stack('button_cancelled_start')
<a class="dropdown-item" href="{{ route('bills.cancelled', $bill->id) }}">{{ trans('general.cancel') }}</a>
@stack('button_cancelled_end')
@endif
@endpermission
@permission('delete-purchases-bills')
@if (!$bill->reconciled)
@stack('button_delete_start')
{!! Form::deleteLink($bill, 'purchases/bills') !!}
@stack('button_delete_end')
@endif
@endpermission
</div>
</div>
@stack('button_group_end')

View File

@ -71,10 +71,16 @@
@endif
<div class="dropdown-divider"></div>
@permission('create-sales-invoices')
<a class="dropdown-item" href="{{ route('invoices.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
<div class="dropdown-divider"></div>
@endpermission
@if ($item->status != 'cancelled')
@permission('create-sales-invoices')
<a class="dropdown-item" href="{{ route('invoices.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
<div class="dropdown-divider"></div>
@endpermission
@permission('update-sales-invoices')
<a class="dropdown-item" href="{{ route('invoices.cancelled', $item->id) }}">{{ trans('general.cancel') }}</a>
@endpermission
@endif
@permission('delete-sales-invoices')
@if (!$item->reconciled)

View File

@ -48,7 +48,7 @@
@stack('status_message_end')
@stack('timeline_start')
@if ($invoice->status != 'paid')
@if (!in_array($invoice->status, ['paid', 'cancelled']))
@stack('timeline_body_start')
<div class="card">
<div class="card-body">
@ -464,7 +464,7 @@
<div class="card-footer">
<div class="row align-items-center">
<div class="col-xs-12 col-sm-4">
@if($invoice->attachment)
@if ($invoice->attachment)
@php $file = $invoice->attachment; @endphp
@include('partials.media.file')
@endif
@ -485,60 +485,72 @@
</a>
@stack('button_print_end')
@stack('button_share_start')
<a href="{{ $signed_url }}" target="_blank" class="btn btn-white header-button-top">
<i class="fa fa-share"></i>&nbsp; {{ trans('general.share') }}
</a>
@stack('button_share_end')
@if ($invoice->status != 'cancelled')
@stack('button_share_start')
<a href="{{ $signed_url }}" target="_blank" class="btn btn-white header-button-top">
<i class="fa fa-share"></i>&nbsp; {{ trans('general.share') }}
</a>
@stack('button_share_end')
@endif
@stack('button_group_start')
<div class="dropup header-drop-top">
<button type="button" class="btn btn-primary header-button-top" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-chevron-up"></i>&nbsp; {{ trans('general.more_actions') }}</button>
<div class="dropdown-menu" role="menu">
@stack('button_pay_start')
@if($invoice->status != 'paid')
@if ($invoice->status != 'cancelled')
@stack('button_pay_start')
@if ($invoice->status != 'paid')
@permission('update-sales-invoices')
<a class="dropdown-item" href="{{ route('invoices.paid', $invoice->id) }}">{{ trans('invoices.mark_paid') }}</a>
@endpermission
@if(empty($invoice->paid) || ($invoice->paid != $invoice->amount))
<button class="dropdown-item" id="button-payment" @click="onPayment">{{ trans('invoices.add_payment') }}</button>
@endif
<div class="dropdown-divider"></div>
@endif
@stack('button_pay_end')
@stack('button_sent_start')
@permission('update-sales-invoices')
<a class="dropdown-item" href="{{ route('invoices.paid', $invoice->id) }}">{{ trans('invoices.mark_paid') }}</a>
@if ($invoice->status == 'draft')
<a class="dropdown-item" href="{{ route('invoices.sent', $invoice->id) }}">{{ trans('invoices.mark_sent') }}</a>
@else
<button type="button" class="dropdown-item" disabled="disabled"><span class="text-disabled">{{ trans('invoices.mark_sent') }}</span></button>
@endif
@endpermission
@stack('button_sent_end')
@if(empty($invoice->paid) || ($invoice->paid != $invoice->amount))
<button class="dropdown-item" id="button-payment" @click="onPayment">{{ trans('invoices.add_payment') }}</button>
@endif
<div class="dropdown-divider"></div>
@endif
@stack('button_pay_end')
@stack('button_sent_start')
@permission('update-sales-invoices')
@if($invoice->status == 'draft')
<a class="dropdown-item" href="{{ route('invoices.sent', $invoice->id) }}">{{ trans('invoices.mark_sent') }}</a>
@stack('button_email_start')
@if ($invoice->contact_email)
<a class="dropdown-item" href="{{ route('invoices.email', $invoice->id) }}">{{ trans('invoices.send_mail') }}</a>
@else
<button type="button" class="dropdown-item" disabled="disabled"><span class="text-disabled">{{ trans('invoices.mark_sent') }}</span></button>
<button type="button" class="dropdown-item" disabled="disabled" data-toggle="tooltip" data-placement="right" title="{{ trans('invoices.messages.email_required') }}">
<span class="text-disabled">{{ trans('invoices.send_mail') }}</span>
</button>
@endif
@endpermission
@stack('button_sent_end')
@stack('button_email_start')
@if($invoice->contact_email)
<a class="dropdown-item" href="{{ route('invoices.email', $invoice->id) }}">{{ trans('invoices.send_mail') }}</a>
@else
<button type="button" class="dropdown-item" disabled="disabled" data-toggle="tooltip" data-placement="right" title="{{ trans('invoices.messages.email_required') }}">
<span class="text-disabled">{{ trans('invoices.send_mail') }}</span>
</button>
@endif
@stack('button_email_end')
@stack('button_email_end')
@endif
@stack('button_pdf_start')
<a class="dropdown-item" href="{{ route('invoices.pdf', $invoice->id) }}">{{ trans('invoices.download_pdf') }}</a>
@stack('button_pdf_end')
@stack('button_delete_start')
@permission('delete-sales-invoices')
@if(!$invoice->reconciled)
{!! Form::deleteLink($invoice, 'sales/invoices') !!}
@endif
@endpermission
@stack('button_delete_end')
@permission('update-sales-invoices')
@if ($invoice->status != 'cancelled')
@stack('button_cancelled_start')
<a class="dropdown-item" href="{{ route('invoices.cancelled', $invoice->id) }}">{{ trans('general.cancel') }}</a>
@stack('button_cancelled_end')
@endif
@endpermission
@permission('delete-sales-invoices')
@if (!$invoice->reconciled)
@stack('button_delete_start')
{!! Form::deleteLink($invoice, 'sales/invoices') !!}
@stack('button_delete_end')
@endif
@endpermission
</div>
</div>
@stack('button_group_end')

View File

@ -69,6 +69,7 @@ Route::group(['prefix' => 'auth'], function () {
Route::group(['prefix' => 'sales'], function () {
Route::get('invoices/{invoice}/sent', 'Sales\Invoices@markSent')->name('invoices.sent');
Route::get('invoices/{invoice}/cancelled', 'Sales\Invoices@markCancelled')->name('invoices.cancelled');
Route::get('invoices/{invoice}/email', 'Sales\Invoices@emailInvoice')->name('invoices.email');
Route::get('invoices/{invoice}/paid', 'Sales\Invoices@markPaid')->name('invoices.paid');
Route::get('invoices/{invoice}/print', 'Sales\Invoices@printInvoice')->name('invoices.print');
@ -97,6 +98,7 @@ Route::group(['prefix' => 'sales'], function () {
Route::group(['prefix' => 'purchases'], function () {
Route::get('bills/{bill}/received', 'Purchases\Bills@markReceived')->name('bills.received');
Route::get('bills/{bill}/cancelled', 'Purchases\Bills@markCancelled')->name('bills.cancelled');
Route::get('bills/{bill}/paid', 'Purchases\Bills@markPaid')->name('bills.paid');
Route::get('bills/{bill}/print', 'Purchases\Bills@printBill')->name('bills.print');
Route::get('bills/{bill}/pdf', 'Purchases\Bills@pdfBill')->name('bills.pdf');