dolibarr 18.0.6
taxes.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2015-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
7 * Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32if (isModEnabled('accounting')) {
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
34}
35
36// Load translation files required by the page
37$langs->loadLangs(array('admin', 'objects', 'companies', 'products'));
38
39if (!$user->admin) {
41}
42
43$action = GETPOST('action', 'aZ09');
44
45
46
47/*
48 * Actions
49 */
50
51// 0=normal, 1=option vat for services is on debit, 2=option vat for product and service on credit
52
53// TAX_MODE=0 (most cases in FR):
54// Buy Sell
55// Product On delivery On delivery
56// Service On payment On payment
57
58// TAX_MODE=1 (option, VAT is due at invoice date):
59// Buy Sell
60// Product On delivery/invoice On delivery/invoice
61// Service On invoice On invoice
62
63// TAX_MODE=2 (option, VAT is due on payment date):
64// Buy Sell
65// Product On payment On payment
66// Service On payment On payment
67
68$tax_mode = getDolGlobalInt('TAX_MODE');
69
70if ($action == 'update') {
71 $error = 0;
72
73 // Tax mode
74 $tax_mode = GETPOST('tax_mode', 'int');
75
76 $db->begin();
77
78 $res = dolibarr_set_const($db, 'TAX_MODE', $tax_mode, 'chaine', 0, '', $conf->entity);
79 if (!($res > 0)) {
80 $error++;
81 }
82
83 switch ($tax_mode) {
84 case 0:
85 $valuesellproduct = 'invoice';
86 $valuebuyproduct = 'invoice';
87 $valuesellservice = 'payment';
88 $valuebuyservice = 'payment';
89 break;
90 case 1:
91 $valuesellproduct = 'invoice';
92 $valuebuyproduct = 'invoice';
93 $valuesellservice = 'invoice';
94 $valuebuyservice = 'invoice';
95 break;
96 case 2:
97 $valuesellproduct = 'payment';
98 $valuebuyproduct = 'payment';
99 $valuesellservice = 'payment';
100 $valuebuyservice = 'payment';
101 break;
102 }
103
104 $res = dolibarr_set_const($db, 'TAX_MODE_SELL_PRODUCT', $valuesellproduct, 'chaine', 0, '', $conf->entity);
105 if (!($res > 0)) {
106 $error++;
107 }
108 $res = dolibarr_set_const($db, 'TAX_MODE_BUY_PRODUCT', $valuebuyproduct, 'chaine', 0, '', $conf->entity);
109 if (!($res > 0)) {
110 $error++;
111 }
112 $res = dolibarr_set_const($db, 'TAX_MODE_SELL_SERVICE', $valuesellservice, 'chaine', 0, '', $conf->entity);
113 if (!($res > 0)) {
114 $error++;
115 }
116 $res = dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', $valuebuyservice, 'chaine', 0, '', $conf->entity);
117 if (!($res > 0)) {
118 $error++;
119 }
120
121 dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva", 'alpha'), 'chaine', 0, '', $conf->entity);
122
123 dolibarr_set_const($db, "MAIN_INFO_VAT_RETURN", GETPOST("MAIN_INFO_VAT_RETURN", 'alpha'), 'chaine', 0, '', $conf->entity);
124
125 dolibarr_set_const($db, "MAIN_INFO_TVA_DAY_DEADLINE_SUBMISSION", GETPOST("deadline_day_vat", 'int'), 'chaine', 0, '', $conf->entity);
126
127 if (!$error) {
128 $db->commit();
129 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
130 } else {
131 $db->rollback();
132 setEventMessages($langs->trans("Error"), null, 'errors');
133 }
134} elseif (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
135 // Set boolean (on/off) constants
136 if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
137 dol_print_error($db);
138 }
139}
140
141
142/*
143 * View
144 */
145
146llxHeader('', $langs->trans("TaxSetup"));
147
148$form = new Form($db);
149if (isModEnabled('accounting')) {
150 $formaccounting = new FormAccounting($db);
151}
152
153$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
154print load_fiche_titre($langs->trans('TaxSetup'), $linkback, 'title_setup');
155
156//print dol_get_fiche_head(null, '', '', -1);
157
158if (empty($mysoc->tva_assuj)) {
159 print $langs->trans("YourCompanyDoesNotUseVAT").'<br>';
160} else {
161 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
162 print '<input type="hidden" name="token" value="'.newToken().'">';
163 print '<input type="hidden" name="action" value="update">';
164
165 print '<table class="noborder centpercent">';
166 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
167
168 print '<tr class="oddeven"><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
169 print '<input name="tva" id="intra_vat" class="minwidth200" value="'.(!empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '').'">';
170 print '</td></tr>';
171
172 print '<tr class="oddeven"><td><label for="activate_MAIN_INFO_VAT_RETURN">'.$langs->trans("VATReturn").'</label></td>';
173 if (!$conf->use_javascript_ajax) {
174 print '<td class="nowrap right">';
175 print $langs->trans("NotAvailableWhenAjaxDisabled");
176 print "</td>";
177 } else {
178 print '<td width="120">';
179 $listval = array(
180 '0'=>$langs->trans(""),
181 '1'=>$langs->trans("Monthly"),
182 '2'=>$langs->trans("Quarterly"),
183 '3'=>$langs->trans("Annual"),
184 );
185 print $form->selectarray("MAIN_INFO_VAT_RETURN", $listval, $conf->global->MAIN_INFO_VAT_RETURN);
186 print "</td>";
187 }
188 print '</tr>';
189
190 print '<tr class="oddeven"><td><label for="deadline_day_vat">'.$langs->trans("DeadlineDayVATSubmission").'</label></td><td>';
191 print '<input placeholder="'.$langs->trans("Example").':21" name="deadline_day_vat" id="deadline_day_vat" class="minwidth200" value="'.(!empty($conf->global->MAIN_INFO_TVA_DAY_DEADLINE_SUBMISSION) ? $conf->global->MAIN_INFO_TVA_DAY_DEADLINE_SUBMISSION : '').'">';
192 print '</td></tr>';
193
194 print '</table>';
195
196 print '<br>';
197
198 print '<table class="noborder centpercent">';
199
200 // Cas des parametres TAX_MODE_SELL/BUY_SERVICE/PRODUCT
201 print '<tr class="liste_titre">';
202 print '<td class="titlefield">'.$langs->trans('OptionVatMode').'</td><td>'.$langs->trans('Description').'</td>';
203 print "</tr>\n";
204 // Standard
205 print '<tr class="oddeven"><td><input type="radio" name="tax_mode" value="0"'.(empty($tax_mode) ? ' checked' : '').'> '.$langs->trans('OptionVATDefault').'</td>';
206 print '<td>'.nl2br($langs->trans('OptionVatDefaultDesc'));
207 print "</td></tr>\n";
208 // On debit for services
209 print '<tr class="oddeven"><td><input type="radio" name="tax_mode" value="1"'.($tax_mode == 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDebitOption').'</td>';
210 print '<td>'.nl2br($langs->trans('OptionVatDebitOptionDesc'))."</td></tr>\n";
211 // On payment for both products and services
212 if ($conf->global->MAIN_FEATURES_LEVEL >= 1) {
213 print '<tr class="oddeven"><td><input type="radio" name="tax_mode" value="2"'.($tax_mode == 2 ? ' checked' : '').'> '.$langs->trans('OptionPaymentForProductAndServices').'</td>';
214 print '<td>'.nl2br($langs->trans('OptionPaymentForProductAndServicesDesc'))."</td></tr>\n";
215 }
216 print "</table>\n";
217
218 print '<br>';
219 print load_fiche_titre('', '', '', 0, 0, '', '-> '.$langs->trans("SummaryOfVatExigibilityUsedByDefault"));
220 //print ' ('.$langs->trans("CanBeChangedWhenMakingInvoice").')';
221
222
223 print '<table class="noborder centpercent">';
224 print '<tr class="oddeven"><td class="titlefield">&nbsp;</td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
225
226 // Products
227 print '<tr class="oddeven"><td>'.$langs->trans("Product").'</td>';
228 print '<td>';
229 if (getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'payment') {
230 print $langs->trans("OnPayment");
231 print ' ('.$langs->trans("SupposedToBePaymentDate").')';
232 } else {
233 print $langs->trans("OnDelivery");
234 print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
235 }
236 print '</td>';
237 print '<td>';
238 if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment') {
239 print $langs->trans("OnPayment");
240 print ' ('.$langs->trans("SupposedToBePaymentDate").')';
241 } else {
242 print $langs->trans("OnDelivery");
243 print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
244 }
245 print '</td></tr>';
246
247 // Services
248 print '<tr class="oddeven"><td>'.$langs->trans("Services").'</td>';
249 print '<td>';
250 if (getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'payment') {
251 print $langs->trans("OnPayment");
252 print ' ('.$langs->trans("SupposedToBePaymentDate").')';
253 } else {
254 print $langs->trans("OnInvoice");
255 print ' ('.$langs->trans("InvoiceDateUsed").')';
256 }
257 print '</td>';
258 print '<td>';
259 if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') {
260 print $langs->trans("OnPayment");
261 print ' ('.$langs->trans("SupposedToBePaymentDate").')';
262 } else {
263 print $langs->trans("OnInvoice");
264 print ' ('.$langs->trans("InvoiceDateUsed").')';
265 }
266 print '</td></tr>';
267
268 print '</table>';
269}
270
271print "<br>\n";
272
273
274print '<div class="center">';
275print '<input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'">';
276print '<br><br>';
277print '</div>';
278
279print '</form>';
280
281// Options
282
283echo '<div>';
284echo '<table class="noborder centpercent">';
285echo '<thead>';
286echo '<tr class="liste_titre"><th>'.$langs->trans('Parameter').'</th><th>'.$langs->trans('Value').'</th></tr>';
287echo '</thead>';
288echo '<tbody>';
289
290$key = 'CREATE_NEW_VAT_WITHOUT_AUTO_PAYMENT';
291echo '<tr><td>', $langs->trans($key), '</td><td>', ajax_constantonoff($key), '</td></tr>';
292
293echo '</tbody>';
294echo '</table>';
295echo '</div>';
296
297
298if (isModEnabled('accounting')) {
299 $langs->load("accountancy");
300 print '<br><br><span class="opacitymedium">'.$langs->trans("AccountingAccountForSalesTaxAreDefinedInto", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup")).'</span>';
301}
302
303// End of page
304llxFooter();
305$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.