From 0c4476e4ff1c5f699cb4c83d8156933540e698cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Tue, 19 Dec 2023 17:49:09 +0300 Subject: [PATCH] Document transaction convert amount issue solved.. --- .../Banking/CreateBankingDocumentTransaction.php | 14 +++++--------- app/Models/Document/Document.php | 4 ++++ resources/assets/js/views/common/documents.js | 7 ------- resources/views/modals/documents/payment.blade.php | 10 ---------- 4 files changed, 9 insertions(+), 26 deletions(-) diff --git a/app/Jobs/Banking/CreateBankingDocumentTransaction.php b/app/Jobs/Banking/CreateBankingDocumentTransaction.php index ada5d06e6e8..7630c659049 100644 --- a/app/Jobs/Banking/CreateBankingDocumentTransaction.php +++ b/app/Jobs/Banking/CreateBankingDocumentTransaction.php @@ -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'; } diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index 17eccaad126..5acdd459efb 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -339,6 +339,10 @@ public function getPaidAttribute() return false; } + if ($this->status == 'paid' ) { + return $this->amount; + } + $paid = 0; $code = $this->currency_code; diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index 1a118ef72ab..778382f7b96 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -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; @@ -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(); - } } }, diff --git a/resources/views/modals/documents/payment.blade.php b/resources/views/modals/documents/payment.blade.php index feac8c1b16b..de09e5c569e 100644 --- a/resources/views/modals/documents/payment.blade.php +++ b/resources/views/modals/documents/payment.blade.php @@ -64,16 +64,6 @@ input="onChangeAmount($event)" /> -
-
-
-
-
-
-
-