Fix FEC on transaction card

Fix for FEC compliance
- Remove useless column label_compte
- label_compte is generated with label of accounting account number
- Insert also the label of the journal
This commit is contained in:
Alexandre SPANGARO 2018-10-17 07:20:04 +02:00
parent 3ef32a24a4
commit a466104b81

View File

@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("accountancy", "bills", "compta")); $langs->loadLangs(array("accountancy", "bills", "compta"));
@ -49,12 +50,21 @@ if ($user->societe_id > 0) {
$mesg = ''; $mesg = '';
$account_number = GETPOST('account_number','alphanohtml'); $accountingaccount = new AccountingAccount($db);
$accountingjournal = new AccountingJournal($db);
$accountingaccount_number = GETPOST('accountingaccount_number','alphanohtml');
$accountingaccount->fetch(null, $accountingaccount_number, true);
$accountingaccount_label = $accountingaccount->label;
$journal_code = GETPOST('code_journal','alpha');
$accountingjournal->fetch(null, $journal_code);
$journal_label = $accountingjournal->label;
$subledger_account = GETPOST('subledger_account','alphanohtml'); $subledger_account = GETPOST('subledger_account','alphanohtml');
if ($subledger_account == - 1) { if ($subledger_account == - 1) {
$subledger_account = null; $subledger_account = null;
} }
$label_compte = GETPOST('label_compte','alphanohtml');
$label_operation= GETPOST('label_operation','alphanohtml'); $label_operation= GETPOST('label_operation','alphanohtml');
$debit = price2num(GETPOST('debit','alpha')); $debit = price2num(GETPOST('debit','alpha'));
$credit = price2num(GETPOST('credit','alpha')); $credit = price2num(GETPOST('credit','alpha'));
@ -80,7 +90,7 @@ if ($action == "confirm_update") {
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$action='update'; $action='update';
} }
if (empty($account_number) || $account_number == '-1') if (empty($accountingaccount_number) || $accountingaccount_number == '-1')
{ {
$error++; $error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
@ -96,9 +106,9 @@ if ($action == "confirm_update") {
$error++; $error++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
$object->numero_compte = $account_number; $object->numero_compte = $accountingaccount_number;
$object->subledger_account = $subledger_account; $object->subledger_account = $subledger_account;
$object->label_compte = $label_compte; $object->label_compte = $accountingaccount_label;
$object->label_operation= $label_operation; $object->label_operation= $label_operation;
$object->debit = $debit; $object->debit = $debit;
$object->credit = $credit; $object->credit = $credit;
@ -139,7 +149,7 @@ else if ($action == "add") {
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$action=''; $action='';
} }
if (empty($account_number) || $account_number == '-1') if (empty($accountingaccount_number) || $accountingaccount_number == '-1')
{ {
$error++; $error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
@ -149,9 +159,9 @@ else if ($action == "add") {
if (! $error) { if (! $error) {
$object = new BookKeeping($db); $object = new BookKeeping($db);
$object->numero_compte = $account_number; $object->numero_compte = $accountingaccount_number;
$object->subledger_account = $subledger_account; $object->subledger_account = $subledger_account;
$object->label_compte = $label_compte; $object->label_compte = $accountingaccount_label;
$object->label_operation= $label_operation; $object->label_operation= $label_operation;
$object->debit = $debit; $object->debit = $debit;
$object->credit = $credit; $object->credit = $credit;
@ -159,7 +169,8 @@ else if ($action == "add") {
$object->doc_type = GETPOST('doc_type','alpha'); $object->doc_type = GETPOST('doc_type','alpha');
$object->piece_num = $piece_num; $object->piece_num = $piece_num;
$object->doc_ref = GETPOST('doc_ref','alpha'); $object->doc_ref = GETPOST('doc_ref','alpha');
$object->code_journal = GETPOST('code_journal','alpha'); $object->code_journal = $journal_code;
$object->journal_label = $journal_label;
$object->fk_doc = GETPOST('fk_doc','alpha'); $object->fk_doc = GETPOST('fk_doc','alpha');
$object->fk_docdet = GETPOST('fk_docdet','alpha'); $object->fk_docdet = GETPOST('fk_docdet','alpha');
@ -212,7 +223,7 @@ else if ($action == "confirm_create") {
$object = new BookKeeping($db); $object = new BookKeeping($db);
if (! GETPOST('code_journal','alpha') || GETPOST('code_journal','alpha') == '-1') { if (! $journal_code || $journal_code == '-1') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors');
$action='create'; $action='create';
$error++; $error++;
@ -232,7 +243,8 @@ else if ($action == "confirm_create") {
$object->doc_type = GETPOST('doc_type','alpha'); $object->doc_type = GETPOST('doc_type','alpha');
$object->piece_num = GETPOST('next_num_mvt','alpha'); $object->piece_num = GETPOST('next_num_mvt','alpha');
$object->doc_ref = GETPOST('doc_ref','alpha'); $object->doc_ref = GETPOST('doc_ref','alpha');
$object->code_journal = GETPOST('code_journal','alpha'); $object->code_journal = $journal_code;
$object->journal_label = $journal_label;
$object->fk_doc = 0; $object->fk_doc = 0;
$object->fk_docdet = 0; $object->fk_docdet = 0;
$object->montant = 0; $object->montant = 0;
@ -267,8 +279,8 @@ if ($action == 'setdate') {
} }
if ($action == 'setjournal') { if ($action == 'setjournal') {
$journaldoc = trim(GETPOST('code_journal','alpha')); $result = $object->updateByMvt($piece_num, 'code_journal', $journal_code, $mode);
$result = $object->updateByMvt($piece_num, 'code_journal', $journaldoc, $mode); $result = $object->updateByMvt($piece_num, 'journal_label', $journal_label, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
@ -312,7 +324,6 @@ if ($action == 'valid') {
$html = new Form($db); $html = new Form($db);
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$accountjournal = new AccountingJournal($db);
llxHeader('', $langs->trans("CreateMvts")); llxHeader('', $langs->trans("CreateMvts"));
@ -357,7 +368,7 @@ if ($action == 'create')
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">' . $langs->trans("Codejournal") . '</td>'; print '<td class="fieldrequired">' . $langs->trans("Codejournal") . '</td>';
print '<td>' . $formaccounting->select_journal(GETPOST('code_journal', 'alpha'),'code_journal',0,1,array(),1,1) . '</td>'; print '<td>' . $formaccounting->select_journal($journal_code,'code_journal',0,0,1,1) . '</td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
@ -590,7 +601,6 @@ if ($action == 'create')
print_liste_field_titre("AccountAccountingShort"); print_liste_field_titre("AccountAccountingShort");
print_liste_field_titre("SubledgerAccount"); print_liste_field_titre("SubledgerAccount");
print_liste_field_titre("LabelAccount");
print_liste_field_titre("LabelOperation"); print_liste_field_titre("LabelOperation");
print_liste_field_titre("Debit", "", "", "", "", 'align="right"'); print_liste_field_titre("Debit", "", "", "", "", 'align="right"');
print_liste_field_titre("Credit", "", "", "", "", 'align="right"'); print_liste_field_titre("Credit", "", "", "", "", 'align="right"');
@ -605,7 +615,7 @@ if ($action == 'create')
if ($action == 'update' && $line->id == $id) { if ($action == 'update' && $line->id == $id) {
print '<td>'; print '<td>';
print $formaccounting->select_account($line->numero_compte, 'account_number', 1, array (), 1, 1, ''); print $formaccounting->select_account($line->numero_compte, 'accountingaccount_number', 1, array (), 1, 1, '');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
@ -628,9 +638,9 @@ if ($action == 'create')
print '<input type="submit" class="button" name="update" value="' . $langs->trans("Update") . '">'; print '<input type="submit" class="button" name="update" value="' . $langs->trans("Update") . '">';
print '</td>'; print '</td>';
} else { } else {
print '<td>' . length_accountg($line->numero_compte) . '</td>'; $accountingaccount->fetch(null, $line->numero_compte, true);
print '<td>' . $accountingaccount->getNomUrl(0,1,1,'',0) . '</td>';
print '<td>' . length_accounta($line->subledger_account) . '</td>'; print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_compte . '</td>';
print '<td>' . $line->label_operation. '</td>'; print '<td>' . $line->label_operation. '</td>';
print '<td align="right">' . price($line->debit) . '</td>'; print '<td align="right">' . price($line->debit) . '</td>';
print '<td align="right">' . price($line->credit) . '</td>'; print '<td align="right">' . price($line->credit) . '</td>';
@ -663,7 +673,7 @@ if ($action == 'create')
if ($action == "" || $action == 'add') { if ($action == "" || $action == 'add') {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
print $formaccounting->select_account($account_number, 'account_number', 1, array (), 1, 1, ''); print $formaccounting->select_account($accountingaccount_number, 'accountingaccount_number', 1, array (), 1, 1, '');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
@ -677,7 +687,6 @@ if ($action == 'create')
print '<input type="text" name="subledger_account" value="">'; print '<input type="text" name="subledger_account" value="">';
} }
print '</td>'; print '</td>';
print '<td><input type="text" class="minwidth100" name="label_compte" value=""/></td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value=""/></td>'; print '<td><input type="text" class="minwidth200" name="label_operation" value=""/></td>';
print '<td align="right"><input type="text" size="6" class="right" name="debit" value=""/></td>'; print '<td align="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';
print '<td align="right"><input type="text" size="6" class="right" name="credit" value=""/></td>'; print '<td align="right"><input type="text" size="6" class="right" name="credit" value=""/></td>';