From 7641d7e315272edd1837efb27528fe44f90b625b Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Tue, 10 Jul 2018 17:21:40 +0300 Subject: [PATCH] refs #412 Added payment check currency --- app/Http/Controllers/Customers/Invoices.php | 20 ++++++++++++++++---- app/Http/Controllers/Incomes/Invoices.php | 20 ++++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) 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;