diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index aec09b5ee23..504ad47fa77 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -1080,11 +1080,10 @@ if (empty($reshook))
// if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary.
if (empty($vatrate)) $vatrate = "0.000";
- $object_ligne->vatrate = price2num($vatrate);
$object_ligne->fk_projet = $fk_projet;
- if (! GETPOST('fk_c_type_fees') > 0)
+ if (! (GETPOST('fk_c_type_fees') > 0))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
@@ -1949,7 +1948,7 @@ else
// Fetch Lines of current expense report
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
- $sql.= ' fde.tva_tx as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
+ $sql.= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
$sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
$sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
@@ -2028,7 +2027,7 @@ else
// print '
'.$langs->trans("TF_".strtoupper(empty($objp->type_fees_libelle)?'OTHER':$objp->type_fees_libelle)).' | ';
print ''.($langs->trans(($objp->type_fees_code)) == $objp->type_fees_code ? $objp->type_fees_libelle : $langs->trans(($objp->type_fees_code))).' | ';
print ''.$objp->comments.' | ';
- print ''.vatrate($objp->vatrate,true).' | ';
+ print ''.vatrate($objp->vatrate.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''),true).' | ';
print ''.price($objp->value_unit).' | ';
print ''.$objp->qty.' | ';
@@ -2082,24 +2081,25 @@ else
// Add comments
print '';
- print '';
+ print '';
print ' | ';
// VAT
print '';
$seller=$mysoc;
$buyer=new Societe($db);
- print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$objp->vatrate), $seller, $buyer, 0, 0, '', false, 1);
+ $selectedvat=(GETPOST("vatrate",'alpha')?GETPOST("vatrate",'alpha'):$objp->vatrate.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
+ print $form->load_tva('vatrate', $selectedvat, $seller, $buyer, 0, 0, '', false, 1);
print ' | ';
// Unit price
print '';
- print '';
+ print '';
print ' | ';
// Quantity
print '';
- print '';
+ print ''; // We must be able to enter decimal qty
print ' | ';
if ($action != 'editline')
@@ -2120,13 +2120,6 @@ else
$db->free($resql);
}
- else
- {
- /* print '';
- print ''.$langs->trans("AucuneLigne").' |
';
- print '
';*/
- }
- //print '';
// Add a line
if (($object->fk_statut==0 || $object->fk_statut==99) && $action != 'editline' && $user->rights->expensereport->creer)
@@ -2143,7 +2136,6 @@ else
print ' | ';
print '';
-
print '';
print ' | ';
@@ -2180,12 +2172,12 @@ else
// Unit price
print '';
- print '';
+ print '';
print ' | ';
// Quantity
print '';
- print '';
+ print ''; // We must be able to enter decimal qty
print ' | ';
if ($action != 'editline')
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index 00076a0e189..a91b1e83dc1 100644
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -2058,7 +2058,7 @@ class ExpenseReportLine
function fetch($rowid)
{
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
- $sql.= ' fde.tva_tx as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
+ $sql.= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
$sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
$sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
@@ -2087,6 +2087,7 @@ class ExpenseReportLine
$this->projet_ref = $objp->projet_ref;
$this->projet_title = $objp->projet_title;
$this->vatrate = $objp->vatrate;
+ $this->vat_src_code = $objp->vat_src_code;
$this->total_ht = $objp->total_ht;
$this->total_tva = $objp->total_tva;
$this->total_ttc = $objp->total_ttc;
@@ -2121,11 +2122,12 @@ class ExpenseReportLine
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'expensereport_det';
$sql.= ' (fk_expensereport, fk_c_type_fees, fk_projet,';
- $sql.= ' tva_tx, comments, qty, value_unit, total_ht, total_tva, total_ttc, date)';
+ $sql.= ' tva_tx, vat_src_code, comments, qty, value_unit, total_ht, total_tva, total_ttc, date)';
$sql.= " VALUES (".$this->fk_expensereport.",";
$sql.= " ".$this->fk_c_type_fees.",";
$sql.= " ".($this->fk_projet>0?$this->fk_projet:'null').",";
$sql.= " ".$this->vatrate.",";
+ $sql.= " '".$this->db->escape($this->vat_src_code)."',";
$sql.= " '".$this->db->escape($this->comments)."',";
$sql.= " ".$this->qty.",";
$sql.= " ".$this->value_unit.",";
@@ -2196,6 +2198,7 @@ class ExpenseReportLine
$sql.= ",total_tva=".$this->total_tva."";
$sql.= ",total_ttc=".$this->total_ttc."";
$sql.= ",tva_tx=".$this->vatrate;
+ $sql.= ",vat_src_code='".$this->db->escape($this->vat_src_code)."'";
if ($this->fk_c_type_fees) $sql.= ",fk_c_type_fees=".$this->fk_c_type_fees;
else $sql.= ",fk_c_type_fees=null";
if ($this->fk_projet) $sql.= ",fk_projet=".$this->fk_projet;