Fixing FormatCurrency

This commit is contained in:
WBLKLeipe 2021-11-05 09:00:18 +01:00
parent 93d8dfcf0b
commit 3f67ac5f21
4 changed files with 15 additions and 11 deletions

View file

@ -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() : '';
})

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -83,7 +83,7 @@
<td>1</td>
<td><i class="fa fa-coins mr-2"></i>{{$product->quantity}} {{strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type}}</td>
<td>{{$product->description}}</td>
<td>{{$product->formatCurrency()}}</td>
<td>{{$product->formatToCurrency($product->price)}}</td>
</tr>
</tbody>
</table>
@ -111,11 +111,11 @@
<table class="table">
<tr>
<th style="width:50%">Subtotal:</th>
<td>{{$product->formatCurrency()}}</td>
<td>{{$product->formatToCurrency($product->price)}}</td>
</tr>
<tr>
<th>Tax ({{$taxpercent}}%)</th>
<td>{{number_format($taxvalue, 2, '.', '')}}</td>
<td>{{$product->formatToCurrency($taxvalue)}}</td>
</tr>
<tr>
<th>Quantity:</th>
@ -123,7 +123,7 @@
</tr>
<tr>
<th>Total:</th>
<td>{{number_format($total, 2, '.', '')}}</td>
<td>{{$product->formatToCurrency($total)}}</td>
</tr>
</table>
</div>