Fix debug various payment module.
Fix debug report income/expense (for situation that should not happen but if it happen, result is consistent with other screens).
This commit is contained in:
parent
10a0c98f94
commit
dac0267a38
@ -122,7 +122,7 @@ if (empty($reshook))
|
|||||||
$object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : "";
|
$object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : "";
|
||||||
$object->subledger_account = $subledger_account;
|
$object->subledger_account = $subledger_account;
|
||||||
|
|
||||||
$object->sens = GETPOST('sens');
|
$object->sens = GETPOST('sens', 'int');
|
||||||
$object->fk_project = GETPOST('fk_project', 'int');
|
$object->fk_project = GETPOST('fk_project', 'int');
|
||||||
|
|
||||||
if (empty($datep) || empty($datev))
|
if (empty($datep) || empty($datev))
|
||||||
@ -131,12 +131,6 @@ if (empty($reshook))
|
|||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
||||||
$error++;
|
$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))
|
if (empty($object->amount))
|
||||||
{
|
{
|
||||||
$langs->load('errors');
|
$langs->load('errors');
|
||||||
@ -149,13 +143,24 @@ if (empty($reshook))
|
|||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
|
||||||
$error++;
|
$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)
|
if (!empty($conf->accounting->enabled) && !$object->accountancy_code)
|
||||||
{
|
{
|
||||||
$langs->load('errors');
|
$langs->load('errors');
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
if ($object->sens < 0)
|
||||||
|
{
|
||||||
|
$langs->load('errors');
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Sens")), null, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
@ -358,13 +363,6 @@ if ($action == 'create')
|
|||||||
print '<input name="label" id="label" class="minwidth300 maxwidth150onsmartphone" value="'.($label ? $label : $langs->trans("VariousPayment")).'">';
|
print '<input name="label" id="label" class="minwidth300 maxwidth150onsmartphone" value="'.($label ? $label : $langs->trans("VariousPayment")).'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Sens
|
|
||||||
print '<tr><td>';
|
|
||||||
print $form->editfieldkey('Sens', 'sens', '', $object, 0, 'string', '', 1).'</td><td>';
|
|
||||||
$sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit"));
|
|
||||||
print $form->selectarray('sens', $sensarray, $sens);
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Amount
|
// Amount
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).'</td><td>';
|
print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||||
@ -396,6 +394,44 @@ if ($action == 'create')
|
|||||||
print '<td><input name="num_payment" class="maxwidth150onsmartphone" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
|
print '<td><input name="num_payment" class="maxwidth150onsmartphone" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\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 '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("AccountAccounting").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1);
|
||||||
|
print '</td></tr>';
|
||||||
|
} else { // For external software
|
||||||
|
print '<tr><td class="titlefieldcreate">'.$langs->trans("AccountAccounting").'</td>';
|
||||||
|
print '<td><input class="minwidth100 maxwidthonsmartphone" name="accountancy_code" value="'.$accountancy_code.'">';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subledger account
|
||||||
|
if (!empty($conf->accounting->enabled)) {
|
||||||
|
print '<tr><td>'.$langs->trans("SubledgerAccount").'aaaa</td>';
|
||||||
|
print '<td>';
|
||||||
|
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
|
||||||
|
{
|
||||||
|
print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, '');
|
||||||
|
} else {
|
||||||
|
print '<input type="text" class="maxwidth200 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
} else { // For external software
|
||||||
|
print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
|
||||||
|
print '<td><input class="minwidth100 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sens
|
||||||
|
print '<tr><td>';
|
||||||
|
$labelsens = $form->textwithpicto('Sens', $langs->trans("AccountingDirectionHelp"));
|
||||||
|
print $form->editfieldkey($labelsens, 'sens', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||||
|
$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 '</td></tr>';
|
||||||
|
|
||||||
// Project
|
// Project
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled))
|
||||||
{
|
{
|
||||||
@ -417,44 +453,9 @@ if ($action == 'create')
|
|||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
// Category
|
// Category
|
||||||
if (is_array($options) && count($options) && $conf->categorie->enabled)
|
if (is_array($options) && count($options) && $conf->categorie->enabled) {
|
||||||
{
|
|
||||||
print '<tr><td>'.$langs->trans("RubriquesTransactions").'</td><td>';
|
print '<tr><td>'.$langs->trans("RubriquesTransactions").'</td><td>';
|
||||||
print Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1);
|
print img_picto('', 'category').Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1, 0, 0, '', 0, 0, 0, '', 'minwidth300', 1);
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Accountancy account
|
|
||||||
if (!empty($conf->accounting->enabled))
|
|
||||||
{
|
|
||||||
// TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code
|
|
||||||
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("AccountAccounting").'</td>';
|
|
||||||
print '<td>';
|
|
||||||
print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1);
|
|
||||||
print '</td></tr>';
|
|
||||||
} else // For external software
|
|
||||||
{
|
|
||||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("AccountAccounting").'</td>';
|
|
||||||
print '<td><input class="minwidth100 maxwidthonsmartphone" name="accountancy_code" value="'.$accountancy_code.'">';
|
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subledger account
|
|
||||||
if (!empty($conf->accounting->enabled))
|
|
||||||
{
|
|
||||||
print '<tr><td>'.$langs->trans("SubledgerAccount").'aaaa</td>';
|
|
||||||
print '<td>';
|
|
||||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
|
|
||||||
{
|
|
||||||
print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, '');
|
|
||||||
} else {
|
|
||||||
print '<input type="text" class="maxwidth200 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
|
|
||||||
}
|
|
||||||
print '</td></tr>';
|
|
||||||
} else // For external software
|
|
||||||
{
|
|
||||||
print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
|
|
||||||
print '<td><input class="minwidth100 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -863,10 +863,18 @@ if (!empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING'))
|
|||||||
{
|
{
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
|
|
||||||
if (!isset($encaiss[$obj->dm])) $encaiss[$obj->dm] = 0;
|
if ($obj->pcg_type == 'INCOME') {
|
||||||
if (!isset($decaiss[$obj->dm])) $decaiss[$obj->dm] = 0;
|
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;
|
||||||
$decaiss[$obj->dm] += $obj->debit;
|
$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($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm] = 0;
|
||||||
if (!isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm] = 0;
|
if (!isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm] = 0;
|
||||||
$encaiss_ttc[$obj->dm] += 0;
|
$encaiss_ttc[$obj->dm] += 0;
|
||||||
|
|||||||
@ -1245,14 +1245,14 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
|
|||||||
|
|
||||||
// Journals
|
// Journals
|
||||||
if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') {
|
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
|
// Multi journal
|
||||||
$sql = "SELECT rowid, code, label, nature";
|
$sql = "SELECT rowid, code, label, nature";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
|
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
|
||||||
$sql .= " WHERE entity = ".$conf->entity;
|
$sql .= " WHERE entity = ".$conf->entity;
|
||||||
$sql .= " AND active = 1";
|
$sql .= " AND active = 1";
|
||||||
$sql .= " ORDER BY label DESC";
|
$sql .= " ORDER BY nature ASC, label DESC";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
|
|||||||
@ -198,7 +198,8 @@ Docdate=Date
|
|||||||
Docref=Reference
|
Docref=Reference
|
||||||
LabelAccount=Label account
|
LabelAccount=Label account
|
||||||
LabelOperation=Label operation
|
LabelOperation=Label operation
|
||||||
Sens=Sens
|
Sens=Direction
|
||||||
|
AccountingDirectionHelp=For an accounting account of a customer, use Credit to record a payment you received<br>For an accounting account of a supplier, use Debit to record a payment you make
|
||||||
LetteringCode=Lettering code
|
LetteringCode=Lettering code
|
||||||
Lettering=Lettering
|
Lettering=Lettering
|
||||||
Codejournal=Journal
|
Codejournal=Journal
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user