diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6d6181ad75c..bdbf00360f2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2682,7 +2682,7 @@ class Commande extends CommonOrder $line->total_ht=100; $line->total_ttc=119.6; $line->total_tva=19.6; - $line->remise_percent=00; + $line->remise_percent=0; } $prodid = rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; @@ -2841,13 +2841,15 @@ class OrderLine var $localtax2_tx; // Local tax 2 var $subprice; // U.P. HT (example 100) var $remise_percent; // % for line discount (example 20%) + var $fk_remise_except; var $rang = 0; var $fk_fournprice; var $pa_ht; var $marge_tx; var $marque_tx; var $info_bits = 0; // Bit 0: 0 si TVA normal - 1 si TVA NPR - // Bit 1: 0 ligne normale - 1 si ligne de remise fixe + // Bit 1: 0 ligne normale - 1 si ligne de remise fixe + var $special_code = 0; var $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne var $total_localtax1; // Total local tax 1 for the line diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6f6c85abd59..e7e01691962 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -691,7 +691,7 @@ class Facture extends CommonInvoice // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; - if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) + if (! empty($object->other_linked_objects) && is_array($object->other_linked_objects)) { $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); } @@ -1330,6 +1330,8 @@ class Facture extends CommonInvoice if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; + $cdr_nbjour=0; $cdr_fdm=0; $cdr_decalage=0; + $sqltemp = 'SELECT c.fdm,c.nbjour,c.decalage'; $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 2ef81f12248..08a36521640 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -24,8 +24,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; /** - * \class CommonInvoice - * \brief Superclass for invoices classes + * Superclass for invoices classes */ abstract class CommonInvoice extends CommonObject { diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index b6df4922534..cf3fa89c655 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -267,7 +267,7 @@ function _unval($val) { // single, escaped unicode character $utf16 = chr(hexdec($reg[1])) . chr(hexdec($reg[2])); - $utf8 .= utf162utf8($utf16); + $utf8 = utf162utf8($utf16); $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i',$utf8,$val); } return $val; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index d1beb882588..77b0a7e0c66 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -263,7 +263,7 @@ class pdf_einstein extends ModelePDFCommandes $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0,0,0); - + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -621,7 +621,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248,248,248); @@ -629,7 +629,7 @@ class pdf_einstein extends ModelePDFCommandes $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && is_float($this->tva['0.000'])) ? true : false); + $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) { // Nothing to do @@ -761,7 +761,13 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0,0,0); - $resteapayer = price2num($object->total_ttc - $deja_regle); + $creditnoteamount=0; + $depositsamount=0; + //$creditnoteamount=$object->getSumCreditNotesUsed(); + //$depositsamount=$object->getSumDepositsUsed(); + //print "x".$creditnoteamount."-".$depositsamount;exit; + $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) { diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php index ad3cf02fcf6..b031341fe30 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php @@ -70,13 +70,18 @@ class pdf_expedition_merou extends ModelePdfExpedition /** - * Fonction generant le document sur le disque + * Function to build pdf onto disk * - * @param Object &$object Objet expedition a generer (ou id si ancienne methode) - * @param Translate $outputlangs Lang output object - * @return int 1=ok, 0=ko + * @param Object &$object Object expedition to generate (or id if old method) + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @param object $hookmanager Hookmanager object + * @return int 1=OK, 0=KO */ - function write_file(&$object, $outputlangs) + function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) { global $user,$conf,$langs,$mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -108,12 +113,12 @@ class pdf_expedition_merou extends ModelePdfExpedition //Creation du destinataire $idcontact = $object->$origin->getIdContact('external','SHIPPING'); $this->destinataire = new Contact($this->db); - if ($idcontact[0]) $this->destinataire->fetch($idcontact[0]); + if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); //Creation du livreur $idcontact = $object->$origin->getIdContact('internal','LIVREUR'); $this->livreur = new User($this->db); - if ($idcontact[0]) $this->livreur->fetch($idcontact[0]); + if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]); // Definition de $dir et $file if ($object->specimen) @@ -201,7 +206,7 @@ class pdf_expedition_merou extends ModelePdfExpedition $curY = $nexY; $pdf->SetFont('','', $default_font_size - 3); $pdf->SetTextColor(0,0,0); - + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php index fe8288d3cca..017a0fd8818 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php @@ -73,13 +73,18 @@ class pdf_expedition_rouget extends ModelePdfExpedition } /** - * Fonction generant le document sur le disque + * Function to build pdf onto disk * - * @param Object &$object Objet expedition a generer (ou id si ancienne methode) - * @param Translate $outputlangs Lang output object - * @return int 1=ok, 0=ko + * @param Object &$object Object expedition to generate (or id if old method) + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @param object $hookmanager Hookmanager object + * @return int 1=OK, 0=KO */ - function write_file(&$object, $outputlangs) + function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) { global $user,$conf,$langs; $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 44a1987aaf2..1f177874b69 100755 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -119,14 +119,14 @@ class pdf_crabe extends ModelePDFFactures /** * Function to build pdf onto disk * - * @param int $object Id of object to generate - * @param object $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object - * @return int 1=OK, 0=KO + * @param Object $object Object to generate + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @param object $hookmanager Hookmanager object + * @return int 1=OK, 0=KO */ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) { @@ -266,7 +266,7 @@ class pdf_crabe extends ModelePDFFactures $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0,0,0); - + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -745,7 +745,6 @@ class pdf_crabe extends ModelePDFFactures $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 0a2d1484bdd..e113b61aa80 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -117,14 +117,14 @@ class pdf_azur extends ModelePDFPropales /** * Function to build pdf onto disk * - * @param int $object Id of object to generate - * @param object $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object - * @return int 1=OK, 0=KO + * @param Object $object Object to generate + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @param object $hookmanager Hookmanager object + * @return int 1=OK, 0=KO */ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) { @@ -264,7 +264,7 @@ class pdf_azur extends ModelePDFPropales $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0,0,0); - + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -393,7 +393,8 @@ class pdf_azur extends ModelePDFPropales $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Affiche zone versements /* @@ -802,7 +803,7 @@ class pdf_azur extends ModelePDFPropales $resteapayer = $object->total_ttc - $deja_regle; if (! empty($object->paye)) $resteapayer=0; */ - + if ($deja_regle > 0) { $index++; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 67786e0a944..de7e988c9bf 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -273,7 +273,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0,0,0); - + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -329,15 +329,18 @@ if ($pageposafter > $pageposbefore) { $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; + if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; + if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; $vatrate=(string) $object->lines[$i]->tva_tx; $localtax1rate=(string) $object->lines[$i]->localtax1_tx; $localtax2rate=(string) $object->lines[$i]->localtax2_tx; if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; + if (! isset($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=''; + if (! isset($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=''; $this->tva[$vatrate] += $tvaligne; $this->localtax1[$localtax1rate]+=$localtax1ligne; $this->localtax2[$localtax2rate]+=$localtax2ligne; @@ -627,7 +630,7 @@ if ($pageposafter > $pageposbefore) { $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248,248,248); @@ -764,7 +767,7 @@ if ($pageposafter > $pageposbefore) { //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); - if ($object->paye) $resteapayer=0; + if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d7e0f4e9ba1..84a21b97a1c 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1904,6 +1904,8 @@ class CommandeFournisseurLigne var $total_localtax1; var $total_localtax2; var $total_ttc; + var $info_bits; + var $special_code; // From llx_product var $libelle; // Label produit diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 9121756bd3b..38d245fa63f 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -77,7 +77,8 @@ class FactureFournisseur extends CommonInvoice var $propalid; var $lines; - var $fournisseur; + var $fournisseur; // deprecated + var $thirdparty; // To store thirdparty var $extraparams=array(); diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 7024c05441b..14ba98526f0 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -548,7 +548,7 @@ if (empty($reshook)) $prod->id, GETPOST('remise_percent'), '', - '', // TODO voir si fk_remise_except est encore valable car n'apparait plus dans les propales + '', $price_base_type, $pu_ttc ); diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index d6dd3d5a16f..8e90d654c1b 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -139,7 +139,7 @@ class ImagesLibTest extends PHPUnit_Framework_TestCase $this->assertEquals($tmp['width'],250); $this->assertEquals($tmp['height'],20);*/ - return $result; + return 1; } } diff --git a/test/phpunit/_NumberingModulesTest.php b/test/phpunit/_NumberingModulesTest.php index 31c88f8dfa1..98c9c31bba3 100644 --- a/test/phpunit/_NumberingModulesTest.php +++ b/test/phpunit/_NumberingModulesTest.php @@ -120,7 +120,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase */ public function testFactureMercure() { - global $conf,$user,$langs,$db; + global $conf,$user,$langs,$db,$mysoc; $conf=$this->savconf; $user=$this->savuser; $langs=$this->savlangs;