FIX Accountancy - Problem with the manage of the zero at the end of an accounting account in dolibarr for somes countries. Add an option.

This commit is contained in:
aspangaro 2016-07-29 07:32:55 +02:00
parent 5d97ce038b
commit 20144c9883
3 changed files with 51 additions and 2 deletions

View File

@ -58,7 +58,17 @@ if ($action == 'add') {
$obj = $db->fetch_object($result);
// Clean code
$account_number = clean_account(GETPOST('account_number')); // Accounting account without zero on the right
// To manage zero or not at the end of the accounting account
if($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
{
$account_number = GETPOST('account_number');
}
else
{
$account_number = clean_account(GETPOST('account_number'));
}
if (GETPOST('account_category') <= 0) {
$account_parent = '';
} else {
@ -98,7 +108,17 @@ if ($action == 'add') {
$obj = $db->fetch_object($result2);
// Clean code
$account_number = clean_account(GETPOST('account_number')); // Accounting account without zero on the right
// To manage zero or not at the end of the accounting account
if($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
{
$account_number = GETPOST('account_number');
}
else
{
$account_number = clean_account(GETPOST('account_number'));
}
if (GETPOST('account_category') <= 0) {
$account_parent = '';
} else {

View File

@ -130,6 +130,7 @@ if ($action == 'update') {
}
}
// TO DO Mutualize code for yes/no constants
if ($action == 'setlistsorttodo') {
$setlistsorttodo = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
@ -155,6 +156,18 @@ if ($action == 'setlistsortdone') {
}
}
if ($action == 'setmanagezero') {
$setmanagezero = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
}
}
/*
* View
*/
@ -286,6 +299,7 @@ foreach ( $list_account as $key ) {
print '</td></tr>';
}
// TO DO Mutualize code for yes/no constants
$var = ! $var;
print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
@ -314,6 +328,20 @@ if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
}
print '</tr>';
$var = ! $var;
print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print "</table>\n";
dol_fiche_end();

View File

@ -56,6 +56,7 @@ ACCOUNTING_LENGTH_DESCRIPTION=Length for displaying product & services descripti
ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT=Length for displaying product & services account description form in listings (Best = 50)
ACCOUNTING_LENGTH_GACCOUNT=Length of the general accounts
ACCOUNTING_LENGTH_AACCOUNT=Length of the third party accounts
ACCOUNTING_MANAGE_ZERO=Manage the zero at the end of an accounting account. Needed by some countries. Disable by default. Be careful with the function of length of the accounts.
ACCOUNTING_SELL_JOURNAL=Sell journal
ACCOUNTING_PURCHASE_JOURNAL=Purchase journal