Merge pull request #4830 from turbo124/v5-develop

Fixes for tests
This commit is contained in:
David Bomba 2021-02-04 09:22:08 +11:00 committed by GitHub
commit 7559bf3ab9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 4 deletions

View File

@ -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

View File

@ -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:

View File

@ -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();
}
});
}
}

View File

@ -21,8 +21,8 @@ use Tests\TestCase;
*/
class AutoBillInvoiceTest extends TestCase
{
use MockAccountData;
use DatabaseTransactions;
use MockAccountData;
public function setUp() :void
{