|
@@ -253,6 +253,8 @@ class Propal extends CommonObject
|
|
|
$tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id);
|
|
|
$tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id);
|
|
|
if (empty($tva_tx)) $tva_npr=0;
|
|
|
+ $vat_src_code = ''; // May be defined into tva_tx
|
|
|
+
|
|
|
$localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->thirdparty,$tva_npr);
|
|
|
$localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->thirdparty,$tva_npr);
|
|
|
|
|
@@ -273,6 +275,7 @@ class Propal extends CommonObject
|
|
|
$line->qty=$qty;
|
|
|
$line->subprice=$price;
|
|
|
$line->remise_percent=$remise_percent;
|
|
|
+ $line->vat_src_code=$vat_src_code;
|
|
|
$line->tva_tx=$tva_tx;
|
|
|
$line->fk_unit=$prod->fk_unit;
|
|
|
if ($tva_npr) $line->info_bits = 1;
|
|
@@ -315,6 +318,7 @@ class Propal extends CommonObject
|
|
|
$line->fk_propal=$this->id;
|
|
|
$line->fk_remise_except=$remise->id;
|
|
|
$line->desc=$remise->description; // Description ligne
|
|
|
+ $line->vat_src_code=$remise->vat_src_code;
|
|
|
$line->tva_tx=$remise->tva_tx;
|
|
|
$line->subprice=-$remise->amount_ht;
|
|
|
$line->fk_product=0; // Id produit predefined
|
|
@@ -391,15 +395,16 @@ class Propal extends CommonObject
|
|
|
* @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
|
|
|
- * @return int >0 if OK, <0 if KO
|
|
|
* @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
|
|
|
* @see add_product
|
|
|
*/
|
|
|
- function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0, $pu_ht_devise = 0)
|
|
|
+ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0, $pu_ht_devise=0, $fk_remise_except=0)
|
|
|
{
|
|
|
global $mysoc, $conf, $langs;
|
|
|
|
|
|
- dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type");
|
|
|
+ dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type, fk_remise_except=".$fk_remise_except);
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
|
|
|
|
|
// Clean parameters
|
|
@@ -515,6 +520,8 @@ class Propal extends CommonObject
|
|
|
$this->line->localtax1_type = $localtaxes_type[0];
|
|
|
$this->line->localtax2_type = $localtaxes_type[2];
|
|
|
$this->line->fk_product=$fk_product;
|
|
|
+ $this->line->product_type=$type;
|
|
|
+ $this->line->fk_remise_except=$fk_remise_except;
|
|
|
$this->line->remise_percent=$remise_percent;
|
|
|
$this->line->subprice=$pu_ht;
|
|
|
$this->line->rang=$rangtouse;
|
|
@@ -524,7 +531,6 @@ class Propal extends CommonObject
|
|
|
$this->line->total_localtax1=$total_localtax1;
|
|
|
$this->line->total_localtax2=$total_localtax2;
|
|
|
$this->line->total_ttc=$total_ttc;
|
|
|
- $this->line->product_type=$type;
|
|
|
$this->line->special_code=$special_code;
|
|
|
$this->line->fk_parent_line=$fk_parent_line;
|
|
|
$this->line->fk_unit=$fk_unit;
|
|
@@ -698,7 +704,8 @@ class Propal extends CommonObject
|
|
|
$this->line->label = $label;
|
|
|
$this->line->desc = $desc;
|
|
|
$this->line->qty = $qty;
|
|
|
- $this->line->product_type = $type;
|
|
|
+ $this->line->product_type = $type;
|
|
|
+ $this->line->vat_src_code = $vat_src_code;
|
|
|
$this->line->tva_tx = $txtva;
|
|
|
$this->line->localtax1_tx = $txlocaltax1;
|
|
|
$this->line->localtax2_tx = $txlocaltax2;
|
|
@@ -708,7 +715,6 @@ class Propal extends CommonObject
|
|
|
$this->line->subprice = $pu_ht;
|
|
|
$this->line->info_bits = $info_bits;
|
|
|
|
|
|
- $this->line->vat_src_code = $vat_src_code;
|
|
|
$this->line->total_ht = $total_ht;
|
|
|
$this->line->total_tva = $total_tva;
|
|
|
$this->line->total_localtax1 = $total_localtax1;
|
|
@@ -1397,7 +1403,7 @@ class Propal extends CommonObject
|
|
|
{
|
|
|
$this->lines=array();
|
|
|
|
|
|
- $sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
|
|
|
+ $sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
|
|
|
$sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,';
|
|
|
$sql.= ' d.fk_unit,';
|
|
|
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
|
|
@@ -1432,6 +1438,7 @@ class Propal extends CommonObject
|
|
|
$line->label = $objp->custom_label;
|
|
|
$line->desc = $objp->description; // Description ligne
|
|
|
$line->qty = $objp->qty;
|
|
|
+ $line->vat_src_code = $objp->vat_src_code;
|
|
|
$line->tva_tx = $objp->tva_tx;
|
|
|
$line->localtax1_tx = $objp->localtax1_tx;
|
|
|
$line->localtax2_tx = $objp->localtax2_tx;
|
|
@@ -3344,8 +3351,10 @@ class Propal extends CommonObject
|
|
|
*/
|
|
|
function getLinesArray()
|
|
|
{
|
|
|
- // For other object, here we call fetch_lines. But fetch_lines does not exists on proposal
|
|
|
-
|
|
|
+ // TODO Duplicate with fetch_lines ? Wich one to keep ?
|
|
|
+
|
|
|
+ $this->lines = array();
|
|
|
+
|
|
|
$sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,';
|
|
|
$sql.= ' pt.qty, pt.vat_src_code, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
|
|
|
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,';
|
|
@@ -3609,7 +3618,7 @@ class PropaleLigne extends CommonObjectLine
|
|
|
*/
|
|
|
function fetch($rowid)
|
|
|
{
|
|
|
- $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,';
|
|
|
+ $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.vat_src_code, pd.tva_tx,';
|
|
|
$sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,';
|
|
|
$sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,';
|
|
|
$sql.= ' pd.fk_unit,';
|
|
@@ -3635,6 +3644,7 @@ class PropaleLigne extends CommonObjectLine
|
|
|
$this->qty = $objp->qty;
|
|
|
$this->price = $objp->price; // deprecated
|
|
|
$this->subprice = $objp->subprice;
|
|
|
+ $this->vat_src_code = $objp->vat_src_code;
|
|
|
$this->tva_tx = $objp->tva_tx;
|
|
|
$this->remise = $objp->remise; // deprecated
|
|
|
$this->remise_percent = $objp->remise_percent;
|