mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Update company tax data
This commit is contained in:
parent
ee7ab54b38
commit
32daee0fa6
@ -184,14 +184,15 @@ class BaseRule implements RuleInterface
|
||||
$company = $this->invoice->company;
|
||||
|
||||
/** If no company tax data has been configured, lets do that now. */
|
||||
if(!$company->origin_tax_data && \DB::transactionLevel() == 0)
|
||||
{
|
||||
/** We should never encounter this scenario */
|
||||
// if(!$company->origin_tax_data && \DB::transactionLevel() == 0)
|
||||
// {
|
||||
|
||||
$tp = new TaxProvider($company);
|
||||
$tp->updateCompanyTaxData();
|
||||
$company->fresh();
|
||||
// $tp = new TaxProvider($company);
|
||||
// $tp->updateCompanyTaxData();
|
||||
// $company->fresh();
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
/** If we are in a Origin based state, force the company tax here */
|
||||
if($company->origin_tax_data?->originDestination == 'O' && ($company->tax_data?->seller_subregion == $this->client_subregion)) {
|
||||
|
@ -11,16 +11,17 @@
|
||||
|
||||
namespace App\Jobs\Client;
|
||||
|
||||
use App\DataProviders\USStates;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Libraries\MultiDB;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use App\DataProviders\USStates;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||
|
||||
class UpdateTaxData implements ShouldQueue
|
||||
{
|
||||
@ -73,6 +74,11 @@ class UpdateTaxData implements ShouldQueue
|
||||
nlog("problem getting tax data => ".$e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function middleware()
|
||||
{
|
||||
return [new WithoutOverlapping($this->company->id)];
|
||||
}
|
||||
|
||||
}
|
@ -19,11 +19,14 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
use App\Services\Tax\Providers\TaxProvider;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||
|
||||
class CompanyTaxRate implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
@ -38,8 +41,14 @@ class CompanyTaxRate implements ShouldQueue
|
||||
MultiDB::setDB($this->company->db);
|
||||
|
||||
$tp = new TaxProvider($this->company);
|
||||
|
||||
$tp->updateCompanyTaxData();
|
||||
|
||||
}
|
||||
|
||||
public function middleware()
|
||||
{
|
||||
return [new WithoutOverlapping($this->company->id)];
|
||||
}
|
||||
|
||||
}
|
@ -15,6 +15,7 @@ use stdClass;
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Company;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\Jobs\Company\CompanyTaxRate;
|
||||
|
||||
/**
|
||||
* Class CompanySettingsSaver.
|
||||
@ -78,15 +79,23 @@ trait CompanySettingsSaver
|
||||
|
||||
$entity->settings = $company_settings;
|
||||
|
||||
if(Ninja::isHosted() && $entity?->calc_taxes && $company_settings->country_id == "840" && array_key_exists('settings', $entity->getDirty()))
|
||||
if( $entity?->calculate_taxes && $company_settings->country_id == "840" && array_key_exists('settings', $entity->getDirty()))
|
||||
{
|
||||
$old_settings = $entity->getOriginal()['settings'];
|
||||
|
||||
/** Monitor changes of the Postal code */
|
||||
if($old_settings->postal_code != $company_settings->postal_code)
|
||||
{
|
||||
|
||||
nlog("postal code change");
|
||||
CompanyTaxRate::dispatch($entity);
|
||||
}
|
||||
|
||||
}
|
||||
elseif( $entity?->calculate_taxes && $company_settings->country_id == "840" && array_key_exists('calculate_taxes', $entity->getDirty()) && $entity->getOriginal('calculate_taxes') == 0)
|
||||
{
|
||||
nlog("calc taxes change");
|
||||
nlog($entity->getOriginal('calculate_taxes'));
|
||||
CompanyTaxRate::dispatch($entity);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user