NEW Easier way to setup the different types of tax. Better visibility.

FIX edit of tax stamp regenerated the PDF.
This commit is contained in:
Laurent Destailleur 2020-04-07 14:06:08 +02:00
parent ff1b3db54b
commit 8e7ad726b2
5 changed files with 110 additions and 34 deletions

View File

@ -41,7 +41,7 @@ $action = GETPOST('action', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search
// Load translation files required by the page
$langs->loadLangs(array('admin', 'companies'));
$langs->loadLangs(array('admin', 'companies', 'bills'));
if (!$user->admin) accessforbidden();
@ -689,17 +689,19 @@ print '<tr class="oddeven"><td><label for="SOCIETE_FISCAL_MONTH_START">'.$langs-
print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START, 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100').'</td></tr>';
print "</table>";
// Fiscal options
print '<br>';
// Sales taxes (VAT, IRPF, ...)
print load_fiche_titre($langs->trans("TypeOfSaleTaxes"));
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->trans("VATManagement").'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>';
print "</tr>\n";
// Main tax
print "<tr class=\"oddeven\"><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"use_vat\" value=\"1\"".(empty($conf->global->FACTURE_TVAOPTION) ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
print '<td colspan="2">';
$tooltiphelp = '';
@ -717,19 +719,16 @@ print "</td></tr>\n";
print "</table>";
/*
* Local Taxes
*/
// Second tax
print '<br>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="25%">'.$form->textwithpicto($langs->transcountry("LocalTax1Management", $mysoc->country_code), $langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code)).'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>';
print "</tr>\n";
if ($mysoc->useLocalTax(1))
{
// Local Tax 1
print '<br>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->transcountry("LocalTax1Management", $mysoc->country_code).'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>';
print "</tr>\n";
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print "<tr class=\"oddeven\"><td><input type=\"radio\" name=\"optionlocaltax1\" id=\"lt1\" value=\"localtax1on\"".(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>";
print '<td colspan="2">';
@ -756,18 +755,27 @@ if ($mysoc->useLocalTax(1))
$tooltiphelp = ($tooltiphelp != "LocalTax1IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
print "<label for=\"nolt1\">".$form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
print "</td></tr>\n";
print "</table>";
} else {
if (empty($mysoc->country_code))
{
print '<tr class="oddeven"><td class="opacitymedium">'.$countrynotdefined.'</td><td></td><td></td></tr>';
} else {
print '<tr class="oddeven"><td class="opacitymedium" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry" , $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax1Management")).'</td></tr>';
}
}
print "</table>";
// Third tax system
print '<br>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="25%">'.$form->textwithpicto($langs->transcountry("LocalTax2Management", $mysoc->country_code), $langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)).'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>';
print "</tr>\n";
if ($mysoc->useLocalTax(2))
{
// Local Tax 2
print '<br>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->transcountry("LocalTax2Management", $mysoc->country_code).'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>';
print "</tr>\n";
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print "<tr class=\"oddeven\"><td><input type=\"radio\" name=\"optionlocaltax2\" id=\"lt2\" value=\"localtax2on\"".(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>";
print '<td colspan="2">';
@ -793,9 +801,45 @@ if ($mysoc->useLocalTax(2))
print "<label for=\"nolt2\">".$form->textwithpicto($langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
print "</div>";
print "</td></tr>\n";
print "</table>";
} else {
if (empty($mysoc->country_code))
{
print '<tr class="oddeven"><td class="opacitymedium">'.$countrynotdefined.'</td><td></td><td></td></tr>';
} else {
print '<tr class="oddeven"><td class="opacitymedium" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry" , $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax2Management")).'</td></tr>';
}
}
print "</table>";
// Third tax system
print '<br>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="25%">'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>';
print "</tr>\n";
if ($mysoc->useRevenueStamp())
{
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print "<tr class=\"oddeven\"><td>";
print $langs->trans("UseRevenueStamp");
print "</td>";
print '<td colspan="2">';
print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"));
print "</td></tr>\n";
} else {
if (empty($mysoc->country_code))
{
print '<tr class="oddeven"><td class="opacitymedium">'.$countrynotdefined.'</td><td></td><td></td></tr>';
} else {
print '<tr class="oddeven"><td class="opacitymedium" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry" , $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"), $langs->transnoentitiesnoconv("RevenueStamp")).'</td></tr>';
}
}
print "</table>";
print '<br><div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';

View File

@ -489,7 +489,7 @@ $tabhelp[19] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[20] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[23] = array('revenuestamp_type'=>'FixedOfPercent');
$tabhelp[23] = array('revenuestamp_type'=>'FixedOrPercent');
$tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode'));
//$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));

View File

@ -413,7 +413,9 @@ if (empty($reshook))
if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement;
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date;
$result = $object->update($user);
if ($result < 0) dol_print_error($db, $object->error);
if ($result < 0) {
dol_print_error($db, $object->error);
}
}
elseif ($action == 'setdate_pointoftax' && $usercancreate)
@ -422,7 +424,9 @@ if (empty($reshook))
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
$object->date_pointoftax = $date_pointoftax;
$result = $object->update($user);
if ($result < 0) dol_print_error($db, $object->error);
if ($result < 0) {
dol_print_error($db, $object->error);
}
}
elseif ($action == 'setconditions' && $usercancreate)
@ -438,7 +442,9 @@ if (empty($reshook))
if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement;
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date;
$result = $object->update($user);
if ($result < 0) dol_print_error($db, $object->error);
if ($result < 0) {
dol_print_error($db, $object->error);
}
}
elseif ($action == 'setpaymentterm' && $usercancreate)
@ -450,8 +456,9 @@ if (empty($reshook))
setEventMessages($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), null, 'warnings');
}
$result = $object->update($user);
if ($result < 0)
if ($result < 0) {
dol_print_error($db, $object->error);
}
}
elseif ($action == 'setrevenuestamp' && $usercancreate)
@ -460,8 +467,28 @@ if (empty($reshook))
$object->revenuestamp = GETPOST('revenuestamp');
$result = $object->update($user);
$object->update_price(1);
if ($result < 0)
if ($result < 0) {
dol_print_error($db, $object->error);
} else {
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('products');
}
$model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
}
}
// Set incoterm
@ -4480,7 +4507,7 @@ elseif ($id > 0 || !empty($ref))
print '<input type="hidden" name="revenuestamp" id="revenuestamp_val" value="'.price2num($object->revenuestamp).'">';
print $formother->select_revenue_stamp('', 'revenuestamp_type', $mysoc->country_code);
print ' &rarr; <span id="revenuestamp_span"></span>';
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print ' <input type="submit" class="button buttongen" value="'.$langs->trans('Modify').'">';
print '</form>';
print " <script>
$(document).ready(function(){

View File

@ -989,6 +989,7 @@ VATIsNotUsedDesc=By default the proposed Sales tax is 0 which can be used for ca
VATIsUsedExampleFR=In France, it means companies or organizations having a real fiscal system (Simplified real or normal real). A system in which VAT is declared.
VATIsNotUsedExampleFR=In France, it means associations that are non Sales tax declared or companies, organizations or liberal professions that have chosen the micro enterprise fiscal system (Sales tax in franchise) and paid a franchise Sales tax without any Sales tax declaration. This choice will display the reference "Non applicable Sales tax - art-293B of CGI" on invoices.
##### Local Taxes #####
TypeOfSaleTaxes=Type of sales tax
LTRate=Rate
LocalTax1IsNotUsed=Do not use second tax
LocalTax1IsUsedDesc=Use a second type of tax (other than first one)
@ -1012,6 +1013,9 @@ LocalTax2IsUsedDescES=The IRPF rate by default when creating prospects, invoices
LocalTax2IsNotUsedDescES=By default the proposed IRPF is 0. End of rule.
LocalTax2IsUsedExampleES=In Spain, freelancers and independent professionals who provide services and companies who have chosen the tax system of modules.
LocalTax2IsNotUsedExampleES=In Spain they are businesses not subject to tax system of modules.
RevenueStampDesc=The "tax stamp" or "revenue stamp" is a fixed tax you per invoice (It does not depend on amount of invoice). It can also be a percent tax but using the second or third type of tax is better for percent taxes as tax stamps des not provide any reporting. Only few countries uses this type of tax.
UseRevenueStamp=Use a tax stamp
UseRevenueStampExample=The value of tax stamp is defined by default into the setup of dictionaries (%s - %s - %s)
CalcLocaltax=Reports on local taxes
CalcLocaltax1=Sales - Purchases
CalcLocaltax1Desc=Local Taxes reports are calculated with the difference between localtaxes sales and localtaxes purchases
@ -1019,6 +1023,7 @@ CalcLocaltax2=Purchases
CalcLocaltax2Desc=Local Taxes reports are the total of localtaxes purchases
CalcLocaltax3=Sales
CalcLocaltax3Desc=Local Taxes reports are the total of localtaxes sales
NoLocalTaxXForThisCountry=According to the setup of taxes (See %s - %s - %s), your country does not need to use such type of tax
LabelUsedByDefault=Label used by default if no translation can be found for code
LabelOnDocuments=Label on documents
LabelOrTranslationKey=Label or translation key

View File

@ -509,7 +509,7 @@ ToMakePayment=Pay
ToMakePaymentBack=Pay back
ListOfYourUnpaidInvoices=List of unpaid invoices
NoteListOfYourUnpaidInvoices=Note: This list contains only invoices for third parties you are linked to as a sale representative.
RevenueStamp=Revenue stamp
RevenueStamp=Tax stamp
YouMustCreateInvoiceFromThird=This option is only available when creating an invoice from tab "Customer" of third party
YouMustCreateInvoiceFromSupplierThird=This option is only available when creating an invoice from tab "Vendor" of third party
YouMustCreateStandardInvoiceFirstDesc=You have to create a standard invoice first and convert it to "template" to create a new template invoice