formatting
This commit is contained in:
parent
8b7ee416a6
commit
b0843151b1
@ -87,11 +87,15 @@ abstract class DocumentModel extends Model
|
||||
return false;
|
||||
}
|
||||
|
||||
static $currencies;
|
||||
|
||||
$paid = 0;
|
||||
$reconciled = $reconciled_amount = 0;
|
||||
|
||||
if ($this->transactions->count()) {
|
||||
$currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
|
||||
if (empty($currencies)) {
|
||||
$currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
|
||||
}
|
||||
|
||||
foreach ($this->transactions as $item) {
|
||||
if ($this->currency_code == $item->currency_code) {
|
||||
|
@ -4,12 +4,12 @@ namespace App\Models\Banking;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Media;
|
||||
use App\Traits\Recurring;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Date;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
@ -40,8 +40,6 @@ class Transaction extends Model
|
||||
*/
|
||||
public $cloneable_relations = ['recurring'];
|
||||
|
||||
public static $currencies;
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Banking\Account')->withDefault(['name' => trans('general.na')]);
|
||||
@ -254,14 +252,16 @@ class Transaction extends Model
|
||||
*/
|
||||
public function getPriceAttribute()
|
||||
{
|
||||
if (empty($this->currencies)) {
|
||||
$this->currencies = \App\Models\Setting\Currency::enabled()->pluck('rate', 'code')->toArray();
|
||||
}
|
||||
static $currencies;
|
||||
|
||||
$amount = $this->amount;
|
||||
|
||||
// Convert amount if not same currency
|
||||
if ($this->account->currency_code != $this->currency_code) {
|
||||
if (empty($currencies)) {
|
||||
$currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
|
||||
}
|
||||
|
||||
$default_currency = setting('default.currency', 'USD');
|
||||
|
||||
$default_amount = $this->amount;
|
||||
@ -282,7 +282,7 @@ class Transaction extends Model
|
||||
$transfer_amount->default_currency_code = $this->currency_code;
|
||||
$transfer_amount->amount = $default_amount;
|
||||
$transfer_amount->currency_code = $this->account->currency_code;
|
||||
$transfer_amount->currency_rate = $this->currencies[$this->account->currency_code];
|
||||
$transfer_amount->currency_rate = $currencies[$this->account->currency_code];
|
||||
|
||||
$amount = $transfer_amount->getAmountConvertedFromDefault();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user