* 260126-bug-autoliquidation:

Fix Bug Intracomm
  Bug PEPPOL: set percent to 0 if autoreverse
This commit is contained in:
sparkyx 2026-01-26 13:45:34 +01:00
commit 0484129bc6
2 changed files with 43 additions and 5 deletions

View file

@ -245,6 +245,31 @@ class InvoiceUBL21 extends XMLInvoice {
$customer->appendChild($customer_party);
return $customer;
}
/**
* @brief Delivery Date is mandatory for INTRACOMM , so by default
* we set the invoice date
<cac:Delivery>
<cbc:ActualDeliveryDate>
2026-01-06
</cbc:ActualDeliveryDate>
</cac:Delivery>
*/
function build_deliveryDate()
{
$delivery=$this->createElement("cac:Delivery");
$delivery->appendChild($this->createElement("cbc:ActualDeliveryDate",$this->data['issue_date']));
//(cac:Delivery/cac:DeliveryLocation/cac:Address/cac:Country/cbc:IdentificationCode//
$loc= $this->createElement("cac:DeliveryLocation");
$addr=$this->createElement('cac:Address');
$country=$this->createElement("cac:Country");
$country->appendChild($this->createElement("cbc:IdentificationCode", $this->data['customer']['country']));
$addr->appendChild($country);
$loc->appendChild($addr);
$delivery->appendChild($loc);
return $delivery;
}
/**
/**
* @brief Build XML Block for payment
* @code
@ -659,6 +684,9 @@ class InvoiceUBL21 extends XMLInvoice {
// add the customer
$root->appendChild($this->build_customer());
// add delivery date
$root->appendChild($this->build_deliveryDate());
// add the payment if there is a bank account
if ( $company['COMPANY_BANK_IBAN'] != "")
$root->appendChild($this->build_paymentInfo());

View file

@ -292,7 +292,10 @@ abstract class XMLInvoice extends \DOMDocument
$VAT_SubTotal[$idx_subtotal]=array();
$VAT_SubTotal[$idx_subtotal]['idx']=$idx;
$VAT_SubTotal[$idx_subtotal]['vat_code']=$result['operation'][$i]['vat_code'] ;
$VAT_SubTotal[$idx_subtotal]['percent']=$percent;
if ( $acc_tva->tva_both_side == 1 )
$VAT_SubTotal[$idx_subtotal]['percent']=0;
else
$VAT_SubTotal[$idx_subtotal]['percent']=$percent;
$VAT_SubTotal[$idx_subtotal]['vatex']=$acc_tva->vx_code;
$VAT_SubTotal[$idx_subtotal]['amount']=$VAT_SubTotal[$idx_subtotal]['vat']=0;
@ -302,12 +305,19 @@ abstract class XMLInvoice extends \DOMDocument
* @todo Pour les intracomm , quel taux utilisé ? 0 ou 21%
*/
$VAT_SubTotal[$n]['amount']=bcadd($VAT_SubTotal[$n]['amount'],$result['operation'][$i]['price']);
$VAT_SubTotal[$n]['vat']=bcadd($VAT_SubTotal[$n]['vat'],$result['operation'][$i]['vat']);
$VAT_SubTotal[$n]['vat']=bcsub($VAT_SubTotal[$n]['vat'],$result['operation'][$i]['vat_reversed']);
if ( $acc_tva->tva_both_side == 0 )
$VAT_SubTotal[$n]['vat']=bcadd($VAT_SubTotal[$n]['vat'],$result['operation'][$i]['vat']);
$result['TaxableAmount']=bcadd( $result['TaxableAmount'],$result['operation'][$i]['price']);
$result['TaxAmount']=bcadd( $result['TaxAmount'],$result['operation'][$i]['vat']);
$result['TaxAmount']=bcsub( $result['TaxAmount'],$result['operation'][$i]['vat_reversed']);
// $result['TaxAmount']=bcsub( $result['TaxAmount'],$result['operation'][$i]['vat_reversed']);
$result['operation'][$i]['vat_percent']=$percent;
if ( $acc_tva->tva_both_side == 1 )
{
$result['operation'][$i]['vat_percent']=0;
}else {
$result['TaxAmount']=bcadd( $result['TaxAmount'],$result['operation'][$i]['vat']);
}
}
$result['subTotalVAT']=$VAT_SubTotal;
$result['LineExtensionAmount']= $result['TaxableAmount'];