diff --git a/include/XMLDocument/InvoiceUBL21.php b/include/XMLDocument/InvoiceUBL21.php index 52f3a9bdc..15bb31dfd 100644 --- a/include/XMLDocument/InvoiceUBL21.php +++ b/include/XMLDocument/InvoiceUBL21.php @@ -88,6 +88,7 @@ class InvoiceUBL21 extends XMLInvoice { // verify that all needed data in PARAMETER are valid $a_error['company'] = $this->check_company_data(); $a_error['customer'] = $this->check_customer_data($this->data['customer']['card_id']); + return $a_error; } /** @@ -469,22 +470,15 @@ class InvoiceUBL21 extends XMLInvoice { $result=$this->createElement('cac:InvoiceLine'); $row=$this->data["operation"][$i]; - $amount=sprintf("%.2f",abs($row['price'])); + $amount=sprintf("%.2f",$row['price']); $result->appendChild($this->createElement("cbc:ID", $i)); - $amount=sprintf("%.2f",abs($row['price'])); + $amount=sprintf("%.2f",$row['price']); $result->appendChild( $this->createElement("cbc:InvoicedQuantity", sprintf("%.2f",$row['quantity']))) ->setAttribute("unitCode", $row["code_quantity"]); $result->appendChild($this->createElement("cbc:LineExtensionAmount", $amount)) ->setAttribute("currencyID",$this->data['currency']); - // @IMPORTANT@ Impossible de connaitre la remise par article, non prévu dans NOALYSS ALLOWANCE - if ( $row['price'] < 0 ) { - $allowanceCharge=$this->createElement("cac:AllowanceCharge"); - $allowanceCharge->appendChild($this->createElement("cbc:ChargeIndicator","false")); - $allowanceCharge->appendChild($this->createElement("cbc:Amount",sprintf("%.2f",$amount))); - $result->appendChild($allowanceCharge); - } // ITEM $item=$this->createElement("cac:Item"); @@ -504,7 +498,7 @@ class InvoiceUBL21 extends XMLInvoice { $item->appendChild($classifiedTaxCat); $result->appendChild($item); $price=$result->appendChild($this->createElement("cac:Price")); - $price->appendChild($this->createElement("cbc:PriceAmount",sprintf("%.2f",$amount))) + $price->appendChild($this->createElement("cbc:PriceAmount",sprintf("%.2f",abs($amount)))) ->setAttribute("currencyID",$this->data['currency']); $result->appendChild($price); @@ -553,7 +547,8 @@ class InvoiceUBL21 extends XMLInvoice { $result=$this->createElement("cac:AdditionalDocumentReference"); $id=$this->createElement("cbc:ID",$i); - $document_description=$this->createElement("cbc:DocumentDescription",'INVOICE PDF'); + $document_description=$this->createElement("cbc:DocumentDescription" + , $this->data['description']); // PDF in base64 $base64Pdf = base64_encode($pdfContent); diff --git a/include/XMLDocument/XMLInvoice.php b/include/XMLDocument/XMLInvoice.php index ba5a2d392..9eea0cc27 100644 --- a/include/XMLDocument/XMLInvoice.php +++ b/include/XMLDocument/XMLInvoice.php @@ -183,8 +183,12 @@ abstract class XMLInvoice extends \DOMDocument $result['currency']=$this->cn->get_value("select cr_code_iso from currency where id=$1" ,array($operation->det->currency_id)); + // document description + $result['description']=$operation->det->jr_comment; + // goods and services $result['operation']=array(); + $nb_operation= count($operation->det->array); for ($i=0;$i < $nb_operation;$i++) { $result['operation'][$i]['card_id']=$operation->det->array[$i]['qs_fiche']; diff --git a/include/class/acc_ledger_sale.class.php b/include/class/acc_ledger_sale.class.php index fd7c35420..8322f8391 100644 --- a/include/class/acc_ledger_sale.class.php +++ b/include/class/acc_ledger_sale.class.php @@ -922,6 +922,7 @@ class Acc_Ledger_Sale extends Acc_Ledger { $r.='' . _('Numéro Pièce') .$span.''. hb($this->pj) . ''; } } + $e_comm=($e_comm == "")?_('Facture')." $e_pj":$e_comm; $r.=''; $r.=''; $r.=' ' . _('Date') . ' ' . hb($e_date) . ''; diff --git a/include/compta_ven.inc.php b/include/compta_ven.inc.php index 55419eecf..cbad690d1 100644 --- a/include/compta_ven.inc.php +++ b/include/compta_ven.inc.php @@ -97,9 +97,6 @@ if ( isset ($_POST['view_invoice'] ) ) { $array['due_date']=$http->post("e_date"); } - ///////////////////////////////////////////////// - ///@todo ajouter date échéance - ///////////////////////////////////////////////// $xmldocument->set_data($array); $xmldocument->display_error(); } @@ -189,7 +186,9 @@ if ( isset($_POST['record']) ) $xmldocument= \Noalyss\XMLDocument\XMLInvoice::build_xmlinvoice($cn); $xmldocument->build_data($Ledger->jr_id); $code_error = $xmldocument->verify() ; - if ( ! empty( $code_error ) ) { + // check that all the sub arrays are empty + if ( ! empty( array_filter($code_error,function($a){ if (!empty($a)) return true; }))) + { $xmldocument->display_error(); $flag_invoice=1; } @@ -210,11 +209,12 @@ if ( isset($_POST['record']) ) // make the XML + PDF $xml=$xmldocument->make_xml($Ledger->jr_id); if (DEBUGNOALYSS > 1) { - $mt=date ('ymd-Hi'); + $mt=date ('ymd-Hi').'+'.$Ledger->jr_id; $uniq= $_ENV['TMP']. DIRECTORY_SEPARATOR."$mt-e-invoice.xml"; file_put_contents($uniq, $xml); chmod ($uniq,774); echo \Noalyss\Dbg::echo_file("file save $uniq"); + } // save XML string into the DB $oid=$cn->lo_write($xml);