Merge pull request #5218 from atm-florian/develop

Fix : Advanced Accountancy module
This commit is contained in:
Laurent Destailleur 2016-05-18 20:22:07 +02:00
commit ee73a91c77
6 changed files with 384 additions and 349 deletions

View File

@ -79,7 +79,7 @@ if (empty($search_date_start)) {
if ($sortorder == "") if ($sortorder == "")
$sortorder = "ASC"; $sortorder = "ASC";
if ($sortfield == "") if ($sortfield == "")
$sortfield = "t.rowid"; $sortfield = "t.numero_compte";
$options = ''; $options = '';
$filter = array (); $filter = array ();

View File

@ -235,93 +235,15 @@ if ($action == 'export_csv') {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
else else
{
if (in_array($conf->global->ACCOUNTING_EXPORT_MODELCSV, array(5,6))) // TODO remove the conditional and keep the code in the "else"
{ {
$accountancyexport = new AccountancyExport($db); $accountancyexport = new AccountancyExport($db);
$accountancyexport->export($object->lines); $accountancyexport->export($object->lines);
if (!empty($accountancyexport->errors)) setEventMessages('', $accountancyexport->errors, 'errors'); if (!empty($accountancyexport->errors)) {
else exit; setEventMessages('', $accountancyexport->errors, 'errors');
} }
}
// TODO remove next 3 lines and foreach to implement the AccountancyExport method for each model
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = 'bookkepping';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
foreach ( $object->lines as $line ) {
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
$sep = ";";
// Model Cegid Expert Export
$date = dol_print_date($line->doc_date, '%d%m%Y');
print $date . $sep;
print $line->code_journal . $sep;
print length_accountg($line->numero_compte) . $sep;
print ' ' . $sep;
print $line->sens . $sep;
print price($line->montant) . $sep;
print dol_trunc($line->label_compte, 32) . $sep;
print $line->doc_ref . $sep;
print "\n";
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
// Std export
$date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
print $date . $sep;
print $line->doc_ref . $sep;
print length_accountg($line->numero_compte) . $sep;
print length_accounta($line->code_tiers) . $sep;
print price($line->debit) . $sep;
print price($line->credit) . $sep;
print $line->code_journal . $sep;
print "\n";
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) {
// Coala export
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $sep;
print $line->code_journal . $sep;
print length_accountg($line->numero_compte) . $sep;
print $line->piece_num . $sep;
print $line->doc_ref . $sep;
print price($line->debit) . $sep;
print price($line->credit) . $sep;
print 'E' . $sep;
print length_accountg($line->code_tiers) . $sep;
print "\n";
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 4) {
// Bob50
print $line->piece_num . $sep;
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $sep;
if (empty($line->code_tiers)) {
print 'G' . $sep;
print length_accounta($line->numero_compte) . $sep;
} else {
if (substr($line->numero_compte,0,3)=='411') {
print 'C' . $sep;
}
if (substr($line->numero_compte,0,3)=='401') {
print 'F' . $sep;
}
print length_accountg($line->code_tiers) . $sep;
}
print price($line->debit) . $sep;
print price($line->credit) . $sep;
print dol_trunc($line->label_compte, 32) . $sep;
print "\n";
}
}
exit; exit;
} }
}
/* /*
* View * View

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net> /*
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
@ -29,10 +30,10 @@
* Manage the different format accountancy export * Manage the different format accountancy export
*/ */
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
class AccountancyExport class AccountancyExport
{ {
/** /**
*
* @var Type of export * @var Type of export
*/ */
public static $EXPORT_TYPE_NORMAL = 1; public static $EXPORT_TYPE_NORMAL = 1;
@ -41,18 +42,22 @@ class AccountancyExport
public static $EXPORT_TYPE_BOB50 = 4; public static $EXPORT_TYPE_BOB50 = 4;
public static $EXPORT_TYPE_CIEL = 5; public static $EXPORT_TYPE_CIEL = 5;
public static $EXPORT_TYPE_QUADRATUS = 6; public static $EXPORT_TYPE_QUADRATUS = 6;
public static $EXPORT_TYPE_EBP = 7;
/** /**
*
* @var string[] Error codes (or messages) * @var string[] Error codes (or messages)
*/ */
public $errors = array (); public $errors = array ();
/** /**
*
* @var string Separator * @var string Separator
*/ */
public $separator = ''; public $separator = '';
/** /**
*
* @var string End of line * @var string End of line
*/ */
public $end_line = ''; public $end_line = '';
@ -62,8 +67,7 @@ class AccountancyExport
* *
* @param DoliDb $db Database handler * @param DoliDb $db Database handler
*/ */
public function __construct(DoliDB &$db) public function __construct(DoliDB &$db) {
{
global $conf; global $conf;
$this->db = &$db; $this->db = &$db;
@ -76,8 +80,7 @@ class AccountancyExport
* *
* @return array of type * @return array of type
*/ */
public static function getType() public static function getType() {
{
global $langs; global $langs;
return array ( return array (
@ -86,7 +89,8 @@ class AccountancyExport
self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'),
self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'),
self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'),
self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus') self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'),
self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'),
); );
} }
@ -95,8 +99,7 @@ class AccountancyExport
* *
* @return void * @return void
*/ */
public static function downloadFile() public static function downloadFile() {
{
global $conf; global $conf;
$journal = 'bookkepping'; $journal = 'bookkepping';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
@ -107,10 +110,11 @@ class AccountancyExport
* *
* @param unknown $TData data * @param unknown $TData data
*/ */
public function export(&$TData) public function export(&$TData) {
{
global $conf, $langs; global $conf, $langs;
self::downloadFile();
switch ($conf->global->ACCOUNTING_EXPORT_MODELCSV) { switch ($conf->global->ACCOUNTING_EXPORT_MODELCSV) {
case self::$EXPORT_TYPE_NORMAL : case self::$EXPORT_TYPE_NORMAL :
$this->exportNormal($TData); $this->exportNormal($TData);
@ -130,79 +134,135 @@ class AccountancyExport
case self::$EXPORT_TYPE_QUADRATUS : case self::$EXPORT_TYPE_QUADRATUS :
$this->exportQuadratus($TData); $this->exportQuadratus($TData);
break; break;
case self::$EXPORT_TYPE_EBP :
$this->exportEbp($TData);
break;
default : default :
$this->errors[] = $langs->trans('accountancy_error_modelnotfound'); $this->errors[] = $langs->trans('accountancy_error_modelnotfound');
break; break;
} }
if (empty($this->errors)) self::downloadFile();
} }
/** /**
* Export format : Normal * Export format : Normal
* *
* @param unknown $TData data * @param array $objectLines data
* *
* @return void * @return void
*/ */
public function exportNormal(&$TData) public function exportNormal($objectLines) {
{ 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->code_tiers) . $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 * Export format : CEGID
* *
* @param unknown $TData data * @param array $objectLines data
* *
* @return void * @return void
*/ */
public function exportCegid(&$TData) public function exportCegid($objectLines) {
{ foreach ( $objectLines as $line ) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
print $date . $this->separator;
print $line->code_journal . $this->separator;
print length_accountg($line->numero_compte) . $this->separator;
print ' ' . $this->separator;
print $line->sens . $this->separator;
print price($line->montant) . $this->separator;
print dol_trunc($line->label_compte, 32) . $this->separator;
print $line->doc_ref . $this->separator;
print $this->end_line;
}
} }
/** /**
* Export format : COALA * Export format : COALA
* *
* @param unknown $TData data * @param array $objectLines data
* *
* @return void * @return void
*/ */
public function exportCoala(&$TData) public function exportCoala($objectLines) {
{ // Coala export
foreach ( $objectLines as $line ) {
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $this->separator;
print $line->code_journal . $this->separator;
print length_accountg($line->numero_compte) . $this->separator;
print $line->piece_num . $this->separator;
print $line->doc_ref . $this->separator;
print price($line->debit) . $this->separator;
print price($line->credit) . $this->separator;
print 'E' . $this->separator;
print length_accountg($line->code_tiers) . $this->separator;
print $this->end_line;
}
} }
/** /**
* Export format : BOB50 * Export format : BOB50
* *
* @param unknown $TData data * @param array $objectLines data
* *
* @return void * @return void
*/ */
public function exportBob50(&$TData) public function exportBob50($objectLines) {
{
// Bob50
foreach ( $objectLines as $line ) {
print $line->piece_num . $this->separator;
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $this->separator;
if (empty($line->code_tiers)) {
print 'G' . $this->separator;
print length_accounta($line->numero_compte) . $this->separator;
} else {
if (substr($line->numero_compte, 0, 3) == '411') {
print 'C' . $this->separator;
}
if (substr($line->numero_compte, 0, 3) == '401') {
print 'F' . $this->separator;
}
print length_accountg($line->code_tiers) . $this->separator;
}
print price($line->debit) . $this->separator;
print price($line->credit) . $this->separator;
print dol_trunc($line->label_compte, 32) . $this->separator;
print $this->end_line;
}
} }
/** /**
* Export format : CIEL * Export format : CIEL
* *
* @param unknown $TData data * @param array $TData data
* *
* @return void * @return void
*/ */
public function exportCiel(&$TData) public function exportCiel(&$TData) {
{
global $conf; global $conf;
$i = 1; $i = 1;
$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd
foreach ($TData as $data) foreach ( $TData as $data ) {
{
$code_compta = $data->numero_compte; $code_compta = $data->numero_compte;
if (!empty($data->code_tiers)) $code_compta = $data->code_tiers; if (! empty($data->code_tiers))
$code_compta = $data->code_tiers;
$Tab = array (); $Tab = array ();
$Tab['num_ecriture'] = str_pad($i, 5); $Tab['num_ecriture'] = str_pad($i, 5);
@ -228,19 +288,18 @@ class AccountancyExport
/** /**
* Export format : Quadratus * Export format : Quadratus
* *
* @param unknown $TData data * @param array $TData data
* *
* @return void * @return void
*/ */
public function exportQuadratus(&$TData) public function exportQuadratus(&$TData) {
{
global $conf; global $conf;
$date_ecriture = dol_print_date(time(), $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) foreach ( $TData as $data ) {
{
$code_compta = $data->numero_compte; $code_compta = $data->numero_compte;
if (!empty($data->code_tiers)) $code_compta = $data->code_tiers; if (! empty($data->code_tiers))
$code_compta = $data->code_tiers;
$Tab = array (); $Tab = array ();
$Tab['type_ligne'] = 'M'; $Tab['type_ligne'] = 'M';
@ -254,8 +313,10 @@ class AccountancyExport
$Tab['signe_montant'] = '+'; $Tab['signe_montant'] = '+';
$Tab['montant'] = str_pad(abs($data->montant) * 100, 12, '0', STR_PAD_LEFT); // TODO manage negative amount $Tab['montant'] = str_pad(abs($data->montant) * 100, 12, '0', STR_PAD_LEFT); // TODO manage negative amount
$Tab['contrepartie'] = str_repeat(' ', 8); $Tab['contrepartie'] = str_repeat(' ', 8);
if (!empty($data->date_echeance)) $Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); if (! empty($data->date_echeance))
else $Tab['date_echeance'] = '000000'; $Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);
else
$Tab['date_echeance'] = '000000';
$Tab['lettrage'] = str_repeat(' ', 5); $Tab['lettrage'] = str_repeat(' ', 5);
$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
$Tab['filler2'] = str_repeat(' ', 20); $Tab['filler2'] = str_repeat(' ', 20);
@ -273,14 +334,45 @@ class AccountancyExport
} }
} }
/**
* Export format : Normal
*
* @param array $objectLines data
*
* @return void
*/
public function exportEbp($objectLines) {
$this->separator = ',';
foreach ( $objectLines as $line ) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
print $line->id . $this->separator;
print $date . $this->separator;
print $line->code_journal . $this->separator;
print length_accountg($line->numero_compte) . $this->separator;
print substr(length_accountg($line->numero_compte),0,2) . $this->separator;
print '"'.dol_trunc($line->label_compte,40,'right','UTF-8',1).'"' . $this->separator;
print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1)."'".$this->separator;
print price2num($line->montant).$this->separator;
print $line->sens.$this->separator;
print $date . $this->separator;
print 'EUR';
print $this->end_line;
}
}
/** /**
* *
* @param unknown $str data * @param unknown $str data
* @param integer $size data * @param integer $size data
*/ */
public static function trunc($str, $size) public static function trunc($str, $size) {
{
return dol_trunc($str, $size, 'right', 'UTF-8', 1); return dol_trunc($str, $size, 'right', 'UTF-8', 1);
} }
} }

View File

@ -117,13 +117,14 @@ if ($result) {
$tabfac = array (); $tabfac = array ();
$tabht = array (); $tabht = array ();
$tabtva = array (); $tabtva = array ();
$def_tva = array ();
$tabttc = array (); $tabttc = array ();
$tabcompany = array (); $tabcompany = array ();
$i = 0; $i = 0;
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// contrôles // contrôles
$compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour;
$compta_prod = $obj->compte; $compta_prod = $obj->compte;
if (empty($compta_prod)) { if (empty($compta_prod)) {
@ -134,12 +135,14 @@ if ($result) {
} }
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
//Define array for display vat tx
$def_tva[$obj->rowid]=price($obj->tva_tx);
$tabfac[$obj->rowid]["date"] = $obj->df; $tabfac[$obj->rowid]["date"] = $obj->df;
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')';
$tabfac[$obj->rowid]["refsologest"] = $obj->ref; $tabfac[$obj->rowid]["refsologest"] = $obj->ref;
$tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier; $tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier;
$tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["type"] = $obj->type;
$tabfac[$obj->rowid]["description"] = $obj->description; $tabfac[$obj->rowid]["description"] = $obj->description;
$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; $tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid;
@ -165,6 +168,9 @@ if ($action == 'writebookkeeping') {
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
$companystatic = new Societe($db);
$invoicestatic = new FactureFournisseur($db);
$invoicestatic->id = $key; $invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"]; $invoicestatic->ref = $val["ref"];
$invoicestatic->ref = $val["refsologest"]; $invoicestatic->ref = $val["refsologest"];
@ -176,7 +182,6 @@ if ($action == 'writebookkeeping') {
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->client = $tabcompany[$key]['code_client'];
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
// get compte id and label // get compte id and label
@ -251,7 +256,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->fk_docdet = $val["fk_facturefourndet"];
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
$bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->refsupplier .' - '. $langs->trans("VAT"); $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key];
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
@ -288,8 +293,7 @@ if ($action == 'export_csv') {
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
// Model Cegid Expert Export // Model Cegid Expert Export
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
{
$sep = ";"; $sep = ";";
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
@ -341,7 +345,7 @@ if ($action == 'export_csv') {
print "\n"; print "\n";
} }
} }
} else { } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
// Model Classic Export // Model Classic Export
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
@ -423,7 +427,11 @@ if ($action == 'export_csv') {
'action' => '' 'action' => ''
)); ));
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 || $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabeld="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
} else {
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
@ -468,7 +476,6 @@ if ($action == 'export_csv') {
$invoicestatic->ref = $val["refsologest"]; $invoicestatic->ref = $val["refsologest"];
$invoicestatic->refsupplier = $val["refsuppliersologest"]; $invoicestatic->refsupplier = $val["refsuppliersologest"];
$invoicestatic->type = $val["type"]; $invoicestatic->type = $val["type"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
@ -500,7 +507,7 @@ if ($action == 'export_csv') {
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>"; print "<td>" . length_accountg($k) . "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16). ' - '.$invoicestatic->refsupplier .' - '. $langs->trans("VAT") . "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>"; print "</tr>";

View File

@ -7,7 +7,7 @@
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2014 Rapha<EFBFBD>l Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -118,6 +118,7 @@ if ($result) {
$tabfac = array (); $tabfac = array ();
$tabht = array (); $tabht = array ();
$tabtva = array (); $tabtva = array ();
$def_tva = array ();
$tabttc = array (); $tabttc = array ();
$tabcompany = array (); $tabcompany = array ();
@ -140,10 +141,14 @@ if ($result) {
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
//Define array for display vat tx
$def_tva[$obj->rowid]=price($obj->tva_tx);
// Situation invoices handling // Situation invoices handling
$line = new FactureLigne($db); $line = new FactureLigne($db);
$line->fetch($obj->rowid); $line->fetch($obj->fdid);
$prev_progress = $line->get_prev_progress(); $prev_progress = $line->get_prev_progress($obj->fdid);
if ($obj->type == Facture::TYPE_SITUATION) { if ($obj->type == Facture::TYPE_SITUATION) {
// Avoid divide by 0 // Avoid divide by 0
if ($obj->situation_percent == 0) { if ($obj->situation_percent == 0) {
@ -193,6 +198,10 @@ if ($action == 'writebookkeeping') {
$error = 0; $error = 0;
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
$companystatic = new Societe($db);
$invoicestatic = new Facture($db);
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->client = $tabcompany[$key]['code_client'];
@ -200,7 +209,6 @@ if ($action == 'writebookkeeping') {
$invoicestatic->id = $key; $invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"]; $invoicestatic->ref = $val["ref"];
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
@ -272,7 +280,7 @@ $invoicestatic->id = $key;
$bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->fk_docdet = $val["fk_facturedet"];
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT"); $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key];
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0; $bookkeeping->debit = ($mt < 0) ? $mt : 0;
@ -296,6 +304,7 @@ $invoicestatic->id = $key;
// Export // Export
if ($action == 'export_csv') { if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
@ -304,8 +313,7 @@ if ($action == 'export_csv') {
$companystatic = new Client($db); $companystatic = new Client($db);
// Model Cegid Expert Export // Model Cegid Expert Export
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
{
$sep = ";"; $sep = ";";
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
@ -364,7 +372,7 @@ $invoicestatic->id = $key;
} }
} }
} }
} else { } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
// Model Classic Export // Model Classic Export
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
@ -440,7 +448,11 @@ $invoicestatic->id = $key;
'action' => '' 'action' => ''
)); ));
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 || $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabeld="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
} else {
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
@ -529,7 +541,7 @@ $invoicestatic->id = $key;
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>"; print "<td>" . length_accountg($k) . "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. "</td>";
// print "<td>" . $langs->trans("VAT") . "</td>"; // print "<td>" . $langs->trans("VAT") . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";

View File

@ -164,6 +164,7 @@ Modelcsv_COALA=Export towards Sage Coala
Modelcsv_bob50=Export towards Sage BOB 50 Modelcsv_bob50=Export towards Sage BOB 50
Modelcsv_ciel=Export towards Sage Ciel Compta or Compta Evolution Modelcsv_ciel=Export towards Sage Ciel Compta or Compta Evolution
Modelcsv_quadratus=Export towards Quadratus QuadraCompta Modelcsv_quadratus=Export towards Quadratus QuadraCompta
Modelcsv_ebp=Export towards EBP
## Tools - Init accounting account on product / service ## Tools - Init accounting account on product / service
InitAccountancy=Init accountancy InitAccountancy=Init accountancy
@ -182,3 +183,4 @@ Formula=Formula
## Error ## Error
ErrorNoAccountingCategoryForThisCountry=No accounting category are available for this country ErrorNoAccountingCategoryForThisCountry=No accounting category are available for this country
ExportNotSupported=The export format setuped is not supported into this page