Fix: TVA Non Perçue Récupérable

This commit is contained in:
eldy 2011-10-09 17:37:27 +02:00
parent cfcccbdfa0
commit c43c2734fb
10 changed files with 54 additions and 50 deletions

1
dev/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/spec

View File

@ -2800,7 +2800,7 @@ class Form
* @param societe_vendeuse Objet societe vendeuse
* @param societe_acheteuse Objet societe acheteuse
* @param idprod Id product
* @param info_bits Miscellaneous information on line
* @param info_bits Miscellaneous information on line (1 for NPR)
* @param type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
* Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
* Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.

View File

@ -64,10 +64,10 @@
<td align="right">
<?php
if ($buyer->tva_assuj == "0") echo '<input type="hidden" name="np_tva_tx" value="0">0';
else echo $html->load_tva('np_tva_tx', -1, $seller, $buyer);
else echo $html->load_tva('np_tva_tx', (isset($_POST["np_tva_tx"])?$_POST["np_tva_tx"]:-1), $seller, $buyer);
?>
</td>
<td align="right"><input type="text" size="5" name="np_price"></td>
<td align="right"><input type="text" size="5" name="np_price" value="<?php echo (isset($_POST["np_price"])?$_POST["np_price"]:''); ?>"></td>
<td align="right"><input type="text" size="2" name="qty" value="<?php echo (isset($_POST["qty"])?$_POST["qty"]:1); ?>"></td>
<td align="right" nowrap><input type="text" size="1" value="<?php echo $buyer->remise_client; ?>" name="remise_percent">%</td>
<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline"></td>

View File

@ -204,7 +204,7 @@ NoSupplierBillsUnpaid=Aucune facture fournisseur impayée
SupplierBillsToPay=Factures fournisseurs à payer
CustomerBillsUnpaid=Factures clients impayées
DispenseMontantLettres=Les factures rédigées par procédés mécanographiques sont dispensées de l'arrêté en lettres
NonPercuRecuperable=Non perçue récupérable
NonPercuRecuperable=Non perçue réc.
SetConditions=Définir conditions de règlement
SetMode=Définir mode de règlement
SetDate= Définir date

View File

@ -2886,15 +2886,16 @@ function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrow
/**
* Fonction qui retourne un taux de tva formate pour visualisation
* Utilisee dans les pdf et les pages html
* Return a string with VAT rate label formated for view output
* Used into pdf and HTML pages
*
* @param float $rate Rate value to format (19.6 19,6 19.6% 19,6%,...)
* @param boolean $addpercent Add a percent % sign in output
* @param int $info_bits Miscellanous information on vat
* @return string Chaine avec montant formate (19,6 ou 19,6% ou 8.5% *)
* @param int $info_bits Miscellanous information on vat (0=Default, 1=French NPR vat)
* @param int $usestarfornpr 1=Use '*' for NPR vat rate intead of MAIN_LABEL_MENTION_NPR
* @return string String with formated amounts (19,6 or 19,6% or 8.5% NPR or 8.5% *)
*/
function vatrate($rate,$addpercent=false,$info_bits=0)
function vatrate($rate,$addpercent=false,$info_bits=0,$usestarfornpr=0)
{
// Test for compatibility
if (preg_match('/%/',$rate))
@ -2902,14 +2903,14 @@ function vatrate($rate,$addpercent=false,$info_bits=0)
$rate=str_replace('%','',$rate);
$addpercent=true;
}
if (preg_match('/\*/',$rate) || preg_match('/'.MAIN_LABEL_MENTION_NPR.'/i',$rate))
if (preg_match('/\*/',$rate) || preg_match('/'.constant('MAIN_LABEL_MENTION_NPR').'/i',$rate))
{
$rate=str_replace('*','',$rate);
$info_bits |= 1;
}
$ret=price($rate,0,'',0,0).($addpercent?'%':'');
if ($info_bits & 1) $ret.=' '.MAIN_LABEL_MENTION_NPR;
if ($info_bits & 1) $ret.=' '.($usestarfornpr?'*':constant('MAIN_LABEL_MENTION_NPR'));
return $ret;
}
@ -3205,9 +3206,10 @@ function get_product_localtax_for_country($idprod, $local, $countrycode)
* Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier ou entreprise sans num TVA intra) alors TVA par defaut=TVA du produit vendu. Fin de regle
* Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise avec num TVA) intra alors TVA par defaut=0. Fin de regle
* Sinon TVA proposee par defaut=0. Fin de regle.
* @param societe_vendeuse Objet societe vendeuse
* @param societe_acheteuse Objet societe acheteuse
* @param idprod Id product
*
* @param Societe $societe_vendeuse Objet societe vendeuse
* @param Societe $societe_acheteuse Objet societe acheteuse
* @param int $idprod Id product
* @return float Taux de tva a appliquer, -1 si ne peut etre determine
*/
function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0)
@ -3282,15 +3284,10 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0)
/**
* Fonction qui renvoie si tva doit etre tva percue recuperable
* Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
* Si le (pays vendeur = pays acheteur) alors TVA par defaut=TVA du produit vendu. Fin de regle.
* Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
* Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier ou entreprise sans num TVA intra) alors TVA par defaut=TVA du produit vendu. Fin de regle
* Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise avec num TVA) intra alors TVA par defaut=0. Fin de regle
* Sinon TVA proposee par defaut=0. Fin de regle.
* @param societe_vendeuse Objet societe vendeuse
* @param societe_acheteuse Objet societe acheteuse
* @param idprod Id product
*
* @param Societe $societe_vendeuse Objet societe vendeuse
* @param Societe $societe_acheteuse Objet societe acheteuse
* @param int $idprod Id product
* @return float 0 or 1
*/
function get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod)
@ -3301,10 +3298,10 @@ function get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod)
/**
* Function that return localtax of a product line (according to seller, buyer and product vat rate)
*
* @param societe_vendeuse Objet societe vendeuse
* @param societe_acheteuse Objet societe acheteuse
* @param local Localtax to process (1 or 2)
* @param idprod Id product
* @param Societe $societe_vendeuse Objet societe vendeuse
* @param Societe $societe_acheteuse Objet societe acheteuse
* @param int $local Localtax to process (1 or 2)
* @param int $idprod Id product
* @return float Taux de localtax appliquer, -1 si ne peut etre determine
*/
function get_default_localtax($societe_vendeuse, $societe_acheteuse, $local, $idprod=0)

View File

@ -963,7 +963,7 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0,$hookmanager=
}
else
{
if (empty($hidedetails) || $hidedetails > 1) return vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits);
if (empty($hidedetails) || $hidedetails > 1) return vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits,1);
}
}

View File

@ -48,27 +48,27 @@ class Product extends CommonObject
var $libelle; // TODO deprecated
var $label;
var $description;
//! Prix de vente
var $price; // Price without tax
//! Type 0 for regular product, 1 for service (Advanced feature: 2 for assembly kit, 3 for stock kit)
var $type;
//! Selling price
var $price; // Price net
var $price_ttc; // Price with tax
var $price_min;
var $price_min_ttc;
//! Base de prix (ttc ou ht)
var $price_min; // Minimum price net
var $price_min_ttc; // Minimum price with tax
//! Base price ('TTC' for price including tax or 'HT' for net price)
var $price_base_type;
//! Tableau des prix multiples
//! Arrays for multiprices
var $multiprices=array();
var $multiprices_ttc=array();
var $multiprices_base_type=array();
var $multiprices_tva_tx=array();
//! Taux de TVA
//! Default VAT rate of product
var $tva_tx;
//! French VAT NPR
//! French VAT NPR (0 or 1)
var $tva_npr=0;
//! Spanish local taxes
var $localtax1_tx;
var $localtax2_tx;
//! Type 0 for regular product, 1 for service (Advanced feature: 2 for assembly kit, 3 for stock kit)
var $type;
//! Stock
var $stock_reel;
@ -207,6 +207,7 @@ class Product extends CommonObject
$this->price_min_ttc=price2num($this->price_min_ttc);
$this->price_min=price2num($this->price_min);
if (empty($this->tva_tx)) $this->tva_tx = 0;
if (empty($this->tva_npr)) $this->tva_npr = 0;
//Local taxes
if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
@ -403,7 +404,7 @@ class Product extends CommonObject
global $langs, $conf;
// Verification parametres
if (! $this->libelle) $this->libelle = 'LIBELLE MANQUANT';
if (! $this->libelle) $this->libelle = 'MISSING LABEL';
// Clean parameters
$this->ref = dol_string_nospecial(trim($this->ref));
@ -419,6 +420,7 @@ class Product extends CommonObject
$this->volume = price2num($this->volume);
$this->volume_units = trim($this->volume_units);
if (empty($this->tva_tx)) $this->tva_tx = 0;
if (empty($this->tva_npr)) $this->tva_npr = 0;
//Local taxes
if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
@ -433,6 +435,7 @@ class Product extends CommonObject
$sql.= " SET label = '" . $this->db->escape($this->libelle) ."'";
$sql.= ",ref = '" . $this->ref ."'";
$sql.= ",tva_tx = " . $this->tva_tx;
$sql.= ",recuperableonly = " . $this->tva_npr;
//Local taxes
$sql.= ",localtax1_tx = " . $this->localtax1_tx;

View File

@ -158,7 +158,8 @@ if (empty($reshook))
else $product->price = $_POST["price"];
if ($product->price_base_type == 'TTC') $product->price_min_ttc = $_POST["price_min"];
else $product->price_min = $_POST["price_min"];
$product->tva_tx = $_POST["tva_tx"];
$product->tva_tx = str_replace('*','',$_POST['tva_tx']);
$product->tva_npr = preg_match('/\*/',$_POST['tva_tx'])?1:0;
// local taxes.
$product->localtax1_tx = get_localtax($product->tva_tx,1);

View File

@ -240,7 +240,7 @@ if ($conf->global->PRODUIT_MULTIPRICES)
else
{
// TVA
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.vatrate($product->tva_tx,true).'</td></tr>';
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.vatrate($product->tva_tx.($product->tva_npr?'*':''),true).'</td></tr>';
// Price
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>';
@ -316,7 +316,7 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user->
// VAT
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
print $html->load_tva("tva_tx",$product->tva_tx,$mysoc,'',$product->id);
print $html->load_tva("tva_tx",$product->tva_tx,$mysoc,'',$product->id,$product->tva_npr);
print '</td></tr>';
// Price base
@ -357,10 +357,12 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user->
}
print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '</form>';
print '<center><br><input type="submit" class="button" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
print '<br></form>';
}
else
{