diff --git a/app/DataMapper/Tax/DE/Rule.php b/app/DataMapper/Tax/DE/Rule.php index 2118adf02e98..98f7016eb5fd 100644 --- a/app/DataMapper/Tax/DE/Rule.php +++ b/app/DataMapper/Tax/DE/Rule.php @@ -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 * diff --git a/app/DataMapper/Tax/US/Rule.php b/app/DataMapper/Tax/US/Rule.php index 854a689cae2a..f22e09b612e4 100644 --- a/app/DataMapper/Tax/US/Rule.php +++ b/app/DataMapper/Tax/US/Rule.php @@ -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; + } + + } diff --git a/app/Services/Tax/Providers/TaxProvider.php b/app/Services/Tax/Providers/TaxProvider.php index c00950e33324..73ecb3a7f119 100644 --- a/app/Services/Tax/Providers/TaxProvider.php +++ b/app/Services/Tax/Providers/TaxProvider.php @@ -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(); diff --git a/app/Services/Tax/Providers/ZipTax.php b/app/Services/Tax/Providers/ZipTax.php index b6f90815db11..7c73c0aeba95 100644 --- a/app/Services/Tax/Providers/ZipTax.php +++ b/app/Services/Tax/Providers/ZipTax.php @@ -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(); diff --git a/lang/en/texts.php b/lang/en/texts.php index 886b2f0e77e3..009e9dee94e6 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5092,4 +5092,4 @@ $LANG = array( return $LANG; -?> +?> \ No newline at end of file