diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 2a8cdaef2a1..188bba430bf 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1436,8 +1436,8 @@ if (empty($reshook)) { $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); // Margin - $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); - $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we must keep this value + $fournprice = (int) (GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only + $buyingprice = price2num((GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''), '', 2); // If buying_price is '0', we must keep this value $date_start = dol_mktime(GETPOSTINT('date_start'.$predef.'hour'), GETPOSTINT('date_start'.$predef.'min'), GETPOSTINT('date_start'.$predef.'sec'), GETPOSTINT('date_start'.$predef.'month'), GETPOSTINT('date_start'.$predef.'day'), GETPOSTINT('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOSTINT('date_end'.$predef.'hour'), GETPOSTINT('date_end'.$predef.'min'), GETPOSTINT('date_end'.$predef.'sec'), GETPOSTINT('date_end'.$predef.'month'), GETPOSTINT('date_end'.$predef.'day'), GETPOSTINT('date_end'.$predef.'year')); @@ -1485,7 +1485,7 @@ if (empty($reshook)) { if (!$error) { // Insert line - $result = $object->addline($desc, $pu_ht, (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count($object->lines) + 1), 0, GETPOSTINT('fk_parent_line'), (int) $fournprice, (float) $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count($object->lines) + 1), 0, GETPOSTINT('fk_parent_line'), (int) $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $db->commit(); @@ -1621,8 +1621,8 @@ if (empty($reshook)) { $pu_ttc = price2num(GETPOST('price_ttc'), '', 2); // Add buying price - $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we must keep this value + $fournprice = (int) (GETPOST('fournprice') ? GETPOST('fournprice') : ''); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only + $buyingprice = price2num((GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''), '', 2); // If buying_price is '0', we must keep this value $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); @@ -1746,7 +1746,7 @@ if (empty($reshook)) { $price_base_type = 'TTC'; } - $result = $object->updateline(GETPOSTINT('lineid'), (float) $pu, (float) $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, $price_base_type, $info_bits, $special_code, GETPOSTINT('fk_parent_line'), 0, (int) $fournprice, (int) $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOSTINT("units"), (float) $pu_ht_devise); + $result = $object->updateline(GETPOSTINT('lineid'), (float) $pu, (float) $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, $price_base_type, $info_bits, $special_code, GETPOSTINT('fk_parent_line'), 0, (int) $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOSTINT("units"), (float) $pu_ht_devise); if ($result >= 0) { $db->commit(); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index d0fdd446324..c4b41528d98 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -618,7 +618,7 @@ class Propal extends CommonObject * @param int $special_code Special code (also used by externals modules!) * @param int $fk_parent_line Id of parent line * @param int $fk_fournprice Id supplier price - * @param float $pa_ht Buying price without tax + * @param float[string $pa_ht Buying price without tax ('' to keep PMP unchanged or a float) * @param string $label ??? * @param int|string $date_start Start date of the line * @param int|string $date_end End date of the line @@ -668,7 +668,7 @@ class Propal extends CommonObject } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - $pa_ht = price2num($pa_ht); // do not convert to float here, it breaks the functioning of $pa_ht_isemptystring + $pa_ht = price2num($pa_ht); // do not convert to float here, it breaks the functioning of $pa_ht is empty string if ($price_base_type == 'HT') { $pu = $pu_ht; } else { @@ -886,7 +886,7 @@ class Propal extends CommonObject * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) * @param int $fk_fournprice Id of origin supplier price - * @param float $pa_ht Price (without tax) of product when it was bought + * @param float|string $pa_ht Price (without tax) of product when it was bought (Can be '' to keep AWP unchanged or a float value) * @param string $label ??? * @param int $type 0/1=Product/service * @param int|string $date_start Start date of the line @@ -894,8 +894,8 @@ class Propal extends CommonObject * @param array $array_options extrafields array * @param int|null $fk_unit Code of the unit to use. Null to use the default one * @param float $pu_ht_devise Unit price in currency - * @param int $notrigger disable line update trigger - * @param int $rang line rank + * @param int $notrigger Disable line update trigger + * @param int $rang Line rank * @return int 0 if OK, <0 if KO */ public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = array(), $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $rang = 0) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0d12f65a90e..03daf9a2e9b 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1192,7 +1192,7 @@ if (empty($reshook)) { $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); // Margin - $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOSTINT('fournprice'.$predef) : 0); + $fournprice = (int) (GETPOST('fournprice'.$predef) ? GETPOSTINT('fournprice'.$predef) : 0); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we must keep this value // Prepare a price equivalent for minimum price check @@ -1238,7 +1238,7 @@ if (empty($reshook)) { if (!$error) { // Insert line - $result = $object->addline($desc, $pu_ht, (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count($object->lines) + 1), 0, GETPOSTINT('fk_parent_line'), $fournprice, (float) $buyingprice, $label, $array_options, $fk_unit, '', 0, (float) $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count($object->lines) + 1), 0, GETPOSTINT('fk_parent_line'), (int) $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, (float) $pu_ht_devise); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records @@ -1352,7 +1352,7 @@ if (empty($reshook)) { */ // Add buying price - $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $fournprice = (int) (GETPOST('fournprice') ? GETPOST('fournprice') : ''); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we must keep this value // Extrafields Lines @@ -1451,7 +1451,7 @@ if (empty($reshook)) { $price_base_type = 'TTC'; } - $result = $object->updateline(GETPOSTINT('lineid'), $description, (float) $pu, (float) $qty, $remise_percent, (float) $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type, GETPOSTINT('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOSTINT('units'), (float) $pu_ht_devise); + $result = $object->updateline(GETPOSTINT('lineid'), $description, (float) $pu, (float) $qty, $remise_percent, (float) $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type, GETPOSTINT('fk_parent_line'), 0, (int) $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOSTINT('units'), (float) $pu_ht_devise); if ($result >= 0) { if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index dac286a0158..bb324da3ff4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1541,7 +1541,7 @@ class Commande extends CommonOrder * @param int $special_code Special code (also used by externals modules!) * @param int $fk_parent_line Parent line * @param int $fk_fournprice Id supplier price - * @param float $pa_ht Buying price (without tax) + * @param float|string $pa_ht Buying price without tax (Can be '' to keep AWP unchanged or a float value) * @param string $label Label * @param array $array_options Extrafields array. Example array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * @param ?int $fk_unit Code of the unit to use. Null to use the default one @@ -3064,7 +3064,7 @@ class Commande extends CommonOrder * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) * @param int $fk_fournprice Id of origin supplier price - * @param float $pa_ht Price (without tax) of product when it was bought + * @param float|string $pa_ht Price (without tax) of product when it was bought (Can be '' to keep AWP unchanged or a float value) * @param string $label Label * @param int $special_code Special code (also used by externals modules!) * @param array $array_options extrafields array diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 017b527f105..e32b4f833fb 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -587,20 +587,20 @@ class Account extends CommonObject /** * Add an entry into table ".MAIN_DB_PREFIX."bank * - * @param int $date Date operation - * @param string $oper 'VIR','PRE','LIQ','VAD','CB','CHQ'... - * @param string $label Description - * @param float $amount Amount - * @param string $num_chq Numero cheque or transfer - * @param int $categorie Category id (optional) - * @param User $user User that create - * @param string $emetteur Name of cheque writer - * @param string $banque Bank of cheque writer - * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. - * @param int $datev Date value - * @param string $num_releve Label of bank receipt for reconciliation + * @param int $date Date operation + * @param string $oper 'VIR','PRE','LIQ','VAD','CB','CHQ'... + * @param string $label Description + * @param float $amount Amount + * @param string $num_chq Numero cheque or transfer + * @param int $categorie Category id (optional) + * @param User $user User that create + * @param string $emetteur Name of cheque writer + * @param string $banque Bank of cheque writer + * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. + * @param int $datev Date value + * @param string $num_releve Label of bank receipt for reconciliation * @param float $amount_main_currency Amount - * @return int Rowid of added entry, <0 if KO + * @return int Rowid of added entry, <0 if KO */ public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '', $amount_main_currency = null) { diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index a030a92bd99..c55e9f69359 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -715,7 +715,7 @@ if (empty($reshook)) { $date_end_fill = GETPOSTINT('date_end_fill'); // Margin - $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); + $fournprice = (in)(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we must keep this value // Local Taxes @@ -734,7 +734,7 @@ if (empty($reshook)) { setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, 0, $pu_ttc, $type, -1, $special_code, $label, (int) $fk_unit, 0, $date_start_fill, $date_end_fill, (int) $fournprice, (int) $buyingprice, $fk_parent_line); + $result = $object->addline($desc, $pu_ht, (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, 0, $pu_ttc, $type, -1, $special_code, $label, (int) $fk_unit, 0, $date_start_fill, $date_end_fill, (int) $fournprice, $buyingprice, $fk_parent_line); if ($result > 0) { // Define output language and generate document @@ -833,7 +833,7 @@ if (empty($reshook)) { $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty); // Add buying price - $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $fournprice = (int) (GETPOST('fournprice') ? GETPOST('fournprice') : ''); $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we must keep this value // Extrafields diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f3347952d47..ca9a0d086bd 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2508,7 +2508,7 @@ if (empty($reshook)) { */ // Margin - $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); + $fournprice = (int) (GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we must keep this value @@ -2707,7 +2707,7 @@ if (empty($reshook)) { $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty); // Add buying price - $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $fournprice = (int) (GETPOST('fournprice') ? GETPOST('fournprice') : ''); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we must keep this value // Prepare a price equivalent for minimum price check @@ -2898,7 +2898,7 @@ if (empty($reshook)) { $type, GETPOSTINT('fk_parent_line'), 0, - $fournprice, + (int) $fournprice, $buyingprice, $label, $special_code, diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 7d00cc09c96..d01da9ea80c 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -956,8 +956,8 @@ class FactureRec extends CommonInvoice * @param float $pu_ht_devise Unit price in currency * @param int $date_start_fill 1=Flag to fill start date when generating invoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice - * @param ?int $fk_fournprice Supplier price id (to calculate margin) or '' - * @param float $pa_ht Buying price of line (to calculate margin) or '' + * @param ?int|string $fk_fournprice Supplier price id (to calculate margin) or string + * @param float $pa_ht Buying price of line (to calculate margin) (Can be '' to keep AWP unchanged or a float value) * @param int $fk_parent_line Id of parent line * @return int Return integer <0 if KO, Id of line if OK */ @@ -1164,7 +1164,7 @@ class FactureRec extends CommonInvoice * @param int $date_start_fill 1=Flag to fill start date when generating invoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @param ?int $fk_fournprice Id of origin supplier price - * @param float $pa_ht Price (without tax) of product for margin calculation + * @param float|string $pa_ht Price (without tax) of product for margin calculation (Can be '' to keep AWP unchanged or a float value) * @param int $fk_parent_line Id of parent line * @return int Return integer <0 if KO, Id of line if OK */ diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3139eb4ab11..f2c4e678dd2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3873,8 +3873,8 @@ class Facture extends CommonInvoice * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id * @param int $fk_parent_line Id of parent line - * @param int $fk_fournprice Supplier price id (to calculate margin) or '' - * @param float|'' $pa_ht Buying price of line (to calculate margin) or '' + * @param int|string $fk_fournprice Supplier price id (to calculate margin) or a string + * @param float|'' $pa_ht Buying price of line (to calculate margin) (Can be '' to keep AWP unchanged or a float value) * @param string $label Label of the line (deprecated, do not use) * @param array $array_options extrafields array * @param float $situation_percent Situation advance percentage @@ -4196,7 +4196,7 @@ class Facture extends CommonInvoice * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) * @param int $fk_fournprice Id of origin supplier price - * @param float $pa_ht Price (without tax) of product when it was bought + * @param float|string $pa_ht Price (without tax) of product when it was bought (Can be '' to keep AWP unchanged or a float value) * @param string $label Label of the line (deprecated, do not use) * @param int $special_code Special code (also used by externals modules!) * @param array $array_options extrafields array diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 65fc36646a7..94871e481ee 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1466,7 +1466,7 @@ class Contrat extends CommonObject * @param float $pu_ttc Prix unitaire TTC * @param int $info_bits Bits of type of lines * @param int $fk_fournprice Fourn price id - * @param float $pa_ht Buying price HT + * @param float|string $pa_ht Buying price HT (Can be '' to keep AWP unchanged or a float value) * @param array $array_options extrafields array * @param ?int $fk_unit Code of the unit to use. Null to use the default one * @param int $rang Position @@ -1691,7 +1691,7 @@ class Contrat extends CommonObject * @param string $price_base_type HT or TTC * @param int $info_bits Bits of type of lines * @param int $fk_fournprice Fourn price id - * @param float $pa_ht Buying price HT + * @param float|string $pa_ht Buying price HT (Can be '' to keep AWP unchanged or a float value) * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param int $rang Position diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b2b320653f6..335549585c6 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2103,7 +2103,7 @@ class FactureFournisseur extends CommonInvoice * @param array $array_options extrafields array * @param int|null $fk_unit Code of the unit to use. Null to use the default one * @param int $origin_id id origin document - * @param float $pu_devise Amount in currency + * @param float $pu_devise Amount in currency * @param string $ref_supplier Supplier ref * @param int $special_code Special code * @param int $fk_parent_line Parent line id diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index b85de2b3891..4bc80b3d839 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -676,7 +676,7 @@ if (empty($reshook)) { $date_end_fill = GETPOSTINT('date_end_fill'); // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); + $fournprice = (in)(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value // Local Taxes diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 7c0960fd68e..04f42adee4c 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -872,16 +872,16 @@ class Reception extends CommonObject * If STOCK_WAREHOUSE_NOT_REQUIRED_FOR_RECEPTIONS is set, you can add a reception line, with no stock source defined * If STOCK_MUST_BE_ENOUGH_FOR_RECEPTION is not set, you can add a reception line, even if not enough into stock * - * @param int $entrepot_id Id of warehouse - * @param int $id Id of source line (supplier order line) - * @param float $qty Quantity + * @param int $entrepot_id Id of warehouse + * @param int $id Id of source line (supplier order line) + * @param float $qty Quantity * @param array $array_options extrafields array - * @param string $comment Comment for stock movement - * @param int $eatby eat-by date - * @param int $sellby sell-by date - * @param string $batch Lot number - * @param float $cost_price Line cost - * @return int Return integer <0 if KO, index of line if OK + * @param string $comment Comment for stock movement + * @param int $eatby eat-by date + * @param int $sellby sell-by date + * @param string $batch Lot number + * @param float|string $cost_price Line cost (Can be '' to keep AWP unchanged or a float value) + * @return int Return integer <0 if KO, index of line if OK */ public function addline($entrepot_id, $id, $qty, $array_options = [], $comment = '', $eatby = null, $sellby = null, $batch = '', $cost_price = 0) { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index dd935b533bf..59fe7245a93 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -799,7 +799,7 @@ if (empty($reshook)) { min($rank, count($object->lines) + 1), 0, GETPOSTINT('fk_parent_line'), - $fournprice, + (int) $fournprice, $buyingprice, $label, $array_options, @@ -878,7 +878,7 @@ if (empty($reshook)) { -1, // rang 0, // special_code GETPOSTINT('fk_parent_line'), - $fournprice, + (int) $fournprice, $buyingprice, $label, $array_options, @@ -1004,8 +1004,8 @@ if (empty($reshook)) { $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'CU', 2); // Add buying price - $fournprice = (GETPOST('fournprice') ? GETPOSTINT('fournprice') : ''); // foreigh key - $buyingprice = (GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we must keep this value + $fournprice = (int) (GETPOST('fournprice') ? GETPOSTINT('fournprice') : ''); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only + $buyingprice = price2num((GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''), '', 2); // If buying_price is '0', we must keep this value // Extrafields Lines $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -1076,7 +1076,7 @@ if (empty($reshook)) { GETPOSTINT('fk_parent_line'), 0, (int) $fournprice, - (float) $buyingprice, + $buyingprice, $label, $type, $array_options, diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 5aa88886622..feadcecac41 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -431,8 +431,8 @@ class SupplierProposal extends CommonObject * @param int $rang Position of line * @param int $special_code Special code (also used by externals modules!) * @param int $fk_parent_line Id of parent line - * @param int $fk_fournprice Id supplier price. If 0, we will take best price. If -1 we keep it empty. - * @param int $pa_ht Buying price without tax + * @param int|string $fk_fournprice Id supplier price or string. If 0, we will take best price. If -1 we keep it empty. + * @param float|string $pa_ht Buying price without tax (Can be '' to keep AWP unchanged or a float value) * @param string $label ??? * @param array $array_options extrafields array * @param string $ref_supplier Supplier price reference @@ -717,7 +717,7 @@ class SupplierProposal extends CommonObject * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) * @param int $fk_fournprice Id of origin supplier price - * @param float $pa_ht Price (without tax) of product when it was bought + * @param float|string $pa_ht Price (without tax) of product when it was bought (Can be '' to keep AWP unchanged or a float value) * @param string $label ??? * @param int<0,1> $type 0/1=Product/service * @param array $array_options extrafields array