fix fetch vat details not working for some use cases (#26771)

* fix not working for some use cases

* fix not working for some use cases

* use DOL_URL_ROOT

* fix travis

* Fix missing address
This commit is contained in:
sonikf 2023-11-23 18:47:17 +02:00 committed by GitHub
parent 8d203f4fd4
commit 22e5ef6e18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -69,7 +69,7 @@ if (isModEnabled('eventorganization')) {
if ($mysoc->country_code == 'GR') {
$u = getDolGlobalString('AADE_WEBSERVICE_USER');
$p = getDolGlobalString('AADE_WEBSERVICE_KEY');
$myafm = getDolGlobalString('MAIN_INFO_TVAINTRA');
$myafm = preg_replace('/\D/', '', getDolGlobalString('MAIN_INFO_TVAINTRA'));
}
@ -3225,7 +3225,7 @@ function GRVAT(a, u, p, myafm) {
$.ajax({
type: "GET",
url: "/societe/checkvat/checkVatGr.php",
url: '<?php echo DOL_URL_ROOT ?>/societe/checkvat/checkVatGr.php',
data: { afm }, // Set request parameters
success: function(data) {
var obj = data; // Parse response data as JSON
@ -3235,6 +3235,7 @@ function GRVAT(a, u, p, myafm) {
alert(obj.pErrorRec_out.errorDescr); // Display error message if AFM is null
} else {
$("#name").val(obj.RgWsPublicBasicRt_out.onomasia); // Set 'name' field value
$("#address").val(obj.RgWsPublicBasicRt_out.postalAddress + " " + obj.RgWsPublicBasicRt_out.postalAddressNo); // Set 'address' field value
$("#zipcode").val(obj.RgWsPublicBasicRt_out.postalZipCode); // Set 'zipcode' field value
$("#town").val(obj.RgWsPublicBasicRt_out.postalAreaDescription); // Set 'town' field value
$("#idprof2").val(obj.RgWsPublicBasicRt_out.doyDescr); // Set 'idprof2' field value

View File

@ -27,7 +27,7 @@ require "../../main.inc.php";
$username = getDolGlobalString('AADE_WEBSERVICE_USER'); // Get username from request
$password = getDolGlobalString('AADE_WEBSERVICE_KEY'); // Get password from request
$myafm = getDolGlobalString('MAIN_INFO_TVAINTRA'); // Get Vat from request
$myafm = preg_replace('/\D/', '', getDolGlobalString('MAIN_INFO_TVAINTRA')); // Get Vat from request after removing non-digit characters
$afm = GETPOST('afm'); // Get client Vat from request
// Make call to check VAT for Greek client
@ -40,11 +40,11 @@ echo json_encode($result); // Encode the result as JSON and output
* Request VAT details
* @param string $username Company AADE username
* @param string $password Company AADE password
* @param string $AFMcalledfor Company vat number
* @param string $AFMcalledby Client vat number
* @param string $AFMcalledby Company vat number
* @param string $AFMcalledfor Client vat number
* @return string
*/
function checkVATGR($username, $password, $AFMcalledfor, $AFMcalledby = '')
function checkVATGR($username, $password, $AFMcalledby, $AFMcalledfor)
{
/*
$WS_DOL_URL_WSDL = "https://www1.gsis.gr/webtax2/wsgsis/RgWsPublic/RgWsPublicPort?WSDL";
@ -76,7 +76,7 @@ function checkVATGR($username, $password, $AFMcalledfor, $AFMcalledby = '')
$authHeader->UsernameToken = new stdClass();
$authHeader->UsernameToken->Username = "$username";
$authHeader->UsernameToken->Password = "$password";
$Headers[] = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $authHeader, true);
$Headers[] = new SoapHeader('https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $authHeader, true);
$client->__setSoapHeaders($Headers);
$result = $client->rgWsPublicAfmMethod(
array(