Skip to content

Commit

Permalink
Wizard on Invoice and Bill work flow
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Oct 29, 2018
1 parent 618ff1c commit 66f0e7c
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Http/Controllers/Expenses/Bills.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use App\Models\Expense\Vendor;
use App\Models\Expense\Bill;
use App\Models\Expense\BillItem;
use App\Models\Expense\BillItemTax;
use App\Models\Expense\BillTotal;
use App\Models\Expense\BillHistory;
use App\Models\Expense\BillPayment;
Expand Down Expand Up @@ -224,7 +225,7 @@ public function store(Request $request)

if ($bill_item_taxes) {
foreach ($bill_item_taxes as $bill_item_tax) {
$bill_item_tax['invoice_item_id'] = $bill_item_created->id;
$bill_item_tax['bill_item_id'] = $bill_item_created->id;

BillItemTax::create($bill_item_tax);

Expand Down Expand Up @@ -460,7 +461,7 @@ public function update(Bill $bill, Request $request)

if ($bill_item_taxes) {
foreach ($bill_item_taxes as $bill_item_tax) {
$bill_item_tax['invoice_item_id'] = $bill_item_created->id;
$bill_item_tax['bill_item_id'] = $bill_item_created->id;

BillItemTax::create($bill_item_tax);

Expand Down Expand Up @@ -548,7 +549,7 @@ public function export()
\Excel::create('bills', function ($excel) {
$bills = Bill::with(['items', 'histories', 'payments', 'totals'])->filter(request()->input())->get();

$excel->sheet('invoices', function ($sheet) use ($bills) {
$excel->sheet('bills', function ($sheet) use ($bills) {
$sheet->fromModel($bills->makeHidden([
'company_id', 'parent_id', 'created_at', 'updated_at', 'deleted_at', 'attachment', 'discount', 'items', 'histories', 'payments', 'totals', 'media'
]));
Expand Down
8 changes: 8 additions & 0 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -831,3 +831,11 @@ input[type="number"] {
line-height: 1.428571;
border-radius: 30px;
}

.row.show-invoice .timeline>li {
margin-right: 0;
}

.row.show-invoice .timeline>li a:first-child {
margin-left: 10px;
}
13 changes: 13 additions & 0 deletions resources/lang/en-GB/bills.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@

'messages' => [
'received' => 'Bill marked as received successfully!',
'draft' => 'This is a <b>DRAFT</b> bill and will be reflected to charts once it gets receive.',

'status' => [
'created' => 'Created on :date',
'receive' => [
'draft' => 'Not sent',
'received' => 'Send on :date',
],
'paid' => [
'await' => 'Awaiting payment',
'partial' => 'Partial paid',
],
],
],

];
3 changes: 3 additions & 0 deletions resources/lang/en-GB/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
'title' => [
'new' => 'New :type',
'edit' => 'Edit :type',
'create' => 'Create :type',
'send' => 'Send :type',
'get' => 'Get :type',
],

'form' => [
Expand Down
13 changes: 13 additions & 0 deletions resources/lang/en-GB/invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@
'email_sent' => 'Invoice email has been sent successfully!',
'marked_sent' => 'Invoice marked as sent successfully!',
'email_required' => 'No email address for this customer!',
'draft' => 'This is a <b>DRAFT</b> invoice and will be reflected to charts once it gets sent.',

'status' => [
'created' => 'Created on :date',
'send' => [
'draft' => 'Not sent',
'sent' => 'Send on :date',
],
'paid' => [
'await' => 'Awaiting payment',
'partial' => 'Partial paid',
],
],
],

'notification' => [
Expand Down
68 changes: 68 additions & 0 deletions resources/views/expenses/bills/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,74 @@
</div>
@endif

@if ($bill->status->code == 'draft')
<div class="callout callout-warning">
<p>{!! trans('invoices.messages.draft') !!}</p>
</div>
@endif

@if ($bill->status->code != 'paid')
<div class="row show-invoice">
<div class="col-md-12 no-padding-right">
<ul class="timeline">
<li>
<i class="fa fa-plus bg-blue"></i>

<div class="timeline-item">
<h3 class="timeline-header">{{ trans('general.title.create', ['type' => trans_choice('general.bills', 1)]) }}</h3>

<div class="timeline-body">
{{ trans_choice('general.statuses', 1) . ': ' . trans('bills.messages.status.created', ['date' => Date::parse($bill->created_at)->format($date_format)]) }}

<a href="{{ url('expenses/bills/' . $bill->id . '/edit') }}" class="btn btn-default btn-xs">
{{ trans('general.edit') }}
</a>
</div>
</div>
</li>
<li>
<i class="fa fa-envelope bg-orange"></i>

<div class="timeline-item">
<h3 class="timeline-header">{{ trans('general.title.send', ['type' => trans_choice('general.bills', 1)]) }}</h3>

<div class="timeline-body">
@if ($bill->status->code == 'draft')
{{ trans_choice('general.statuses', 1) . ': ' . trans('bills.messages.status.receive.draft') }}

@permission('update-expenses-bills')
<a href="{{ url('expenses/bills/' . $bill->id . '/received') }}" class="btn btn-warning btn-xs">{{ trans('bills.mark_received') }}</a>
@endpermission
@else
{{ trans_choice('general.statuses', 1) . ': ' . trans('bills.messages.status.receive.received', ['date' => Date::parse($bill->created_at)->format($date_format)]) }}
@endif
</div>
</div>
</li>
<li>
<i class="fa fa-money bg-green"></i>

<div class="timeline-item">
<h3 class="timeline-header">{{ trans('general.title.get', ['type' => trans('general.paid')]) }}</h3>

<div class="timeline-body">
@if($bill->status->code != 'paid' && empty($bill->payments()->count()))
{{ trans_choice('general.statuses', 1) . ': ' . trans('bills.messages.status.paid.await') }}
@else
{{ trans_choice('general.statuses', 1) . ': ' . trans('bills.messages.status.paid.partial') }}
@endif

@if(empty($bill->payments()->count()) || (!empty($bill->payments()->count()) && $bill->paid != $bill->amount))
<a href="#" id="button-payment" class="btn btn-success btn-xs">{{ trans('bills.add_payment') }}</a>
@endif
</div>
</div>
</li>
</ul>
</div>
</div>
@endif

<div class="box box-success">
<div class="bill">
<div id="badge">
Expand Down
82 changes: 82 additions & 0 deletions resources/views/incomes/invoices/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,88 @@
</div>
@endif

@if ($invoice->status->code == 'draft')
<div class="callout callout-warning">
<p>{!! trans('invoices.messages.draft') !!}</p>
</div>
@endif

@if ($invoice->status->code != 'paid')
<div class="row show-invoice">
<div class="col-md-12 no-padding-right">
<ul class="timeline">
<li>
<i class="fa fa-plus bg-blue"></i>

<div class="timeline-item">
<h3 class="timeline-header">{{ trans('general.title.create', ['type' => trans_choice('general.invoices', 1)]) }}</h3>

<div class="timeline-body">
{{ trans_choice('general.statuses', 1) . ': ' . trans('invoices.messages.status.created', ['date' => Date::parse($invoice->created_at)->format($date_format)]) }}

<a href="{{ url('incomes/invoices/' . $invoice->id . '/edit') }}" class="btn btn-default btn-xs">
{{ trans('general.edit') }}
</a>
</div>
</div>
</li>
<li>
<i class="fa fa-envelope bg-orange"></i>

<div class="timeline-item">
<h3 class="timeline-header">{{ trans('general.title.send', ['type' => trans_choice('general.invoices', 1)]) }}</h3>

<div class="timeline-body">
@if ($invoice->status->code != 'sent' && $invoice->status->code != 'partial')
{{ trans_choice('general.statuses', 1) . ': ' . trans('invoices.messages.status.send.draft') }}

@permission('update-incomes-invoices')
@if($invoice->invoice_status_code == 'draft')
<a href="{{ url('incomes/invoices/' . $invoice->id . '/sent') }}" class="btn btn-default btn-xs">{{ trans('invoices.mark_sent') }}</a>
@else
<a href="javascript:void(0);" class="disabled btn btn-default btn-xs"><span class="text-disabled"> {{ trans('invoices.mark_sent') }}</span></a>
@endif
@endpermission
@if($invoice->customer_email)
<a href="{{ url('incomes/invoices/' . $invoice->id . '/email') }}" class="btn btn-warning btn-xs">{{ trans('invoices.send_mail') }}</a>
@else
<a href="javascript:void(0);" class="btn btn-warning btn-xs green-tooltip disabled" data-toggle="tooltip" data-placement="right" title="{{ trans('invoices.messages.email_required') }}">
<span class="text-disabled">{{ trans('invoices.send_mail') }}</span>
</a>
@endif
@else
{{ trans_choice('general.statuses', 1) . ': ' . trans('invoices.messages.status.send.sent', ['date' => Date::parse($invoice->created_at)->format($date_format)]) }}
@endif
</div>
</div>
</li>
<li>
<i class="fa fa-money bg-green"></i>

<div class="timeline-item">
<h3 class="timeline-header">{{ trans('general.title.get', ['type' => trans('general.paid')]) }}</h3>

<div class="timeline-body">
@if($invoice->status->code != 'paid' && empty($invoice->payments()->count()))
{{ trans_choice('general.statuses', 1) . ': ' . trans('invoices.messages.status.paid.await') }}
@else
{{ trans_choice('general.statuses', 1) . ': ' . trans('invoices.messages.status.paid.partial') }}
@endif

@permission('update-incomes-invoices')
<a href="{{ url('incomes/invoices/' . $invoice->id . '/pay') }}" class="btn btn-default btn-xs">{{ trans('invoices.mark_paid') }}</a>
@endpermission
@if(empty($invoice->payments()->count()) || (!empty($invoice->payments()->count()) && $invoice->paid != $invoice->amount))
<a href="#" id="button-payment" class="btn btn-success btn-xs">{{ trans('invoices.add_payment') }}</a>
@endif
</div>
</div>
</li>
</ul>
</div>
</div>
@endif

<div class="box box-success">
<section class="invoice">
<div id="badge">
Expand Down

0 comments on commit 66f0e7c

Please sign in to comment.