New: Add 4 constants TAX_MODE_SELL/BUY_PRODUCT/SERVICE to define rule to calculate VAT.

This commit is contained in:
Laurent Destailleur 2010-09-29 18:38:47 +00:00
parent 7f46b1fcf8
commit 8d0cc908d9
5 changed files with 55 additions and 20 deletions

View File

@ -56,7 +56,7 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["c
$new_pays_id=$_POST["pays_id"];
$new_pays_code=getCountry($new_pays_id,2);
$new_pays_label=getCountry($new_pays_id,0);
//dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS", $new_pays_id,'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS", $new_pays_id.':'.$new_pays_code.':'.$new_pays_label,'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"],'chaine',0,'',$conf->entity);

View File

@ -35,6 +35,7 @@ $langs->load('taxes');
if (!$user->admin)
accessforbidden();
/*
* View
*/
@ -43,7 +44,7 @@ llxHeader();
// 0=normal, 1=option vat for services is on debit
$tax_mode = defined('TAX_MODE')?TAX_MODE:0;
$tax_mode = empty($conf->global->TAX_MODE)?0:$conf->global->TAX_MODE;
// TAX_MODE=0 (most cases):
// Buy Sell
@ -53,13 +54,29 @@ $tax_mode = defined('TAX_MODE')?TAX_MODE:0;
// TAX_MODE=1 (option):
// Buy Sell
// Product On delivery On delivery
// Service On payment On invoice
// Service On invoice On invoice
if ($_POST['action'] == 'settaxmode')
{
$tax_mode = $_POST['tax_mode'];
if (! dolibarr_set_const($db, 'TAX_MODE', $tax_mode,'chaine',0,'',$conf->entity)) { print $db->error(); }
if ($tax_mode == 0)
{
if (! dolibarr_set_const($db, 'TAX_MODE_SELL_PRODUCT', 'invoice','chaine',0,'',$conf->entity)) { print $db->error(); }
if (! dolibarr_set_const($db, 'TAX_MODE_BUY_PRODUCT', 'invoice','chaine',0,'',$conf->entity)) { print $db->error(); }
if (! dolibarr_set_const($db, 'TAX_MODE_SELL_SERVICE', 'payment','chaine',0,'',$conf->entity)) { print $db->error(); }
if (! dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', 'payment','chaine',0,'',$conf->entity)) { print $db->error(); }
}
if ($tax_mode == 1)
{
if (! dolibarr_set_const($db, 'TAX_MODE_SELL_PRODUCT', 'invoice','chaine',0,'',$conf->entity)) { print $db->error(); }
if (! dolibarr_set_const($db, 'TAX_MODE_BUY_PRODUCT', 'invoice','chaine',0,'',$conf->entity)) { print $db->error(); }
if (! dolibarr_set_const($db, 'TAX_MODE_SELL_SERVICE', 'invoice','chaine',0,'',$conf->entity)) { print $db->error(); }
if (! dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', 'invoice','chaine',0,'',$conf->entity)) { print $db->error(); }
}
}
if ($_POST['action'] == 'update' || $_POST['action'] == 'add')
@ -121,21 +138,31 @@ else
print '<table class="border" width="100%">';
print '<tr><td>&nbsp;</td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
// Products
print '<tr><td>'.$langs->trans("Product").'</td>';
print '<td>';
print $langs->trans("OnDelivery");
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
print '</td>';
print '<td>';
print $langs->trans("OnDelivery");
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
print '</td></tr>';
// Services
print '<tr><td>'.$langs->trans("Services").'</td>';
print '<td>';
print $langs->trans("OnPayment");
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
if ($tax_mode == 0)
{
print $langs->trans("OnPayment");
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
}
if ($tax_mode == 1)
{
print $langs->trans("OnInvoice");
print ' ('.$langs->trans("InvoiceDateUsed").')';
}
print '</td>';
print '<td>';
if ($tax_mode == 0)
@ -146,9 +173,10 @@ else
if ($tax_mode == 1)
{
print $langs->trans("OnInvoice");
print ' ('.$langs->trans("InvoiceValidateDateUsed").')';
print ' ('.$langs->trans("InvoiceDateUsed").')';
}
print '</td></tr>';
print '</table>';
}

View File

@ -202,7 +202,6 @@ class Conf
//var_dump($this->modules);
// Clean some variables
// conf->menu_top is defined in main.inc.php
if (! $this->global->MAIN_MENU_BARRETOP) $this->global->MAIN_MENU_BARRETOP="eldy_backoffice.php";
if (! $this->global->MAIN_MENUFRONT_BARRETOP) $this->global->MAIN_MENUFRONT_BARRETOP="eldy_frontoffice.php";
if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE="iphone_backoffice.php";
@ -307,6 +306,7 @@ class Conf
$this->boutique->livre->enabled=defined("BOUTIQUE_LIVRE")?BOUTIQUE_LIVRE:0;
$this->boutique->album->enabled=defined("BOUTIQUE_ALBUM")?BOUTIQUE_ALBUM:0;
/*
* Set some default values
*/
@ -420,11 +420,16 @@ class Conf
// Define umask
if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK='0664';
/* TODO Ajouter une option Gestion de la TVA dans le module compta qui permet de desactiver la fonction TVA
* (pour particuliers ou liberaux en franchise)
* En attendant, valeur forcee a 1 car toujours interessant a avoir meme ceux qui veulent pas.
// Set default variable to calculate VAT as if option tax_mode was 0 (standard)
if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT='invoice';
if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT='invoice';
if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE='payment';
if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE='payment';
/* We always show vat menus if module tax is enabled.
* Because even when vat option is 'franchise' and vat rate is 0, we have to pay vat.
*/
$this->compta->tva=1;
$this->compta->tva=1; // This option means "Show vat menus"
// Delais de tolerance des alertes
$this->actions->warning_delay=$this->global->MAIN_DELAY_ACTIONS_TODO*24*60*60;

View File

@ -1146,16 +1146,17 @@ TaxSetup=Taxes, social contributions and dividends module setup
OptionVatMode=VAT due
OptionVATDefault=Standard
OptionVATDebitOption=Option services on Debit
OptionVatDefaultDesc=VAT is due:<br>- on delivery/payments for goods<br>- on payments for services
OptionVatDebitOptionDesc=VAT is due:<br>- on delivery/payments for goods<br>- on invoice (debit) for services
OptionVatDefaultDesc=VAT is due:<br>- on delivery for goods (we use invoice date)<br>- on payments for services
OptionVatDebitOptionDesc=VAT is due:<br>- on delivery for goods (we use invoice date)<br>- on invoice (debit) for services
SummaryOfVatExigibilityUsedByDefault=Time of VAT exigibility by default according to choosed option:
OnDelivery=On delivery
OnPayment=On payment
OnInvoice=On invoice
SupposedToBePaymentDate=Payment date used if delivery date not known
SupposedToBePaymentDate=Payment date used
SupposedToBeInvoiceDate=Invoice date used
Buy=Buy
Sell=Sell
InvoiceValidateDateUsed=Invoice dtate used
InvoiceDateUsed=Invoice date used
YourCompanyDoesNotUseVAT=Your company has been defined to not use VAT (Home - Setup - Company/Foundation), so there is no VAT options to setup.
##### Agenda #####
AgendaSetup=Actions and agenda module setup

View File

@ -1158,16 +1158,17 @@ TaxSetup= Configuration du module Taxes, charges sociales et dividendes
OptionVatMode= Option d'exigibilité de TVA par défaut
OptionVATDefault= Standard
OptionVATDebitOption= Option services sur Débit
OptionVatDefaultDesc= L'exigibilité de la TVA est:<br>- sur livraison pour les biens<br>- sur paiement pour les services
OptionVatDebitOptionDesc= L'exigibilité de la TVA est:<br>- sur livraison pour les biens<br>- sur facturation (débit) pour les services
OptionVatDefaultDesc= L'exigibilité de la TVA est:<br>- sur livraison pour les biens (en pratique on utilise la date de facturation)<br>- sur paiement pour les services
OptionVatDebitOptionDesc= L'exigibilité de la TVA est:<br>- sur livraison pour les biens (en pratique on utilise la date de facturation)<br>- sur facturation (débit) pour les services
SummaryOfVatExigibilityUsedByDefault=Moment d'exigibilité par défaut de la TVA pour l'option choisie:
OnDelivery=Sur livraison
OnPayment=Sur paiement
OnInvoice=Sur facture
SupposedToBePaymentDate=Date de paiement utilisée
SupposedToBeInvoiceDate=Date de facture utilisée
Buy=Achat
Sell=Vente
InvoiceValidateDateUsed=Date de validation utilisée
InvoiceDateUsed=Date de facture utilisée
YourCompanyDoesNotUseVAT=Votre institution est configurée comme non assujettie à la TVA (Accueil - Configuration - Société/Institution), aussi il n'y a aucune option sur la gestion TVA à paramétrer.
##### Agenda #####= undefined
AgendaSetup= Configuration du module actions et agenda