Merge pull request #7828 from papoteur-mga/develop

Fix:[proposals]Allow lines to be added from REST API
This commit is contained in:
Laurent Destailleur 2017-11-22 11:16:32 +01:00 committed by GitHub
commit 46d1318a32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1005,6 +1005,7 @@ class Propal extends CommonObject
/* /*
* Insertion du detail des produits dans la base * Insertion du detail des produits dans la base
* Insert products detail in database
*/ */
if (! $error) if (! $error)
{ {
@ -1013,40 +1014,47 @@ class Propal extends CommonObject
for ($i=0;$i<$num;$i++) for ($i=0;$i<$num;$i++)
{ {
if (! is_object($this->lines[$i])) // If this->lines is not array of objects, coming from REST API
{ // Convert into object this->lines[$i].
$line = (object) $this->lines[$i];
}
else
{
$line = $this->lines[$i];
}
// Reset fk_parent_line for line that are not child lines or special product // Reset fk_parent_line for line that are not child lines or special product
if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) { if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
$fk_parent_line = 0; $fk_parent_line = 0;
} }
// Complete vat rate with code // Complete vat rate with code
$vatrate = $this->lines[$i]->tva_tx; $vatrate = $line->tva_tx;
if ($this->lines[$i]->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$this->lines[$i]->vat_src_code.')'; if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')';
$result = $this->addline( $result = $this->addline(
$this->lines[$i]->desc, $line->desc,
$this->lines[$i]->subprice, $line->subprice,
$this->lines[$i]->qty, $line->qty,
$vatrate, $vatrate,
$this->lines[$i]->localtax1_tx, $line->localtax1_tx,
$this->lines[$i]->localtax2_tx, $line->localtax2_tx,
$this->lines[$i]->fk_product, $line->fk_product,
$this->lines[$i]->remise_percent, $line->remise_percent,
'HT', 'HT',
0, 0,
$this->lines[$i]->info_bits, $line->info_bits,
$this->lines[$i]->product_type, $line->product_type,
$this->lines[$i]->rang, $line->rang,
$this->lines[$i]->special_code, $line->special_code,
$fk_parent_line, $fk_parent_line,
$this->lines[$i]->fk_fournprice, $line->fk_fournprice,
$this->lines[$i]->pa_ht, $line->pa_ht,
$this->lines[$i]->label, $line->label,
$this->lines[$i]->date_start, $line->date_start,
$this->lines[$i]->date_end, $line->date_end,
$this->lines[$i]->array_options, $line->array_options,
$this->lines[$i]->fk_unit, $line->fk_unit,
$this->element, $this->element,
$this->lines[$i]->id $line->id
); );
if ($result < 0) if ($result < 0)
@ -1057,7 +1065,7 @@ class Propal extends CommonObject
break; break;
} }
// Defined the new fk_parent_line // Defined the new fk_parent_line
if ($result > 0 && $this->lines[$i]->product_type == 9) { if ($result > 0 && $line->product_type == 9) {
$fk_parent_line = $result; $fk_parent_line = $result;
} }
} }