client = $client; return $this; } public function setTaxData(Response $tax_data): self { $this->tax_data = $tax_data; return $this; } public function tax(): self { $this->tax_name1 = $this->vat_rate; $this->tax_rate1 = "VAT"; return $this; } public function taxByType(?int $product_tax_type): self { if(!$product_tax_type) return $this; match($product_tax_type){ Product::PRODUCT_TAX_EXEMPT => $this->taxExempt(), Product::PRODUCT_TYPE_DIGITAL => $this->taxDigital(), Product::PRODUCT_TYPE_SERVICE => $this->taxService(), Product::PRODUCT_TYPE_SHIPPING => $this->taxShipping(), Product::PRODUCT_TYPE_PHYSICAL => $this->taxPhysical(), Product::PRODUCT_TYPE_REDUCED_TAX => $this->taxReduced(), default => $this->default(), }; return $this; } public function taxReduced(): self { $this->tax_rate1 = $this->vat_reduced_rate; $this->tax_name1 = 'VAT'; return $this; } public function taxExempt(): self { $this->tax_name1 = ''; $this->tax_rate1 = 0; return $this; } public function taxDigital(): self { $this->tax(); return $this; } public function taxService(): self { if($this->tax_data->txbService == 'Y') $this->tax(); return $this; } public function taxShipping(): self { if($this->tax_data->txbFreight == 'Y') $this->tax(); return $this; } public function taxPhysical(): self { $this->tax(); return $this; } public function default(): self { $this->tax_name1 = ''; $this->tax_rate1 = 0; return $this; } }