diff --git a/app/Http/Controllers/Customers/Invoices.php b/app/Http/Controllers/Customers/Invoices.php index f394eb5c8..aea447a7f 100644 --- a/app/Http/Controllers/Customers/Invoices.php +++ b/app/Http/Controllers/Customers/Invoices.php @@ -50,9 +50,15 @@ class Invoices extends Controller $paid = 0; foreach ($invoice->payments as $item) { - $item->default_currency_code = $invoice->currency_code; + $amount = $item->amount; - $paid += $item->getDynamicConvertedAmount(); + if ($invoice->currency_code != $item->currency_code) { + $item->default_currency_code = $invoice->currency_code; + + $amount = $item->getDynamicConvertedAmount(); + } + + $paid += $amount; } $invoice->paid = $paid; @@ -118,9 +124,15 @@ class Invoices extends Controller $paid = 0; foreach ($invoice->payments as $item) { - $item->default_currency_code = $invoice->currency_code; + $amount = $item->amount; - $paid += $item->getDynamicConvertedAmount(); + if ($invoice->currency_code != $item->currency_code) { + $item->default_currency_code = $invoice->currency_code; + + $amount = $item->getDynamicConvertedAmount(); + } + + $paid += $amount; } $invoice->paid = $paid; diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php index 21f36a254..6070b022a 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -69,9 +69,15 @@ class Invoices extends Controller $paid = 0; foreach ($invoice->payments as $item) { - $item->default_currency_code = $invoice->currency_code; + $amount = $item->amount; - $paid += $item->getDynamicConvertedAmount(); + if ($invoice->currency_code != $item->currency_code) { + $item->default_currency_code = $invoice->currency_code; + + $amount = $item->getDynamicConvertedAmount(); + } + + $paid += $amount; } $invoice->paid = $paid; @@ -821,9 +827,15 @@ class Invoices extends Controller $paid = 0; foreach ($invoice->payments as $item) { - $item->default_currency_code = $invoice->currency_code; + $amount = $item->amount; - $paid += $item->getDynamicConvertedAmount(); + if ($invoice->currency_code != $item->currency_code) { + $item->default_currency_code = $invoice->currency_code; + + $amount = $item->getDynamicConvertedAmount(); + } + + $paid += $amount; } $invoice->paid = $paid;