diff --git a/app/Helpers/date_time.php b/app/Helpers/date_time.php index 19963b7..dea70f1 100644 --- a/app/Helpers/date_time.php +++ b/app/Helpers/date_time.php @@ -1,23 +1,6 @@ __('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 = []; diff --git a/app/Helpers/helpers.php b/app/Helpers/helpers.php index d2a0006..8b2dbd0 100644 --- a/app/Helpers/helpers.php +++ b/app/Helpers/helpers.php @@ -1,17 +1,17 @@ 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'; diff --git a/app/Http/Controllers/CartController.php b/app/Http/Controllers/CartController.php index fb586a0..7397693 100644 --- a/app/Http/Controllers/CartController.php +++ b/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')); diff --git a/app/Http/Controllers/Reports/SalesController.php b/app/Http/Controllers/Reports/SalesController.php index 84174df..d3e2aaf 100755 --- a/app/Http/Controllers/Reports/SalesController.php +++ b/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')); } diff --git a/resources/views/backups/index.blade.php b/resources/views/backups/index.blade.php index 745e233..2848ff7 100644 --- a/resources/views/backups/index.blade.php +++ b/resources/views/backups/index.blade.php @@ -21,7 +21,7 @@ {{ $key + 1 }} {{ $backup->getFilename() }} - {{ formatSizeUnits($backup->getSize()) }} + {{ format_size_units($backup->getSize()) }} {{ date('Y-m-d H:i:s', $backup->getMTime()) }} {{ $key + 1 }} {{ $item->name }} - {{ formatRp($item->price) }} - {{ formatRp($item->item_discount) }} + {{ format_rp($item->price) }} + {{ format_rp($item->item_discount) }} {{ $item->qty }} - {{ formatRp($item->subtotal) }} + {{ format_rp($item->subtotal) }} @empty @endforelse @@ -32,15 +32,15 @@ {{ trans('transaction.subtotal') }} : - {{ formatRp($draft->getSubtotal()) }} + {{ format_rp($draft->getSubtotal()) }} {{ trans('transaction.discount_total') }} : - {{ formatRp($draft->getDiscountTotal()) }} + {{ format_rp($draft->getDiscountTotal()) }} {{ trans('transaction.total') }} : - {{ formatRp($draft->getTotal()) }} + {{ format_rp($draft->getTotal()) }} @@ -55,9 +55,9 @@ {{ trans('transaction.customer_name') }}{{ $draft->customer['name'] }} {{ trans('transaction.customer_phone') }}{{ $draft->customer['phone'] }} - {{ trans('transaction.payment') }}{{ formatRp($draft->payment) }} - {{ trans('transaction.total') }}{{ formatRp($draft->getTotal()) }} - {{ trans('transaction.exchange') }}{{ formatRp($draft->getExchange()) }} + {{ trans('transaction.payment') }}{{ format_rp($draft->payment) }} + {{ trans('transaction.total') }}{{ format_rp($draft->getTotal()) }} + {{ trans('transaction.exchange') }}{{ format_rp($draft->getExchange()) }} {{ trans('transaction.notes') }}{{ $draft->notes }} diff --git a/resources/views/cart/partials/draft-item-list.blade.php b/resources/views/cart/partials/draft-item-list.blade.php index 7029cae..40b9a9c 100644 --- a/resources/views/cart/partials/draft-item-list.blade.php +++ b/resources/views/cart/partials/draft-item-list.blade.php @@ -27,7 +27,7 @@ {{ $item->name }}
({{ $item->unit }}) - {{ formatRp($item->price) }} + {{ format_rp($item->price) }} {{ Form::open(['route' => ['cart.update-draft-item', $draft->draftKey], 'method' => 'patch']) }} {{ Form::hidden('item_key', $key) }} @@ -43,7 +43,7 @@ 'min' => 1 ]) }} - {{ formatRp($item->subtotal) }} + {{ format_rp($item->subtotal) }} {{ Form::submit('update-item-' . $key, ['style'=>'display:none']) }} {{ Form::close() }} @@ -60,17 +60,17 @@ {{ trans('transaction.subtotal') }} : - {{ formatRp($draft->getSubtotal()) }} + {{ format_rp($draft->getSubtotal()) }} {{ trans('transaction.discount_total') }} : - {{ formatRp($draft->getDiscountTotal()) }} + {{ format_rp($draft->getDiscountTotal()) }} {{ trans('transaction.total') }} : - {{ formatRp($draft->getTotal()) }} + {{ format_rp($draft->getTotal()) }} diff --git a/resources/views/cart/partials/product-search-result-box.blade.php b/resources/views/cart/partials/product-search-result-box.blade.php index 60e050c..1266191 100644 --- a/resources/views/cart/partials/product-search-result-box.blade.php +++ b/resources/views/cart/partials/product-search-result-box.blade.php @@ -13,7 +13,7 @@ {{ $product->name }} {{ $product->unit->name }} - {{ formatRp($product->getPrice($draftType)) }} + {{ format_rp($product->getPrice($draftType)) }}
diff --git a/resources/views/log-files.blade.php b/resources/views/log-files.blade.php index ca3dd32..4edc119 100755 --- a/resources/views/log-files.blade.php +++ b/resources/views/log-files.blade.php @@ -20,7 +20,7 @@ 0 error_log - {{ formatSizeUnits(File::size('error_log')) }} + {{ format_size_units(File::size('error_log')) }} {{ date('Y-m-d H:i:s', File::lastModified('error_log')) }} {!! html_link_to_route('log-files.server-error-log','',[],[ @@ -37,7 +37,7 @@ {{ $key + 1 }} {{ $logFile->getFilename() }} - {{ formatSizeUnits($logFile->getSize()) }} + {{ format_size_units($logFile->getSize()) }} {{ date('Y-m-d H:i:s', $logFile->getMTime()) }} {{ link_to_route('log-files.show', 'Lihat', [$logFile->getFilename()],[ diff --git a/resources/views/products/index.blade.php b/resources/views/products/index.blade.php index ac6476d..386e624 100644 --- a/resources/views/products/index.blade.php +++ b/resources/views/products/index.blade.php @@ -40,8 +40,8 @@ {{ $products->firstItem() + $key }} {{ $product->name }} {{ $product->unit->name }} - {{ formatRp($product->cash_price) }} - {{ formatRp($product->credit_price) }} + {{ format_rp($product->cash_price) }} + {{ format_rp($product->credit_price) }} {!! 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]) !!} diff --git a/resources/views/products/partials/forms.blade.php b/resources/views/products/partials/forms.blade.php index a1c886e..4a5121e 100644 --- a/resources/views/products/partials/forms.blade.php +++ b/resources/views/products/partials/forms.blade.php @@ -37,8 +37,8 @@ {{ __('product.name') }}{{ $editableProduct->name }} {{ __('product.unit') }}{{ $editableProduct->unit->name }} - {{ __('product.cash_price') }}{{ formatRp($editableProduct->cash_price) }} - {{ __('product.credit_price') }}{{ formatRp($editableProduct->credit_price) }} + {{ __('product.cash_price') }}{{ format_rp($editableProduct->cash_price) }} + {{ __('product.credit_price') }}{{ format_rp($editableProduct->credit_price) }}
diff --git a/resources/views/products/price-list.blade.php b/resources/views/products/price-list.blade.php index 7b45004..a64a720 100644 --- a/resources/views/products/price-list.blade.php +++ b/resources/views/products/price-list.blade.php @@ -22,8 +22,8 @@ @foreach($chunckedProducts as $key => $product) {{ $key + 1 }}) {{ $product->name }} ({{ $product->unit->name }}) - {{ formatRp($product->cash_price) }} - {{ formatRp($product->credit_price) }} + {{ format_rp($product->cash_price) }} + {{ format_rp($product->credit_price) }} @endforeach diff --git a/resources/views/reports/sales/daily.blade.php b/resources/views/reports/sales/daily.blade.php index 6692548..1f1f335 100755 --- a/resources/views/reports/sales/daily.blade.php +++ b/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) {{ 1 + $key }} - {{ dateId($transaction->created_at->format('Y-m-d')) }} - {{ formatRp($transaction->total) }} + {{ date_id($transaction->created_at->format('Y-m-d')) }} + {{ format_rp($transaction->total) }} {{ link_to_route( 'transactions.show', @@ -53,7 +53,7 @@ {{ __('app.total') }} - {{ formatRp($transactions->sum('total')) }} + {{ format_rp($transactions->sum('total')) }}   diff --git a/resources/views/reports/sales/monthly.blade.php b/resources/views/reports/sales/monthly.blade.php index 06a8374..74c0198 100755 --- a/resources/views/reports/sales/monthly.blade.php +++ b/resources/views/reports/sales/monthly.blade.php @@ -34,7 +34,7 @@ @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) - {{ dateId($date = $year.'-'.$month.'-'.$dateNumber) }} + {{ date_id($date = $year.'-'.$month.'-'.$dateNumber) }} {{ $count }} - {{ formatRp($subtotal) }} + {{ format_rp($subtotal) }} {{ 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)]), ] ) }} @@ -67,7 +67,7 @@ {{ __('app.total') }} {{ $reports->sum('count') }} - {{ formatRp($reports->sum('amount')) }} + {{ format_rp($reports->sum('amount')) }}   diff --git a/resources/views/reports/sales/yearly.blade.php b/resources/views/reports/sales/yearly.blade.php index 394ade1..35b3a06 100755 --- a/resources/views/reports/sales/yearly.blade.php +++ b/resources/views/reports/sales/yearly.blade.php @@ -32,30 +32,30 @@ @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 - {{ monthId($monthNumber) }} - {{ $any ? $reports[$monthNumber]->count : 0 }} - {{ formatRp($omzet) }} + {{ month_id($month_number) }} + {{ $any ? $reports[$month_number]->count : 0 }} + {{ format_rp($omzet) }} {{ 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]), ] ) }} @php - $chartData[] = ['month' => monthId($monthNumber), 'value' => $omzet]; + $chartData[] = ['month' => month_id($month_number), 'value' => $omzet]; @endphp @endforeach @@ -63,7 +63,7 @@ {{ trans('app.total') }} {{ $reports->sum('count') }} - {{ formatRp($reports->sum('omzet')) }} + {{ format_rp($reports->sum('omzet')) }}   diff --git a/resources/views/transactions/index.blade.php b/resources/views/transactions/index.blade.php index b03bb59..39538ea 100644 --- a/resources/views/transactions/index.blade.php +++ b/resources/views/transactions/index.blade.php @@ -51,7 +51,7 @@ {{ $transaction->customer['phone'] ? '(' . $transaction->customer['phone'] . ')' : '' }} {{ $transaction->items_count }} - {{ formatRp($transaction->total) }} + {{ format_rp($transaction->total) }} {{ link_to_route('transactions.show', trans('app.show'), $transaction->invoice_no) }} | {{ link_to_route('transactions.receipt', trans('app.print'), $transaction->invoice_no) }} diff --git a/resources/views/transactions/pdf.blade.php b/resources/views/transactions/pdf.blade.php index f12d40a..c16ae46 100644 --- a/resources/views/transactions/pdf.blade.php +++ b/resources/views/transactions/pdf.blade.php @@ -47,32 +47,32 @@ {{ $item['qty'] }} - {{ formatRp($item['price']) }}
({{ formatRp($item['item_discount']) }}) + {{ format_rp($item['price']) }}
({{ format_rp($item['item_discount']) }}) - {{ formatRp($item['subtotal']) }} + {{ format_rp($item['subtotal']) }} @endforeach @if ($loop->last && $loop->parent->last) {{ trans('transaction.subtotal') }} : - {{ formatRp($transaction['total'] + $discountTotal) }} + {{ format_rp($transaction['total'] + $discountTotal) }} {{ trans('transaction.discount_total') }} : - {{ formatRp($discountTotal) }} + {{ format_rp($discountTotal) }} {{ trans('transaction.total') }} : - {{ formatRp($transaction['total']) }} + {{ format_rp($transaction['total']) }} {{ trans('transaction.payment') }} : - {{ formatRp($transaction->payment) }} + {{ format_rp($transaction->payment) }} {{ trans('transaction.exchange') }} : - {{ formatRp($transaction->getExchange()) }} + {{ format_rp($transaction->getExchange()) }} @endif diff --git a/resources/views/transactions/receipt.blade.php b/resources/views/transactions/receipt.blade.php index a884566..3edf2e2 100644 --- a/resources/views/transactions/receipt.blade.php +++ b/resources/views/transactions/receipt.blade.php @@ -53,31 +53,31 @@ {{ $item['qty'] }} - {{ formatRp($item['price']) }} ({{ formatRp($item['item_discount']) }}) + {{ format_rp($item['price']) }} ({{ format_rp($item['item_discount']) }}) - {{ formatRp($item['subtotal']) }} + {{ format_rp($item['subtotal']) }} @endforeach {{ trans('transaction.subtotal') }} : - {{ formatRp($transaction['total'] + $discountTotal) }} + {{ format_rp($transaction['total'] + $discountTotal) }} {{ trans('transaction.discount_total') }} : - {{ formatRp($discountTotal) }} + {{ format_rp($discountTotal) }} {{ trans('transaction.total') }} : - {{ formatRp($transaction['total']) }} + {{ format_rp($transaction['total']) }} {{ trans('transaction.payment') }} : - {{ formatRp($transaction->payment) }} + {{ format_rp($transaction->payment) }} {{ trans('transaction.exchange') }} : - {{ formatRp($transaction->getExchange()) }} + {{ format_rp($transaction->getExchange()) }} diff --git a/resources/views/transactions/show.blade.php b/resources/views/transactions/show.blade.php index 925a904..21d7d80 100644 --- a/resources/views/transactions/show.blade.php +++ b/resources/views/transactions/show.blade.php @@ -20,9 +20,9 @@ {{ trans('transaction.customer_name') }}{{ $transaction->customer['name'] }} {{ trans('transaction.customer_phone') }}{{ $transaction->customer['phone'] }} {{ trans('transaction.items_count') }}{{ $transaction->items_count }} - {{ trans('transaction.total') }}{{ formatRp($transaction->total) }} - {{ trans('transaction.payment') }}{{ formatRp($transaction->payment) }} - {{ trans('transaction.exchange') }}{{ formatRp($transaction->getExchange()) }} + {{ trans('transaction.total') }}{{ format_rp($transaction->total) }} + {{ trans('transaction.payment') }}{{ format_rp($transaction->payment) }} + {{ trans('transaction.exchange') }}{{ format_rp($transaction->getExchange()) }} @@ -52,10 +52,10 @@ {{ $item['name'] }}
({{ $item['unit'] }}) - {{ formatRp($item['price']) }} - {{ formatRp($item['item_discount']) }} + {{ format_rp($item['price']) }} + {{ format_rp($item['item_discount']) }} {{ $item['qty'] }} - {{ formatRp($item['subtotal']) }} + {{ format_rp($item['subtotal']) }} @endforeach @@ -63,15 +63,15 @@ {{ trans('transaction.subtotal') }} : - {{ formatRp($transaction['total'] + $discountTotal) }} + {{ format_rp($transaction['total'] + $discountTotal) }} {{ trans('transaction.discount_total') }} : - {{ formatRp($discountTotal) }} + {{ format_rp($discountTotal) }} {{ trans('transaction.total') }} : - {{ formatRp($transaction['total']) }} + {{ format_rp($transaction['total']) }} diff --git a/tests/Feature/TransactionEntryTest.php b/tests/Feature/TransactionEntryTest.php index b602dea..f67ca46 100644 --- a/tests/Feature/TransactionEntryTest.php +++ b/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']); }