diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 1212f9c9e16..d7ca7823b25 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -122,7 +122,7 @@ if (empty($reshook)) $object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : ""; $object->subledger_account = $subledger_account; - $object->sens = GETPOST('sens'); + $object->sens = GETPOST('sens', 'int'); $object->fk_project = GETPOST('fk_project', 'int'); if (empty($datep) || empty($datev)) @@ -131,12 +131,6 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $error++; } - if (empty($object->type_payment) || $object->type_payment < 0) - { - $langs->load('errors'); - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); - $error++; - } if (empty($object->amount)) { $langs->load('errors'); @@ -149,13 +143,24 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); $error++; } - // TODO Remove this and allow instead to edit a various payment to enter accounting code + if (empty($object->type_payment) || $object->type_payment < 0) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); + $error++; + } if (!empty($conf->accounting->enabled) && !$object->accountancy_code) { $langs->load('errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); $error++; } + if ($object->sens < 0) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Sens")), null, 'errors'); + $error++; + } if (!$error) { @@ -358,13 +363,6 @@ if ($action == 'create') print ''; print ''; - // Sens - print ''; - print $form->editfieldkey('Sens', 'sens', '', $object, 0, 'string', '', 1).''; - $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); - print $form->selectarray('sens', $sensarray, $sens); - print ''; - // Amount print ''; print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).''; @@ -396,6 +394,44 @@ if ($action == 'create') print ''."\n"; } + // Accountancy account + if (!empty($conf->accounting->enabled)) { + // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code + print ''.$langs->trans("AccountAccounting").''; + print ''; + print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1); + print ''; + } else { // For external software + print ''.$langs->trans("AccountAccounting").''; + print ''; + print ''; + } + + // Subledger account + if (!empty($conf->accounting->enabled)) { + print ''.$langs->trans("SubledgerAccount").'aaaa'; + print ''; + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + { + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, ''); + } else { + print ''; + } + print ''; + } else { // For external software + print ''.$langs->trans("SubledgerAccount").''; + print ''; + print ''; + } + + // Sens + print ''; + $labelsens = $form->textwithpicto('Sens', $langs->trans("AccountingDirectionHelp")); + print $form->editfieldkey($labelsens, 'sens', '', $object, 0, 'string', '', 1).''; + $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); + print $form->selectarray('sens', $sensarray, $sens, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1); + print ''; + // Project if (!empty($conf->projet->enabled)) { @@ -417,44 +453,9 @@ if ($action == 'create') print $hookmanager->resPrint; // Category - if (is_array($options) && count($options) && $conf->categorie->enabled) - { + if (is_array($options) && count($options) && $conf->categorie->enabled) { print ''.$langs->trans("RubriquesTransactions").''; - print Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1); - print ''; - } - - // Accountancy account - if (!empty($conf->accounting->enabled)) - { - // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code - print ''.$langs->trans("AccountAccounting").''; - print ''; - print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1); - print ''; - } else // For external software - { - print ''.$langs->trans("AccountAccounting").''; - print ''; - print ''; - } - - // Subledger account - if (!empty($conf->accounting->enabled)) - { - print ''.$langs->trans("SubledgerAccount").'aaaa'; - print ''; - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) - { - print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, ''); - } else { - print ''; - } - print ''; - } else // For external software - { - print ''.$langs->trans("SubledgerAccount").''; - print ''; + print img_picto('', 'category').Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1, 0, 0, '', 0, 0, 0, '', 'minwidth300', 1); print ''; } diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index e5d0c4f85d3..ec2a8bb2623 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -863,10 +863,18 @@ if (!empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING')) { $obj = $db->fetch_object($result); - if (!isset($encaiss[$obj->dm])) $encaiss[$obj->dm] = 0; - if (!isset($decaiss[$obj->dm])) $decaiss[$obj->dm] = 0; - $encaiss[$obj->dm] += $obj->credit; - $decaiss[$obj->dm] += $obj->debit; + if ($obj->pcg_type == 'INCOME') { + if (!isset($encaiss[$obj->dm])) $encaiss[$obj->dm] = 0; // To avoid warning of var not defined + $encaiss[$obj->dm] += $obj->credit; + $encaiss[$obj->dm] -= $obj->credit; + } + if ($obj->pcg_type == 'INCOME') { + if (!isset($decaiss[$obj->dm])) $decaiss[$obj->dm] = 0; // To avoid warning of var not defined + $decaiss[$obj->dm] += $obj->debit; + $decaiss[$obj->dm] -= $obj->credit; + } + + // ??? if (!isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm] = 0; if (!isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm] = 0; $encaiss_ttc[$obj->dm] += 0; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4e339c4880e..85b63a6f4e3 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1245,14 +1245,14 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Journals if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') { - $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->rights->accounting->comptarapport->lire); + $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->rights->accounting->comptarapport->lire, '', '', ''); // Multi journal $sql = "SELECT rowid, code, label, nature"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql .= " WHERE entity = ".$conf->entity; $sql .= " AND active = 1"; - $sql .= " ORDER BY label DESC"; + $sql .= " ORDER BY nature ASC, label DESC"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 3211a0b62df..41a4cfa59d5 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -198,7 +198,8 @@ Docdate=Date Docref=Reference LabelAccount=Label account LabelOperation=Label operation -Sens=Sens +Sens=Direction +AccountingDirectionHelp=For an accounting account of a customer, use Credit to record a payment you received
For an accounting account of a supplier, use Debit to record a payment you make LetteringCode=Lettering code Lettering=Lettering Codejournal=Journal