diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index f2e12615293..e4d0b1fc1f4 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -134,14 +134,21 @@ if ($_POST["action"] == 'add' && $user->rights->fournisseur->facture->creer)
{
$label = "label$i";
$amount = "amount$i";
+ $amountttc = "amountttc$i";
$tauxtva = "tauxtva$i";
$qty = "qty$i";
- if (strlen($_POST["$label"]) > 0 && $_POST["$amount"] > 0)
+ if (strlen($_POST[$label]) > 0 && !empty($_POST[$amount]))
{
$atleastoneline=1;
$facfou->addline($_POST["$label"], $_POST["$amount"], $_POST["$tauxtva"], $_POST["$qty"], 1);
}
+ else if (strlen($_POST[$label]) > 0 && empty($_POST[$amount]))
+ {
+ $ht = $_POST[$amountttc] / (1 + ($_POST[$tauxtva] / 100));
+ $atleastoneline=1;
+ $facfou->addline($_POST[$label], $ht, $_POST[$tauxtva], $_POST[$qty], 1);
+ }
}
$db->commit();
@@ -173,8 +180,13 @@ if ($_GET["action"] == 'add_ligne')
{
$facfou = new FactureFournisseur($db,"", $_GET["facid"]);
- $facfou->addline($_POST["label"], $_POST["amount"], $_POST["tauxtva"], $_POST["qty"]);
-
+ if (strlen($_POST["label"]) > 0 && $_POST["amount"] > 0)
+ $facfou->addline($_POST["label"], $_POST["amount"], $_POST["tauxtva"], $_POST["qty"]);
+ else
+ {
+ $ht = $_POST['amountttc'] / (1 + ($_POST['tauxtva'] / 100));
+ $facfou->addline($_POST["label"], $ht, $_POST["tauxtva"], $_POST["qty"]);
+ }
$_GET["action"] = "edit";
}
@@ -264,7 +276,13 @@ if ($_GET["action"] == 'create' or $_GET["action"] == 'copy')
print "
";
print '
| '.$langs->trans("Label").' | '.$langs->trans("PriceUHT").' | '.$langs->trans("Qty").' | '.$langs->trans("VATRate").' | |||
| '.$langs->trans("Label").' | '; + print ''.$langs->trans("PriceUHT").' | '; + print ''.$langs->trans("Qty").' | '; + print ''.$langs->trans("VATRate").' | '; + print ''.$langs->trans("PriceUTTC").' | '; + print '||
| '.$i.' | '; print ''; print ' | '; - print ' | '; + print ' | '; + print ' | '; $html->select_tva("tauxtva".$i); - print ' | '; } print " |
| '.$langs->trans("Label").' | '; print ''.$langs->trans("PriceUHT").' | '; + print ''.$langs->trans("PriceUTTC").' | '; print ''.$langs->trans("Qty").' | '; print ''.$langs->trans("TotalHT").' | '; print ''.$langs->trans("VATRate").' | '; @@ -381,6 +402,7 @@ else { print "|||
| '.$fac->lignes[$i][0]." | "; print ''.price($fac->lignes[$i][1])." | "; + print ''.price($fac->lignes[$i][1] * (1+($fac->lignes[$i][2]/100)))." | "; print ''.$fac->lignes[$i][3]." | "; print ''.price($fac->lignes[$i][4])." | "; print ''.$fac->lignes[$i][2]." | "; @@ -400,6 +422,9 @@ else print ''; print ''; print ''; + print ''; + print ' | '; + print ''; print ''; print ' | '; print '- | '; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 73f6e621a37..c75a4df5370 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -129,6 +129,7 @@ Price=Price UnitPrice=Unit price PriceU=U.P. PriceUHT=U.P. HT +PriceUTTC=U.P. w/ tax Amount=Amount AmountHT=Amount HT AmountTTC=Amount TTC diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 49e56c80dfc..2289ddc7846 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -129,6 +129,7 @@ Price=Prix UnitPrice=Prix unitaire PriceU=P.U. PriceUHT=P.U. HT +PriceUTTC=P.U. TTC Amount=Montant AmountHT=Montant HT AmountTTC=Montant TTC