Browse Source

Change formatNo and formatRp helper name

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

6
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);
}
/**

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'));

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/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>

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

@ -32,7 +32,7 @@
<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-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>

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

@ -44,7 +44,7 @@
<tr>
<td class="text-center">{{ dateId($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',
@ -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>

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

@ -40,7 +40,7 @@
<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-right">{{ format_rp($omzet) }}</td>
<td class="text-center">
{{ link_to_route(
'reports.sales.monthly',
@ -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