From 5475b1bc90794d4f4f70c8af49a3e957c5d0e6a2 Mon Sep 17 00:00:00 2001 From: celikerde Date: Wed, 1 Apr 2026 10:47:03 +0300 Subject: [PATCH] fix(Payment): update global scope and currency formatting - Adjusted the query to correctly reference the currency_id instead of price_id. - Updated the amountFormatted method to use the new currency_iso_4217 property for formatting amounts. --- modules/SystemPayment/Entities/Payment.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/SystemPayment/Entities/Payment.php b/modules/SystemPayment/Entities/Payment.php index e36efed41..f2a9f2da0 100644 --- a/modules/SystemPayment/Entities/Payment.php +++ b/modules/SystemPayment/Entities/Payment.php @@ -60,16 +60,14 @@ class Payment extends \Unusualify\Payable\Models\Payment protected static function booted(): void { - static::addGlobalScope('price_currency_iso_4217', function (Builder $builder) { - $pricesTable = (new Price)->getTable(); + static::addGlobalScope('currency_iso_4217', function (Builder $builder) { $currenciesTable = (new Currency)->getTable(); $paymentTable = (new static)->getTable(); $builder->addSelect([ - 'price_currency_iso_4217' => Currency::query() + 'currency_iso_4217' => Currency::query() ->select($currenciesTable . '.iso_4217') - ->join($pricesTable, $pricesTable . '.currency_id', '=', $currenciesTable . '.id') - ->whereColumn($pricesTable . '.id', $paymentTable . '.price_id') + ->whereColumn($currenciesTable . '.id', $paymentTable . '.currency_id') ->limit(1), ]); }); @@ -168,7 +166,7 @@ protected function amountFormatted(): Attribute { return Attribute::make( get: function () { - return PriceService::formatAmount($this->amount, new \Money\Currency($this->price_currency_iso_4217 ?? $this->currency->iso_4217)); + return PriceService::formatAmount($this->amount, new \Money\Currency($this->currency_iso_4217 ?? $this->currency->iso_4217)); }, ); }