close #2186 Fixed: Invoice/Bill mark paid currency code issue. #nqbpdm
This commit is contained in:
parent
fc57b3bc34
commit
552ad0edfa
@ -329,7 +329,7 @@ class Invoices extends Controller
|
||||
public function markPaid(Document $invoice)
|
||||
{
|
||||
try {
|
||||
event(new \App\Events\Document\PaymentReceived($invoice, ['type' => 'income']));
|
||||
event(new \App\Events\Document\PaymentReceived($invoice, ['type' => 'income', 'mark_paid' => 'invoice']));
|
||||
|
||||
$message = trans('documents.messages.marked_paid', ['type' => trans_choice('general.invoices', 1)]);
|
||||
|
||||
|
@ -6,6 +6,7 @@ use App\Abstracts\Job;
|
||||
use App\Jobs\Banking\CreateTransaction;
|
||||
use App\Jobs\Document\CreateDocumentHistory;
|
||||
use App\Events\Document\PaidAmountCalculated;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Traits\Currencies;
|
||||
use App\Utilities\Date;
|
||||
@ -83,12 +84,27 @@ class CreateBankingDocumentTransaction extends Job
|
||||
$this->request['category_id'] = isset($this->request['category_id']) ? $this->request['category_id'] : $this->model->category_id;
|
||||
$this->request['payment_method'] = isset($this->request['payment_method']) ? $this->request['payment_method'] : setting('default.payment_method');
|
||||
$this->request['notify'] = isset($this->request['notify']) ? $this->request['notify'] : 0;
|
||||
|
||||
if ($this->request['mark_paid'] || $this->request['account_id'] == setting('default.account')) {
|
||||
$account = Account::find((int) $this->request['account_id']);
|
||||
|
||||
$code = $account->currency_code;
|
||||
$rate = config('money.' . $account->currency_code . '.rate');
|
||||
|
||||
if ($account->currency_code != $this->model->currency_code) {
|
||||
$this->request['currency_code'] = $code;
|
||||
$this->request['currency_rate'] = $rate;
|
||||
|
||||
$this->request['amount'] = $this->convertBetween($this->request['amount'], $this->model->currency_code, $this->model->currency_rate, $code, $rate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkAmount()
|
||||
{
|
||||
$code = $this->request['currency_code'];
|
||||
$rate = $this->request['currency_rate'];
|
||||
|
||||
$precision = config('money.' . $code . '.precision');
|
||||
|
||||
$amount = $this->request['amount'] = round($this->request['amount'], $precision);
|
||||
|
Loading…
x
Reference in New Issue
Block a user