Browse Source
Added transactions index and show page
Added transactions index and show page
Added redirection to transaction show page after transaction has created Prepared for transaction print (A4 PDF)pull/4/head
13 changed files with 238 additions and 6 deletions
-
2app/Helpers/helpers.php
-
2app/Http/Controllers/CartController.php
-
20app/Http/Controllers/TransactionsController.php
-
19app/Transaction.php
-
2database/migrations/2017_04_27_121204_create_transactions_table.php
-
4resources/lang/id/product.php
-
4resources/lang/id/transaction.php
-
9resources/views/layouts/partials/top-nav.blade.php
-
41resources/views/transactions/index.blade.php
-
78resources/views/transactions/show.blade.php
-
7routes/web.php
-
2tests/Feature/TransactionEntryTest.php
-
54tests/Unit/Integration/TransactionTest.php
@ -0,0 +1,20 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Http\Controllers; |
||||
|
|
||||
|
use App\Transaction; |
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
|
class TransactionsController extends Controller |
||||
|
{ |
||||
|
public function index(Request $request) |
||||
|
{ |
||||
|
$transactions = Transaction::orderBy('invoice_no','desc')->paginate(24); |
||||
|
return view('transactions.index', compact('transactions')); |
||||
|
} |
||||
|
|
||||
|
public function show(Transaction $transaction) |
||||
|
{ |
||||
|
return view('transactions.show', compact('transaction')); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
@extends('layouts.app') |
||||
|
|
||||
|
@section('title', trans('transaction.list')) |
||||
|
|
||||
|
@section('content') |
||||
|
<div class="panel panel-default"> |
||||
|
<div class="panel-heading"><h3 class="panel-title">{{ trans('transaction.list') }}</h3></div> |
||||
|
<div class="panel-body"> |
||||
|
<table class="table table-condensed"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>{{ trans('app.table_no') }}</th> |
||||
|
<th>{{ trans('transaction.invoice_no') }}</th> |
||||
|
<th>{{ trans('app.date') }}</th> |
||||
|
<th>{{ trans('transaction.customer') }}</th> |
||||
|
<th>{{ trans('transaction.items_count') }}</th> |
||||
|
<th class="text-right">{{ trans('transaction.total') }}</th> |
||||
|
<th>{{ trans('app.action') }}</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
@forelse($transactions as $key => $transaction) |
||||
|
<tr> |
||||
|
<td>{{ 1 + $key }}</td> |
||||
|
<td>{{ $transaction->invoice_no }}</td> |
||||
|
<td>{{ $transaction->created_at->format('Y-m-d') }}</td> |
||||
|
<td>{{ $transaction->customer['name'] }}</td> |
||||
|
<td>{{ $transaction->items_count }}</td> |
||||
|
<td class="text-right">{{ formatRp($transaction->total) }}</td> |
||||
|
<td> |
||||
|
{{ link_to_route('transactions.show', trans('app.show'), $transaction->invoice_no) }} | |
||||
|
{{ link_to_route('transactions.pdf', trans('app.print'), $transaction->invoice_no) }} |
||||
|
</td> |
||||
|
</tr> |
||||
|
@empty |
||||
|
@endforelse |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
@endsection |
||||
@ -0,0 +1,78 @@ |
|||||
|
@extends('layouts.app') |
||||
|
|
||||
|
@section('title', trans('transaction.detail')) |
||||
|
|
||||
|
@section('content') |
||||
|
<h3 class="page-header">{{ $transaction->invoice_no }} <small>{{ trans('transaction.detail') }}</small></h3> |
||||
|
<div class="row"> |
||||
|
<div class="col-sm-4"> |
||||
|
<div class="panel panel-default"> |
||||
|
<div class="panel-heading"><h3 class="panel-title">{{ trans('transaction.detail') }}</h3></div> |
||||
|
<div class="panel-body"> |
||||
|
<table class="table table-condensed"> |
||||
|
<tbody> |
||||
|
<tr><td>{{ trans('transaction.invoice_no') }}</td><td class="text-primary strong">{{ $transaction->invoice_no }}</td></tr> |
||||
|
<tr><td>{{ trans('app.date') }}</td><td>{{ $transaction->created_at->format('Y-m-d') }}</td></tr> |
||||
|
<tr><td>{{ trans('transaction.customer_name') }}</td><td>{{ $transaction->customer['name'] }}</td></tr> |
||||
|
<tr><td>{{ trans('transaction.customer_phone') }}</td><td>{{ $transaction->customer['phone'] }}</td></tr> |
||||
|
<tr><td>{{ trans('transaction.items_count') }}</td><td>{{ $transaction->items_count }}</td></tr> |
||||
|
<tr><td>{{ trans('transaction.total') }}</td><td class="text-right strong">{{ formatRp($transaction->total) }}</td></tr> |
||||
|
<tr><td>{{ trans('transaction.payment') }}</td><td class="text-right">{{ formatRp($transaction->payment) }}</td></tr> |
||||
|
<tr><td>{{ trans('transaction.exchange') }}</td><td class="text-right">{{ formatRp($transaction->getExchange()) }}</td></tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-sm-8"> |
||||
|
<div class="panel panel-default"> |
||||
|
<div class="panel-heading"><h3 class="panel-title">{{ trans('transaction.items') }}</h3></div> |
||||
|
<div class="panel-body"> |
||||
|
<table class="table table-condensed"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>{{ trans('app.table_no') }}</th> |
||||
|
<th>{{ trans('product.name') }}</th> |
||||
|
<th class="text-right">{{ trans('product.item_price') }}</th> |
||||
|
<th class="text-right">{{ trans('product.item_discount') }}</th> |
||||
|
<th class="text-center">{{ trans('product.item_qty') }}</th> |
||||
|
<th class="text-right">{{ trans('product.item_subtotal') }}</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<?php $discountTotal = 0; ?>
|
||||
|
@foreach($transaction->items as $key => $item) |
||||
|
<tr> |
||||
|
<td>{{ $key + 1 }}</td> |
||||
|
<td> |
||||
|
{{ $item['name'] }} <br> |
||||
|
<small class="text-primary">({{ $item['unit'] }})</small> |
||||
|
</td> |
||||
|
<td class="text-right">{{ formatRp($item['price']) }}</td> |
||||
|
<td class="text-right">{{ formatRp($item['item_discount']) }}</td> |
||||
|
<td class="text-center">{{ $item['qty'] }}</td> |
||||
|
<td class="text-right">{{ formatRp($item['subtotal']) }}</td> |
||||
|
</tr> |
||||
|
<?php $discountTotal = $transaction['item_discount_subtotal'] ?>
|
||||
|
@endforeach |
||||
|
</tbody> |
||||
|
<tfoot> |
||||
|
<tr> |
||||
|
<th colspan="5" class="text-right">{{ trans('transaction.subtotal') }} :</th> |
||||
|
<th class="text-right">{{ formatRp($transaction['total'] + $discountTotal) }}</th> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<th colspan="5" class="text-right">{{ trans('transaction.discount_total') }} :</th> |
||||
|
<th class="text-right">{{ formatRp($discountTotal) }}</th> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<th colspan="5" class="text-right">{{ trans('transaction.total') }} :</th> |
||||
|
<th class="text-right">{{ formatRp($transaction['total']) }}</th> |
||||
|
</tr> |
||||
|
</tfoot> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
@endsection |
||||
@ -0,0 +1,54 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests\Unit\Integration; |
||||
|
|
||||
|
use App\Transaction; |
||||
|
use Illuminate\Foundation\Testing\DatabaseMigrations; |
||||
|
use Tests\TestCase; |
||||
|
|
||||
|
class TransactionTest extends TestCase |
||||
|
{ |
||||
|
use DatabaseMigrations; |
||||
|
|
||||
|
/** @test */ |
||||
|
public function it_has_items_count_attribute() |
||||
|
{ |
||||
|
$transaction = new Transaction; |
||||
|
|
||||
|
$items = [ |
||||
|
[ |
||||
|
'id' => '1', |
||||
|
'name' => 'Test Item', |
||||
|
'unit' => 'Test unit', |
||||
|
'price' => 1000, |
||||
|
'qty' => 2, |
||||
|
'item_discount' => 0, |
||||
|
'item_discount_subtotal' => 0, |
||||
|
'subtotal' => 2000, |
||||
|
], |
||||
|
[ |
||||
|
'id' => '2', |
||||
|
'name' => 'Test Item 2', |
||||
|
'unit' => 'Test unit', |
||||
|
'price' => 1000, |
||||
|
'qty' => 3, |
||||
|
'item_discount' => 0, |
||||
|
'item_discount_subtotal' => 0, |
||||
|
'subtotal' => 2000, |
||||
|
], |
||||
|
]; |
||||
|
$transaction->items = $items; |
||||
|
|
||||
|
$this->assertEquals('2 Item, 5 Pcs', $transaction->items_count); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function it_has_get_exchange_method() |
||||
|
{ |
||||
|
$transaction = new Transaction; |
||||
|
$transaction->payment = 100000; |
||||
|
$transaction->total = 90000; |
||||
|
|
||||
|
$this->assertEquals(10000, $transaction->getExchange()); |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue