Commit 1367143761172f1bcfd0e3c2913b240e88fc8b48

Authored by Darkjeff
1 parent c30077bd
Exists in 3.5 and in 1 other branch 3.6

purchase journal grouping account

groupage degroupage des comptes pour le journal achat
(attention encore a debuggé, probleme montant)
Showing 1 changed file with 54 additions and 8 deletions   Show diff stats
accountingex/journal/purchasesjournal.php
... ... @@ -142,19 +142,47 @@ if ($result) {
142 142 $compta_prod = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT)) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef");
143 143 }
144 144 $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
145   -
  145 + // la ligne facture
146 146 $tabfac[$obj->rowid]["date"] = $obj->df;
147 147 $tabfac[$obj->rowid]["ref"] = $obj->ref;
148 148 $tabfac[$obj->rowid]["type"] = $obj->type;
149 149 if (!empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
150   - $tabfac[$obj->rowid]["description"] = $obj->label_compte;
151   - } else {
  150 + $compte = new AccountingAccount($db);
  151 + $resultcompte=$compte->fetch($obj->fk_compte);
  152 +
  153 + if ($resultcompte) {
152 154 $tabfac[$obj->rowid]["description"] = $obj->description;
  155 + } }else {
  156 + $tabfac[$obj->rowid]["description"][$obj->fdid] = $obj->description;
153 157 }
154 158 //$tabfac[$obj->rowid]["description"] = $obj->description;
155 159 $tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid;
  160 + if (! isset($tabttc[$obj->rowid][$compta_soc]))
  161 + $tabttc[$obj->rowid][$compta_soc] = 0;
  162 +
  163 + if (!empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  164 + if (! isset($tabht[$obj->rowid][$compta_prod])) {
  165 + $tabht[$obj->rowid][$compta_prod] = 0;
  166 + }
  167 + } else {
  168 + if (! isset($tabht[$obj->rowid][$compta_prod])) {
  169 + $tabht[$obj->rowid][$compta_prod][$obj->fdid] = 0;
  170 + }
  171 + }
  172 + /*if (! isset($tabht[$obj->rowid][$compta_prod])) {
  173 + $tabht[$obj->rowid][$compta_prod] = 0;
  174 + }*/
  175 +
  176 + if (! isset($tabtva[$obj->rowid][$compta_tva]))
  177 + $tabtva[$obj->rowid][$compta_tva] = 0;
156 178 $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
157   - $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
  179 +
  180 + if (!empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  181 + $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
  182 + } else {
  183 +
  184 + $tabht[$obj->rowid][$compta_prod] [$obj->fdid]= $obj->total_ht;
  185 + }
158 186 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
159 187 $tabcompany[$obj->rowid] = array (
160 188 'id' => $obj->socid,
... ... @@ -164,7 +192,7 @@ if ($result) {
164 192  
165 193 $i ++;
166 194 }
167   -} else {
  195 + }else {
168 196 dol_print_error($db);
169 197 }
170 198  
... ... @@ -424,23 +452,41 @@ if ($action == 'export_csv') {
424 452 $invoicestatic->id = $key;
425 453 $invoicestatic->ref = $val["ref"];
426 454 $invoicestatic->type = $val["type"];
427   - $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
  455 + $invoicestatic->description = $val["description"];
428 456  
429 457 $date = dol_print_date($db->jdate($val["date"]), 'day');
430 458  
431 459 // Product / Service
432 460 foreach ( $tabht[$key] as $k => $mt ) {
433   - if ($mt) {
  461 + if (is_array($mt) && count($mt) > 0 && empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  462 + foreach ( $mt as $ligneid => $line_mt ) {
  463 + if ($mt) {
434 464 print "<tr " . $bc[$var] . " >";
435 465 // print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
436 466 print "<td>" . $date . "</td>";
437 467 print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
438 468 print "<td>" . length_accountg($k) . "</td>";
439   - print "<td>" . $invoicestatic->description . "</td>";
  469 + print "<td>" . html_entity_decode(dol_trunc($invoicestatic->description[$ligneid])) . "</td>";
440 470 print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
441 471 print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
442 472 print "</tr>";
443 473 }
  474 + }
  475 + } else {
  476 + if ($mt) {
  477 + $compte = new AccountingAccount($db);
  478 + $compte->fetch(null, $k) ;
  479 + print "<tr " . $bc[$var] . " >";
  480 + // print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
  481 + print "<td>" . $date . "</td>";
  482 + print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
  483 + print "<td>" . length_accountg($k) . "</td>";
  484 + print "<td>" . html_entity_decode(dol_trunc($compte->label)) . "</td>";
  485 + print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
  486 + print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
  487 + print "</tr>";
  488 + }
  489 + }
444 490 }
445 491 // VAT
446 492 // var_dump($tabtva);
... ...