diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 598c472f52a..25a29270976 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -899,6 +899,7 @@ if (empty($reshook)) { $price_ht_devise = ''; $price_ttc = ''; $price_ttc_devise = ''; + if (GETPOST('price_ht') !== '') { $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); } @@ -1319,7 +1320,7 @@ if (empty($reshook)) { $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); - //$pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); + $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); @@ -1403,7 +1404,14 @@ if (empty($reshook)) { $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); - $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOST("units"), $pu_ht_devise); + $pu = $pu_ht; + $price_base_type = 'HT'; + if (empty($pu) && ! empty($pu_ttc)) { + $pu = $pu_ttc; + $price_base_type = 'TTC'; + } + + $result = $object->updateline(GETPOST('lineid', 'int'), $pu, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, $price_base_type, $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOST("units"), $pu_ht_devise); if ($result >= 0) { $db->commit(); @@ -2717,7 +2725,7 @@ if ($action == 'create') { * Lines */ - // Show object lines + // Get object lines $result = $object->getLinesArray(); // Add products/services form @@ -2725,7 +2733,7 @@ if ($action == 'create') { global $inputalsopricewithtax; $inputalsopricewithtax = 1; - print '
+ print ' diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9831c6d7772..aa7753946a7 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -932,9 +932,6 @@ class Propal extends CommonObject $this->line->date_start = $date_start; $this->line->date_end = $date_end; - // TODO deprecated - $this->line->price = $price; - if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options foreach ($array_options as $key => $value) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 667b55d7bb3..b7ef455f515 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1058,12 +1058,14 @@ if (empty($reshook)) { $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml')); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0); $vat_rate = str_replace('*', '', $vat_rate); + $pu_ht = price2num(GETPOST('price_ht'), '', 2); $pu_ttc = price2num(GETPOST('price_ttc'), '', 2); - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); - //$pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); - $qty = price2num(GETPOST('qty'), 'MS'); + $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); + $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); + + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); // Define info_bits $info_bits = 0; @@ -1158,7 +1160,15 @@ if (empty($reshook)) { } } } - $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise); + + $price_base_type = 'HT'; + $pu = $pu_ht; + if (empty($pu) && ! empty($pu_ttc)) { + $pu = $pu_ttc; + $price_base_type = 'TTC'; + } + + $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise); if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -2701,9 +2711,16 @@ if ($action == 'create' && $usercancreate) { /* * Lines */ + + // Get object lines $result = $object->getLinesArray(); - print ' + // Add products/services form + //$forceall = 1; + global $inputalsopricewithtax; + $inputalsopricewithtax = 1; + + print ' diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 10d19a689a2..c5d1bf2d8bf 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2068,7 +2068,7 @@ if (empty($reshook)) { $error++; } if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && (($price_ht_devise < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht_devise == '') && $price_ttc === '' && $price_ttc_devise === '' && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not '' - if ($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { + if (($price_ht < 0 || $price_ttc < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { $langs->load("errors"); if ($object->type == $object::TYPE_DEPOSIT) { // Using negative lines on deposit lead to headach and blocking problems when you want to consume them. @@ -2405,12 +2405,14 @@ if (empty($reshook)) { $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml')); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $vat_rate = str_replace('*', '', $vat_rate); + $pu_ht = price2num(GETPOST('price_ht'), '', 2); $pu_ttc = price2num(GETPOST('price_ttc'), '', 2); - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); - //$pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); - $qty = GETPOST('qty'); + $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); + $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); + + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); // Define info_bits $info_bits = 0; @@ -2519,8 +2521,8 @@ if (empty($reshook)) { setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); $error++; } - if ((empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && $pu_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not '' - if ($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { + if (empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && (($pu_ht_devise < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht_devise == '') && $pu_ttc === '' && $pu_ttc_devise === '' && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not '' + if (($pu_ht < 0 || $pu_ttc < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { $langs->load("errors"); if ($object->type == $object::TYPE_DEPOSIT) { // Using negative lines on deposit lead to headach and blocking problems when you want to consume them. @@ -2548,10 +2550,17 @@ if (empty($reshook)) { } } + $price_base_type = 'HT'; + $pu = $pu_ht; + if (empty($pu) && ! empty($pu_ttc)) { + $pu = $pu_ttc; + $price_base_type = 'TTC'; + } + $result = $object->updateline( GETPOST('lineid', 'int'), $description, - $pu_ht, + $pu, $qty, $remise_percent, $date_start, @@ -2559,7 +2568,7 @@ if (empty($reshook)) { $vat_rate, $localtax1_rate, $localtax2_rate, - 'HT', + $price_base_type, $info_bits, $type, GETPOST('fk_parent_line', 'int'), @@ -5342,10 +5351,15 @@ if ($action == 'create') { include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - // Lines + // Get object lines $result = $object->getLinesArray(); - // Show global modifiers + // Add products/services form + //$forceall = 1; + global $inputalsopricewithtax; + $inputalsopricewithtax = 1; + + // Show global modifiers for situation invoices if (!empty($conf->global->INVOICE_USE_SITUATION)) { if ($object->situation_cycle_ref && $object->statut == 0) { print ''."\n"; @@ -5387,7 +5401,7 @@ if ($action == 'create') { } } - print ' + print ' diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 21e82d306a8..761be27b512 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010-2020 Laurent Destailleur + * Copyright (C) 2010-2022 Laurent Destailleur * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud @@ -325,8 +325,8 @@ $coldisplay++; - ">
- "> + ">
+ ">