Browse Source

Merge branch 'helper_naming_conventions'

pull/20/head
Nafies Luthfi 7 years ago
parent
commit
e69ccb0c88
  1. 35
      app/Helpers/date_time.php
  2. 8
      app/Helpers/helpers.php
  3. 4
      app/Http/Controllers/CartController.php
  4. 6
      app/Http/Controllers/Reports/SalesController.php
  5. 2
      resources/views/backups/index.blade.php
  6. 18
      resources/views/cart/partials/draft-confirm.blade.php
  7. 10
      resources/views/cart/partials/draft-item-list.blade.php
  8. 2
      resources/views/cart/partials/product-search-result-box.blade.php
  9. 4
      resources/views/log-files.blade.php
  10. 4
      resources/views/products/index.blade.php
  11. 4
      resources/views/products/partials/forms.blade.php
  12. 4
      resources/views/products/price-list.blade.php
  13. 10
      resources/views/reports/sales/daily.blade.php
  14. 10
      resources/views/reports/sales/monthly.blade.php
  15. 22
      resources/views/reports/sales/yearly.blade.php
  16. 2
      resources/views/transactions/index.blade.php
  17. 14
      resources/views/transactions/pdf.blade.php
  18. 14
      resources/views/transactions/receipt.blade.php
  19. 18
      resources/views/transactions/show.blade.php
  20. 12
      tests/Feature/TransactionEntryTest.php

35
app/Helpers/date_time.php

@ -1,23 +1,6 @@
<?php
function formatDate($date)
{
if (!$date || $date == '0000-00-00') {
return;
}
$explodedDate = explode('-', $date);
if (count($explodedDate) == 3 && checkdate($explodedDate[1], $explodedDate[0], $explodedDate[2])) {
return $explodedDate[2].'-'.$explodedDate[1].'-'.$explodedDate[0];
} elseif (count($explodedDate) == 3 && checkdate($explodedDate[1], $explodedDate[2], $explodedDate[0])) {
return $explodedDate[2].'-'.$explodedDate[1].'-'.$explodedDate[0];
}
throw new App\Exceptions\InvalidDateException('Invalid date format.');
}
function dateId($date)
function date_id($date)
{
if (is_null($date) || $date == '0000-00-00') {
return '-';
@ -26,7 +9,7 @@ function dateId($date)
$explodedDate = explode('-', $date);
if (count($explodedDate) == 3 && checkdate($explodedDate[1], $explodedDate[2], $explodedDate[0])) {
$months = getMonths();
$months = get_months();
return $explodedDate[2].' '.$months[$explodedDate[1]].' '.$explodedDate[0];
}
@ -34,24 +17,24 @@ function dateId($date)
throw new App\Exceptions\InvalidDateException('Invalid date format.');
}
function monthNumber($number)
function month_number($number)
{
return str_pad($number, 2, '0', STR_PAD_LEFT);
}
function monthId($monthNumber)
function month_id($monthNumber)
{
if (is_null($monthNumber)) {
return $monthNumber;
}
$months = getMonths();
$monthNumber = monthNumber($monthNumber);
$months = get_months();
$monthNumber = month_number($monthNumber);
return $months[$monthNumber];
}
function getMonths()
function get_months()
{
return [
'01' => __('time.months.01'),
@ -69,7 +52,7 @@ function getMonths()
];
}
function getYears()
function get_years()
{
$yearRange = range(2017, date('Y'));
foreach ($yearRange as $year) {
@ -79,7 +62,7 @@ function getYears()
return $years;
}
function monthDateArray($year, $month)
function month_date_array($year, $month)
{
$dateCount = Carbon\Carbon::parse($year.'-'.$month)->format('t');
$dates = [];

8
app/Helpers/helpers.php

@ -1,17 +1,17 @@
<?php
function formatNo($number)
function format_no($number)
{
return number_format($number, 0, ',', '.');
}
function formatRp($number)
function format_rp($number)
{
if ($number == 0) {
return 0;
}
return 'Rp. '.formatNo($number);
return 'Rp. '.format_no($number);
}
/**
@ -31,7 +31,7 @@ function html_link_to_route($name, $title = null, $parameters = [], $attributes
return app('html')->decode(link_to_route($name, $title, $parameters, $attributes));
}
function formatSizeUnits($bytes)
function format_size_units($bytes)
{
if ($bytes >= 1073741824) {
$bytes = number_format($bytes / 1073741824, 2).' GB';

4
app/Http/Controllers/CartController.php

@ -125,8 +125,8 @@ class CartController extends Controller
'payment' => 'required|numeric|min:'.$request->get('total').'|max:'.($request->get('total') + 100000),
'notes' => 'nullable|string|max:100',
], [
'payment.min' => 'Pembayaran minimal '.formatRp($request->get('total')).'.',
'payment.max' => 'Pembayaran terlalu besar '.formatRp($request->get('payment')).'.',
'payment.min' => 'Pembayaran minimal '.format_rp($request->get('total')).'.',
'payment.max' => 'Pembayaran terlalu besar '.format_rp($request->get('payment')).'.',
]);
$draft = $this->cart->updateDraftAttributes($draftKey, $request->only('customer', 'notes', 'payment'));

6
app/Http/Controllers/Reports/SalesController.php

@ -27,8 +27,8 @@ class SalesController extends Controller
public function monthly(Request $request)
{
$years = getYears();
$months = getMonths();
$years = get_years();
$months = get_months();
$year = $request->get('year', date('Y'));
$month = $request->get('month', date('m'));
$reports = $this->getMonthlyReports($year, $month);
@ -41,7 +41,7 @@ class SalesController extends Controller
$year = $request->get('year', date('Y'));
$reports = $this->getYearlyReports($year);
$years = getYears();
$years = get_years();
return view('reports.sales.yearly', compact('reports', 'years', 'year'));
}

2
resources/views/backups/index.blade.php

@ -21,7 +21,7 @@
<tr>
<td>{{ $key + 1 }}</td>
<td>{{ $backup->getFilename() }}</td>
<td>{{ formatSizeUnits($backup->getSize()) }}</td>
<td>{{ format_size_units($backup->getSize()) }}</td>
<td>{{ date('Y-m-d H:i:s', $backup->getMTime()) }}</td>
<td class="text-center">
<a href="{{ route('backups.index', ['action' => 'restore', 'file_name' => $backup->getFilename()]) }}"

18
resources/views/cart/partials/draft-confirm.blade.php

@ -19,10 +19,10 @@
<tr>
<td>{{ $key + 1 }}</td>
<td>{{ $item->name }}</td>
<td class="text-right">{{ formatRp($item->price) }}</td>
<td class="text-right">{{ formatRp($item->item_discount) }}</td>
<td class="text-right">{{ format_rp($item->price) }}</td>
<td class="text-right">{{ format_rp($item->item_discount) }}</td>
<td class="text-center">{{ $item->qty }}</td>
<td class="text-right">{{ formatRp($item->subtotal) }}</td>
<td class="text-right">{{ format_rp($item->subtotal) }}</td>
</tr>
@empty
@endforelse
@ -32,15 +32,15 @@
<th colspan="5" class="text-right">{{ trans('transaction.subtotal') }} :</th>
<th class="text-right">{{ formatRp($draft->getSubtotal()) }}</th>
<th class="text-right">{{ format_rp($draft->getSubtotal()) }}</th>
</tr>
<tr>
<th colspan="5" class="text-right">{{ trans('transaction.discount_total') }} :</th>
<th class="text-right">{{ formatRp($draft->getDiscountTotal()) }}</th>
<th class="text-right">{{ format_rp($draft->getDiscountTotal()) }}</th>
</tr>
<tr>
<th colspan="5" class="text-right">{{ trans('transaction.total') }} :</th>
<th class="text-right">{{ formatRp($draft->getTotal()) }}</th>
<th class="text-right">{{ format_rp($draft->getTotal()) }}</th>
</tr>
</tfoot>
</table>
@ -55,9 +55,9 @@
<tbody>
<tr><td>{{ trans('transaction.customer_name') }}</td><td>{{ $draft->customer['name'] }}</td></tr>
<tr><td>{{ trans('transaction.customer_phone') }}</td><td>{{ $draft->customer['phone'] }}</td></tr>
<tr><td>{{ trans('transaction.payment') }}</td><th class="text-right">{{ formatRp($draft->payment) }}</th></tr>
<tr><td>{{ trans('transaction.total') }}</td><th class="text-right">{{ formatRp($draft->getTotal()) }}</th></tr>
<tr><td>{{ trans('transaction.exchange') }}</td><th class="text-right">{{ formatRp($draft->getExchange()) }}</th></tr>
<tr><td>{{ trans('transaction.payment') }}</td><th class="text-right">{{ format_rp($draft->payment) }}</th></tr>
<tr><td>{{ trans('transaction.total') }}</td><th class="text-right">{{ format_rp($draft->getTotal()) }}</th></tr>
<tr><td>{{ trans('transaction.exchange') }}</td><th class="text-right">{{ format_rp($draft->getExchange()) }}</th></tr>
<tr><td>{{ trans('transaction.notes') }}</td><td>{{ $draft->notes }}</td></tr>
</tbody>
</table>

10
resources/views/cart/partials/draft-item-list.blade.php

@ -27,7 +27,7 @@
{{ $item->name }} <br>
<small class="text-primary">({{ $item->unit }})</small>
</td>
<td>{{ formatRp($item->price) }}</td>
<td>{{ format_rp($item->price) }}</td>
{{ Form::open(['route' => ['cart.update-draft-item', $draft->draftKey], 'method' => 'patch']) }}
{{ Form::hidden('item_key', $key) }}
<td class="text-right">
@ -43,7 +43,7 @@
'min' => 1
]) }}
</td>
<td class="text-right">{{ formatRp($item->subtotal) }}</td>
<td class="text-right">{{ format_rp($item->subtotal) }}</td>
{{ Form::submit('update-item-' . $key, ['style'=>'display:none']) }}
{{ Form::close() }}
<td class="text-center show-on-hover-parent">
@ -60,17 +60,17 @@
<tfoot>
<tr>
<th colspan="5" class="text-right">{{ trans('transaction.subtotal') }} :</th>
<th class="text-right">{{ formatRp($draft->getSubtotal()) }}</th>
<th class="text-right">{{ format_rp($draft->getSubtotal()) }}</th>
<th></th>
</tr>
<tr>
<th colspan="5" class="text-right">{{ trans('transaction.discount_total') }} :</th>
<th class="text-right">{{ formatRp($draft->getDiscountTotal()) }}</th>
<th class="text-right">{{ format_rp($draft->getDiscountTotal()) }}</th>
<th></th>
</tr>
<tr>
<th colspan="5" class="text-right">{{ trans('transaction.total') }} :</th>
<th class="text-right">{{ formatRp($draft->getTotal()) }}</th>
<th class="text-right">{{ format_rp($draft->getTotal()) }}</th>
<th></th>
</tr>
</tfoot>

2
resources/views/cart/partials/product-search-result-box.blade.php

@ -13,7 +13,7 @@
<tr>
<td>{{ $product->name }}</td>
<td>{{ $product->unit->name }}</td>
<td>{{ formatRp($product->getPrice($draftType)) }}</td>
<td>{{ format_rp($product->getPrice($draftType)) }}</td>
<td>
<form action="{{ route('cart.add-draft-item', [$draftKey, $product->id]) }}" method="post" style="display:inline">
<input type="hidden" name="query" value="{{ isset($query) ? $query : request('query') }}">

4
resources/views/log-files.blade.php

@ -20,7 +20,7 @@
<tr>
<td>0</td>
<td>error_log</td>
<td>{{ formatSizeUnits(File::size('error_log')) }}</td>
<td>{{ format_size_units(File::size('error_log')) }}</td>
<td>{{ date('Y-m-d H:i:s', File::lastModified('error_log')) }}</td>
<td>
{!! html_link_to_route('log-files.server-error-log','',[],[
@ -37,7 +37,7 @@
<tr>
<td>{{ $key + 1 }}</td>
<td>{{ $logFile->getFilename() }}</td>
<td>{{ formatSizeUnits($logFile->getSize()) }}</td>
<td>{{ format_size_units($logFile->getSize()) }}</td>
<td>{{ date('Y-m-d H:i:s', $logFile->getMTime()) }}</td>
<td>
{{ link_to_route('log-files.show', 'Lihat', [$logFile->getFilename()],[

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

@ -40,8 +40,8 @@
<td class="text-center">{{ $products->firstItem() + $key }}</td>
<td>{{ $product->name }}</td>
<td>{{ $product->unit->name }}</td>
<td class="text-right">{{ formatRp($product->cash_price) }}</td>
<td class="text-right">{{ formatRp($product->credit_price) }}</td>
<td class="text-right">{{ format_rp($product->cash_price) }}</td>
<td class="text-right">{{ format_rp($product->credit_price) }}</td>
<td class="text-center">
{!! link_to_route('products.index', __('app.edit'), ['action' => 'edit', 'id' => $product->id] + request(['page','q']), ['id' => 'edit-product-' . $product->id]) !!} |
{!! link_to_route('products.index', __('app.delete'), ['action' => 'delete', 'id' => $product->id] + request(['page','q']), ['id' => 'del-product-' . $product->id]) !!}

4
resources/views/products/partials/forms.blade.php

@ -37,8 +37,8 @@
<tbody>
<tr><th>{{ __('product.name') }}</th><td>{{ $editableProduct->name }}</td></tr>
<tr><th>{{ __('product.unit') }}</th><td>{{ $editableProduct->unit->name }}</td></tr>
<tr><th>{{ __('product.cash_price') }}</th><td>{{ formatRp($editableProduct->cash_price) }}</td></tr>
<tr><th>{{ __('product.credit_price') }}</th><td>{{ formatRp($editableProduct->credit_price) }}</td></tr>
<tr><th>{{ __('product.cash_price') }}</th><td>{{ format_rp($editableProduct->cash_price) }}</td></tr>
<tr><th>{{ __('product.credit_price') }}</th><td>{{ format_rp($editableProduct->credit_price) }}</td></tr>
</tbody>
</table>
<hr>

4
resources/views/products/price-list.blade.php

@ -22,8 +22,8 @@
@foreach($chunckedProducts as $key => $product)
<tr>
<td>{{ $key + 1 }})&nbsp;{{ $product->name }} ({{ $product->unit->name }})</td>
<td class="text-right" style="width:20%">{{ formatRp($product->cash_price) }}</td>
<td class="text-right" style="width:20%">{{ formatRp($product->credit_price) }}</td>
<td class="text-right" style="width:20%">{{ format_rp($product->cash_price) }}</td>
<td class="text-right" style="width:20%">{{ format_rp($product->credit_price) }}</td>
</tr>
@endforeach
</tbody>

10
resources/views/reports/sales/daily.blade.php

@ -1,6 +1,6 @@
@extends('layouts.app')
@section('title', __('report.daily', ['date' => dateId($date)]))
@section('title', __('report.daily', ['date' => date_id($date)]))
@section('content')
@ -14,7 +14,7 @@
{{ link_to_route(
'reports.sales.monthly',
__('report.view_monthly'),
['month' => monthNumber($dt->month), 'year' => $dt->year],
['month' => month_number($dt->month), 'year' => $dt->year],
['class' => 'btn btn-default btn-sm']
) }}
{{ Form::close() }}
@ -31,8 +31,8 @@
@forelse($transactions as $key => $transaction)
<tr>
<td class="text-center">{{ 1 + $key }}</td>
<td class="text-center">{{ dateId($transaction->created_at->format('Y-m-d')) }}</td>
<td class="text-right">{{ formatRp($transaction->total) }}</td>
<td class="text-center">{{ date_id($transaction->created_at->format('Y-m-d')) }}</td>
<td class="text-right">{{ format_rp($transaction->total) }}</td>
<td class="text-center">
{{ link_to_route(
'transactions.show',
@ -53,7 +53,7 @@
<tfoot>
<tr>
<th class="text-right" colspan="2">{{ __('app.total') }}</th>
<th class="text-right">{{ formatRp($transactions->sum('total')) }}</th>
<th class="text-right">{{ format_rp($transactions->sum('total')) }}</th>
<th>&nbsp;</th>
</tr>
</tfoot>

10
resources/views/reports/sales/monthly.blade.php

@ -34,7 +34,7 @@
</thead>
<tbody>
@php $chartData = []; @endphp
@foreach(monthDateArray($year, $month) as $dateNumber)
@foreach(month_date_array($year, $month) as $dateNumber)
@php
$any = isset($reports[$dateNumber]);
$count = $any ? $reports[$dateNumber]->count : 0;
@ -42,9 +42,9 @@
@endphp
@if ($any)
<tr>
<td class="text-center">{{ dateId($date = $year.'-'.$month.'-'.$dateNumber) }}</td>
<td class="text-center">{{ date_id($date = $year.'-'.$month.'-'.$dateNumber) }}</td>
<td class="text-center">{{ $count }}</td>
<td class="text-right">{{ formatRp($subtotal) }}</td>
<td class="text-right">{{ format_rp($subtotal) }}</td>
<td class="text-center">
{{ link_to_route(
'reports.sales.daily',
@ -52,7 +52,7 @@
['date' => $date],
[
'class' => 'btn btn-info btn-xs',
'title' => __('report.daily', ['date' => dateId($date)]),
'title' => __('report.daily', ['date' => date_id($date)]),
]
) }}
</td>
@ -67,7 +67,7 @@
<tr>
<th class="text-right">{{ __('app.total') }}</th>
<th class="text-center">{{ $reports->sum('count') }}</th>
<th class="text-right">{{ formatRp($reports->sum('amount')) }}</th>
<th class="text-right">{{ format_rp($reports->sum('amount')) }}</th>
<td>&nbsp;</td>
</tr>
</tfoot>

22
resources/views/reports/sales/yearly.blade.php

@ -32,30 +32,30 @@
</thead>
<tbody>
@php $chartData = []; @endphp
@foreach(getMonths() as $monthNumber => $monthName)
@foreach(get_months() as $month_number => $monthName)
@php
$any = isset($reports[$monthNumber]);
$omzet = $any ? $reports[$monthNumber]->omzet : 0
$any = isset($reports[$month_number]);
$omzet = $any ? $reports[$month_number]->omzet : 0
@endphp
<tr>
<td class="text-center">{{ monthId($monthNumber) }}</td>
<td class="text-center">{{ $any ? $reports[$monthNumber]->count : 0 }}</td>
<td class="text-right">{{ formatRp($omzet) }}</td>
<td class="text-center">{{ month_id($month_number) }}</td>
<td class="text-center">{{ $any ? $reports[$month_number]->count : 0 }}</td>
<td class="text-right">{{ format_rp($omzet) }}</td>
<td class="text-center">
{{ link_to_route(
'reports.sales.monthly',
__('report.view_monthly'),
['month' => $monthNumber, 'year' => $year],
['month' => $month_number, 'year' => $year],
[
'class' => 'btn btn-info btn-xs',
'title' => __('report.monthly', ['year_month' => monthId($monthNumber)]),
'title' => __('report.monthly', ['year_month' => monthId($monthNumber).' '.$year]),
'title' => __('report.monthly', ['year_month' => month_id($month_number)]),
'title' => __('report.monthly', ['year_month' => month_id($month_number).' '.$year]),
]
) }}
</td>
</tr>
@php
$chartData[] = ['month' => monthId($monthNumber), 'value' => $omzet];
$chartData[] = ['month' => month_id($month_number), 'value' => $omzet];
@endphp
@endforeach
</tbody>
@ -63,7 +63,7 @@
<tr>
<th class="text-center">{{ trans('app.total') }}</th>
<th class="text-center">{{ $reports->sum('count') }}</th>
<th class="text-right">{{ formatRp($reports->sum('omzet')) }}</th>
<th class="text-right">{{ format_rp($reports->sum('omzet')) }}</th>
<td>&nbsp;</td>
</tr>
</tfoot>

2
resources/views/transactions/index.blade.php

@ -51,7 +51,7 @@
{{ $transaction->customer['phone'] ? '(' . $transaction->customer['phone'] . ')' : '' }}
</td>
<td>{{ $transaction->items_count }}</td>
<td class="text-right">{{ formatRp($transaction->total) }}</td>
<td class="text-right">{{ format_rp($transaction->total) }}</td>
<td class="text-center">
{{ link_to_route('transactions.show', trans('app.show'), $transaction->invoice_no) }} |
{{ link_to_route('transactions.receipt', trans('app.print'), $transaction->invoice_no) }}

14
resources/views/transactions/pdf.blade.php

@ -47,32 +47,32 @@
<tr>
<td class="text-center border-bottom">{{ $item['qty'] }}</td>
<td class="text-right border-bottom">
{{ formatRp($item['price']) }}<br>({{ formatRp($item['item_discount']) }})
{{ format_rp($item['price']) }}<br>({{ format_rp($item['item_discount']) }})
</td>
<td class="text-right border-bottom">{{ formatRp($item['subtotal']) }}</td>
<td class="text-right border-bottom">{{ format_rp($item['subtotal']) }}</td>
</tr>
<?php $discountTotal += $item['item_discount_subtotal'] ?>
@endforeach
@if ($loop->last && $loop->parent->last)
<tr>
<th colspan="2" class="text-right">{{ trans('transaction.subtotal') }} :</th>
<th class="text-right">{{ formatRp($transaction['total'] + $discountTotal) }}</th>
<th class="text-right">{{ format_rp($transaction['total'] + $discountTotal) }}</th>
</tr>
<tr>
<th colspan="2" class="text-right">{{ trans('transaction.discount_total') }} :</th>
<th class="text-right">{{ formatRp($discountTotal) }}</th>
<th class="text-right">{{ format_rp($discountTotal) }}</th>
</tr>
<tr>
<th colspan="2" class="text-right">{{ trans('transaction.total') }} :</th>
<th class="text-right">{{ formatRp($transaction['total']) }}</th>
<th class="text-right">{{ format_rp($transaction['total']) }}</th>
</tr>
<tr>
<th colspan="2" class="text-right">{{ trans('transaction.payment') }} :</th>
<th class="text-right">{{ formatRp($transaction->payment) }}</th>
<th class="text-right">{{ format_rp($transaction->payment) }}</th>
</tr>
<tr>
<th colspan="2" class="text-right">{{ trans('transaction.exchange') }} :</th>
<th class="text-right">{{ formatRp($transaction->getExchange()) }}</th>
<th class="text-right">{{ format_rp($transaction->getExchange()) }}</th>
</tr>
@endif
</tbody>

14
resources/views/transactions/receipt.blade.php

@ -53,31 +53,31 @@
<tr>
<td class="text-center border-bottom" style="vertical-align: top;">{{ $item['qty'] }}</td>
<td class="text-right border-bottom">
{{ formatRp($item['price']) }} ({{ formatRp($item['item_discount']) }})
{{ format_rp($item['price']) }} ({{ format_rp($item['item_discount']) }})
</td>
<td class="text-right border-bottom">{{ formatRp($item['subtotal']) }}</td>
<td class="text-right border-bottom">{{ format_rp($item['subtotal']) }}</td>
</tr>
<?php $discountTotal += $item['item_discount_subtotal'] ?>
@endforeach
<tr>
<th colspan="2" class="text-right">{{ trans('transaction.subtotal') }} :</th>
<th class="text-right">{{ formatRp($transaction['total'] + $discountTotal) }}</th>
<th class="text-right">{{ format_rp($transaction['total'] + $discountTotal) }}</th>
</tr>
<tr>
<th colspan="2" class="text-right">{{ trans('transaction.discount_total') }} :</th>
<th class="text-right">{{ formatRp($discountTotal) }}</th>
<th class="text-right">{{ format_rp($discountTotal) }}</th>
</tr>
<tr>
<th colspan="2" class="text-right">{{ trans('transaction.total') }} :</th>
<th class="text-right">{{ formatRp($transaction['total']) }}</th>
<th class="text-right">{{ format_rp($transaction['total']) }}</th>
</tr>
<tr>
<th colspan="2" class="text-right">{{ trans('transaction.payment') }} :</th>
<th class="text-right">{{ formatRp($transaction->payment) }}</th>
<th class="text-right">{{ format_rp($transaction->payment) }}</th>
</tr>
<tr>
<th colspan="2" class="text-right">{{ trans('transaction.exchange') }} :</th>
<th class="text-right">{{ formatRp($transaction->getExchange()) }}</th>
<th class="text-right">{{ format_rp($transaction->getExchange()) }}</th>
</tr>
</tbody>
</table>

18
resources/views/transactions/show.blade.php

@ -20,9 +20,9 @@
<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>
<tr><td>{{ trans('transaction.total') }}</td><td class="text-right strong">{{ format_rp($transaction->total) }}</td></tr>
<tr><td>{{ trans('transaction.payment') }}</td><td class="text-right">{{ format_rp($transaction->payment) }}</td></tr>
<tr><td>{{ trans('transaction.exchange') }}</td><td class="text-right">{{ format_rp($transaction->getExchange()) }}</td></tr>
</tbody>
</table>
</div>
@ -52,10 +52,10 @@
{{ $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-right">{{ format_rp($item['price']) }}</td>
<td class="text-right">{{ format_rp($item['item_discount']) }}</td>
<td class="text-center">{{ $item['qty'] }}</td>
<td class="text-right">{{ formatRp($item['subtotal']) }}</td>
<td class="text-right">{{ format_rp($item['subtotal']) }}</td>
</tr>
<?php $discountTotal += $item['item_discount_subtotal'] ?>
@endforeach
@ -63,15 +63,15 @@
<tfoot>
<tr>
<th colspan="5" class="text-right">{{ trans('transaction.subtotal') }} :</th>
<th class="text-right">{{ formatRp($transaction['total'] + $discountTotal) }}</th>
<th class="text-right">{{ format_rp($transaction['total'] + $discountTotal) }}</th>
</tr>
<tr>
<th colspan="5" class="text-right">{{ trans('transaction.discount_total') }} :</th>
<th class="text-right">{{ formatRp($discountTotal) }}</th>
<th class="text-right">{{ format_rp($discountTotal) }}</th>
</tr>
<tr>
<th colspan="5" class="text-right">{{ trans('transaction.total') }} :</th>
<th class="text-right">{{ formatRp($transaction['total']) }}</th>
<th class="text-right">{{ format_rp($transaction['total']) }}</th>
</tr>
</tfoot>
</table>

12
tests/Feature/TransactionEntryTest.php

@ -67,7 +67,7 @@ class TransactionEntryTest extends BrowserKitTestCase
$this->seePageIs(route('cart.show', [$draft->draftKey, 'query' => 'testing']));
// See product list appears
$this->see($product->name);
$this->see(formatRp($product->credit_price));
$this->see(format_rp($product->credit_price));
$this->seeElement('form', ['action' => route('cart.add-draft-item', [$draft->draftKey, $product->id])]);
$this->seeElement('input', ['id' => 'qty-'.$product->id, 'name' => 'qty']);
$this->seeElement('input', ['id' => 'add-product-'.$product->id]);
@ -110,7 +110,7 @@ class TransactionEntryTest extends BrowserKitTestCase
$this->seeElement('input', ['id' => 'qty-'. 0]);
$this->seeElement('input', ['id' => 'item_discount-'. 0]);
$this->seeElement('button', ['id' => 'remove-item-'. 0]);
$this->see(formatRp(3800));
$this->see(format_rp(3800));
}
/** @test */
@ -173,8 +173,8 @@ class TransactionEntryTest extends BrowserKitTestCase
$this->assertEquals(6000, $draft->getSubtotal());
$this->assertEquals(5600, $draft->getTotal());
$this->see(formatRp($draft->getSubtotal()));
$this->see(formatRp($draft->getTotal()));
$this->see(format_rp($draft->getSubtotal()));
$this->see(format_rp($draft->getTotal()));
}
/** @test */
@ -208,8 +208,8 @@ class TransactionEntryTest extends BrowserKitTestCase
$this->see($draft->customer['name']);
$this->see($draft->customer['phone']);
$this->see($draft->notes);
$this->see(formatRp(10000));
$this->see(formatRp(3000));
$this->see(format_rp(10000));
$this->see(format_rp(3000));
$this->seeElement('input', ['id' => 'save-transaction-draft']);
}

Loading…
Cancel
Save