Browse Source

Add invoice index page

pull/3/head
Nafies Luthfi 8 years ago
parent
commit
ce269376d9
  1. 3
      app/Entities/Invoices/Invoice.php
  2. 7
      app/Http/Controllers/InvoicesController.php
  3. 2
      resources/views/invoice-drafts/index.blade.php
  4. 56
      resources/views/invoices/index.blade.php
  5. 1
      resources/views/layouts/partials/sidebar.blade.php
  6. 4
      resources/views/payments/index.blade.php
  7. 6
      resources/views/projects/invoices.blade.php
  8. 1
      routes/web/invoices.php
  9. 2
      tests/Feature/Invoices/InvoiceEntryTest.php
  10. 19
      tests/Feature/Invoices/ManageInvoiceTest.php

3
app/Entities/Invoices/Invoice.php

@ -11,6 +11,7 @@ class Invoice extends Model
protected $guarded = ['id', 'created_at', 'updated_at'];
protected $casts = ['items' => 'array'];
protected $perPage = 25;
public function getRouteKeyName()
{
@ -33,7 +34,7 @@ class Invoice extends Model
$lastInvoice = $this->orderBy('number', 'desc')->first();
if ( ! is_null($lastInvoice)) {
if (!is_null($lastInvoice)) {
$lastInvoiceNo = $lastInvoice->number;
if (substr($lastInvoiceNo, 0, 4) == $prefix) {
return ++$lastInvoiceNo;

7
app/Http/Controllers/InvoicesController.php

@ -11,6 +11,13 @@ use App\Entities\Invoices\Invoice;
*/
class InvoicesController extends Controller
{
public function index()
{
$invoices = Invoice::paginate();
return view('invoices.index', compact('invoices'));
}
public function show(Invoice $invoice)
{
return view('invoices.show', compact('invoice'));

2
resources/views/invoice-drafts/index.blade.php

@ -6,7 +6,7 @@
<h1 class="page-header">
<div class="pull-right">
{!! FormField::formButton(['route' => 'invoice-drafts.create'], trans('invoice.create'), [
'class' => 'btn btn-default',
'class' => 'btn btn-success',
'name' => 'create-invoice-draft',
'id' => 'invoice-draft-create-button'
] ) !!}

56
resources/views/invoices/index.blade.php

@ -0,0 +1,56 @@
@extends('layouts.app')
@section('title', trans('invoice.list'))
@section('content')
<h1 class="page-header">
<div class="pull-right">
{!! FormField::formButton(['route' => 'invoice-drafts.create'], trans('invoice.create'), [
'class' => 'btn btn-success',
'name' => 'create-invoice-draft',
'id' => 'invoice-draft-create-button'
]) !!}
</div>
{{ trans('invoice.list') }}
</h1>
<div class="panel panel-default">
<table class="table table-condensed">
<thead>
<th class="text-center">{{ trans('app.table_no') }}</th>
<th class="col-md-2 text-center">{{ trans('invoice.number') }}</th>
<th class="col-md-2 text-center">{{ trans('app.date') }}</th>
<th class="col-md-2">{{ trans('project.project') }}</th>
<th class="col-md-2">{{ trans('invoice.customer') }}</th>
<th class="col-md-2 text-right">{{ trans('invoice.amount') }}</th>
<th class="col-md-2 text-center">{{ trans('app.action') }}</th>
</thead>
<tbody>
@forelse($invoices as $key => $invoice)
<tr>
<td class="text-center">{{ 1 + $key }}</td>
<td class="text-center">{{ $invoice->number }}</td>
<td class="text-center">{{ $invoice->created_at->format('Y-m-d') }}</td>
<td>{{ $invoice->project->nameLink() }}</td>
<td>{{ $invoice->project->customer->nameLink() }}</td>
<td class="text-right">{{ formatRp($invoice->amount) }}</td>
<td class="text-center">
{!! html_link_to_route('invoices.show', '', [$invoice->number], ['class' => 'btn btn-info btn-xs','icon' => 'search','title' => 'Lihat ' . trans('invoice.show')]) !!}
{!! html_link_to_route('invoices.pdf', '', [$invoice->number], ['class' => 'btn btn-default btn-xs','icon' => 'print','title' => trans('invoice.print'), 'target' => '_blank']) !!}
</td>
</tr>
@empty
<tr><td colspan="7">{{ trans('invoice.empty') }}</td></tr>
@endforelse
</tbody>
<tfoot>
<tr>
<th colspan="5" class="text-right">{{ trans('app.total') }}</th>
<th class="text-right">{{ formatRp($invoices->sum('amount')) }}</th>
<th></th>
</tr>
</tfoot>
</table>
</div>
@endsection

1
resources/views/layouts/partials/sidebar.blade.php

@ -25,6 +25,7 @@
<li>{!! html_link_to_route('reports.current-credits', 'Piutang', [], ['icon' => 'money']) !!}</li>
<li>{!! html_link_to_route('users.calendar', 'Calendar', [], ['icon' => 'calendar']) !!}</li>
<li>{!! html_link_to_route('subscriptions.index', trans('subscription.subscription'), [], ['icon' => 'retweet']) !!}</li>
<li>{!! html_link_to_route('invoices.index', trans('invoice.list'), [], ['icon' => 'table']) !!}</li>
<li>{!! html_link_to_route('payments.index', trans('payment.payments'), [], ['icon' => 'money']) !!}</li>
<li>{!! html_link_to_route('customers.index', trans('customer.list'), [], ['icon' => 'users']) !!}</li>
<li>{!! html_link_to_route('vendors.index', trans('vendor.list'), [], ['icon' => 'users']) !!}</li>

4
resources/views/payments/index.blade.php

@ -4,7 +4,9 @@
@section('content')
<h1 class="page-header">
{!! link_to_route('payments.create', trans('payment.create'), [], ['class'=>'btn btn-success pull-right']) !!}
<div class="pull-right">
{!! link_to_route('payments.create', trans('payment.create'), [], ['class'=>'btn btn-success']) !!}
</div>
{{ trans('payment.payments') }} <small>{{ $payments->total() }} {{ trans('payment.found') }}</small>
</h1>
<div class="well well-sm text-right">

6
resources/views/projects/invoices.blade.php

@ -7,11 +7,11 @@
<h1 class="page-header">
<div class="pull-right">
{!! FormField::formButton(['route' => 'invoice-drafts.store'], trans('invoice.create'), [
'class' => 'btn btn-default',
{!! FormField::formButton(['route' => 'invoice-drafts.create'], trans('invoice.create'), [
'class' => 'btn btn-success',
'name' => 'create-invoice-draft',
'id' => 'invoice-draft-create-button'
] ) !!}
]) !!}
</div>
{{ $project->name }} <small>{{ trans('project.invoices') }}</small>
</h1>

1
routes/web/invoices.php

@ -19,6 +19,7 @@ Route::group(['middleware' => ['web', 'role:admin']], function () {
/*
* Invoices Routes
*/
Route::get('invoices', ['as' => 'invoices.index', 'uses' => 'InvoicesController@index']);
Route::get('invoices/{invoice}', ['as' => 'invoices.show', 'uses' => 'InvoicesController@show']);
Route::get('invoices/{invoice}/pdf', ['as' => 'invoices.pdf', 'uses' => 'InvoicesController@pdf']);
});

2
tests/Feature/InvoiceEntryTest.php → tests/Feature/Invoices/InvoiceEntryTest.php

@ -1,6 +1,6 @@
<?php
namespace Tests\Feature;
namespace Tests\Feature\Invoices;
use App\Entities\Partners\Customer;
use App\Entities\Projects\Project;

19
tests/Feature/Invoices/ManageInvoiceTest.php

@ -0,0 +1,19 @@
<?php
namespace Tests\Feature\Invoices;
use Tests\TestCase;
class ManageInvoiceTest extends TestCase
{
/** @test */
public function user_can_browse_invoice_list_page()
{
$this->adminUserSigningIn();
$this->visit(route('invoices.index'));
$this->seePageIs(route('invoices.index'));
$this->see(trans('invoice.list'));
}
}
Loading…
Cancel
Save