From 3f67ac5f2138019f19c88945fef25b3d6a849537 Mon Sep 17 00:00:00 2001 From: WBLKLeipe Date: Fri, 5 Nov 2021 09:00:18 +0100 Subject: [PATCH] Fixing FormatCurrency --- app/Http/Controllers/Admin/PaymentController.php | 9 +++++++-- app/Models/Payment.php | 5 ++--- app/Models/PaypalProduct.php | 4 ++-- resources/views/store/checkout.blade.php | 8 ++++---- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index a6aedf09..ef1cf7b2 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -255,9 +255,14 @@ class PaymentController extends Controller return $payment->user->name; }) ->editColumn('price', function (Payment $payment) { - return $payment->formatCurrency(); + return $payment->formatToCurrency($payment->price); + }) + ->editColumn('tax_value', function (Payment $payment) { + return $payment->formatToCurrency($payment->tax_value); + }) + ->editColumn('total_price', function (Payment $payment) { + return $payment->formatToCurrency($payment->total_price); }) - ->editColumn('created_at', function (Payment $payment) { return $payment->created_at ? $payment->created_at->diffForHumans() : ''; }) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 6646327e..d43c291d 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -53,10 +53,9 @@ class Payment extends Model { return $this->belongsTo(User::class); } - - public function formatCurrency($locale = 'en_US') + public function formatToCurrency($value,$locale = 'de_DE') { $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); - return $formatter->formatCurrency($this->price, $this->currency_code); + return $formatter->formatCurrency($value, $this->currency_code); } } diff --git a/app/Models/PaypalProduct.php b/app/Models/PaypalProduct.php index c39c0f8e..f0aef5d9 100644 --- a/app/Models/PaypalProduct.php +++ b/app/Models/PaypalProduct.php @@ -43,9 +43,9 @@ class PaypalProduct extends Model * @param string $locale * @return string */ - public function formatCurrency($locale = 'en_US') + public function formatToCurrency($value,$locale = 'de_DE') { $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); - return $formatter->formatCurrency($this->price, $this->currency_code); + return $formatter->formatCurrency($value, $this->currency_code); } } diff --git a/resources/views/store/checkout.blade.php b/resources/views/store/checkout.blade.php index 1f817071..f2bce40a 100644 --- a/resources/views/store/checkout.blade.php +++ b/resources/views/store/checkout.blade.php @@ -83,7 +83,7 @@ 1 {{$product->quantity}} {{strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type}} {{$product->description}} - {{$product->formatCurrency()}} + {{$product->formatToCurrency($product->price)}} @@ -111,11 +111,11 @@ - + - + @@ -123,7 +123,7 @@ - +
Subtotal:{{$product->formatCurrency()}}{{$product->formatToCurrency($product->price)}}
Tax ({{$taxpercent}}%)€{{number_format($taxvalue, 2, '.', '')}}{{$product->formatToCurrency($taxvalue)}}
Quantity:
Total:€{{number_format($total, 2, '.', '')}}{{$product->formatToCurrency($total)}}