NEW add ref supplier on supplier invoice

This commit is contained in:
atm-quentin 2018-10-22 14:32:50 +02:00
parent cfba5a5e0f
commit cfff4c7df8
4 changed files with 14 additions and 7 deletions

View File

@ -1363,11 +1363,12 @@ class FactureFournisseur extends CommonInvoice
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param int $origin_id id origin document
* @param double $pu_ht_devise Amount in currency
* @param string $ref_supplier Supplier ref
* @return int >0 if OK, <0 if KO
*
* FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order.
*/
public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0)
public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0,$ref_supplier='')
{
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -1426,7 +1427,7 @@ class FactureFournisseur extends CommonInvoice
//$this->line->label=$label; // deprecated
$this->line->desc=$desc;
$this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
$this->line->ref_supplier=$ref_supplier;
$this->line->vat_src_code=$vat_src_code;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
@ -2718,7 +2719,7 @@ class SupplierInvoiceLine extends CommonObjectLine
// Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' (fk_facture_fourn, fk_parent_line, label, description, qty,';
$sql.= ' (fk_facture_fourn, fk_parent_line, label, description, ref, qty,';
$sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql.= ' fk_product, product_type, remise_percent, pu_ht, pu_ttc,';
$sql.= ' date_start, date_end, fk_code_ventilation, rang, special_code,';
@ -2729,6 +2730,7 @@ class SupplierInvoiceLine extends CommonObjectLine
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " '".$this->db->escape($this->desc)."',";
$sql.= " '".$this->db->escape($this->ref_supplier)."',";
$sql.= " ".price2num($this->qty).",";
$sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->vat_src_code."'").",";

View File

@ -708,7 +708,6 @@ if (empty($reshook))
$date_end=$lines[$i]->date_fin_prevue;
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
// FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example.
$result = $object->addline(
$desc,
@ -729,7 +728,9 @@ if (empty($reshook))
0,
$lines[$i]->array_options,
$lines[$i]->fk_unit,
$lines[$i]->id
$lines[$i]->id,
0,
$lines[$i]->ref_supplier
);
if ($result < 0)

View File

@ -1044,7 +1044,7 @@ class Reception extends CommonObject
$line = new CommandeFournisseurDispatch($db);
$line->fetch($obj->rowid);
$line->fetch_product();
$sql_commfourndet = 'SELECT qty, label, tva_tx, vat_src_code, subprice, multicurrency_subprice, remise_percent FROM llx_commande_fournisseurdet WHERE rowid='.$line->fk_commandefourndet;
$sql_commfourndet = 'SELECT qty, ref, label, tva_tx, vat_src_code, subprice, multicurrency_subprice, remise_percent FROM llx_commande_fournisseurdet WHERE rowid='.$line->fk_commandefourndet;
$resql_commfourndet = $db->query($sql_commfourndet);
if(!empty($resql_commfourndet)){
$obj = $db->fetch_object($resql_commfourndet);
@ -1057,6 +1057,8 @@ class Reception extends CommonObject
$line->multicurrency_subprice = $obj->multicurrency_subprice;
$line->remise_percent = $obj->remise_percent;
$line->label = $obj->label;
$line->ref_supplier = $obj->ref;
}else {
$line->qty_asked = 0;
$line->description = '';

View File

@ -327,7 +327,9 @@ if (empty($reshook))
false,
0,
null,
$lines[$i]->rowid
$lines[$i]->rowid,
0,
$lines[$i]->ref_supplier
);