NEW Accountancy - Add an option to disable autolettering when transferring to accounting

This commit is contained in:
Alexandre SPANGARO 2023-01-07 08:20:48 +01:00
parent 2c9e4495db
commit 183552461c
5 changed files with 32 additions and 3 deletions

View File

@ -261,6 +261,20 @@ if ($action == 'setenablelettering') {
}
}
if ($action == 'setenableautolettering') {
$setenableautolettering = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_AUTOLETTERING", $setenableautolettering, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
}
}
/*
* View
@ -479,6 +493,7 @@ if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
print '</tr>';
print '</table>';
print '<br>';
// Lettering params
print '<table class="noborder centpercent">';
@ -499,6 +514,19 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
}
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING").'</td>';
if (!empty($conf->global->ACCOUNTING_ENABLE_AUTOLETTERING)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setenableautolettering&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setenableautolettering&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '</table>';
print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';

View File

@ -793,7 +793,7 @@ if (!$error && $action == 'writebookkeeping') {
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
} else {
if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) {
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
$lettering_static = new Lettering($db);
$nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id));

View File

@ -376,7 +376,7 @@ if ($action == 'writebookkeeping') {
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
} else {
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) {
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
$lettering_static = new Lettering($db);
$nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));

View File

@ -390,7 +390,7 @@ if ($action == 'writebookkeeping') {
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
} else {
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) {
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
$lettering_static = new Lettering($db);
$nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));

View File

@ -339,6 +339,7 @@ ACCOUNTING_DISABLE_BINDING_ON_SALES=Disable binding & transfer in accountancy on
ACCOUNTING_DISABLE_BINDING_ON_PURCHASES=Disable binding & transfer in accountancy on purchases (vendor invoices will not be taken into account in accounting)
ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS=Disable binding & transfer in accountancy on expense reports (expense reports will not be taken into account in accounting)
ACCOUNTING_ENABLE_LETTERING=Enable the lettering function in the accounting
ACCOUNTING_ENABLE_AUTOLETTERING=Enable the automatic lettering when transferring to accounting
## Export
NotExportLettering=Do not export the lettering when generating the file