Commit 2b573b4aeae918b547d6037b4ae5108f8a3f687c

Authored by Florian HENRY
1 parent adaae0f4
Exists in 3.5 and in 1 other branch 3.6

Add accounting account group by option

accountingex/admin/export.php
... ... @@ -54,13 +54,13 @@ $action = GETPOST('action', 'alpha');
54 54  
55 55 // Other parameters ACCOUNTINGEX_*
56 56 $list = array (
57   - 'ACCOUNTINGEX_SEPARATORCSV'
58   - /* 'ACCOUNTINGEX_EXP_DATE'
59   - 'ACCOUNTINGEX_EXP_PIECE'
60   - 'ACCOUNTINGEX_EXP_GLOBAL_ACCOUNT'
61   - 'ACCOUNTINGEX_EXP_LABEL'
62   - 'ACCOUNTINGEX_EXP_AMOUNT'
63   - 'ACCOUNTINGEXP_EXP_DEVISE'*/
  57 + 'ACCOUNTINGEX_SEPARATORCSV',
  58 + 'ACCOUNTINGEX_EXP_DATE',
  59 + 'ACCOUNTINGEX_EXP_PIECE',
  60 + 'ACCOUNTINGEX_EXP_GLOBAL_ACCOUNT',
  61 + 'ACCOUNTINGEX_EXP_LABEL',
  62 + 'ACCOUNTINGEX_EXP_AMOUNT',
  63 + 'ACCOUNTINGEXP_EXP_DEVISE'
64 64 );
65 65  
66 66 /*
... ... @@ -150,9 +150,6 @@ print "<br>\n";
150 150 * Params
151 151 *
152 152 */
153   -$list = array (
154   - 'ACCOUNTINGEX_SEPARATORCSV'
155   -);
156 153  
157 154 $num = count($list);
158 155 if ($num) {
... ...
accountingex/class/accountingaccount.class.php
... ... @@ -73,6 +73,8 @@ class AccountingAccount {
73 73 } else {
74 74 return null;
75 75 }
  76 + } else {
  77 + return -1;
76 78 }
77 79  
78 80 $this->id = $obj->rowid;
... ... @@ -369,7 +371,7 @@ class AccountingAccount {
369 371  
370 372 $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
371 373 $sql .= "SET active = '0'";
372   - $sql .= " WHERE rowid = ".$this->db->escape($id);
  374 + $sql .= " WHERE rowid = " . $this->db->escape($id);
373 375  
374 376 dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG);
375 377 $result = $this->db->query($sql);
... ... @@ -400,7 +402,7 @@ class AccountingAccount {
400 402  
401 403 $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
402 404 $sql .= "SET active = '1'";
403   - $sql .= " WHERE rowid = ".$this->db->escape($id);
  405 + $sql .= " WHERE rowid = " . $this->db->escape($id);
404 406  
405 407 dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG);
406 408 $result = $this->db->query($sql);
... ...
accountingex/core/modules/modAccountingExpert.class.php
... ... @@ -172,7 +172,7 @@ class modAccountingExpert extends DolibarrModules {
172 172 $this->const[18] = array (
173 173 "ACCOUNTINGEX_EXP_DATE",
174 174 "chaine",
175   - ""
  175 + "%d%m%Y"
176 176 );
177 177 $this->const[19] = array (
178 178 "ACCOUNTINGEX_EXP_PIECE",
... ...
accountingex/journal/sellsjournal.php
... ... @@ -152,40 +152,41 @@ if ($result) {
152 152 $tabfac[$obj->rowid]["ref"] = $obj->facnumber;
153 153 $tabfac[$obj->rowid]["type"] = $obj->type;
154 154 if (!empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
155   - $compte = new AccountingAccount($db);
156   - if ($compte->fetch(null, $k))
157   - {
158   - $tabfac[$obj->rowid]["description"] = $compte->label;
159   - } }else {
160   - $tabfac[$obj->rowid]["description"] = $obj->description;
  155 + $compte = new AccountingAccount($db);
  156 + $resultcompte=$compte->fetch($obj->fk_compte);
  157 + if ($resultcompte) {
  158 + $tabfac[$obj->rowid]["description"] = $compte->label;
  159 + }
  160 + } else {
  161 + $tabfac[$obj->rowid]["description"][$obj->fdid]= $obj->description;
161 162 }
162 163 $tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
163 164 if (! isset($tabttc[$obj->rowid][$compta_soc]))
164 165 $tabttc[$obj->rowid][$compta_soc] = 0;
165 166  
166   - /*if (empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  167 + if (!empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
167 168 if (! isset($tabht[$obj->rowid][$compta_prod])) {
168 169 $tabht[$obj->rowid][$compta_prod] = 0;
169   - }
  170 + }
170 171 } else {
171 172 if (! isset($tabht[$obj->rowid][$compta_prod])) {
172   - $tabht[$obj->rowid][$compta_prod] = 0;
  173 + $tabht[$obj->rowid][$compta_prod][$obj->fdid] = 0;
173 174 }
174   - }*/
175   - if (! isset($tabht[$obj->rowid][$compta_prod])) {
176   - $tabht[$obj->rowid][$compta_prod] = 0;
177 175 }
  176 + /*if (! isset($tabht[$obj->rowid][$compta_prod])) {
  177 + $tabht[$obj->rowid][$compta_prod] = 0;
  178 + }*/
178 179  
179 180 if (! isset($tabtva[$obj->rowid][$compta_tva]))
180 181 $tabtva[$obj->rowid][$compta_tva] = 0;
181 182 $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
182 183  
183   - /*if (empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  184 + if (!empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
184 185 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
185 186 } else {
186   - $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
187   - }*/
188   - $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
  187 + $tabht[$obj->rowid][$compta_prod][$obj->fdid] = $obj->total_ht;
  188 + }
  189 + // $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
189 190  
190 191 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
191 192 $tabcompany[$obj->rowid] = array (
... ... @@ -297,7 +298,7 @@ if ($action == 'export_csv') {
297 298 $companystatic->name = $tabcompany[$key]['name'];
298 299 $companystatic->client = $tabcompany[$key]['code_client'];
299 300  
300   - $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
  301 + $date = dol_print_date($db->jdate($val["date"]), $conf->global->ACCOUNTINGEX_EXP_DATE);
301 302  
302 303 print $date . $sep;
303 304 print $conf->global->ACCOUNTINGEX_SELL_JOURNAL . $sep;
... ... @@ -313,16 +314,32 @@ if ($action == 'export_csv') {
313 314  
314 315 // Product / Service
315 316 foreach ( $tabht[$key] as $k => $mt ) {
316   - if ($mt) {
317   - print $date . $sep;
318   - print $conf->global->ACCOUNTINGEX_SELL_JOURNAL . $sep;
319   - print length_accountg(html_entity_decode($k)) . $sep;
320   - print $sep;
321   - print ($mt < 0 ? 'D' : 'C') . $sep;
322   - print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
323   - print dol_trunc($val["description"], 32) . $sep;
324   - print $val["ref"];
325   - print "\n";
  317 + if (is_array($mt) && count($mt)>0 && empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  318 + foreach($mt as $lineid=>$amountline) {
  319 + if ($amountline) {
  320 + print $date . $sep;
  321 + print $conf->global->ACCOUNTINGEX_SELL_JOURNAL . $sep;
  322 + print length_accountg(html_entity_decode($k)) . $sep;
  323 + print $sep;
  324 + print ($amountline < 0 ? 'D' : 'C') . $sep;
  325 + print ($amountline <= 0 ? price(- $amountline) : $amountline) . $sep;
  326 + print dol_trunc($val["description"][$lineid], 32) . $sep;
  327 + print $val["ref"];
  328 + print "\n";
  329 + }
  330 + }
  331 + } else {
  332 + if ($mt) {
  333 + print $date . $sep;
  334 + print $conf->global->ACCOUNTINGEX_SELL_JOURNAL . $sep;
  335 + print length_accountg(html_entity_decode($k)) . $sep;
  336 + print $sep;
  337 + print ($mt < 0 ? 'D' : 'C') . $sep;
  338 + print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
  339 + print dol_trunc($val["description"], 32) . $sep;
  340 + print $val["ref"];
  341 + print "\n";
  342 + }
326 343 }
327 344 }
328 345 // TVA
... ... @@ -360,14 +377,28 @@ if ($action == &#39;export_csv&#39;) {
360 377  
361 378 // Product / Service
362 379 foreach ( $tabht[$key] as $k => $mt ) {
363   - if ($mt) {
364   - print '"' . $date . '"' . $sep;
365   - print '"' . $val["ref"] . '"' . $sep;
366   - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
367   - print '"' . dol_trunc($val["description"], 32) . '"' . $sep;
368   - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
369   - print '"' . ($mt >= 0 ? price($mt) : '') . '"';
370   - print "\n";
  380 + if (is_array($mt) && count($mt)>0 && empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  381 + foreach($mt as $lineid=>$amountline) {
  382 + if ($amountline) {
  383 + print '"' . $date . '"' . $sep;
  384 + print '"' . $val["ref"] . '"' . $sep;
  385 + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
  386 + print '"' . dol_trunc($val["description"][$lineid], 32) . '"' . $sep;
  387 + print '"' . ($amountline < 0 ? price(- $amountline) : '') . '"' . $sep;
  388 + print '"' . ($amountline >= 0 ? price($amountline) : '') . '"';
  389 + print "\n";
  390 + }
  391 + }
  392 + } else {
  393 + if ($mt) {
  394 + print '"' . $date . '"' . $sep;
  395 + print '"' . $val["ref"] . '"' . $sep;
  396 + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
  397 + print '"' . dol_trunc($val["description"], 32) . '"' . $sep;
  398 + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
  399 + print '"' . ($mt >= 0 ? price($mt) : '') . '"';
  400 + print "\n";
  401 + }
371 402 }
372 403 }
373 404  
... ... @@ -452,7 +483,7 @@ if ($action == &#39;export_csv&#39;) {
452 483 $invoicestatic->ref = $val["ref"];
453 484 $invoicestatic->type = $val["type"];
454 485  
455   - $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
  486 + $invoicestatic->description = $val["description"];
456 487  
457 488 $date = dol_print_date($db->jdate($val["date"]), 'day');
458 489  
... ... @@ -476,27 +507,33 @@ if ($action == &#39;export_csv&#39;) {
476 507  
477 508 // Product / Service
478 509 foreach ( $tabht[$key] as $k => $mt ) {
479   - if ($mt) {
480   - print "<tr " . $bc[$var] . ">";
481   - // print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
482   - print "<td>" . $date . "</td>";
483   - print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
484   - print "<td>" . length_accountg($k) . "</td>";
485   -
486   - if (!empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
487   - $compte = new AccountingAccount($db);
488   - if ($compte->fetch(null, $k))
489   - {
490   - print "<td>" . $compte->label . "</td>";
491 510  
492   - } else {
493   - print "<td>" . $invoicestatic->description . "</td>";
494   - }
495   -
  511 + if (is_array($mt) && count($mt) > 0 && empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  512 + foreach ( $mt as $ligneid => $line_mt ) {
  513 + if ($mt) {
  514 + print "<tr " . $bc[$var] . ">";
  515 + // print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
  516 + print "<td>" . $date . "</td>";
  517 + print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
  518 + print "<td>" . length_accountg($k) . "</td>";
  519 + print "<td>" . html_entity_decode(dol_trunc($invoicestatic->description[$ligneid])) . "</td>";
  520 + print "<td align='right'>" . ($line_mt < 0 ? price(- $line_mt) : '') . "</td>";
  521 + print "<td align='right'>" . ($line_mt >= 0 ? price($line_mt) : '') . "</td>";
  522 + print "</tr>";
  523 + }
  524 + }
  525 + } else {
  526 + if ($mt) {
  527 + print "<tr " . $bc[$var] . ">";
  528 + // print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
  529 + print "<td>" . $date . "</td>";
  530 + print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
  531 + print "<td>" . length_accountg($k) . "</td>";
  532 + print "<td>" . html_entity_decode(dol_trunc($invoicestatic->description)) . "</td>";
  533 + print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
  534 + print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
  535 + print "</tr>";
496 536 }
497   - print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
498   - print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
499   - print "</tr>";
500 537 }
501 538 }
502 539  
... ...
accountingex/langs/en_US/accountingex.lang
... ... @@ -171,4 +171,6 @@ CreateMvts=Create a movement
171 171  
172 172 customer_invoice=Customer invoice
173 173 supplier_invoice=Supplier invoice
174   -GroupByAccount=Display account number (else product label)
175 174 \ No newline at end of file
  175 +GroupByAccount=Group invoice record
  176 +
  177 +ACCOUNTINGEX_EXP_DATE=Format export date
176 178 \ No newline at end of file
... ...
accountingex/langs/es_ES/accountingex.lang
... ... @@ -173,4 +173,6 @@ CreateMvts=Crear movimiento
173 173  
174 174 customer_invoice=Factura a cliente
175 175 supplier_invoice=Factura de proveedor
176   -GroupByAccount=Display account number (else product label)
177 176 \ No newline at end of file
  177 +GroupByAccount=Group invoice line
  178 +
  179 +ACCOUNTINGEX_EXP_DATE=Format export date
178 180 \ No newline at end of file
... ...
accountingex/langs/fr_FR/accountingex.lang
... ... @@ -171,4 +171,6 @@ CreateMvts=Créer un mouvement
171 171  
172 172 customer_invoice=Facture client
173 173 supplier_invoice=Facture fournisseur
174   -GroupByAccount=Afficher le libélé du compte (sinon libelle produit)
175 174 \ No newline at end of file
  175 +GroupByAccount=Grouper les écritures de compte
  176 +
  177 +ACCOUNTINGEX_EXP_DATE=Format de la date d'export
176 178 \ No newline at end of file
... ...