FIX: implement mdeweerd review

This commit is contained in:
Noé Cendrier 2025-01-28 15:31:08 +01:00
parent 2589febbae
commit 966d079019
5 changed files with 10 additions and 10 deletions

View File

@ -343,7 +343,7 @@ class PropaleLigne extends CommonObjectLine
*/
public $multicurrency_total_ttc;
/**
/**
* @var float
*/
public $packaging;

View File

@ -3185,7 +3185,7 @@ class Commande extends CommonOrder
if ($qty < $this->line->packaging) {
$qty = $this->line->packaging;
} else {
if (!empty($this->line->packaging) && ($qty % $this->line->packaging) > 0) {
if (!empty($this->line->packaging) && fmod($qty, $this->line->packaging) > 0) {
$coeff = intval($qty / $this->line->packaging) + 1;
$qty = $this->line->packaging * $coeff;
setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs');

View File

@ -4316,7 +4316,7 @@ class Facture extends CommonInvoice
if ($qty < $this->line->packaging) {
$qty = $this->line->packaging;
} else {
if (!empty($this->line->packaging) && ($qty % $this->line->packaging) > 0) {
if (!empty($this->line->packaging) && fmod($qty, $this->line->packaging) > 0) {
$coeff = intval($qty / $this->line->packaging) + 1;
$qty = $this->line->packaging * $coeff;
setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs');

View File

@ -1592,7 +1592,7 @@ class Product extends CommonObject
$sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL');
$sql .= ", mandatory_period = ".($this->mandatory_period);
if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING') && !empty($this->packaging)) {
$sql .= ", packaging = ".($this->packaging);
$sql .= ", packaging = " . (int) $this->packaging;
}
// stock field is not here because it is a denormalized value from product_stock.
$sql .= " WHERE rowid = ".((int) $id);

View File

@ -283,7 +283,7 @@ if (empty($reshook)) {
$psq = empty($newpsq) ? 0 : $newpsq;
$maxpricesupplier = $object->min_recommended_price();
// Packaging / Conditionnement
// Packaging
$packaging = getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING') ? GETPOST('packaging') : null;
if (isModEnabled('dynamicprices')) {
@ -484,9 +484,9 @@ if (empty($reshook)) {
if (!$error) {
$db->begin();
// Packaging / Conditionnement
// Packaging
if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
$object->packaging = (double) $packaging;
$object->packaging = (float) $packaging;
}
foreach ($pricestoupdate as $key => $val) {
@ -1429,7 +1429,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS
}
print '</td></tr>';
// Packaging / Conditionnement
// Packaging
if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
print '<tr class="field_price_label"><td>'.$form->textwithpicto($langs->trans("PackagingForThisProduct"), $langs->trans("PackagingForThisProductSellDesc")).'</td><td>';
print $object->packaging;
@ -1758,13 +1758,13 @@ if (($action == 'edit_price' || $action == 'edit_level_price') && $object->getRi
print '</td>';
print '</tr>';
// Packaging / Conditionnement
// Packaging
if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
print '<tr><td>';
print $form->textwithpicto($langs->trans("PackagingForThisProduct"), $langs->trans("PackagingForThisProductSellDesc"));
print '</td><td>';
$packaging = $object->packaging;
print '<input class="flat" name="packaging" size="5" value="'.$packaging.'">';
print '<input class="flat" name="packaging" size="5" value="' . price2num($packaging, 2).'">';
print '</td>';
print '</tr>';
}