ADD: packaging to round the quantities to some given multiples for the sales orders
This commit is contained in:
parent
a14a474a70
commit
b7b0a29e42
2 changed files with 41 additions and 0 deletions
|
|
@ -1634,6 +1634,20 @@ class Commande extends CommonOrder
|
|||
|
||||
$localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
|
||||
|
||||
if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
|
||||
$product = new Product($this->db);
|
||||
$result = $product->fetch($fk_product);
|
||||
if ($qty < $product->packaging) {
|
||||
$qty = $product->packaging;
|
||||
} else {
|
||||
if (!empty($product->packaging) && (fmod((float) $qty, $product->packaging) > 0.000001)) {
|
||||
$coeff = intval((float) $qty / $product->packaging) + 1;
|
||||
$qty = (float) $product->packaging * $coeff;
|
||||
setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clean vat code
|
||||
$reg = array();
|
||||
$vat_src_code = '';
|
||||
|
|
@ -2192,6 +2206,10 @@ class Commande extends CommonOrder
|
|||
$line->volume = $objp->volume;
|
||||
$line->volume_units = $objp->volume_units;
|
||||
|
||||
if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
|
||||
$line->packaging = $objp->packaging;
|
||||
}
|
||||
|
||||
$line->date_start = $this->db->jdate($objp->date_start);
|
||||
$line->date_end = $this->db->jdate($objp->date_end);
|
||||
|
||||
|
|
@ -3163,6 +3181,18 @@ class Commande extends CommonOrder
|
|||
$this->line->rang = $rangmax + 1;
|
||||
}
|
||||
|
||||
if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
|
||||
if ($qty < $this->line->packaging) {
|
||||
$qty = $this->line->packaging;
|
||||
} else {
|
||||
if (!empty($this->line->packaging) && ($qty % $this->line->packaging) > 0) {
|
||||
$coeff = intval($qty / $this->line->packaging) + 1;
|
||||
$qty = $this->line->packaging * $coeff;
|
||||
setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->line->id = $rowid;
|
||||
$this->line->label = $label;
|
||||
$this->line->desc = $desc;
|
||||
|
|
|
|||
|
|
@ -145,6 +145,10 @@ class OrderLine extends CommonOrderLine
|
|||
*/
|
||||
public $skip_update_total;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
public $packaging;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -171,6 +175,9 @@ class OrderLine extends CommonOrderLine
|
|||
$sql .= ' cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,';
|
||||
$sql .= ' p.ref as product_ref, p.label as product_label, p.description as product_desc, p.tobatch as product_tobatch,';
|
||||
$sql .= ' cd.date_start, cd.date_end, cd.vat_src_code';
|
||||
if (getDolGlobalInt('PRODUCT_USE_CUSTOMER_PACKAGING')) {
|
||||
$sql .= ', p.packaging';
|
||||
}
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
|
||||
$sql .= ' WHERE cd.rowid = '.((int) $rowid);
|
||||
|
|
@ -225,6 +232,10 @@ class OrderLine extends CommonOrderLine
|
|||
$this->product_tobatch = $objp->product_tobatch;
|
||||
$this->fk_unit = $objp->fk_unit;
|
||||
|
||||
if (getDolGlobalInt('PRODUCT_USE_CUSTOMER_PACKAGING')) {
|
||||
$this->packaging = $objp->packaging;
|
||||
}
|
||||
|
||||
$this->date_start = $this->db->jdate($objp->date_start);
|
||||
$this->date_end = $this->db->jdate($objp->date_end);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue