Skip to content

Commit

Permalink
Merge pull request #5564 from aspangaro/4.0-p36
Browse files Browse the repository at this point in the history
FIX Accountancy - Problem with the manage of the zero at the end of an accounting account in dolibarr for somes countries. Add an option.
  • Loading branch information
Juanjo Menent committed Jul 29, 2016
2 parents 5d97ce0 + 20144c9 commit 501a25e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
24 changes: 22 additions & 2 deletions htdocs/accountancy/admin/card.php
Expand Up @@ -58,7 +58,17 @@
$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 {
Expand Down Expand Up @@ -98,7 +108,17 @@
$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 {
Expand Down
28 changes: 28 additions & 0 deletions htdocs/accountancy/admin/index.php
Expand Up @@ -130,6 +130,7 @@
}
}

// 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);
Expand All @@ -155,6 +156,18 @@
}
}

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
*/
Expand Down Expand Up @@ -286,6 +299,7 @@
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>';
Expand Down Expand Up @@ -314,6 +328,20 @@
}
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();
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/accountancy.lang
Expand Up @@ -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
Expand Down

0 comments on commit 501a25e

Please sign in to comment.