Exceptions for emailing when company is deactivated

This commit is contained in:
David Bomba 2021-05-12 20:46:59 +10:00
parent 4326e3d1ca
commit da6ccddaaf
3 changed files with 12 additions and 6 deletions

View File

@ -54,7 +54,9 @@ class NinjaMailerJob implements ShouldQueue
public $nmo; public $nmo;
public function __construct(NinjaMailerObject $nmo) public $override;
public function __construct(NinjaMailerObject $nmo, bool $override = false)
{ {
$this->nmo = $nmo; $this->nmo = $nmo;
@ -64,7 +66,7 @@ class NinjaMailerJob implements ShouldQueue
public function handle() public function handle()
{ {
/*If we are migrating data we don't want to fire any emails*/ /*If we are migrating data we don't want to fire any emails*/
if ($this->nmo->company->is_disabled) if ($this->nmo->company->is_disabled && !$this->override)
return true; return true;
/*Set the correct database*/ /*Set the correct database*/

View File

@ -55,9 +55,6 @@ class UserEmailChanged implements ShouldQueue
public function handle() public function handle()
{ {
nlog("notifying user of email change"); nlog("notifying user of email change");
if ($this->company->is_disabled)
return true;
//Set DB //Set DB
MultiDB::setDb($this->company->db); MultiDB::setDb($this->company->db);
@ -78,7 +75,7 @@ class UserEmailChanged implements ShouldQueue
$nmo->company = $this->company; $nmo->company = $this->company;
$nmo->to_user = $this->old_user; $nmo->to_user = $this->old_user;
NinjaMailerJob::dispatch($nmo); NinjaMailerJob::dispatch($nmo, true);
// $nmo->to_user = $this->new_user; // $nmo->to_user = $this->new_user;
// NinjaMailerJob::dispatch($nmo); // NinjaMailerJob::dispatch($nmo);

View File

@ -209,6 +209,9 @@ class Import implements ShouldQueue
$this->{$method}($data[$import]); $this->{$method}($data[$import]);
} }
if(Ninja::isHosted())
$this->processNinjaTokens($data['ninja_tokens']);
$this->setInitialCompanyLedgerBalances(); $this->setInitialCompanyLedgerBalances();
// $this->fixClientBalances(); // $this->fixClientBalances();
@ -1636,6 +1639,10 @@ class Import implements ShouldQueue
return $response->getBody(); return $response->getBody();
} }
private function processNinjaTokens(array $data)
{
}
/* In V4 we use negative invoices (credits) and add then into the client balance. In V5, these sit off ledger and are applied later. /* 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 This next section will check for credit balances and reduce the client balance so that the V5 balances are correct