Merge pull request #27568 from comaiteseb/19.0

FIX #27536 VAT of the buyer's country not applied while SERVICE_ARE_ECOMMERCE_200238EC option is activated
This commit is contained in:
Laurent Destailleur
2024-01-18 11:05:14 +01:00
committed by GitHub

View File

@@ -6509,14 +6509,31 @@ class Form
}
if (getDolGlobalString('SERVICE_ARE_ECOMMERCE_200238EC')) { // If option to have vat for end customer for services is on
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
if (!isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) {
// If SERVICE_ARE_ECOMMERCE_200238EC=1 combo list vat rate of purchaser and seller countries
// If SERVICE_ARE_ECOMMERCE_200238EC=2 combo list only the vat rate of the purchaser country
$selectVatComboMode = getDolGlobalString('SERVICE_ARE_ECOMMERCE_200238EC');
if (isInEEC($societe_vendeuse) && isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()) {
// We also add the buyer country code
if (is_numeric($type)) {
if ($type == 1) { // We know product is a service
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
switch ($selectVatComboMode) {
case '1':
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
break;
case '2':
$code_country = "'" . $societe_acheteuse->country_code . "'";
break;
}
}
} elseif (!$idprod) { // We don't know type of product
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
switch ($selectVatComboMode) {
case '1':
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
break;
case '2':
$code_country = "'" . $societe_acheteuse->country_code . "'";
break;
}
} else {
$prodstatic = new Product($this->db);
$prodstatic->fetch($idprod);