Skip to content

Commit

Permalink
Document transaction convert amount issue solved..
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Dec 19, 2023
1 parent addf3cd commit 0c4476e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 26 deletions.
14 changes: 5 additions & 9 deletions app/Jobs/Banking/CreateBankingDocumentTransaction.php
Expand Up @@ -104,17 +104,13 @@ protected function checkAmount(): bool
$compare = bccomp($amount, $total_amount, $precision);

if ($compare === 1) {
$error_amount = $total_amount;
if ($this->model->currency_code == $code) {
$message = trans('messages.error.over_payment', ['amount' => money($total_amount, $code)]);

if ($this->model->currency_code != $code) {
$converted_amount = $this->convertBetween($total_amount, $this->model->currency_code, $this->model->currency_rate, $code, $rate);

$error_amount = round($converted_amount, $precision);
throw new \Exception($message);
} else {
$this->model->status = 'paid';
}

$message = trans('messages.error.over_payment', ['amount' => money($error_amount, $code)]);

throw new \Exception($message);
} else {
$this->model->status = ($compare === 0) ? 'paid' : 'partial';
}
Expand Down
4 changes: 4 additions & 0 deletions app/Models/Document/Document.php
Expand Up @@ -339,6 +339,10 @@ public function getPaidAttribute()
return false;
}

if ($this->status == 'paid' ) {
return $this->amount;
}

$paid = 0;

$code = $this->currency_code;
Expand Down
7 changes: 0 additions & 7 deletions resources/assets/js/views/common/documents.js
Expand Up @@ -161,8 +161,6 @@ const app = new Vue({
return;
}

this.form.error_amount = 0;

let code = this.form.currency_code;
let rate = this.form.currency_rate;
let precision = this.currency.precision;
Expand All @@ -187,11 +185,6 @@ const app = new Vue({
}

this.form.default_amount = amount;

if (error_amount) {
this.form.error_amount = error_amount;
//this.form.error_amount = new Money(this.form.currency_code, error_amount, true).format();
}
}
},

Expand Down
10 changes: 0 additions & 10 deletions resources/views/modals/documents/payment.blade.php
Expand Up @@ -64,16 +64,6 @@
input="onChangeAmount($event)"
/>

<div class="sm:col-span-6 grid sm:grid-cols-6 gap-x-4 -mt-6" v-if="form.error_amount">
<div class="relative col-span-6 text-xs flex mt-5">
<div class="rounded-xl px-5 py-3 bg-red-100">
<div class="w-auto text-xs mr-2 text-red-600"
v-html="'{{ trans('invoices.over_payment', ['amount' => '#amount']) }}'.replace('#amount', form.error_amount)"
></div>
</div>
</div>
</div>

<div class="sm:col-span-2 text-xs absolute right-0 top-1">
<div class="custom-control custom-checkbox">
<x-form.input.checkbox
Expand Down

0 comments on commit 0c4476e

Please sign in to comment.