From 81e17d9cdcc9640a732c62d89f67c30df6b022be Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 4 Feb 2021 07:46:18 +1100 Subject: [PATCH 1/4] fixes for tests --- tests/Unit/AutoBillInvoiceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/AutoBillInvoiceTest.php b/tests/Unit/AutoBillInvoiceTest.php index ffd49c9819e8..7d9da63a4044 100644 --- a/tests/Unit/AutoBillInvoiceTest.php +++ b/tests/Unit/AutoBillInvoiceTest.php @@ -21,8 +21,8 @@ use Tests\TestCase; */ class AutoBillInvoiceTest extends TestCase { - use MockAccountData; use DatabaseTransactions; + use MockAccountData; public function setUp() :void { From a5372b1cf36fe2c25239a3d67bdabcda5330bf02 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 4 Feb 2021 07:52:37 +1100 Subject: [PATCH 2/4] Fixes for migrating V4 data - pushing credits off leger --- app/Jobs/Util/Import.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 16552117ab53..dcfaaa1a0237 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -205,6 +205,8 @@ class Import implements ShouldQueue $this->setInitialCompanyLedgerBalances(); + $this->fixClientBalances(); + Mail::to($this->user) ->send(new MigrationCompleted($this->company)); @@ -789,6 +791,7 @@ class Import implements ShouldQueue /*Improve memory handling by setting everything to null when we have finished*/ $data = null; $credit_repository = null; + } private function processQuotes(array $data): void @@ -1425,4 +1428,23 @@ class Import implements ShouldQueue return $response->getBody(); } + + /* In V4 we use negative invoices (credits) and add then into the client balance. In V5, these sit off ledger and are applied later. + This next section will check for credit balances and reduce the client balance so that the V5 balances are correct + */ + private function fixClientBalances() + { + + Client::cursor()->each(function ($client) { + + $credit_balance = $client->credits->where('is_deleted', false)->sum('balance'); + + if($credit_balance > 0){ + $client->balance += $credit_balance; + $client->save(); + } + + }); + + } } From c7f33df5dca1f2337a1970d573790cf438d76fb5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 4 Feb 2021 08:22:18 +1100 Subject: [PATCH 3/4] Fixes for phpunit --- .github/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 76b658d7da7a..b6f99dfacd6e 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -67,7 +67,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - extensions: mysql, mysqlnd, sqlite3, bcmath, gmp, gd, curl, zip, openssl, mbstring, xml + extensions: mysql, sqlite3, bcmath, gmp, gd, curl, zip, openssl, mbstring, xml - uses: actions/checkout@v1 with: From 9e784e6046945ee65f253126970e1f0509a6638e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 4 Feb 2021 08:25:54 +1100 Subject: [PATCH 4/4] Fixes for DB ports for testing .ci --- .env.ci | 2 -- 1 file changed, 2 deletions(-) diff --git a/.env.ci b/.env.ci index d4b797cd2ea3..0d25250e49b7 100644 --- a/.env.ci +++ b/.env.ci @@ -10,8 +10,6 @@ DB_DATABASE1=ninja DB_USERNAME1=root DB_PASSWORD1=ninja DB_HOST1=127.0.0.1 -DB_PORT1=32768 -DB_PORT=32768 DB_DATABASE=ninja DB_USERNAME=root DB_PASSWORD=ninja