mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for tax calculations
This commit is contained in:
parent
17d68e7aca
commit
e5bd186b61
@ -308,7 +308,8 @@ class ClientController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function updateTaxData(PurgeClientRequest $request, Client $client)
|
public function updateTaxData(PurgeClientRequest $request, Client $client)
|
||||||
{
|
{
|
||||||
(new UpdateTaxData($client, $client->company))->handle();
|
if($client->company->account->isPaid())
|
||||||
|
(new UpdateTaxData($client, $client->company))->handle();
|
||||||
|
|
||||||
return $this->itemResponse($client->fresh());
|
return $this->itemResponse($client->fresh());
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ class UpdateTaxData implements ShouldQueue
|
|||||||
{
|
{
|
||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
if($this->company->account->isFreeHostedClient())
|
if($this->company->account->isFreeHostedClient() || $this->client->country_id != 840)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$tax_provider = new \App\Services\Tax\Providers\TaxProvider($this->company, $this->client);
|
$tax_provider = new \App\Services\Tax\Providers\TaxProvider($this->company, $this->client);
|
||||||
@ -73,69 +73,6 @@ class UpdateTaxData implements ShouldQueue
|
|||||||
nlog("problem getting tax data => ".$e->getMessage());
|
nlog("problem getting tax data => ".$e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if(!$tax_provider->updatedTaxStatus() && $this->client->country_id == 840){
|
|
||||||
|
|
||||||
$calculated_state = false;
|
|
||||||
|
|
||||||
if(array_key_exists($this->client->shipping_state, USStates::get())) {
|
|
||||||
$calculated_state = $this->client->shipping_state;
|
|
||||||
$calculated_postal_code = $this->client->shipping_postal_code;
|
|
||||||
$calculated_city = $this->client->shipping_city;
|
|
||||||
}
|
|
||||||
elseif(array_key_exists($this->client->state, USStates::get())){
|
|
||||||
$calculated_state = $this->client->state;
|
|
||||||
$calculated_postal_code = $this->client->postal_code;
|
|
||||||
$calculated_city = $this->client->city;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
try{
|
|
||||||
$calculated_state = USStates::getState($this->client->shipping_postal_code);
|
|
||||||
$calculated_postal_code = $this->client->shipping_postal_code;
|
|
||||||
$calculated_city = $this->client->shipping_city;
|
|
||||||
}
|
|
||||||
catch(\Exception $e){
|
|
||||||
nlog("could not calculate state from postal code => {$this->client->shipping_postal_code} or from state {$this->client->shipping_state}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$calculated_state) {
|
|
||||||
try {
|
|
||||||
$calculated_state = USStates::getState($this->client->postal_code);
|
|
||||||
$calculated_postal_code = $this->client->postal_code;
|
|
||||||
$calculated_city = $this->client->city;
|
|
||||||
} catch(\Exception $e) {
|
|
||||||
nlog("could not calculate state from postal code => {$this->client->postal_code} or from state {$this->client->state}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->company->tax_data?->seller_subregion)
|
|
||||||
$calculated_state = $this->company->tax_data?->seller_subregion;
|
|
||||||
|
|
||||||
nlog("i am trying");
|
|
||||||
|
|
||||||
if(!$calculated_state) {
|
|
||||||
nlog("could not determine state");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'seller_subregion' => $this->company->tax_data?->seller_subregion ?: '',
|
|
||||||
'geoPostalCode' => $this->client->postal_code ?? '',
|
|
||||||
'geoCity' => $this->client->city ?? '',
|
|
||||||
'geoState' => $calculated_state,
|
|
||||||
'taxSales' => $this->company->tax_data->regions->US->subregions?->{$calculated_state}?->taxSales ?? 0,
|
|
||||||
];
|
|
||||||
|
|
||||||
$tax_data = new Response($data);
|
|
||||||
|
|
||||||
$this->client->tax_data = $tax_data;
|
|
||||||
$this->client->saveQuietly();
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function middleware()
|
public function middleware()
|
||||||
|
@ -225,6 +225,8 @@ class TaxProvider
|
|||||||
*/
|
*/
|
||||||
private function configureEuTax(): self
|
private function configureEuTax(): self
|
||||||
{
|
{
|
||||||
|
throw new \Exception("No tax region defined for this country");
|
||||||
|
|
||||||
$this->provider = EuTax::class;
|
$this->provider = EuTax::class;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user