Merge pull request #15762 from aspangaro/13b1

FIX: Accountancy - Quadra export format - Manage negative amount
This commit is contained in:
Laurent Destailleur 2020-12-16 15:24:14 +01:00 committed by GitHub
commit 1d6e2a01a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 24 deletions

View File

@ -402,7 +402,6 @@ if (empty($reshook)) {
$newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php', '', 1, array('morecss' => 'marginleftonly'));
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
}

View File

@ -515,9 +515,9 @@ class AccountancyExport
$end_line = "\r\n";
//We should use dol_now function not time however this is wrong date to transfert in accounting
//$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
//$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
// We should use dol_now function not time however this is wrong date to transfert in accounting
// $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
// $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
foreach ($TData as $data) {
$code_compta = $data->numero_compte;
if (!empty($data->subledger_account))
@ -529,36 +529,46 @@ class AccountancyExport
$Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
$Tab['folio'] = '000';
//We use invoice date $data->doc_date not $date_ecriture which is the transfert date
//maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
// We use invoice date $data->doc_date not $date_ecriture which is the transfert date
// maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
//$Tab['date_ecriture'] = $date_ecriture;
$Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
$Tab['filler'] = ' ';
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20);
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
//elarifr le montant doit etre en centimes sans point decimal !
$Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
// $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
// Credit invoice - invert sens
if ($data->montant < 0) {
if ($data->sens == 'C') {
$Tab['sens'] = 'D';
} else {
$Tab['sens'] = 'C';
}
$Tab['signe_montant'] = '-';
} else {
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
}
// The amount must be in centimes without decimal points.
$Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT);
$Tab['contrepartie'] = str_repeat(' ', 8);
// elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting
// Force date format : %d%m%y
if (!empty($data->date_echeance)) {
//$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // Format must be ddmmyy
} else {
$Tab['date_echeance'] = '000000';
}
//elarifr please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
//$Tab['lettrage'] = str_repeat(' ', 5);
// Please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
// $Tab['lettrage'] = str_repeat(' ', 5);
$Tab['lettrage'] = str_repeat(' ', 2);
$Tab['codestat'] = str_repeat(' ', 3);
$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
//elarifr keep correct quadra named field instead of anon filler
//$Tab['filler2'] = str_repeat(' ', 20);
// Keep correct quadra named field instead of anon filler
// $Tab['filler2'] = str_repeat(' ', 20);
$Tab['affaire'] = str_repeat(' ', 10);
$Tab['quantity1'] = str_repeat(' ', 10);
$Tab['num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8);
@ -566,17 +576,17 @@ class AccountancyExport
$Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
$Tab['filler3'] = str_repeat(' ', 3);
//elarifr keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!!
//as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec
//todo we should filter more than only accent to avoid wrong line size
//TODO: remove invoice number doc_ref in libelle,
//TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software
// Keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!!
// as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec
// TODO: we should filter more than only accent to avoid wrong line size
// TODO: remove invoice number doc_ref in libelle,
// TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software
//$Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 30), 30);
$Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 30), 30);
$Tab['codetva'] = str_repeat(' ', 2);
//elarifr we need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part
//$Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10);
// We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part
// $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10);
$Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
$Tab['filler4'] = str_repeat(' ', 73);

View File

@ -48,6 +48,7 @@ CountriesExceptMe=All countries except %s
AccountantFiles=Export source documents
ExportAccountingSourceDocHelp=With this tool, you can export the source events (list and PDFs) that were used to generate your accountancy. To export your journals, use the menu entry %s - %s.
VueByAccountAccounting=View by accounting account
VueBySubAccountAccounting=View by accounting subaccount
MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup
MainAccountForSuppliersNotDefined=Main accounting account for vendors not defined in setup