Fixes for storecove additional identifier
This commit is contained in:
parent
46fa587e46
commit
7b9b18cbb1
|
|
@ -96,7 +96,7 @@ class EInvoicePeppolController extends BaseController
|
|||
* Update legal properties such as acting as sender or receiver.
|
||||
*
|
||||
* @param \App\Http\Requests\EInvoice\Peppol\UpdateEntityRequest $request
|
||||
* @return JsonResponse|mixed|Response
|
||||
* @return JsonResponse|
|
||||
*/
|
||||
public function updateLegalEntity(UpdateEntityRequest $request, Storecove $storecove): JsonResponse
|
||||
{
|
||||
|
|
@ -127,8 +127,8 @@ class EInvoicePeppolController extends BaseController
|
|||
* Removed the legal identity from the Peppol network
|
||||
*
|
||||
* @param DisconnectRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
*
|
||||
*/
|
||||
public function disconnect(DisconnectRequest $request, Storecove $storecove): JsonResponse
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||
|
||||
class AddTaxIdentifierRequest extends FormRequest
|
||||
{
|
||||
public static array $vat_regex_patterns = [
|
||||
public array $vat_regex_patterns = [
|
||||
'DE' => '/^DE\d{9}$/',
|
||||
'AT' => '/^ATU\d{8}$/',
|
||||
'BE' => '/^BE0\d{9}$/',
|
||||
|
|
@ -66,14 +66,14 @@ class AddTaxIdentifierRequest extends FormRequest
|
|||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'country' => ['required', 'bail', Rule::in(array_keys(self::$vat_regex_patterns))],
|
||||
'country' => ['required', 'bail', Rule::in(array_keys($this->vat_regex_patterns))],
|
||||
'vat_number' => [
|
||||
'required',
|
||||
'string',
|
||||
'bail',
|
||||
function ($attribute, $value, $fail) {
|
||||
if ($this->country && isset(self::$vat_regex_patterns[$this->country])) {
|
||||
if (!preg_match(self::$vat_regex_patterns[$this->country], $value)) {
|
||||
if ($this->country && isset($this->vat_regex_patterns[$this->country])) {
|
||||
if (!preg_match($this->vat_regex_patterns[$this->country], $value)) {
|
||||
$fail(ctrans('texts.invalid_vat_number'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ class Storecove
|
|||
* @param int $legal_entity_id
|
||||
* @param string $identifier
|
||||
* @param string $scheme
|
||||
* @return mixed
|
||||
* @return array|\Illuminate\Http\Client\Response
|
||||
*/
|
||||
|
||||
public function addAdditionalTaxIdentifier(int $legal_entity_id, string $identifier, string $scheme): array|\Illuminate\Http\Client\Response
|
||||
|
|
|
|||
|
|
@ -119,16 +119,19 @@ class StorecoveProxy
|
|||
|
||||
public function addAdditionalTaxIdentifier(array $data): array
|
||||
{
|
||||
$scheme = $this->storecove->router->resolveRouting($data['country'], $this->company->settings->classification);
|
||||
|
||||
$data = [
|
||||
...$data,
|
||||
'classification' => $this->company->settings->classification,
|
||||
'legal_entity_id' => $this->company->legal_entity_id,
|
||||
'scheme' => $scheme,
|
||||
];
|
||||
|
||||
if (Ninja::isHosted()) {
|
||||
$scheme = $this->storecove->router->resolveRouting($data['country'], $data['classification']);
|
||||
|
||||
$response = $this->storecove->addAdditionalTaxIdentifier($data['legal_entity_id'], $data['vat_number'], $scheme);
|
||||
|
||||
|
||||
if (is_array($response)) {
|
||||
return $response;
|
||||
}
|
||||
|
|
@ -147,7 +150,7 @@ class StorecoveProxy
|
|||
* @param mixed $response
|
||||
* @return array
|
||||
*/
|
||||
private function handleResponseError($response): array
|
||||
public function handleResponseError($response): array
|
||||
{
|
||||
$error = [
|
||||
'status' => 'error',
|
||||
|
|
|
|||
Loading…
Reference in New Issue