From d9047b413a97b4475e1726da5821a962e8ecccdb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 6 Apr 2021 07:36:20 +1000 Subject: [PATCH] Disable product price updating if currencies do not match --- app/Jobs/Product/UpdateOrCreateProduct.php | 3 ++ tests/Unit/CompanySettingsTest.php | 32 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/app/Jobs/Product/UpdateOrCreateProduct.php b/app/Jobs/Product/UpdateOrCreateProduct.php index 156159791934..b5149e6b84cd 100644 --- a/app/Jobs/Product/UpdateOrCreateProduct.php +++ b/app/Jobs/Product/UpdateOrCreateProduct.php @@ -55,6 +55,9 @@ class UpdateOrCreateProduct implements ShouldQueue { MultiDB::setDB($this->company->db); + if(strval($this->invoice->client->getSetting('currency_id')) != strval($this->company->settings->currency_id)) + return; + /* * If the invoice was generated from a Task or Expense then * we do NOT update the product details this short block we diff --git a/tests/Unit/CompanySettingsTest.php b/tests/Unit/CompanySettingsTest.php index fca71d397064..de748e2f2839 100644 --- a/tests/Unit/CompanySettingsTest.php +++ b/tests/Unit/CompanySettingsTest.php @@ -55,4 +55,36 @@ class CompanySettingsTest extends TestCase $this->assertEquals(1, count($diff)); } + + public function testStringEquivalence() + { + + $value = (strval(4) != strval(3)); + + $this->assertTrue($value); + + $value = (strval(4) != strval(4)); + + $this->assertFalse($value); + + $value = (strval('4') != strval(4)); + $this->assertFalse($value); + + $value = (strval('4') != strval('4')); + + $this->assertFalse($value); + + $value = (strval('4') != strval(3)); + + $this->assertTrue($value); + + $value = (strval(4) != strval('3')); + + $this->assertTrue($value); + + $value = (strval('4') != strval('3')); + + $this->assertTrue($value); + + } }