Skip to content

Commit

Permalink
Merge pull request #503 from atm-irvine/new_extrafields_on_addline_fa…
Browse files Browse the repository at this point in the history
…cturerec

Added extrafields when inserting a line of facturerec
  • Loading branch information
atm-etienne committed Sep 2, 2024
2 parents dfdec2a + 84f7e20 commit 55a98fd
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions htdocs/compta/facture/class/facture-rec.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,10 @@ public function delete(User $user, $notrigger = 0, $idwarehouse = -1)
* @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 int $pa_ht Buying price of line (to calculate margin) or ''
* @param array $array_options Extrafields array
* @return int <0 if KO, Id of line if OK
*/
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0)
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = [])
{
global $mysoc;

Expand Down Expand Up @@ -1019,16 +1020,28 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocalt
$sql .= ", ".price2num($multicurrency_total_ttc, 'CT');
$sql .= ")";

dol_syslog(get_class($this)."::addline", LOG_DEBUG);
if ($this->db->query($sql)) {
$lineId = $this->db->last_insert_id(MAIN_DB_PREFIX."facturedet_rec");
$this->id = $facid;
$this->update_price(1);
return $lineId;
} else {
$this->error = $this->db->lasterror();
return -1;
}
dol_syslog(get_class($this) . "::addline", LOG_DEBUG);
if ($this->db->query($sql)) {
$lineId = $this->db->last_insert_id(MAIN_DB_PREFIX . "facturedet_rec");
$this->id = $facid;
$this->update_price(1);

/**
* Backported from contract
*/
$factureRecLine = new FactureLigneRec($this->db);
$factureRecLine->array_options = $array_options;
$factureRecLine->id = $lineId;
$result = $factureRecLine->insertExtraFields();
if ($result < 0) {
$this->error[] = $factureRecLine->error;
}

return $lineId;
} else {
$this->error = $this->db->lasterror();
return -1;
}
}
}

Expand Down

0 comments on commit 55a98fd

Please sign in to comment.