NEW : special option MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION to store in document line created form other document s lines the id of origin lines and origin class line rather than origin object id and origin object type

This commit is contained in:
florian HENRY 2020-03-12 09:44:43 +01:00
parent dbb80aecd1
commit 29b2ea77d5
3 changed files with 36 additions and 12 deletions

View File

@ -440,8 +440,8 @@ class Propal extends CommonObject
* @param int $date_end End date of the line
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param string $origin 'order', ...
* @param int $origin_id Id of origin object
* @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 double $pu_ht_devise Unit price in currency
* @param int $fk_remise_except Id discount if line is from a discount
* @return int >0 if OK, <0 if KO
@ -1099,6 +1099,14 @@ class Propal extends CommonObject
$vatrate = $line->tva_tx;
if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')';
if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) {
$originid=$line->origin_id;
$origintype=$line->origin;
} else {
$originid=$line->id;
$origintype=$this->element;
}
$result = $this->addline(
$line->desc,
$line->subprice,
@ -1122,8 +1130,8 @@ class Propal extends CommonObject
$line->date_end,
$line->array_options,
$line->fk_unit,
$this->element,
$line->id
$origintype,
$originid
);
if ($result < 0)

View File

@ -927,6 +927,14 @@ class Commande extends CommonOrder
$vatrate = $line->tva_tx;
if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')';
if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) {
$originid=$line->origin_id;
$origintype=$line->origin;
} else {
$originid=$line->id;
$origintype=$this->element;
}
$result = $this->addline(
$line->desc,
$line->subprice,
@ -951,8 +959,8 @@ class Commande extends CommonOrder
$line->label,
$line->array_options,
$line->fk_unit,
$line->origin,
$line->origin_id
$origintype,
$originid
);
if ($result < 0)
{
@ -1355,8 +1363,8 @@ class Commande extends CommonOrder
* @param string $label Label
* @param array $array_options extrafields array. Example array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param string $origin 'order', ...
* @param int $origin_id Id of origin object
* @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 double $pu_ht_devise Unit price in currency
* @return int >0 if OK, <0 if KO
*

View File

@ -807,6 +807,14 @@ class Facture extends CommonInvoice
$vatrate = $line->tva_tx;
if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')';
if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) {
$originid=$line->origin_id;
$origintype=$line->origin;
} else {
$originid=$line->id;
$origintype=$this->element;
}
$result = $this->addline(
$line->desc,
$line->subprice,
@ -826,8 +834,8 @@ class Facture extends CommonInvoice
$line->product_type,
$line->rang,
$line->special_code,
$this->element,
$line->id,
$origintype,
$originid,
$fk_parent_line,
$line->fk_fournprice,
$line->pa_ht,
@ -2936,8 +2944,8 @@ class Facture extends CommonInvoice
* @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
* @param int $rang Position of line
* @param int $special_code Special code (also used by externals modules!)
* @param string $origin 'order', ...
* @param int $origin_id Id of origin object
* @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 int $pa_ht Buying price of line (to calculate margin) or ''