Multicurrency on supplier order and invoice
This commit is contained in:
parent
177ec97689
commit
3d2143809b
@ -1333,9 +1333,10 @@ class CommandeFournisseur extends CommonOrder
|
||||
* @param int $date_end Date end of service
|
||||
* @param array $array_options extrafields array
|
||||
* @param string $fk_unit Code of the unit to use. Null to use the default one
|
||||
* @param string $pu_ht_devise Amount in currency
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null)
|
||||
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null, $pu_ht_devise=0)
|
||||
{
|
||||
global $langs,$mysoc,$conf;
|
||||
|
||||
@ -1441,17 +1442,19 @@ class CommandeFournisseur extends CommonOrder
|
||||
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
||||
}
|
||||
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx);
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx,$pu_ht_devise);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
$total_localtax1 = $tabprice[9];
|
||||
$total_localtax2 = $tabprice[10];
|
||||
$pu_ht = $tabprice[3];
|
||||
|
||||
// MultiCurrency
|
||||
$multicurrency_total_ht = $tabprice[16];
|
||||
$multicurrency_total_tva = $tabprice[17];
|
||||
$multicurrency_total_ttc = $tabprice[18];
|
||||
$pu_ht_devise = $tabprice[19];
|
||||
|
||||
$localtax1_type=$localtaxes_type[0];
|
||||
$localtax2_type=$localtaxes_type[2];
|
||||
@ -1498,12 +1501,12 @@ class CommandeFournisseur extends CommonOrder
|
||||
// Multicurrency
|
||||
$this->line->fk_multicurrency = $this->fk_multicurrency;
|
||||
$this->line->multicurrency_code = $this->multicurrency_code;
|
||||
$this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx);
|
||||
$this->line->multicurrency_subprice = $pu_ht_devise;
|
||||
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
|
||||
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
|
||||
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
|
||||
|
||||
$this->line->subprice=$pu;
|
||||
$this->line->subprice=$pu_ht;
|
||||
$this->line->price=$this->line->subprice;
|
||||
|
||||
$this->line->remise_percent=$remise_percent;
|
||||
@ -2247,9 +2250,10 @@ class CommandeFournisseur extends CommonOrder
|
||||
* @param timestamp $date_end Date end of service
|
||||
* @param array $array_options Extrafields array
|
||||
* @param string $fk_unit Code of the unit to use. Null to use the default one
|
||||
* @param double $pu_ht_devise Unit price in currency
|
||||
* @return int < 0 if error, > 0 if ok
|
||||
*/
|
||||
public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit=null)
|
||||
public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit=null, $pu_ht_devise = 0)
|
||||
{
|
||||
global $mysoc, $conf;
|
||||
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit");
|
||||
@ -2296,17 +2300,21 @@ class CommandeFournisseur extends CommonOrder
|
||||
$vatrate = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
||||
}
|
||||
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx);
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
$total_localtax1 = $tabprice[9];
|
||||
$total_localtax2 = $tabprice[10];
|
||||
$pu_ht = $tabprice[3];
|
||||
$pu_tva = $tabprice[4];
|
||||
$pu_ttc = $tabprice[5];
|
||||
|
||||
// MultiCurrency
|
||||
$multicurrency_total_ht = $tabprice[16];
|
||||
$multicurrency_total_tva = $tabprice[17];
|
||||
$multicurrency_total_ttc = $tabprice[18];
|
||||
$pu_ht_devise = $tabprice[19];
|
||||
|
||||
$localtax1_type=$localtaxes_type[0];
|
||||
$localtax2_type=$localtaxes_type[2];
|
||||
@ -2330,7 +2338,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$this->line->localtax1_type = $localtaxes_type[0];
|
||||
$this->line->localtax2_type = $localtaxes_type[2];
|
||||
$this->line->remise_percent = $remise_percent;
|
||||
$this->line->subprice = $pu;
|
||||
$this->line->subprice = $pu_ht;
|
||||
$this->line->rang = $this->rang;
|
||||
$this->line->info_bits = $info_bits;
|
||||
$this->line->total_ht = $total_ht;
|
||||
@ -2349,12 +2357,12 @@ class CommandeFournisseur extends CommonOrder
|
||||
// Multicurrency
|
||||
$this->line->fk_multicurrency = $this->fk_multicurrency;
|
||||
$this->line->multicurrency_code = $this->multicurrency_code;
|
||||
$this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx);
|
||||
$this->line->multicurrency_subprice = $pu_ht_devise;
|
||||
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
|
||||
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
|
||||
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
|
||||
|
||||
$this->line->subprice=$pu;
|
||||
$this->line->subprice=$pu_ht;
|
||||
$this->line->price=$this->line->subprice;
|
||||
|
||||
$this->line->remise_percent=$remise_percent;
|
||||
@ -3087,10 +3095,10 @@ class CommandeFournisseurLigne extends CommonOrderLine
|
||||
$sql.= ($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'":"null");
|
||||
$sql.= ", ".($this->fk_multicurrency ? $this->fk_multicurrency : "null");
|
||||
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
|
||||
$sql.= ", ".price2num($this->pu_ht * $this->multicurrency_tx);
|
||||
$sql.= ", ".$this->multicurrency_total_ht;
|
||||
$sql.= ", ".$this->multicurrency_total_tva;
|
||||
$sql.= ", ".$this->multicurrency_total_ttc;
|
||||
$sql.= ", ".price2num($this->multicurrency_subprice);
|
||||
$sql.= ", ".price2num($this->multicurrency_total_ht);
|
||||
$sql.= ", ".price2num($this->multicurrency_total_tva);
|
||||
$sql.= ", ".price2num($this->multicurrency_total_ttc);
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
|
||||
@ -3176,7 +3184,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
|
||||
$sql.= ($this->fk_unit ? ", fk_unit='".$this->db->escape($this->fk_unit)."'":", fk_unit=null");
|
||||
|
||||
// Multicurrency
|
||||
$sql.= ", multicurrency_subprice=".price2num($this->subprice * $this->multicurrency_tx)."";
|
||||
$sql.= ", multicurrency_subprice=".price2num($this->multicurrency_subprice)."";
|
||||
$sql.= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht)."";
|
||||
$sql.= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
|
||||
$sql.= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
|
||||
|
||||
@ -1310,11 +1310,12 @@ class FactureFournisseur extends CommonInvoice
|
||||
* @param array $array_options extrafields array
|
||||
* @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
|
||||
* @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)
|
||||
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)
|
||||
{
|
||||
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';
|
||||
@ -1347,17 +1348,19 @@ class FactureFournisseur extends CommonInvoice
|
||||
$txlocaltax1=price2num($txlocaltax1);
|
||||
$txlocaltax2=price2num($txlocaltax2);
|
||||
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx);
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
$total_localtax1 = $tabprice[9];
|
||||
$total_localtax2 = $tabprice[10];
|
||||
$pu_ht = $tabprice[3];
|
||||
|
||||
// MultiCurrency
|
||||
$multicurrency_total_ht = $tabprice[16];
|
||||
$multicurrency_total_tva = $tabprice[17];
|
||||
$multicurrency_total_ttc = $tabprice[18];
|
||||
$pu_ht_devise = $tabprice[19];
|
||||
|
||||
// Check parameters
|
||||
if ($type < 0) return -1;
|
||||
@ -1379,7 +1382,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
$this->line->fk_product=$fk_product;
|
||||
$this->line->product_type=$type;
|
||||
$this->line->remise_percent=$remise_percent;
|
||||
$this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu):$pu); // For credit note, unit price always negative, always positive otherwise
|
||||
$this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise
|
||||
$this->line->date_start=$date_start;
|
||||
$this->line->date_end=$date_end;
|
||||
$this->line->ventil=$ventil;
|
||||
@ -1401,7 +1404,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
// Multicurrency
|
||||
$this->line->fk_multicurrency = $this->fk_multicurrency;
|
||||
$this->line->multicurrency_code = $this->multicurrency_code;
|
||||
$this->line->multicurrency_subprice = price2num($this->line->subprice * $this->multicurrency_tx);
|
||||
$this->line->multicurrency_subprice = $pu_ht_devise;
|
||||
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
|
||||
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
|
||||
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
|
||||
@ -1458,9 +1461,10 @@ class FactureFournisseur extends CommonInvoice
|
||||
* @param timestamp $date_end Date end of service
|
||||
* @param array $array_options extrafields array
|
||||
* @param string $fk_unit Code of the unit to use. Null to use the default one
|
||||
* @param double $pu_ht_devise Amount in currency
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null)
|
||||
public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null, $pu_ht_devise=0)
|
||||
{
|
||||
global $mysoc;
|
||||
dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$fk_unit", LOG_DEBUG);
|
||||
@ -1469,9 +1473,10 @@ class FactureFournisseur extends CommonInvoice
|
||||
$pu = price2num($pu);
|
||||
$qty = price2num($qty);
|
||||
$remise_percent=price2num($remise_percent);
|
||||
$pu_ht_devise = price2num($pu_ht_devise);
|
||||
|
||||
// Check parameters
|
||||
if (! is_numeric($pu) || ! is_numeric($qty)) return -1;
|
||||
//if (! is_numeric($pu) || ! is_numeric($qty)) return -1;
|
||||
if ($type < 0) return -1;
|
||||
|
||||
// Clean parameters
|
||||
@ -1499,7 +1504,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
$vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate.
|
||||
}
|
||||
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx);
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
@ -1513,6 +1518,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
$multicurrency_total_ht = $tabprice[16];
|
||||
$multicurrency_total_tva = $tabprice[17];
|
||||
$multicurrency_total_ttc = $tabprice[18];
|
||||
$pu_ht_devise = $tabprice[19];
|
||||
|
||||
if (empty($info_bits)) $info_bits=0;
|
||||
|
||||
@ -1558,7 +1564,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
$line->array_options = $array_options;
|
||||
|
||||
// Multicurrency
|
||||
$line->multicurrency_subprice = price2num($line->subprice * $this->multicurrency_tx);
|
||||
$line->multicurrency_subprice = $pu_ht_devise;
|
||||
$line->multicurrency_total_ht = $multicurrency_total_ht;
|
||||
$line->multicurrency_total_tva = $multicurrency_total_tva;
|
||||
$line->multicurrency_total_ttc = $multicurrency_total_ttc;
|
||||
@ -2493,9 +2499,7 @@ class SupplierInvoiceLine extends CommonObjectLine
|
||||
$qty = price2num($this->qty);
|
||||
|
||||
// Check parameters
|
||||
if (! is_numeric($pu) || ! is_numeric($qty)) {
|
||||
return -1;
|
||||
}
|
||||
if (empty($this->qty)) $this->qty=0;
|
||||
|
||||
if ($this->product_type < 0) {
|
||||
return -1;
|
||||
|
||||
@ -299,6 +299,7 @@ if (empty($reshook))
|
||||
|
||||
$qty = GETPOST('qty'.$predef);
|
||||
$remise_percent=GETPOST('remise_percent'.$predef);
|
||||
$price_ht_devise = GETPOST('multicurrency_price_ht');
|
||||
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
@ -322,7 +323,7 @@ if (empty($reshook))
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (GETPOST('prod_entry_mode')=='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='') // Unit price can be 0 but not ''
|
||||
if (GETPOST('prod_entry_mode')=='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='' && $price_ht_devise === '') // Unit price can be 0 but not ''
|
||||
{
|
||||
setEventMessages($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), null, 'errors');
|
||||
$error++;
|
||||
@ -410,7 +411,7 @@ if (empty($reshook))
|
||||
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors');
|
||||
}
|
||||
}
|
||||
else if ((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error))
|
||||
else if (empty($error))
|
||||
{
|
||||
$pu_ht = price2num($price_ht, 'MU');
|
||||
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
|
||||
@ -440,8 +441,10 @@ if (empty($reshook))
|
||||
$ht = $ttc / (1 + ($tva_tx / 100));
|
||||
$price_base_type = 'HT';
|
||||
}
|
||||
|
||||
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit);
|
||||
|
||||
$pu_ht_devise = price2num($price_ht_devise, 'MU');
|
||||
echo $pu_ht_devise;
|
||||
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit, $pu_ht_devise);
|
||||
}
|
||||
|
||||
//print "xx".$tva_tx; exit;
|
||||
@ -540,6 +543,8 @@ if (empty($reshook))
|
||||
|
||||
$localtax1_tx=get_localtax($tva_tx,1,$mysoc,$object->thirdparty);
|
||||
$localtax2_tx=get_localtax($tva_tx,2,$mysoc,$object->thirdparty);
|
||||
|
||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
||||
|
||||
// Extrafields Lines
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
@ -568,7 +573,8 @@ if (empty($reshook))
|
||||
$date_start,
|
||||
$date_end,
|
||||
$array_options,
|
||||
$_POST['units']
|
||||
$_POST['units'],
|
||||
$pu_ht_devise
|
||||
);
|
||||
unset($_POST['qty']);
|
||||
unset($_POST['type']);
|
||||
|
||||
@ -804,6 +804,7 @@ if (empty($reshook))
|
||||
$localtax1_tx= get_localtax($_POST['tauxtva'], 1, $mysoc,$object->thirdparty);
|
||||
$localtax2_tx= get_localtax($_POST['tauxtva'], 2, $mysoc,$object->thirdparty);
|
||||
$remise_percent=GETPOST('remise_percent');
|
||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
||||
|
||||
// Extrafields Lines
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
@ -816,7 +817,7 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
$result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units']);
|
||||
$result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise);
|
||||
if ($result >= 0)
|
||||
{
|
||||
unset($_POST['label']);
|
||||
@ -875,6 +876,7 @@ if (empty($reshook))
|
||||
|
||||
$qty = GETPOST('qty'.$predef);
|
||||
$remise_percent=GETPOST('remise_percent'.$predef);
|
||||
$price_ht_devise = GETPOST('multicurrency_price_ht');
|
||||
|
||||
$date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
|
||||
$date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
|
||||
@ -901,7 +903,7 @@ if (empty($reshook))
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (GETPOST('prod_entry_mode')=='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='') // Unit price can be 0 but not ''
|
||||
if (GETPOST('prod_entry_mode')=='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='' && $price_ht_devise==='') // Unit price can be 0 but not ''
|
||||
{
|
||||
setEventMessages($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), null, 'errors');
|
||||
$error++;
|
||||
@ -917,7 +919,7 @@ if (empty($reshook))
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (GETPOST('prod_entry_mode') != 'free') // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
|
||||
if (GETPOST('prod_entry_mode') != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
|
||||
{
|
||||
$idprod=0;
|
||||
$productsupplier=new ProductFournisseur($db);
|
||||
@ -966,7 +968,7 @@ if (empty($reshook))
|
||||
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors');
|
||||
}
|
||||
}
|
||||
else if ($price_ht !== '' || GETPOST('price_ttc') !== '') // $price_ht is already set
|
||||
else if (empty($error)) // $price_ht is already set
|
||||
{
|
||||
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
|
||||
$tva_tx = str_replace('*', '', $tva_tx);
|
||||
@ -992,8 +994,9 @@ if (empty($reshook))
|
||||
$pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings
|
||||
}
|
||||
$price_base_type = 'HT';
|
||||
$pu_ht_devise = price2num($price_ht_devise, 'MU');
|
||||
|
||||
$result=$object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit);
|
||||
$result=$object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_ht_devise);
|
||||
}
|
||||
|
||||
//print "xx".$tva_tx; exit;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user