FIX #7471
This commit is contained in:
parent
adb3827d1e
commit
270aba99fa
@ -279,11 +279,12 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
$this->fetchObjectLinked();
|
||||
|
||||
//$result=$this->fetch_lines();
|
||||
$this->lines=array();
|
||||
|
||||
$sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description, l.qty,";
|
||||
$sql.= " l.vat_src_code, l.tva_tx, l.remise_percent, l.subprice,";
|
||||
$sql.= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,";
|
||||
$sql.= " l.localtax1_tx, l. localtax2_tx, l.localtax1_type, l. localtax2_type, l.total_localtax1, l.total_localtax2,";
|
||||
$sql.= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,";
|
||||
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,";
|
||||
$sql.= " l.fk_unit,";
|
||||
@ -315,6 +316,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
$line->tva_tx = $objp->tva_tx;
|
||||
$line->localtax1_tx = $objp->localtax1_tx;
|
||||
$line->localtax2_tx = $objp->localtax2_tx;
|
||||
$line->localtax1_type = $objp->localtax1_type;
|
||||
$line->localtax2_type = $objp->localtax2_type;
|
||||
$line->subprice = $objp->subprice;
|
||||
$line->pu_ht = $objp->subprice;
|
||||
$line->remise_percent = $objp->remise_percent;
|
||||
@ -2977,7 +2980,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
|
||||
public function fetch($rowid)
|
||||
{
|
||||
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx,';
|
||||
$sql.= ' cd.localtax1_tx, cd.localtax2_tx, cd.ref,';
|
||||
$sql.= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref,';
|
||||
$sql.= ' cd.remise, cd.remise_percent, cd.subprice,';
|
||||
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,';
|
||||
$sql.= ' cd.total_localtax1, cd.total_localtax2,';
|
||||
@ -3003,6 +3006,8 @@ class CommandeFournisseurLigne extends CommonOrderLine
|
||||
$this->tva_tx = $objp->tva_tx;
|
||||
$this->localtax1_tx = $objp->localtax1_tx;
|
||||
$this->localtax2_tx = $objp->localtax2_tx;
|
||||
$this->localtax1_type = $objp->localtax1_type;
|
||||
$this->localtax2_type = $objp->localtax2_type;
|
||||
$this->remise = $objp->remise;
|
||||
$this->remise_percent = $objp->remise_percent;
|
||||
$this->fk_product = $objp->fk_product;
|
||||
|
||||
@ -640,7 +640,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
function fetch_lines()
|
||||
{
|
||||
$sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx';
|
||||
$sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn ';
|
||||
$sql.= ', f.localtax1_tx, f.localtax2_tx, f.localtax1_type, f.localtax2_type, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn ';
|
||||
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
|
||||
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
|
||||
$sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc';
|
||||
@ -681,6 +681,8 @@ class FactureFournisseur extends CommonInvoice
|
||||
$line->tva_tx = $obj->tva_tx;
|
||||
$line->localtax1_tx = $obj->localtax1_tx;
|
||||
$line->localtax2_tx = $obj->localtax2_tx;
|
||||
$line->localtax1_type = $obj->localtax1_type;
|
||||
$line->localtax2_type = $obj->localtax2_type;
|
||||
$line->qty = $obj->qty;
|
||||
$line->remise_percent = $obj->remise_percent;
|
||||
$line->tva = $obj->total_tva;
|
||||
|
||||
@ -544,19 +544,7 @@ if (empty($reshook))
|
||||
*/
|
||||
if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && ! GETPOST('cancel'))
|
||||
{
|
||||
$tva_tx = GETPOST('tva_tx');
|
||||
|
||||
if (GETPOST('price_ht') != '')
|
||||
{
|
||||
$price_base_type = 'HT';
|
||||
$ht = price2num(GETPOST('price_ht'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$ttc = price2num(GETPOST('price_ttc'));
|
||||
$ht = $ttc / (1 + ($tva_tx / 100));
|
||||
$price_base_type = 'HT';
|
||||
}
|
||||
$vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0);
|
||||
|
||||
if ($lineid)
|
||||
{
|
||||
@ -568,10 +556,36 @@ if (empty($reshook))
|
||||
$date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
||||
$date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
||||
|
||||
$localtax1_tx=get_localtax($tva_tx,1,$mysoc,$object->thirdparty);
|
||||
$localtax2_tx=get_localtax($tva_tx,2,$mysoc,$object->thirdparty);
|
||||
// Define info_bits
|
||||
$info_bits = 0;
|
||||
if (preg_match('/\*/', $vat_rate))
|
||||
$info_bits |= 0x01;
|
||||
|
||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
||||
// Define vat_rate
|
||||
$vat_rate = str_replace('*', '', $vat_rate);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty);
|
||||
$localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty);
|
||||
|
||||
if (GETPOST('price_ht') != '')
|
||||
{
|
||||
$price_base_type = 'HT';
|
||||
$ht = price2num(GETPOST('price_ht'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$vatratecleaned = $vat_rate;
|
||||
if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)"
|
||||
{
|
||||
$vatratecleaned = trim($reg[1]);
|
||||
$vatratecode = $reg[2];
|
||||
}
|
||||
|
||||
$ttc = price2num(GETPOST('price_ttc'));
|
||||
$ht = $ttc / (1 + ($vatratecleaned / 100));
|
||||
$price_base_type = 'HT';
|
||||
}
|
||||
|
||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
||||
|
||||
// Extrafields Lines
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
@ -590,9 +604,9 @@ if (empty($reshook))
|
||||
$ht,
|
||||
$_POST['qty'],
|
||||
$_POST['remise_percent'],
|
||||
$tva_tx,
|
||||
$localtax1_tx,
|
||||
$localtax2_tx,
|
||||
$vat_rate,
|
||||
$localtax1_rate,
|
||||
$localtax2_rate,
|
||||
$price_base_type,
|
||||
0,
|
||||
isset($_POST["type"])?$_POST["type"]:$line->product_type,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user