FIX Date into filename of FEC file.

This commit is contained in:
Laurent Destailleur 2018-10-21 16:22:56 +02:00
parent 4e6b21881f
commit 2816bdf747
4 changed files with 29 additions and 35 deletions

View File

@ -337,7 +337,7 @@ if ($action == 'delmouvconfirm') {
}
}
// Export into a file with format defined into setup
// Export into a file with format defined into setup (FEC, CSV, ...)
if ($action == 'export_file') {
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
@ -350,7 +350,9 @@ if ($action == 'export_file') {
{
$accountancyexport = new AccountancyExport($db);
$accountancyexport->export($object->lines);
if (!empty($accountancyexport->errors)) {
if (!empty($accountancyexport->errors))
{
setEventMessages('', $accountancyexport->errors, 'errors');
}
exit;

View File

@ -206,7 +206,7 @@ class AccountancyExport
/**
* Function who chose which export to use with the default config
* Function who chose which export to use with the default config, and make the export into a file
*
* @param array $TData data
* @return void
@ -214,16 +214,16 @@ class AccountancyExport
public function export(&$TData)
{
global $conf, $langs;
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
// Define name of file to save
$filename = 'general_ledger-'.$this->getFormatCode($conf->global->ACCOUNTING_EXPORT_MODELCSV);
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
switch ($conf->global->ACCOUNTING_EXPORT_MODELCSV) {
case self::$EXPORT_TYPE_NORMAL :
/*$this->exportNormal($TData);
break;*/
case self::$EXPORT_TYPE_CONFIGURABLE :
$this->exportConfigurable($TData);
break;
@ -261,32 +261,6 @@ class AccountancyExport
}
}
/**
* Export format : Normal
*
* @param array $objectLines data
*
* @return void
*/
/* Use $EXPORT_TYPE_CONFIGURABLE instead
public function exportNormal($objectLines)
{
global $conf;
foreach ( $objectLines as $line ) {
// Std export
$date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
print $date . $this->separator;
print $line->doc_ref . $this->separator;
print length_accountg($line->numero_compte) . $this->separator;
print length_accounta($line->subledger_account) . $this->separator;
print price($line->debit) . $this->separator;
print price($line->credit) . $this->separator;
print $line->code_journal . $this->separator;
print $this->end_line;
}
}
*/
/**
* Export format : CEGID

View File

@ -1001,8 +1001,7 @@ class BookKeeping extends CommonObject
}
}
}
$sql.= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
$sql.= ' WHERE entity IN (' . getEntity('accountancy') . ')';
if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
}

View File

@ -37,7 +37,26 @@ header('Content-Type: text/csv');
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "11") // Specific filename for FEC model export
{
$completefilename = $siren . "FEC" . $search_date_end . $endaccountingperiod . "." . $format;
// FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle
if (empty($search_date_end))
{
// TODO Get the max date into bookeeping table
$search_date_end = dol_now();
}
$datetouseforfilename = $search_date_end;
$tmparray=dol_getdate($datetouseforfilename);
$fiscalmonth=empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START;
// Define end of month to use
if ($tmparray['mon'] <= $fiscalmonth) $tmparray['mon']=$fiscalmonth;
else {
$tmparray['mon'] = $fiscalmonth;
$tmparray['year']++;
}
$endaccountingperiod = dol_print_date(dol_get_last_day($tmparray['year'], $tmparray['mon']), 'dayxcard');
$completefilename = $siren . "FEC" . $endaccountingperiod . "." . $format;
}
else
{