mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 00:24:36 -04:00
Adjustments for taxes
This commit is contained in:
parent
524901c872
commit
527c99eb5b
@ -212,6 +212,7 @@ class BaseRule implements RuleInterface
|
|||||||
// $tp->updateClientTaxData();
|
// $tp->updateClientTaxData();
|
||||||
// $this->client->fresh();
|
// $this->client->fresh();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if($this->client->tax_data)
|
if($this->client->tax_data)
|
||||||
$tax_data = $this->client->tax_data;
|
$tax_data = $this->client->tax_data;
|
||||||
|
|
||||||
|
@ -161,13 +161,15 @@ class Rule extends BaseRule implements RuleInterface
|
|||||||
if($this->tax_data?->stateSalesTax == 0) {
|
if($this->tax_data?->stateSalesTax == 0) {
|
||||||
|
|
||||||
$this->tax_rate1 = $this->invoice->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
|
$this->tax_rate1 = $this->invoice->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
|
||||||
$this->tax_name1 = $this->invoice->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
|
$this->tax_name1 = "Sales Tax";
|
||||||
|
// $this->tax_name1 = $this->invoice->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->tax_rate1 = $this->tax_data->taxSales * 100;
|
$this->tax_rate1 = $this->tax_data->taxSales * 100;
|
||||||
$this->tax_name1 = "{$this->tax_data->geoState} Sales Tax";
|
// $this->tax_name1 = "{$this->tax_data->geoState} Sales Tax";
|
||||||
|
$this->tax_name1 = "Sales Tax";
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,12 @@ class TaxProvider
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateCompanyTaxData
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
public function updateCompanyTaxData(): self
|
public function updateCompanyTaxData(): self
|
||||||
{
|
{
|
||||||
$this->configureProvider($this->provider, $this->company->country()->iso_3166_2); //hard coded for now to one provider, but we'll be able to swap these out later
|
$this->configureProvider($this->provider, $this->company->country()->iso_3166_2); //hard coded for now to one provider, but we'll be able to swap these out later
|
||||||
@ -83,7 +88,12 @@ class TaxProvider
|
|||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateClientTaxData
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
public function updateClientTaxData(): self
|
public function updateClientTaxData(): self
|
||||||
{
|
{
|
||||||
$this->configureProvider($this->provider, $this->client->country->iso_3166_2); //hard coded for now to one provider, but we'll be able to swap these out later
|
$this->configureProvider($this->provider, $this->client->country->iso_3166_2); //hard coded for now to one provider, but we'll be able to swap these out later
|
||||||
@ -106,8 +116,9 @@ class TaxProvider
|
|||||||
'country_id' => $this->client->shipping_country_id,
|
'country_id' => $this->client->shipping_country_id,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$taxable_address = $this->taxShippingAddress() ? $shipping_details : $billing_details;
|
||||||
$tax_provider = new $this->provider($billing_details);
|
|
||||||
|
$tax_provider = new $this->provider($taxable_address);
|
||||||
|
|
||||||
$tax_provider->setApiCredentials($this->api_credentials);
|
$tax_provider->setApiCredentials($this->api_credentials);
|
||||||
|
|
||||||
@ -120,7 +131,29 @@ class TaxProvider
|
|||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* taxShippingAddress
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function taxShippingAddress(): bool
|
||||||
|
{
|
||||||
|
|
||||||
|
if($this->client->shipping_country_id == "840" && strlen($this->client->shipping_postal_code) > 3)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* configureProvider
|
||||||
|
*
|
||||||
|
* @param string $provider
|
||||||
|
* @param string $country_code
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
private function configureProvider(?string $provider, string $country_code): self
|
private function configureProvider(?string $provider, string $country_code): self
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -159,21 +192,36 @@ class TaxProvider
|
|||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* configureEuTax
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
private function configureEuTax(): self
|
private function configureEuTax(): self
|
||||||
{
|
{
|
||||||
$this->provider = EuTax::class;
|
$this->provider = EuTax::class;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* noTaxRegionDefined
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function noTaxRegionDefined()
|
private function noTaxRegionDefined()
|
||||||
{
|
{
|
||||||
throw new \Exception("No tax region defined for this country");
|
throw new \Exception("No tax region defined for this country");
|
||||||
|
|
||||||
// return $this;
|
// return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* configureZipTax
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
private function configureZipTax(): self
|
private function configureZipTax(): self
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user