Skip to content

Commit

Permalink
Merge branch '9.0' of git@github.com:Dolibarr/dolibarr.git into 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 23, 2020
2 parents 7ee37dd + 3a9ef7c commit 42769e2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
11 changes: 6 additions & 5 deletions htdocs/accountancy/class/accountancyexport.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*/

require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';

class AccountancyExport
{
Expand Down Expand Up @@ -658,9 +659,9 @@ public function exportFEC($objectLines)
print $end_line;

foreach ( $objectLines as $line ) {
$date_creation = dol_print_date($line->date_creation, '%d%m%Y');
$date_doc = dol_print_date($line->doc_date, '%d%m%Y');
$date_valid = dol_print_date($line->date_validated, '%d%m%Y');
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_doc = dol_print_date($line->doc_date, '%Y%m%d');
$date_valid = dol_print_date($line->date_validated, '%Y%m%d');

// FEC:JournalCode
print $line->code_journal . $separator;
Expand Down Expand Up @@ -696,10 +697,10 @@ public function exportFEC($objectLines)
print $line->label_operation . $separator;

// FEC:Debit
print price2num($line->debit) . $separator;
print price2fec($line->debit) . $separator;

// FEC:Credit
print price2num($line->credit) . $separator;
print price2fec($line->credit) . $separator;

// FEC:EcritureLet
print $line->lettering_code . $separator;
Expand Down
1 change: 0 additions & 1 deletion htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4523,7 +4523,6 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
return $amount;
}


/**
* Output a dimension with best unit
*
Expand Down
41 changes: 35 additions & 6 deletions htdocs/core/lib/functions2.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2320,9 +2320,9 @@ function getModuleDirForApiClass($module)
/*
* Return 2 hexa code randomly
*
* @param $min int Between 0 and 255
* @param $max int Between 0 and 255
* @return String
* @param int $min Between 0 and 255
* @param int $max Between 0 and 255
* @return String Color string
*/
function random_color_part($min=0,$max=255)
{
Expand All @@ -2332,11 +2332,40 @@ function random_color_part($min=0,$max=255)
/*
* Return hexadecimal color randomly
*
* @param $min int Between 0 and 255
* @param $max int Between 0 and 255
* @return String
* @param int $min Between 0 and 255
* @param int $max Between 0 and 255
* @return String Color string
*/
function random_color($min=0, $max=255)
{
return random_color_part($min, $max) . random_color_part($min, $max) . random_color_part($min, $max);
}

/**
* Function to format a value into a defined format for French administration (no thousand separator & decimal separator force to ',' with two decimals)
* Function used into accountancy FEC export
*
* @param float $amount Amount to format
* @return string Chain with formatted upright
* @see price2num() Format a numeric into a price for FEC files
*/
function price2fec($amount)
{
global $conf;

// Clean parameters
if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = ''
$amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number)

// Output decimal number by default
$nbdecimal = (empty($conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH) ? 2 : $conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH);

// Output separators by default
$dec = (empty($conf->global->ACCOUNTING_FEC_DECIMAL_SEPARATOR) ? ',' : $conf->global->ACCOUNTING_FEC_DECIMAL_SEPARATOR);
$thousand = (empty($conf->global->ACCOUNTING_FEC_THOUSAND_SEPARATOR) ? '' : $conf->global->ACCOUNTING_FEC_THOUSAND_SEPARATOR);

// Format number
$output = number_format($amount, $nbdecimal, $dec, $thousand);

return $output;
}

0 comments on commit 42769e2

Please sign in to comment.