diff --git a/include/XMLDocument/error_message.class.php b/include/XMLDocument/error_message.class.php index 365425c97..de60b4a6a 100644 --- a/include/XMLDocument/error_message.class.php +++ b/include/XMLDocument/error_message.class.php @@ -95,7 +95,7 @@ class Error_Message , 'postalzone' => _("Code postal") , 'city' => _("Ville") , 'country'=>_("Code pays") - , 'customer_id' => _("Numéro de TVA") + , 'customer_vat_id' => _("Numéro de TVA") , 'endpoint_id' => _('Identifiant PEPPOL') // here 9925:BE.... ); diff --git a/include/XMLDocument/facturx.class.php b/include/XMLDocument/facturx.class.php index b4fe7c9ee..4111796b0 100644 --- a/include/XMLDocument/facturx.class.php +++ b/include/XMLDocument/facturx.class.php @@ -90,7 +90,7 @@ class FacturX extends XMLInvoice ,ATTR_DEF_POSTCODE=>'postalzone' ,ATTR_DEF_CITY=>'city' ,ATTR_DEF_COUNTRY_CODE=>'country' - ,ATTR_DEF_NUMTVA=>'customer_id' + ,ATTR_DEF_NUMTVA=>'customer_vat_id' ,ATTR_DEF_PEPPOLID=>'endpoint_id' ]; @@ -148,7 +148,7 @@ class FacturX extends XMLInvoice // BUYER //------------------------------------------------ - $documentBuilder->setDocumentBuyer($this->data['customer']['name'], $this->data['customer']['customer_id']); + $documentBuilder->setDocumentBuyer($this->data['customer']['name'], $this->data['customer']['customer_vat_id']); $documentBuilder->setDocumentBuyerAddress( $this->data['customer']['street'] , '' diff --git a/include/XMLDocument/invoiceubl21.class.php b/include/XMLDocument/invoiceubl21.class.php index 09b161361..6f8db429f 100644 --- a/include/XMLDocument/invoiceubl21.class.php +++ b/include/XMLDocument/invoiceubl21.class.php @@ -218,7 +218,7 @@ class InvoiceUBL21 extends XMLInvoice { $postal_address->appendChild($this->createElement("cbc:StreetName", $this->data['supplier']['street'])); $postal_address->appendChild($this->createElement("cbc:CityName", $this->data['supplier']['city'])); $postal_address->appendChild($this->createElement("cbc:PostalZone", $this->data['supplier']['postalzone'])); - $country_code = $company['COUNTRY_CODE']; + $country_code = $company['MY_COUNTRY_CODE']; $country=$postal_address->appendChild($this->createElement("cac:Country")); $country->appendChild($this->createElement('cbc:IdentificationCode',$country_code??"ERROR")); $postal_address->appendChild($country); diff --git a/include/class/acc_ledger_sale.class.php b/include/class/acc_ledger_sale.class.php index 81d4521fe..5a075c252 100644 --- a/include/class/acc_ledger_sale.class.php +++ b/include/class/acc_ledger_sale.class.php @@ -1852,7 +1852,59 @@ EOF; return $array; } - + /** + * @brief convert an Acc_Sold to an array usable by + * Acc_Document::create_document + * @parameters $sold (Acc_Sold) convert to convert + */ + static function convert_to_array(Acc_Sold $sold) + { + //print $sold; + $item=count($sold->det->array); + if ( $item ==0) + { + throw new \Exception('No Data in Quant_sold'); + } + $array=array(); + + $array['e_ech']=format_date($sold->det->jr_ech); + $array['e_comm']=$sold->det->jr_comment; + $array['p_jrn']=$sold->det->jr_def_id; + $array['nb_item']=$item; + $array['ledger_type']=$sold->signature; + $array['e_date']= format_date($sold->det->jr_date); + $array['e_pj']= $sold->det->jr_pj_number; + $array['jr_date_paid']=$sold->det->jr_date_paid; + + //$this->pj=$array['e_pj']; + $array['internal']=$sold->det->jr_internal; + + $client=new \Fiche($sold->db,$sold->det->array[0]['qs_client']); + $array['e_client']=$client->get_quick_code(); + bcscale(2); + for ($i=0;$i < $item ; $i++) + { + $idx='e_march'; + $serv=new \Fiche($sold->db,$sold->det->array[$i]['qs_fiche']); + $array[$idx.$i]=$serv->get_quick_code(); + $array[$idx.$i.'_label']=$sold->det->array[$i]['j_text']; + $array[$idx.$i.'_price']=bcdiv($sold->det->array[$i]['qs_price'],$sold->det->array[$i]['qs_quantite']); + $array[$idx.$i.'_tva_id']=$sold->det->array[$i]['qs_vat_code']; + $array[$idx.$i.'_tva_amount']=bcsub($sold->det->array[$i]['qs_vat'],$sold->det->array[$i]['qs_vat_sided']); + $array['e_quant'.$i]=$sold->det->array[$i]['qs_quantite']; + } + // Get OTHER_INFO and BON_COMM + $cn=\Dossier::connect(); + $array['bon_comm']=$cn->get_value("select ji_value from jrn_info where jr_id=$1 and id_type = 'BON_COMMANDE' ",[$sold->det->jr_id]); + $array['other_info']=$cn->get_value("select ji_value from jrn_info where jr_id=$1 and id_type = 'OTHER' ",[$sold->det->jr_id]); + $array['jrn_note_input']=$cn->get_value("select n_text from + jrn_note where jr_id=$1 ",[$sold->det->jr_id]); + $array['p_currency_code']=$sold->det->currency_id; + $array['p_currency_rate']=$sold->det->currency_rate; + return $array; + + + } }