From 8fbab48019f742af11b530d80baea95eef3d5c44 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 8 Feb 2022 20:36:07 +1100 Subject: [PATCH] Do not set exchange rate if already set --- app/Repositories/Migration/PaymentMigrationRepository.php | 3 +++ app/Services/Invoice/ApplyPaymentAmount.php | 3 +++ app/Services/Invoice/InvoiceService.php | 3 +++ app/Services/Invoice/MarkPaid.php | 3 +++ 4 files changed, 12 insertions(+) diff --git a/app/Repositories/Migration/PaymentMigrationRepository.php b/app/Repositories/Migration/PaymentMigrationRepository.php index 32c253e14758..a93c6ea453e7 100644 --- a/app/Repositories/Migration/PaymentMigrationRepository.php +++ b/app/Repositories/Migration/PaymentMigrationRepository.php @@ -202,6 +202,9 @@ class PaymentMigrationRepository extends BaseRepository */ private function processExchangeRates($data, $payment) { + if($payment->exchange_rate != 1) + return $payment; + $client = Client::where('id', $data['client_id'])->withTrashed()->first(); $client_currency = $client->getSetting('currency_id'); diff --git a/app/Services/Invoice/ApplyPaymentAmount.php b/app/Services/Invoice/ApplyPaymentAmount.php index ee6a0f657ec0..51ec7995955d 100644 --- a/app/Services/Invoice/ApplyPaymentAmount.php +++ b/app/Services/Invoice/ApplyPaymentAmount.php @@ -111,6 +111,9 @@ class ApplyPaymentAmount extends AbstractService private function setExchangeRate(Payment $payment) { + if($payment->exchange_rate != 1) + return; + $client_currency = $payment->client->getSetting('currency_id'); $company_currency = $payment->client->company->settings->currency_id; diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 281cea3ebc8d..a38464c89a1d 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -79,6 +79,9 @@ class InvoiceService public function setExchangeRate() { + if($this->invoice->exchange_rate != 0) + return $this; + $client_currency = $this->invoice->client->getSetting('currency_id'); $company_currency = $this->invoice->company->settings->currency_id; diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index 026892f495ba..205c5cee57ab 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -116,6 +116,9 @@ class MarkPaid extends AbstractService private function setExchangeRate(Payment $payment) { + if($payment->exchange_rate != 1) + return; + $client_currency = $payment->client->getSetting('currency_id'); $company_currency = $payment->client->company->settings->currency_id;