Suite gestion des arrondis sur les montants
This commit is contained in:
parent
e8ae7de9db
commit
b34c0c22be
@ -621,7 +621,7 @@ class Commande extends CommonObject
|
||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||
*/
|
||||
function addline($commandeid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $fk_remise_except=0, $info_bits=0)
|
||||
function addline($commandeid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $fk_remise_except=0, $info_bits=0, $price_base_type='HT')
|
||||
{
|
||||
dolibarr_syslog("Commande.class.php::addline this->id=$this->id, $commandeid, $desc, $pu, $qty, $txtva, $fk_product, $remise_percent");
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
@ -641,7 +641,7 @@ class Commande extends CommonObject
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva);
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
@ -1805,7 +1805,7 @@ class Commande extends CommonObject
|
||||
* \param tva_tx Taux TVA
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva)
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $price_base_type='HT')
|
||||
{
|
||||
dolibarr_syslog("Commande::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva");
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
@ -1825,7 +1825,7 @@ class Commande extends CommonObject
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva);
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
@ -2222,7 +2222,7 @@ else
|
||||
print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>';
|
||||
print '<td align="right" width="50">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td align="right" width="50">'.$langs->trans('TotalHT').'</td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="12"> </td>';
|
||||
@ -2407,7 +2407,7 @@ else
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '<td align="center" rowspan="1" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
|
||||
print '<td align="center" rowspan="1" colspan="5" valign="middle"><input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
|
||||
print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td>';
|
||||
print '</tr>' . "\n";
|
||||
if ($conf->service->enabled)
|
||||
|
||||
@ -283,7 +283,7 @@ class FactureRec extends Facture
|
||||
/**
|
||||
* \brief Ajoute une ligne de facture
|
||||
*/
|
||||
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product='NULL', $remise_percent=0)
|
||||
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product='NULL', $remise_percent=0, $price_base_type='HT')
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
|
||||
@ -301,7 +301,7 @@ class FactureRec extends Facture
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva);
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
@ -1308,12 +1308,14 @@ class Facture extends CommonObject
|
||||
if (! $info_bits) $info_bits=0;
|
||||
$pu = price2num($pu);
|
||||
$txtva=price2num($txtva);
|
||||
|
||||
if ($price_base_type=='HT') $pu=$pu;
|
||||
else $pu=$pu_ttc;
|
||||
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $pu_ttc);
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
@ -1382,15 +1384,16 @@ class Facture extends CommonObject
|
||||
* \brief Mets à jour une ligne de facture
|
||||
* \param rowid Id de la ligne de facture
|
||||
* \param desc Description de la ligne
|
||||
* \param pu Prix unitaire
|
||||
* \param pu Prix unitaire (HT ou TTC selon price_base_type)
|
||||
* \param qty Quantité
|
||||
* \param remise_percent Pourcentage de remise de la ligne
|
||||
* \param date_start Date de debut de validité du service
|
||||
* \param date_end Date de fin de validité du service
|
||||
* \param date_start Date de debut de validité du service
|
||||
* \param date_end Date de fin de validité du service
|
||||
* \param tva_tx Taux TVA
|
||||
* \param price_base_type HT ou TTC
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $date_start, $date_end, $txtva)
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $date_start, $date_end, $txtva, $price_base_type='HT')
|
||||
{
|
||||
dolibarr_syslog("Facture::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva", LOG_DEBUG);
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
@ -1410,10 +1413,13 @@ class Facture extends CommonObject
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
$pu_ht = $tabprice[3];
|
||||
$pu_tva = $tabprice[4];
|
||||
$pu_ttc = $tabprice[5];
|
||||
|
||||
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
|
||||
$price = $pu;
|
||||
|
||||
@ -106,13 +106,6 @@ if($_GET['action'] == 'deletepaiement')
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'modif_libelle')
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn set libelle = \''.addslashes($form_libelle).'\' WHERE rowid = '.$_GET['facid'];
|
||||
$result = $db->query( $sql);
|
||||
}
|
||||
|
||||
|
||||
if ($_POST['action'] == 'update' && ! $_POST['cancel'])
|
||||
{
|
||||
$datefacture = $db->idate(mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']));
|
||||
@ -165,22 +158,23 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer)
|
||||
for ($i = 1 ; $i < 9 ; $i++)
|
||||
{
|
||||
$label = $_POST['label'.$i];
|
||||
$amount = price2num($_POST['amount'.$i]);
|
||||
$amountht = price2num($_POST['amount'.$i]);
|
||||
$amountttc = price2num($_POST['amountttc'.$i]);
|
||||
$tauxtva = price2num($_POST['tauxtva'.$i]);
|
||||
$tauxtva = price2num($_POST['tauxtva'.$i]);
|
||||
$qty = $_POST['qty'.$i];
|
||||
|
||||
if (strlen($label) > 0 && !empty($amount))
|
||||
$fk_product = $_POST['fk_product'.$i];
|
||||
if ($label)
|
||||
{
|
||||
if ($amountht)
|
||||
{
|
||||
$price_base='HT'; $amount=$amountht;
|
||||
}
|
||||
else
|
||||
{
|
||||
$price_base='TTC'; $amount=$amountttc;
|
||||
}
|
||||
$atleastoneline=1;
|
||||
$ret=$facfou->addline($label, $amount, $tauxtva, $qty, 1);
|
||||
if ($ret < 0) $nberror++;
|
||||
}
|
||||
else if (strlen($label) > 0 && empty($amount))
|
||||
{
|
||||
$ht = $amountttc / (1 + ($tauxtva / 100));
|
||||
$atleastoneline=1;
|
||||
$ret=$facfou->addline($label, $ht, $tauxtva, $qty, 1);
|
||||
$ret=$facfou->addline($label, $amount, $tauxtva, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base);
|
||||
if ($ret < 0) $nberror++;
|
||||
}
|
||||
}
|
||||
@ -379,8 +373,8 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy')
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td> </td><td>'.$langs->trans('Label').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VATRate').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUTTC').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -401,10 +395,10 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy')
|
||||
print '<tr><td>'.$i.'</td>';
|
||||
print '<td><input size="50" name="label'.$i.'" value="'.$value_label.'" type="text"></td>';
|
||||
print '<td align="right"><input type="text" size="8" name="amount'.$i.'" value="'.$value_pu.'"></td>';
|
||||
print '<td align="right"><input type="text" size="3" name="qty'.$i.'" value="'.$value_qty.'"></td>';
|
||||
print '<td align="right">';
|
||||
$html->select_tva('tauxtva'.$i,$value_tauxtva,$societe,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" size="3" name="qty'.$i.'" value="'.$value_qty.'"></td>';
|
||||
print '<td align="right"><input type="text" size="8" name="amountttc'.$i.'" value=""></td></tr>';
|
||||
}
|
||||
|
||||
@ -490,12 +484,11 @@ else
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans('Label').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUTTC').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right">'.$langs->trans('TotalHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VATRate').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('TotalTTC').'</td>';
|
||||
print '<td colspan="2"> </td></tr>';
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
@ -503,15 +496,14 @@ else
|
||||
$var=!$var;
|
||||
// Affichage simple de la ligne
|
||||
print '<tr '.$bc[$var].'><td>'.$fac->lignes[$i]->description.'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->pu_ht).'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->pu_ht * (1+($fac->lignes[$i]->tva_taux/100))).'</td>';
|
||||
print '<td align="right">'.price($fac->lignes[$i]->tva_taux).'%</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->pu_ht,'MU').'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.($fac->lignes[$i]->pu_ttc?price($fac->lignes[$i]->pu_ttc,'MU'):' ').'</td>';
|
||||
print '<td align="right">'.$fac->lignes[$i]->qty.'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ht).'</td>';
|
||||
print '<td align="right">'.price($fac->lignes[$i]->tva_taux).'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->tva).'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ttc).'</td>';
|
||||
print '<td align="center"><a href="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=0&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_edit().'</a></td>';
|
||||
print '<td align="center"><a href="fiche.php?facid='.$fac->id.'&action=confirm_delete_line&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_delete().'</a></td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ht,'MT').'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ttc,'MT').'</td>';
|
||||
print '<td align="center" width="16"><a href="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=0&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_edit().'</a></td>';
|
||||
print '<td align="center" width="16"><a href="fiche.php?facid='.$fac->id.'&action=confirm_delete_line&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_delete().'</a></td>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -578,11 +570,11 @@ else
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3" nowrap="nowrap">';
|
||||
print dolibarr_print_date($fac->datep,'dayhourtext').'</td></tr>';
|
||||
print dolibarr_print_date($fac->datep,'daytext').'</td></tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateEcheance').'</td><td colspan="3">';
|
||||
print dolibarr_print_date($fac->date_echeance,'dayhourtext');
|
||||
print dolibarr_print_date($fac->date_echeance,'daytext');
|
||||
if (($fac->paye == 0) && ($fac->statut > 0) && $fac->date_echeance < (time() - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
|
||||
print '</td></tr>';
|
||||
|
||||
@ -634,7 +626,7 @@ else
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td nowrap><a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans('Payment'),'payment').'</a> '.dolibarr_print_date($objp->dp)."</td>\n";
|
||||
print '<td nowrap><a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans('Payment'),'payment').'</a> '.dolibarr_print_date($objp->dp,'day')."</td>\n";
|
||||
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement.'</td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td>';
|
||||
|
||||
@ -689,12 +681,11 @@ else
|
||||
if ($i == 0)
|
||||
{
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans('Label').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUTTC').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right">'.$langs->trans('TotalHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VATRate').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('TotalTTC').'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
@ -718,15 +709,14 @@ else
|
||||
print '<textarea class="flat" cols="70" rows="'.ROWS_2.'" name="label">'.$fac->lignes[$i]->description.'</textarea>';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
$html->select_tva('tauxtva',$fac->lignes[$i]->tva_taux,$societe,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right" nowrap="nowrap"><input size="6" name="puht" type="text" value="'.price($fac->lignes[$i]->pu_ht).'"></td>';
|
||||
print '<td align="right" nowrap="nowrap"><input size="6" name="amountttc" type="text" value=""></td>';
|
||||
print '<td align="right"><input size="1" name="qty" type="text" value="'.$fac->lignes[$i]->qty.'"></td>';
|
||||
print '<td align="right" nowrap="nowrap"> </td>';
|
||||
print '<td align="right">';
|
||||
$html->select_tva('tauxtva',$fac->lignes[$i]->tva_taux,$societe,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right" nowrap="nowrap"></td>';
|
||||
print '<td align="right" nowrap="nowrap"></td>';
|
||||
print '<td align="right" nowrap="nowrap"> </td>';
|
||||
print '<td align="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans('Save').'">';
|
||||
print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td>';
|
||||
print '</tr>';
|
||||
@ -750,15 +740,14 @@ else
|
||||
print nl2br($fac->lignes[$i]->description);
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->pu_ht).'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price(price2num($fac->lignes[$i]->pu_ht * (1+($fac->lignes[$i]->tva_taux/100)),'MU')).'</td>';
|
||||
print '<td align="right">'.price($fac->lignes[$i]->tva_taux).'%</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->pu_ht,'MU').'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.($fac->lignes[$i]->pu_ttc?price($fac->lignes[$i]->pu_ttc,'MU'):' ').'</td>';
|
||||
print '<td align="right">'.$fac->lignes[$i]->qty.'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ht).'</td>';
|
||||
print '<td align="right">'.price($fac->lignes[$i]->tva_taux).'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->tva).'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ttc).'</td>';
|
||||
print '<td align="center"><a href="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=0&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_edit().'</a></td>';
|
||||
print '<td align="center"><a href="fiche.php?facid='.$fac->id.'&action=confirm_delete_line&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_delete().'</a></td>';
|
||||
print '<td align="center" width="16"><a href="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=0&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_edit().'</a></td>';
|
||||
print '<td align="center" width="16"><a href="fiche.php?facid='.$fac->id.'&action=confirm_delete_line&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_delete().'</a></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
@ -767,12 +756,11 @@ else
|
||||
if ($fac->statut == 0 && $_GET['action'] != 'mod_ligne')
|
||||
{
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans('Label').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUTTC').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right">'.$langs->trans('TotalHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VATRate').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('TotalTTC').'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
@ -788,6 +776,9 @@ else
|
||||
print '<textarea class="flat" cols="70" rows="'.ROWS_2.'" name="label"></textarea>';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
$html->select_tva('tauxtva','',$societe,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print '<input size="6" name="amount" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
@ -797,11 +788,8 @@ else
|
||||
print '<input size="1" name="qty" type="text" value="1">';
|
||||
print '</td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td align="right">';
|
||||
$html->select_tva('tauxtva','',$societe,$mysoc);
|
||||
print '</td><td align="center" colspan="2">';
|
||||
print ' ';
|
||||
print '</td><td align="center" valign="middle" colspan="2"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td></tr>';
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="center" valign="middle" colspan="2"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td></tr>';
|
||||
print '</form>';
|
||||
|
||||
// Ajout de produits/services prédéfinis
|
||||
@ -813,15 +801,13 @@ else
|
||||
print '<input type="hidden" name="socid" value="'.$fac->socid.'">';
|
||||
$var=! $var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td colspan="3">';
|
||||
print '<td colspan="4">';
|
||||
$html->select_produits_fournisseurs($fac->socid,'','idprod',$filtre);
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center" valign="middle" rowspan="2" colspan="5"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '<td align="center" valign="middle" rowspan="2" colspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
@ -1224,7 +1224,7 @@ class CommandeFournisseur extends Commande
|
||||
* \param tva_tx Taux TVA
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva)
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $price_base_type='HT')
|
||||
{
|
||||
dolibarr_syslog("CommandeFournisseur::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva");
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
@ -1244,7 +1244,7 @@ class CommandeFournisseur extends Commande
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva);
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $price_base_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
@ -209,7 +209,7 @@ class FactureFournisseur extends Facture
|
||||
/*
|
||||
* Lignes
|
||||
*/
|
||||
$sql = 'SELECT f.rowid, f.description, f.pu_ht, f.qty, f.tva_taux, f.tva';
|
||||
$sql = 'SELECT f.rowid, f.description, f.pu_ht, f.pu_ttc, f.qty, f.tva_taux, f.tva';
|
||||
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product';
|
||||
$sql.= ', p.ref, p.label as label, p.description as product_desc';
|
||||
//$sql.= ', pf.ref_fourn';
|
||||
@ -236,6 +236,7 @@ class FactureFournisseur extends Facture
|
||||
$this->lignes[$i]->libelle = $obj->label; // Label du produit
|
||||
$this->lignes[$i]->product_desc = $obj->product_desc; // Description du produit
|
||||
$this->lignes[$i]->pu_ht = $obj->pu_ht;
|
||||
$this->lignes[$i]->pu_ttc = $obj->pu_ttc;
|
||||
$this->lignes[$i]->tva_taux = $obj->tva_taux;
|
||||
$this->lignes[$i]->qty = $obj->qty;
|
||||
$this->lignes[$i]->tva = $obj->tva;
|
||||
@ -367,12 +368,13 @@ class FactureFournisseur extends Facture
|
||||
* \param date_end Date de fin de validité du service
|
||||
* \param ventil Code de ventilation comptable
|
||||
* \param info_bits Bits de type de lignes
|
||||
* \param price_base HT ou TTC
|
||||
* \remarks Les parametres sont deja censé etre juste et avec valeurs finales a l'appel
|
||||
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete défini
|
||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||
*/
|
||||
function addline($desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $fk_remise_except='', $price_base_type='HT', $pu_ttc=0)
|
||||
function addline($desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT')
|
||||
{
|
||||
dolibarr_syslog("FactureFourn::Addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits", LOG_DEBUG);
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
@ -382,23 +384,18 @@ class FactureFournisseur extends Facture
|
||||
// Nettoyage paramètres
|
||||
$txtva=price2num($txtva);
|
||||
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice = calcul_price_total($qty, $pu, 0, $txtva, 0, 'HT', 0);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)';
|
||||
$sql .= ' VALUES ('.$this->id.');';
|
||||
dolibarr_syslog("Fournisseur.facture::addline sql=".$sql);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
|
||||
$this->updateline($idligne, $desc, $pu, $txtva, $qty, $fk_product);
|
||||
|
||||
$this->updateline($idligne, $desc, $pu, $txtva, $qty, $fk_product);
|
||||
|
||||
// Mise a jour prix facture
|
||||
$result=$this->update_price($this->id);
|
||||
if ($result > 0)
|
||||
@ -424,50 +421,60 @@ class FactureFournisseur extends Facture
|
||||
|
||||
/**
|
||||
* \brief Mets à jour une ligne de facture
|
||||
* \param id Id de la ligne de facture
|
||||
* \param label Description de la ligne
|
||||
* \param puht Prix unitaire
|
||||
* \param tauxtva Taux tva
|
||||
* \param qty Quantité
|
||||
* \param idproduct Id produit
|
||||
* \return int <0 si ko, >0 si ok
|
||||
* \param id Id de la ligne de facture
|
||||
* \param label Description de la ligne
|
||||
* \param pu Prix unitaire (HT ou TTC selon price_base_type)
|
||||
* \param tauxtva Taux tva
|
||||
* \param qty Quantité
|
||||
* \param idproduct Id produit
|
||||
* \param price_base_type HT ou TTC
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function updateline($id, $label, $puht, $tauxtva, $qty=1, $idproduct=0)
|
||||
function updateline($id, $label, $pu, $tauxtva, $qty=1, $idproduct=0, $price_base_type='HT')
|
||||
{
|
||||
$puht = price2num($puht);
|
||||
$pu = price2num($pu);
|
||||
$qty = price2num($qty);
|
||||
|
||||
if (is_numeric($puht) && is_numeric($qty))
|
||||
// Validation
|
||||
if (! is_numeric($pu) || ! is_numeric($qty)) return -1;
|
||||
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice = calcul_price_total($qty, $pu, 0, $tauxtva, 0, $price_base_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
$pu_ht = $tabprice[3];
|
||||
$pu_tva = $tabprice[4];
|
||||
$pu_ttc = $tabprice[5];
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn_det ';
|
||||
$sql.= 'SET ';
|
||||
$sql.= 'description =\''.addslashes($label).'\'';
|
||||
$sql.= ', pu_ht = ' .price2num($pu_ht);
|
||||
$sql.= ', pu_ttc= ' .price2num($pu_ttc);
|
||||
$sql.= ', qty =' .price2num($qty);
|
||||
$sql.= ', tva_taux=' .price2num($tauxtva);
|
||||
$sql.= ', total_ht=' .price2num($total_ht);
|
||||
$sql.= ', tva=' .price2num($total_tva);
|
||||
$sql.= ', total_ttc='.price2num($total_ttc);
|
||||
if ($idproduct) $sql.= ', fk_product='.$idproduct;
|
||||
else $sql.= ', fk_product=null';
|
||||
$sql.= ' WHERE rowid = '.$id;
|
||||
|
||||
dolibarr_syslog("Fournisseur.facture::updateline sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$totalht = ($puht * $qty);
|
||||
$tva = ($totalht * $tauxtva / 100);
|
||||
$totalttc = $totalht + $tva;
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn_det ';
|
||||
$sql.= 'SET ';
|
||||
$sql.= 'description =\''.addslashes($label).'\'';
|
||||
$sql.= ', pu_ht = ' .price2num($puht);
|
||||
$sql.= ', qty =' .price2num($qty);
|
||||
$sql.= ', total_ht=' .price2num($totalht);
|
||||
$sql.= ', tva=' .price2num($tva);
|
||||
$sql.= ', tva_taux=' .price2num($tauxtva);
|
||||
$sql.= ', total_ttc='.price2num($totalttc);
|
||||
if ($idproduct) $sql.= ', fk_product='.$idproduct;
|
||||
else $sql.= ', fk_product=null';
|
||||
$sql.= ' WHERE rowid = '.$id;
|
||||
|
||||
dolibarr_syslog("Fournisseur.facture::updateline sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
// Mise a jour prix facture
|
||||
return $this->update_price($this->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
// Mise a jour prix total facture
|
||||
return $this->update_price($this->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,6 +504,8 @@ class FactureFournisseur extends Facture
|
||||
*/
|
||||
function update_price($facid)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$total_ht = 0;
|
||||
$total_tva = 0;
|
||||
$total_ttc = 0;
|
||||
@ -521,9 +530,9 @@ class FactureFournisseur extends Facture
|
||||
$total_ttc = $total_ttc != '' ? $total_ttc : 0;
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn SET';
|
||||
$sql .= ' total_ht = '. price2num($total_ht);
|
||||
$sql .= ',total_tva = '.price2num($total_tva);
|
||||
$sql .= ',total_ttc = '.price2num($total_ttc);
|
||||
$sql .= ' total_ht = '. price2num($total_ht,'MT');
|
||||
$sql .= ',total_tva = '.price2num($total_tva,'MT');
|
||||
$sql .= ',total_ttc = '.price2num($total_ttc,'MT');
|
||||
$sql .= ' WHERE rowid = '.$facid.';';
|
||||
dolibarr_syslog("Fournisseur.facture::update_price sql=".$sql);
|
||||
$resql2 = $this->db->query($sql);
|
||||
|
||||
@ -929,7 +929,7 @@ class Form
|
||||
{
|
||||
$sql.="DISTINCT";
|
||||
}
|
||||
$sql.= " p.rowid, p.label, p.ref, p.price, p.duration";
|
||||
$sql.= " p.rowid, p.label, p.ref, p.price, p.price_ttc, p.price_base_type, p.duration";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p ";
|
||||
if ($conf->categorie->enabled && ! $user->rights->categorie->voir)
|
||||
{
|
||||
@ -1005,24 +1005,23 @@ class Form
|
||||
// Multiprix
|
||||
if ($price_level > 1)
|
||||
{
|
||||
$sql= "SELECT price ";
|
||||
$sql= "SELECT price, price_ttc, price_base_type ";
|
||||
$sql.= "FROM ".MAIN_DB_PREFIX."product_price ";
|
||||
$sql.= "where fk_product='".$objp->rowid."' and price_level=".$price_level;
|
||||
$sql.= " order by date_price DESC limit 1";
|
||||
$result2 = $this->db->query($sql) ;
|
||||
$objp2 = $this->db->fetch_object($result2);
|
||||
if ($objp2->price)
|
||||
{
|
||||
$opt.= $objp2->price.' '.$langs->trans("Currency".$conf->monnaie);
|
||||
}
|
||||
if ($objp2->price_base_type == 'HT')
|
||||
$opt.= price2num($objp2->price,'MU').' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
|
||||
else
|
||||
{
|
||||
$opt.= $objp->price.' '.$langs->trans("Currency".$conf->monnaie);
|
||||
}
|
||||
$opt.= price2num($objp2->price_ttc,'MU').' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
|
||||
}
|
||||
else
|
||||
{
|
||||
$opt.= $objp->price.' '.$langs->trans("Currency".$conf->monnaie);
|
||||
if ($objp->price_base_type == 'HT')
|
||||
$opt.= price2num($objp->price,'MU').' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
|
||||
else
|
||||
$opt.= price2num($objp->price_ttc,'MU').' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
|
||||
}
|
||||
|
||||
if ($objp->duration) $opt.= ' - '.$objp->duration;
|
||||
|
||||
@ -900,7 +900,7 @@ function migrate_price_facture($db,$langs,$conf)
|
||||
$facligne= new FactureLigne($db);
|
||||
$facligne->fetch($rowid);
|
||||
|
||||
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global);
|
||||
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT');
|
||||
$total_ht = $result[0];
|
||||
$total_tva = $result[1];
|
||||
$total_ttc = $result[2];
|
||||
@ -1006,7 +1006,7 @@ function migrate_price_propal($db,$langs,$conf)
|
||||
$propalligne= new PropaleLigne($db);
|
||||
$propalligne->fetch($rowid);
|
||||
|
||||
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global);
|
||||
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT');
|
||||
$total_ht = $result[0];
|
||||
$total_tva = $result[1];
|
||||
$total_ttc = $result[2];
|
||||
@ -1112,7 +1112,7 @@ function migrate_price_commande($db,$langs,$conf)
|
||||
$commandeligne= new CommandeLigne($db);
|
||||
$commandeligne->fetch($rowid);
|
||||
|
||||
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global);
|
||||
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT');
|
||||
$total_ht = $result[0];
|
||||
$total_tva = $result[1];
|
||||
$total_ttc = $result[2];
|
||||
|
||||
@ -35,42 +35,48 @@
|
||||
facture, propale, commande ou autre depuis:
|
||||
quantité, prix unitaire, remise_percent_ligne, txtva, remise_percent_global
|
||||
\param qty Quantité
|
||||
\param pu Prix unitaire HT
|
||||
\param pu Prix unitaire (HT ou TTC selon price_base_type)
|
||||
\param remise_percent_ligne Remise ligne
|
||||
\param txtva Taux tva
|
||||
\param remise_percent_global 0
|
||||
\param price_base_type HT=on calcule sur le HT, TTC=on calcule sur le TTC
|
||||
\param pu_ttc Prix unitaire TTC
|
||||
\return result[0,1,2] (total_ht, total_tva, total_ttc)
|
||||
\return result[0,1,2,3,4,5] (total_ht, total_tva, total_ttc, pu_ht, pu_tva, pu_ttc)
|
||||
*/
|
||||
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $remise_percent_global=0, $price_base_type='HT', $pu_ttc=0)
|
||||
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $remise_percent_global=0, $price_base_type='HT')
|
||||
{
|
||||
$maxdecimalfortotal=2;
|
||||
global $conf;
|
||||
|
||||
$result=array();
|
||||
|
||||
if ($price_base_type =='HT')
|
||||
//dolibarr_syslog("price.lib::calcul_price_total $qty, $pu, $remise_percent_ligne, $txtva, $price_base_type");
|
||||
if ($price_base_type == 'HT')
|
||||
{
|
||||
// On travaille par defaut en partant du prix HT
|
||||
$tot_sans_remise = $pu * $qty;
|
||||
$tot_avec_remise_ligne = $tot_sans_remise * ( 1 - ($remise_percent_ligne / 100));
|
||||
$tot_avec_remise = $tot_avec_remise_ligne * ( 1 - ($remise_percent_global / 100));
|
||||
$result[0] = round($tot_avec_remise, $maxdecimalfortotal);
|
||||
$result[2] = round($tot_avec_remise * ( 1 + ($txtva / 100)), $maxdecimalfortotal);
|
||||
$result[0] = price2num($tot_avec_remise, 'MT');
|
||||
$result[2] = price2num($tot_avec_remise * ( 1 + ($txtva / 100)), 'MT');
|
||||
$result[1] = $result[2] - $result[0];
|
||||
$result[3] = price2num($pu, 'MU');
|
||||
$result[5] = price2num($pu * ( 1 + ($txtva / 100)), 'MU');
|
||||
$result[4] = $result[5] - $result[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
// On cacule à l'envers en partant du prix TTC
|
||||
// Utilise pour les produits a prix TTC reglemente (livres, ...)
|
||||
|
||||
$tot_sans_remise = $pu_ttc * $qty;
|
||||
$tot_sans_remise = $pu * $qty;
|
||||
$tot_avec_remise_ligne = $tot_sans_remise * ( 1 - ($remise_percent_ligne / 100));
|
||||
$tot_avec_remise = $tot_avec_remise_ligne * ( 1 - ($remise_percent_global / 100));
|
||||
|
||||
$result[2] = round($tot_avec_remise, $maxdecimalfortotal);
|
||||
$result[0] = round($tot_avec_remise / ( 1 + ($txtva / 100)), $maxdecimalfortotal);
|
||||
$result[2] = price2num($tot_avec_remise, 'MT');
|
||||
$result[0] = price2num($tot_avec_remise / ( 1 + ($txtva / 100)), 'MT');
|
||||
$result[1] = $result[2] - $result[0];
|
||||
$result[5] = price2num($pu, 'MU');
|
||||
$result[3] = price2num($pu / ( 1 + ($txtva / 100)), 'MU');
|
||||
$result[4] = $result[5] - $result[3];
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
@ -267,7 +267,7 @@ class Propal extends CommonObject
|
||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||
*/
|
||||
function addline($propalid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0)
|
||||
function addline($propalid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT')
|
||||
{
|
||||
dolibarr_syslog("Propal.class::addline $propalid, $desc, $pu, $qty, $txtva, $fk_product, $remise_percent");
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
@ -287,7 +287,7 @@ class Propal extends CommonObject
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva);
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
@ -359,7 +359,7 @@ class Propal extends CommonObject
|
||||
* \param desc Description
|
||||
* \return int 0 en cas de succès
|
||||
*/
|
||||
function updateline($rowid, $pu, $qty, $remise_percent=0, $txtva, $desc='')
|
||||
function updateline($rowid, $pu, $qty, $remise_percent=0, $txtva, $desc='', $price_base_type='HT')
|
||||
{
|
||||
dolibarr_syslog("propal.class.php::UpdateLine $rowid, $pu, $qty, $remise_percent, $txtva, $desc");
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
@ -379,7 +379,7 @@ class Propal extends CommonObject
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva);
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
@ -591,7 +591,8 @@ ALTER TABLE llx_facture_fourn MODIFY total_ht double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn MODIFY total_tva double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn MODIFY total_ttc double(16,8) DEFAULT 0;
|
||||
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY pu_ht double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY pu_ht double(16,8);
|
||||
ALTER TABLE llx_facture_fourn_det ADD pu_ttc double(16,8) AFTER pu_ht;
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY qty smallint DEFAULT 1;
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY total_ht double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY tva_taux double(16,8) DEFAULT 0;
|
||||
|
||||
@ -25,10 +25,11 @@ create table llx_facture_fourn_det
|
||||
fk_facture_fourn integer NOT NULL,
|
||||
fk_product integer NULL,
|
||||
description text,
|
||||
pu_ht double(16,8) DEFAULT 0,
|
||||
pu_ht double(16,8),
|
||||
pu_ttc double(16,8),
|
||||
qty smallint DEFAULT 1,
|
||||
total_ht double(16,8) DEFAULT 0,
|
||||
tva_taux double(16,8) DEFAULT 0,
|
||||
total_ht double(16,8) DEFAULT 0,
|
||||
tva double(16,8) DEFAULT 0,
|
||||
total_ttc double(16,8) DEFAULT 0
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user