mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Rules
This commit is contained in:
parent
50c26bee4c
commit
63da663afa
@ -74,12 +74,27 @@ class Rule extends BaseRule implements RuleInterface
|
||||
Product::PRODUCT_TYPE_PHYSICAL => $this->taxPhysical(),
|
||||
Product::PRODUCT_TYPE_REDUCED_TAX => $this->taxReduced(),
|
||||
Product::PRODUCT_TYPE_OVERRIDE_TAX => $this->override(),
|
||||
Product::PRODUCT_TYPE_ZERO_RATED => $this->zeroRated(),
|
||||
Product::PRODUCT_TYPE_REVERSE_TAX => $this->reverseTax(),
|
||||
default => $this->default(),
|
||||
};
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the tax rate for a reduced tax product
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function reverseTax(): self
|
||||
{
|
||||
$this->tax_rate1 = 0;
|
||||
$this->tax_name1 = 'ermäßigte MwSt.';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the tax rate for a reduced tax product
|
||||
*
|
||||
@ -93,6 +108,20 @@ class Rule extends BaseRule implements RuleInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the tax rate for a zero rated tax product
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function zeroRated(): self
|
||||
{
|
||||
$this->tax_rate1 = 0;
|
||||
$this->tax_name1 = 'ermäßigte MwSt.';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the tax rate for a tax exempt product
|
||||
*
|
||||
|
@ -64,7 +64,8 @@ class Rule extends BaseRule implements RuleInterface
|
||||
Product::PRODUCT_TYPE_SHIPPING => $this->taxShipping(),
|
||||
Product::PRODUCT_TYPE_PHYSICAL => $this->taxPhysical(),
|
||||
Product::PRODUCT_TYPE_REDUCED_TAX => $this->taxReduced(),
|
||||
Product::PRODUCT_TYPE_OVERRIDE_TAX => $this->override(),
|
||||
Product::PRODUCT_TYPE_OVERRIDE_TAX => $this->override(),
|
||||
Product::PRODUCT_TYPE_ZERO_RATED => $this->zeroRated(),
|
||||
default => $this->default(),
|
||||
};
|
||||
|
||||
@ -169,6 +170,16 @@ class Rule extends BaseRule implements RuleInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function zeroRated(): self
|
||||
{
|
||||
|
||||
$this->tax_rate1 = 0;
|
||||
$this->tax_name1 = "{$this->tax_data->geoState} Zero Rated Tax";
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the tax rate for a reduced tax product
|
||||
*
|
||||
@ -190,4 +201,18 @@ class Rule extends BaseRule implements RuleInterface
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the tax rate for a reverse tax product
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function reverseTax(): self
|
||||
{
|
||||
$this->default();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ class TaxProvider
|
||||
|
||||
public function __construct(public Company $company, public Client $client)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -114,6 +113,8 @@ class TaxProvider
|
||||
|
||||
$tax_data = $tax_provider->run();
|
||||
|
||||
nlog($tax_data);
|
||||
|
||||
$this->client->tax_data = $tax_data;
|
||||
|
||||
$this->client->save();
|
||||
|
@ -27,8 +27,9 @@ class ZipTax implements TaxProviderInterface
|
||||
|
||||
public function run()
|
||||
{
|
||||
$string_address = implode(" ", $this->address);
|
||||
|
||||
$response = $this->callApi(['key' => $this->api_key, 'address' => $this->address]);
|
||||
$response = $this->callApi(['key' => $this->api_key, 'address' => $string_address]);
|
||||
|
||||
if($response->successful())
|
||||
return $response->json();
|
||||
@ -36,6 +37,9 @@ class ZipTax implements TaxProviderInterface
|
||||
if(isset($this->address['postal_code'])) {
|
||||
$response = $this->callApi(['key' => $this->api_key, 'address' => $this->address['postal_code']]);
|
||||
|
||||
nlog($response->json());
|
||||
nlog($response->body());
|
||||
|
||||
if($response->successful())
|
||||
return $response->json();
|
||||
|
||||
|
@ -5092,4 +5092,4 @@ $LANG = array(
|
||||
|
||||
return $LANG;
|
||||
|
||||
?>
|
||||
?>
|
Loading…
Reference in New Issue
Block a user