Skip to content

Commit

Permalink
refs #412 Added payment check currency
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Jul 10, 2018
1 parent 51b3e37 commit 7641d7e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
20 changes: 16 additions & 4 deletions app/Http/Controllers/Customers/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ public function show(Invoice $invoice)
$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;
Expand Down Expand Up @@ -118,9 +124,15 @@ protected function prepareInvoice(Invoice $invoice)
$paid = 0;

foreach ($invoice->payments as $item) {
$item->default_currency_code = $invoice->currency_code;
$amount = $item->amount;

if ($invoice->currency_code != $item->currency_code) {
$item->default_currency_code = $invoice->currency_code;

$amount = $item->getDynamicConvertedAmount();
}

$paid += $item->getDynamicConvertedAmount();
$paid += $amount;
}

$invoice->paid = $paid;
Expand Down
20 changes: 16 additions & 4 deletions app/Http/Controllers/Incomes/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,15 @@ public function show(Invoice $invoice)
$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;
Expand Down Expand Up @@ -821,9 +827,15 @@ protected function prepareInvoice(Invoice $invoice)
$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;
Expand Down

0 comments on commit 7641d7e

Please sign in to comment.