From ce99fa3d8281999ea485ac3f0971228e2b8c22f2 Mon Sep 17 00:00:00 2001 From: radhu587 Date: Fri, 13 Dec 2019 13:31:26 +0530 Subject: [PATCH] Fix PDF issues --- app/Space/helpers.php | 12 ++++++++++-- .../components/base/modal/CustomerModal.vue | 1 + .../app/pdf/estimate/partials/table.blade.php | 19 ++++++++++++------- .../app/pdf/invoice/partials/table.blade.php | 19 ++++++++++++------- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/app/Space/helpers.php b/app/Space/helpers.php index 78c8eab9..2ce77f82 100644 --- a/app/Space/helpers.php +++ b/app/Space/helpers.php @@ -41,10 +41,18 @@ function clean_slug($string) * @param $money * @return formated_money */ -function format_money_pdf($money) +function format_money_pdf($money, $getCurrency = null) { $money = $money / 100; - $currency = Currency::findOrFail(CompanySetting::getSetting('currency', 1)); + + $currency = null; + + if ($getCurrency == null) { + $currency = Currency::findOrFail(CompanySetting::getSetting('currency', 1)); + } else { + $currency = $getCurrency; + } + $format_money = number_format( $money, $currency->precision, diff --git a/resources/assets/js/components/base/modal/CustomerModal.vue b/resources/assets/js/components/base/modal/CustomerModal.vue index 1034793b..af2e2941 100644 --- a/resources/assets/js/components/base/modal/CustomerModal.vue +++ b/resources/assets/js/components/base/modal/CustomerModal.vue @@ -55,6 +55,7 @@ v-model="currency" :options="currencies" :searchable="true" + :allow-empty="false" :show-labels="false" :placeholder="$t('customers.select_currency')" label="name" diff --git a/resources/views/app/pdf/estimate/partials/table.blade.php b/resources/views/app/pdf/estimate/partials/table.blade.php index 40092a6d..b7ec1471 100644 --- a/resources/views/app/pdf/estimate/partials/table.blade.php +++ b/resources/views/app/pdf/estimate/partials/table.blade.php @@ -47,7 +47,7 @@ Subtotal {!! format_money_pdf($estimate->sub_total) !!} + style="padding-right:10px; text-align: right; font-size:12px; color: #040405; font-weight: 500;">{!! format_money_pdf($estimate->sub_total, $estimate->user->currency) !!} @if ($estimate->tax_per_item === 'YES') @@ -57,7 +57,7 @@ {{$labels[$i]}} - {!! format_money_pdf($taxes[$i]) !!} + {!! format_money_pdf($taxes[$i], $estimate->user->currency) !!} @endfor @@ -68,7 +68,7 @@ {{$tax->name.' ('.$tax->percent.'%)'}} - {!! format_money_pdf($tax->amount) !!} + {!! format_money_pdf($tax->amount, $estimate->user->currency) !!} @endforeach @@ -77,14 +77,19 @@ @if ($estimate->discount_per_item === 'NO') - Discount ({{$estimate->discount}}%) + @if($estimate->discount_type === 'fixed') + Discount + @endif + @if($estimate->discount_type === 'percentage') + Discount ({{$estimate->discount}}%) + @endif @if($estimate->discount_type === 'fixed') - {!! format_money_pdf($estimate->discount_val) !!} + {!! format_money_pdf($estimate->discount_val, $estimate->user->currency) !!} @endif @if($estimate->discount_type === 'percentage') - {!! format_money_pdf($estimate->discount_val) !!} + {!! format_money_pdf($estimate->discount_val, $estimate->user->currency) !!} @endif @@ -103,7 +108,7 @@ class="no-border total-border-right items padd8" style="padding-right:10px; font-weight: 500; text-align: right; font-size:12px; padding-top:20px; color: #5851DB" > - {!! format_money_pdf($estimate->total)!!} + {!! format_money_pdf($estimate->total, $estimate->user->currency)!!} diff --git a/resources/views/app/pdf/invoice/partials/table.blade.php b/resources/views/app/pdf/invoice/partials/table.blade.php index aa4e6758..0bcc30c2 100644 --- a/resources/views/app/pdf/invoice/partials/table.blade.php +++ b/resources/views/app/pdf/invoice/partials/table.blade.php @@ -47,7 +47,7 @@ Subtotal {!! format_money_pdf($invoice->sub_total) !!} + style="padding-right:10px; text-align: right; font-size:12px; color: #040405; font-weight: 500;">{!! format_money_pdf($invoice->sub_total, $invoice->user->currency) !!} @if ($invoice->tax_per_item === 'YES') @@ -57,7 +57,7 @@ {{$labels[$i]}} - {!! format_money_pdf($taxes[$i]) !!} + {!! format_money_pdf($taxes[$i], $invoice->user->currency) !!} @endfor @@ -68,7 +68,7 @@ {{$tax->name.' ('.$tax->percent.'%)'}} - {!! format_money_pdf($tax->amount) !!} + {!! format_money_pdf($tax->amount, $invoice->user->currency) !!} @endforeach @@ -77,14 +77,19 @@ @if ($invoice->discount_per_item === 'NO') - Discount ({{$invoice->discount}}%) + @if($invoice->discount_type === 'fixed') + Discount + @endif + @if($invoice->discount_type === 'percentage') + Discount ({{$invoice->discount}}%) + @endif @if($invoice->discount_type === 'fixed') - {!! format_money_pdf($invoice->discount_val) !!} + {!! format_money_pdf($invoice->discount_val, $invoice->user->currency) !!} @endif @if($invoice->discount_type === 'percentage') - {!! format_money_pdf($invoice->discount_val) !!} + {!! format_money_pdf($invoice->discount_val, $invoice->user->currency) !!} @endif @@ -103,7 +108,7 @@ class="no-border total-border-right items padd8" style="padding-right:10px; font-weight: 500; text-align: right; font-size:12px; padding-top:20px; color: #5851DB" > - {!! format_money_pdf($invoice->total)!!} + {!! format_money_pdf($invoice->total, $invoice->user->currency)!!}