/** * Returns the tax rate for the given country. * * @param Request $request * * @return \Illuminate\Http\Response */ public function calculateGrossPrice(Request $request) { if (!$request->has('netPrice')) { return Response::json(['error' => "The 'netPrice' parameter is missing"], 422); } $valid_vat_id = null; $valid_company = false; if ($request->has('vat_number')) { $valid_company = $this->validateVATID($request->get('vat_number')); $valid_company = $valid_company['is_valid']; $valid_vat_id = $valid_company; } return ['gross_price' => $this->calculator->calculate($request->get('netPrice'), $request->get('country'), $request->get('postal_code'), $valid_company), 'net_price' => $this->calculator->getNetPrice(), 'tax_rate' => $this->calculator->getTaxRate(), 'tax_value' => $this->calculator->getTaxValue(), 'valid_vat_id' => $valid_vat_id]; }