Skip to content

Commit

Permalink
removed unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Feb 27, 2020
1 parent 82f51a3 commit e54ee59
Showing 1 changed file with 2 additions and 40 deletions.
42 changes: 2 additions & 40 deletions app/Jobs/Banking/CreateDocumentTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ protected function checkAmount()
$amount = (double) $convert_amount_model->getAmountConvertedFromCustomDefault();
}

$total_amount -= $this->getPaidAmount();
$total_amount -= $this->model->paid;
unset($this->model->reconciled);

// For amount cover integer
$multiplier = 1;
Expand Down Expand Up @@ -146,45 +147,6 @@ protected function checkAmount()
return true;
}

protected function getPaidAmount()
{
$paid = 0;

if (!$this->model->transactions->count()) {
return $paid;
}

$currencies = Currency::enabled()->pluck('rate', 'code')->toArray();

foreach ($this->model->transactions as $item) {
$default_amount = $item->amount;

if ($this->model->currency_code == $item->currency_code) {
$amount = (double) $default_amount;
} else {
$default_amount_model = new Transaction();
$default_amount_model->default_currency_code = $this->model->currency_code;
$default_amount_model->amount = $default_amount;
$default_amount_model->currency_code = $item->currency_code;
$default_amount_model->currency_rate = $currencies[$item->currency_code];

$default_amount = (double) $default_amount_model->getDivideConvertedAmount();

$convert_amount_model = new Transaction();
$convert_amount_model->default_currency_code = $item->currency_code;
$convert_amount_model->amount = $default_amount;
$convert_amount_model->currency_code = $this->model->currency_code;
$convert_amount_model->currency_rate = $currencies[$this->model->currency_code];

$amount = (double) $convert_amount_model->getAmountConvertedFromCustomDefault();
}

$paid += $amount;
}

return $paid;
}

protected function createHistory($transaction)
{
$history_desc = money((double) $transaction->amount, (string) $transaction->currency_code, true)->format() . ' ' . trans_choice('general.payments', 1);
Expand Down

0 comments on commit e54ee59

Please sign in to comment.