dolibarr  9.0.0
sellsjournal.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
4  * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
7  * Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@zendsi.com>
8  * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
9  * Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
10  * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
11  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <http://www.gnu.org/licenses/>.
25  */
26 
33 require '../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
35 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
37 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
38 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
39 require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
40 require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php';
41 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
42 
43 // Load translation files required by the page
44 $langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors"));
45 
46 $id_journal = GETPOST('id_journal', 'int');
47 $action = GETPOST('action','aZ09');
48 
49 $date_startmonth = GETPOST('date_startmonth');
50 $date_startday = GETPOST('date_startday');
51 $date_startyear = GETPOST('date_startyear');
52 $date_endmonth = GETPOST('date_endmonth');
53 $date_endday = GETPOST('date_endday');
54 $date_endyear = GETPOST('date_endyear');
55 $in_bookkeeping = GETPOST('in_bookkeeping');
56 if ($in_bookkeeping == '') $in_bookkeeping = 'notyet';
57 
58 $now = dol_now();
59 
60 // Security check
61 if ($user->societe_id > 0)
63 
64 $hookmanager->initHooks(array('sellsjournal'));
65 $parameters=array();
66 
67 /*
68  * Actions
69  */
70 
71 $reshook=$hookmanager->executeHooks('doActions',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks
72 
73 $accountingaccount = new AccountingAccount($db);
74 
75 // Get informations of journal
76 $accountingjournalstatic = new AccountingJournal($db);
77 $accountingjournalstatic->fetch($id_journal);
78 $journal = $accountingjournalstatic->code;
79 $journal_label = $accountingjournalstatic->label;
80 
81 $year_current = strftime("%Y", dol_now());
82 $pastmonth = strftime("%m", dol_now()) - 1;
83 $pastmonthyear = $year_current;
84 if ($pastmonth == 0) {
85  $pastmonth = 12;
86  $pastmonthyear --;
87 }
88 
89 $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
90 $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
91 
92 if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
93 {
94  $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
95  $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
96 }
97 
98 $idpays = $mysoc->country_id;
99 
100 $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code,";
101 $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,";
102 $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
103 $sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
104 $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
105 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
106 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
107 $sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
108 $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
109 $sql .= " WHERE fd.fk_code_ventilation > 0";
110 $sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy, we use source object sharing
111 $sql .= " AND f.fk_statut > 0";
112 if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common setup
113  $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
114 } else {
115  $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
116 }
117 $sql .= " AND fd.product_type IN (0,1)";
118 if ($date_start && $date_end)
119  $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
120 // Already in bookkeeping or not
121 if ($in_bookkeeping == 'already')
122 {
123  $sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
124  // $sql .= " AND fd.rowid IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account
125 }
126 if ($in_bookkeeping == 'notyet')
127 {
128  $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
129 // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account
130 }
131 $sql .= " ORDER BY f.datef";
132 //print $sql;
133 
134 dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
135 $result = $db->query($sql);
136 if ($result) {
137  $tabfac = array ();
138  $tabht = array ();
139  $tabtva = array ();
140  $def_tva = array ();
141  $tabttc = array ();
142  $tablocaltax1 = array ();
143  $tablocaltax2 = array ();
144  $tabcompany = array ();
145 
146  $num = $db->num_rows($result);
147 
148  // Variables
149  $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined';
150  $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined';
151 
152  $i = 0;
153  while ( $i < $num ) {
154  $obj = $db->fetch_object($result);
155 
156  // Controls
157  $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
158 
159  $compta_prod = $obj->compte;
160  if (empty($compta_prod)) {
161  if ($obj->product_type == 0)
162  $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
163  else
164  $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
165  }
166 
167  $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
168  $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
169  $compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
170  $compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
171 
172  // Define array to display all VAT rates that use this accounting account $compta_tva
173  if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
174  {
175  $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
176  }
177 
178  $line = new FactureLigne($db);
179  $line->fetch($obj->fdid);
180 
181  // Situation invoices handling
182  $prev_progress = $line->get_prev_progress($obj->rowid);
183 
184  if ($obj->type == Facture::TYPE_SITUATION) {
185  // Avoid divide by 0
186  if ($obj->situation_percent == 0) {
187  $situation_ratio = 0;
188  } else {
189  $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
190  }
191  } else {
192  $situation_ratio = 1;
193  }
194 
195  // Invoice lines
196  $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
197  $tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr);
198  $tabfac[$obj->rowid]["ref"] = $obj->facnumber;
199  $tabfac[$obj->rowid]["type"] = $obj->type;
200  $tabfac[$obj->rowid]["description"] = $obj->label_compte;
201  $tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
202  //$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
203 
204  // Avoid warnings
205  if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
206  if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
207  if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
208  if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
209  if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
210 
211  $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
212  $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
213  if (empty($line->tva_npr)) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR
214  $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
215  $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
216  $tabcompany[$obj->rowid] = array (
217  'id' => $obj->socid,
218  'name' => $obj->name,
219  'code_client' => $obj->code_client,
220  'code_compta' => $compta_soc
221  );
222 
223  $i ++;
224  }
225 } else {
226  dol_print_error($db);
227 }
228 
229 $errorforinvoice = array();
230 
231 // Loop in invoices to detect lines with not binding lines
232 foreach ($tabfac as $key => $val) { // Loop on each invoice
233  $sql = "SELECT COUNT(fd.rowid) as nb";
234  $sql.= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
235  $sql.= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
236  $sql.= " AND fd.total_ttc <> 0 AND fk_facture = ".$key;
237  $resql=$db->query($sql);
238  if ($resql)
239  {
240  $obj = $db->fetch_object($resql);
241  if ($obj->nb > 0)
242  {
243  $errorforinvoice[$key]='somelinesarenotbound';
244  }
245  }
246  else dol_print_error($db);
247 }
248 //var_dump($errorforinvoice);exit;
249 
250 
251 // Bookkeeping Write
252 if ($action == 'writebookkeeping') {
253  $now = dol_now();
254  $error = 0;
255 
256  $companystatic = new Societe($db);
257  $invoicestatic = new Facture($db);
258 
259  foreach ($tabfac as $key => $val) { // Loop on each invoice
260 
261  $errorforline = 0;
262 
263  $totalcredit = 0;
264  $totaldebit = 0;
265 
266  $db->begin();
267 
268  $companystatic->id = $tabcompany[$key]['id'];
269  $companystatic->name = $tabcompany[$key]['name'];
270  $companystatic->code_compta = $tabcompany[$key]['code_compta'];
271  $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
272  $companystatic->code_client = $tabcompany[$key]['code_client'];
273  $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
274  $companystatic->client = 3;
275 
276  $invoicestatic->id = $key;
277  $invoicestatic->ref = (string) $val["ref"];
278  $invoicestatic->type = $val["type"];
279  $invoicestatic->close_code = $val["close_code"];
280 
281  $date = dol_print_date($val["date"], 'day');
282 
283  // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
284  $replacedinvoice = 0;
285  if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
286  {
287  $replacedinvoice = 1;
288  $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
289  if ($alreadydispatched) $replacedinvoice = 2;
290  }
291 
292  // If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
293  if ($replacedinvoice == 1)
294  {
295  $db->rollback();
296  continue;
297  }
298 
299  // Error if some lines are not binded/ready to be journalized
300  if ($errorforinvoice[$key] == 'somelinesarenotbound')
301  {
302  $error++;
303  $errorforline++;
304  setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
305  }
306 
307  // Thirdparty
308  if (! $errorforline)
309  {
310  foreach ( $tabttc[$key] as $k => $mt ) {
311  //if ($mt) {
312  $bookkeeping = new BookKeeping($db);
313  $bookkeeping->doc_date = $val["date"];
314  $bookkeeping->date_lim_reglement = $val["datereg"];
315  $bookkeeping->doc_ref = $val["ref"];
316  $bookkeeping->date_create = $now;
317  $bookkeeping->doc_type = 'customer_invoice';
318  $bookkeeping->fk_doc = $key;
319  $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
320  $bookkeeping->thirdparty_code = $companystatic->code_client;
321  $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
322  $bookkeeping->subledger_label = $tabcompany[$key]['name'];
323  $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
324 
325  $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
326  $bookkeeping->label_compte = $accountingaccount->label;
327 
328  $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount");
329  $bookkeeping->montant = $mt;
330  $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
331  $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
332  $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
333  $bookkeeping->code_journal = $journal;
334  $bookkeeping->journal_label = $journal_label;
335  $bookkeeping->fk_user_author = $user->id;
336  $bookkeeping->entity = $conf->entity;
337 
338  $totaldebit += $bookkeeping->debit;
339  $totalcredit += $bookkeeping->credit;
340 
341  $result = $bookkeeping->create($user);
342  if ($result < 0) {
343  if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
344  {
345  $error++;
346  $errorforline++;
347  $errorforinvoice[$key]='alreadyjournalized';
348  //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
349  }
350  else
351  {
352  $error++;
353  $errorforline++;
354  $errorforinvoice[$key]='other';
355  setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
356  }
357  }
358  //}
359  }
360  }
361 
362  // Product / Service
363  if (! $errorforline)
364  {
365  foreach ( $tabht[$key] as $k => $mt ) {
366  //if ($mt) {
367  // get compte id and label
368  if ($accountingaccount->fetch(null, $k, true)) {
369  $bookkeeping = new BookKeeping($db);
370  $bookkeeping->doc_date = $val["date"];
371  $bookkeeping->date_lim_reglement = $val["datereg"];
372  $bookkeeping->doc_ref = $val["ref"];
373  $bookkeeping->date_create = $now;
374  $bookkeeping->doc_type = 'customer_invoice';
375  $bookkeeping->fk_doc = $key;
376  $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
377  $bookkeeping->thirdparty_code = $companystatic->code_client;
378  $bookkeeping->subledger_account = '';
379  $bookkeeping->subledger_label = '';
380  $bookkeeping->numero_compte = $k;
381  $bookkeeping->label_compte = $accountingaccount->label;
382  $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label;
383  $bookkeeping->montant = $mt;
384  $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
385  $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
386  $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
387  $bookkeeping->code_journal = $journal;
388  $bookkeeping->journal_label = $journal_label;
389  $bookkeeping->fk_user_author = $user->id;
390  $bookkeeping->entity = $conf->entity;
391 
392  $totaldebit += $bookkeeping->debit;
393  $totalcredit += $bookkeeping->credit;
394 
395  $result = $bookkeeping->create($user);
396  if ($result < 0) {
397  if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
398  {
399  $error++;
400  $errorforline++;
401  $errorforinvoice[$key]='alreadyjournalized';
402  //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
403  }
404  else
405  {
406  $error++;
407  $errorforline++;
408  $errorforinvoice[$key]='other';
409  setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
410  }
411  }
412  }
413  //}
414  }
415  }
416 
417  // VAT
418  if (! $errorforline)
419  {
420  $listoftax=array(0, 1, 2);
421  foreach($listoftax as $numtax)
422  {
423  $arrayofvat = $tabtva;
424  if ($numtax == 1) $arrayofvat = $tablocaltax1;
425  if ($numtax == 2) $arrayofvat = $tablocaltax2;
426 
427  foreach ( $arrayofvat[$key] as $k => $mt ) {
428  if ($mt) {
429  $bookkeeping = new BookKeeping($db);
430  $bookkeeping->doc_date = $val["date"];
431  $bookkeeping->date_lim_reglement = $val["datereg"];
432  $bookkeeping->doc_ref = $val["ref"];
433  $bookkeeping->date_create = $now;
434  $bookkeeping->doc_type = 'customer_invoice';
435  $bookkeeping->fk_doc = $key;
436  $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
437  $bookkeeping->thirdparty_code = $companystatic->code_client;
438  $bookkeeping->subledger_account = '';
439  $bookkeeping->subledger_label = '';
440  $bookkeeping->numero_compte = $k;
441 
442  $accountingaccount->fetch($k, null, true);
443  $bookkeeping->label_compte = $accountingaccount->label;
444 
445  $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'');
446  $bookkeeping->montant = $mt;
447  $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
448  $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
449  $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
450  $bookkeeping->code_journal = $journal;
451  $bookkeeping->journal_label = $journal_label;
452  $bookkeeping->fk_user_author = $user->id;
453  $bookkeeping->entity = $conf->entity;
454 
455  $totaldebit += $bookkeeping->debit;
456  $totalcredit += $bookkeeping->credit;
457 
458  $result = $bookkeeping->create($user);
459  if ($result < 0) {
460  if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
461  {
462  $error++;
463  $errorforline++;
464  $errorforinvoice[$key]='alreadyjournalized';
465  //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
466  }
467  else
468  {
469  $error++;
470  $errorforline++;
471  $errorforinvoice[$key]='other';
472  setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
473  }
474  }
475  }
476  }
477  }
478  }
479 
480  // Protection against a bug on lines before
481  if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit)))
482  {
483  $error++;
484  $errorforline++;
485  $errorforinvoice[$key]='amountsnotbalanced';
486  setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
487  }
488 
489  if (! $errorforline)
490  {
491  $db->commit();
492  }
493  else
494  {
495  $db->rollback();
496 
497  if ($error >= 10)
498  {
499  setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
500  break; // Break in the foreach
501  }
502  }
503  }
504 
505  $tabpay = $tabfac;
506 
507  if (empty($error) && count($tabpay) > 0) {
508  setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
509  }
510  elseif (count($tabpay) == $error)
511  {
512  setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
513  }
514  else
515  {
516  setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
517  }
518 
519  $action='';
520 
521  // Must reload data, so we make a redirect
522  if (count($tabpay) != $error)
523  {
524  $param='id_journal='.$id_journal;
525  $param.='&date_startday='.$date_startday;
526  $param.='&date_startmonth='.$date_startmonth;
527  $param.='&date_startyear='.$date_startyear;
528  $param.='&date_endday='.$date_endday;
529  $param.='&date_endmonth='.$date_endmonth;
530  $param.='&date_endyear='.$date_endyear;
531  $param.='&in_bookkeeping='.$in_bookkeeping;
532  header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
533  exit;
534  }
535 }
536 
537 
538 
539 /*
540  * View
541  */
542 
543 $form = new Form($db);
544 
545 // Export
546 if ($action == 'exportcsv') { // ISO and not UTF8 !
547  $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
548 
549  $filename = 'journal';
550  $type_export = 'journal';
551  include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
552 
553  $companystatic = new Client($db);
554  $invoicestatic = new Facture($db);
555 
556  foreach ( $tabfac as $key => $val )
557  {
558  $companystatic->id = $tabcompany[$key]['id'];
559  $companystatic->name = $tabcompany[$key]['name'];
560  $companystatic->code_compta = $tabcompany[$key]['code_compta'];
561  $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
562  $companystatic->code_client = $tabcompany[$key]['code_client'];
563  $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
564  $companystatic->client = 3;
565 
566  $invoicestatic->id = $key;
567  $invoicestatic->ref = (string) $val["ref"];
568  $invoicestatic->type = $val["type"];
569  $invoicestatic->close_code = $val["close_code"];
570 
571  $date = dol_print_date($val["date"], 'day');
572 
573  // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
574  $replacedinvoice = 0;
575  if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
576  {
577  $replacedinvoice = 1;
578  $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
579  if ($alreadydispatched) $replacedinvoice = 2;
580  }
581 
582  // If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
583  if ($replacedinvoice == 1)
584  {
585  continue;
586  }
587 
588  // Third party
589  foreach ($tabttc[$key] as $k => $mt) {
590  //if ($mt) {
591  print '"' . $key . '"' . $sep;
592  print '"' . $date . '"' . $sep;
593  print '"' . $val["ref"] . '"' . $sep;
594  print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
595  print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
596  print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
597  print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
598  print '"' . $langs->trans("Thirdparty") . '"' . $sep;
599  print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Thirdparty") . '"' . $sep;
600  print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
601  print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
602  print '"' . $journal . '"';
603  print "\n";
604  //}
605  }
606 
607  // Product / Service
608  foreach ($tabht[$key] as $k => $mt) {
609  $accountingaccount = new AccountingAccount($db);
610  $accountingaccount->fetch(null, $k, true);
611  //if ($mt) {
612  print '"' . $key . '"' . $sep;
613  print '"' . $date . '"' . $sep;
614  print '"' . $val["ref"] . '"' . $sep;
615  print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
616  print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
617  print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
618  print '""' . $sep;
619  print '"' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
620  print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
621  print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
622  print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
623  print '"' . $journal . '"';
624  print "\n";
625  //}
626  }
627 
628  // VAT
629  $listoftax = array(0, 1, 2);
630  foreach ($listoftax as $numtax) {
631  $arrayofvat = $tabtva;
632  if ($numtax == 1) $arrayofvat = $tablocaltax1;
633  if ($numtax == 2) $arrayofvat = $tablocaltax2;
634 
635  foreach ($arrayofvat[$key] as $k => $mt) {
636  if ($mt) {
637  print '"' . $key . '"' . $sep;
638  print '"' . $date . '"' . $sep;
639  print '"' . $val["ref"] . '"' . $sep;
640  print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
641  print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
642  print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
643  print '""' . $sep;
644  print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . ' %"' . $sep;
645  print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
646  print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
647  print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
648  print '"' . $journal . '"';
649  print "\n";
650  }
651  }
652  }
653  }
654 }
655 
656 
657 
658 if (empty($action) || $action == 'view') {
659 
660  llxHeader('', $langs->trans("SellsJournal"));
661 
662  $nom = $langs->trans("SellsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0,1,1,'',1);
663  $nomlink = '';
664  $periodlink = '';
665  $exportlink = '';
666  $builddate=dol_now();
667  $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
668  if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
669  $description .= $langs->trans("DepositsAreNotIncluded");
670  else
671  $description .= $langs->trans("DepositsAreIncluded");
672 
673  $listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
674  $period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0);
675  $period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
676 
677  $varlink = 'id_journal=' . $id_journal;
678 
679  journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
680 
681  // Button to write into Ledger
682  if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
683  print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
684  print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
685  }
686  print '<div class="tabsAction tabsActionNoBottom">';
687  if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
688  if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
689  print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
690  }
691  else {
692  if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
693  else print '<a href="#" class="butActionRefused" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>';
694  }
695  print '</div>';
696 
697  // TODO Avoid using js. We can use a direct link with $param
698  print '
699  <script type="text/javascript">
700  function launch_export() {
701  $("div.fiche form input[name=\"action\"]").val("exportcsv");
702  $("div.fiche form input[type=\"submit\"]").click();
703  $("div.fiche form input[name=\"action\"]").val("");
704  }
705  function writebookkeeping() {
706  console.log("click on writebookkeeping");
707  $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
708  $("div.fiche form input[type=\"submit\"]").click();
709  $("div.fiche form input[name=\"action\"]").val("");
710  }
711  </script>';
712 
713  /*
714  * Show result array
715  */
716  print '<br>';
717 
718  $i = 0;
719  print '<div class="div-table-responsive">';
720  print "<table class=\"noborder\" width=\"100%\">";
721  print "<tr class=\"liste_titre\">";
722  print "<td></td>";
723  print "<td>" . $langs->trans("Date") . "</td>";
724  print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
725  print "<td>" . $langs->trans("AccountAccounting") . "</td>";
726  print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
727  print "<td>" . $langs->trans("LabelOperation") . "</td>";
728  print "<td align='right'>" . $langs->trans("Debit") . "</td>";
729  print "<td align='right'>" . $langs->trans("Credit") . "</td>";
730  print "</tr>\n";
731 
732  $r = '';
733 
734  $companystatic = new Client($db);
735  $invoicestatic = new Facture($db);
736 
737  foreach ( $tabfac as $key => $val )
738  {
739  $companystatic->id = $tabcompany[$key]['id'];
740  $companystatic->name = $tabcompany[$key]['name'];
741  $companystatic->code_compta = $tabcompany[$key]['code_compta'];
742  $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
743  $companystatic->code_client = $tabcompany[$key]['code_client'];
744  $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
745  $companystatic->client = 3;
746 
747  $invoicestatic->id = $key;
748  $invoicestatic->ref = (string) $val["ref"];
749  $invoicestatic->type = $val["type"];
750  $invoicestatic->close_code = $val["close_code"];
751 
752  $date = dol_print_date($val["date"], 'day');
753 
754  // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
755  $replacedinvoice = 0;
756  if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
757  {
758  $replacedinvoice = 1;
759  $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
760  if ($alreadydispatched) $replacedinvoice = 2;
761  }
762 
763  // If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
764  if ($replacedinvoice == 1)
765  {
766  print '<tr class="oddeven">';
767  print "<td><!-- Replaced invoice --></td>";
768  print "<td>" . $date . "</td>";
769  print "<td><strike>" . $invoicestatic->getNomUrl(1) . "</strike></td>";
770  // Account
771  print "<td>";
772  print $langs->trans("Replaced");
773  print '</td>';
774  // Subledger account
775  print "<td>";
776  print '</td>';
777  print "<td>";
778  print "</td>";
779  print '<td align="right"></td>';
780  print '<td align="right"></td>';
781  print "</tr>";
782 
783  continue;
784  }
785  if ($errorforinvoice[$key] == 'somelinesarenotbound')
786  {
787  print '<tr class="oddeven">';
788  print "<td><!-- Some lines are not bound --></td>";
789  print "<td>" . $date . "</td>";
790  print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
791  // Account
792  print "<td>";
793  print '<span class="error">'.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).'</span>';
794  print '</td>';
795  // Subledger account
796  print "<td>";
797  print '</td>';
798  print "<td>";
799  print "</td>";
800  print '<td align="right"></td>';
801  print '<td align="right"></td>';
802  print "</tr>";
803  }
804 
805  // Third party
806  foreach ($tabttc[$key] as $k => $mt)
807  {
808  //if ($mt) {
809  print '<tr class="oddeven">';
810  print "<td><!-- Thirdparty --></td>";
811  print "<td>" . $date . "</td>";
812  print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
813  // Account
814  print "<td>";
815  $accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
816  if (empty($accountoshow) || $accountoshow == 'NotDefined')
817  {
818  print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
819  }
820  else print $accountoshow;
821  print '</td>';
822  // Subledger account
823  print "<td>";
824  $accountoshow = length_accounta($k);
825  if (empty($accountoshow) || $accountoshow == 'NotDefined')
826  {
827  print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
828  }
829  else print $accountoshow;
830  print '</td>';
831  print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
832  print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
833  print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
834  print "</tr>";
835  //}
836  }
837 
838  // Product / Service
839  foreach ($tabht[$key] as $k => $mt)
840  {
841  $accountingaccount = new AccountingAccount($db);
842  $accountingaccount->fetch(null, $k, true);
843 
844  //if ($mt) {
845  print '<tr class="oddeven">';
846  print "<td><!-- Product --></td>";
847  print "<td>" . $date . "</td>";
848  print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
849  // Account
850  print "<td>";
851  $accountoshow = length_accountg($k);
852  if (empty($accountoshow) || $accountoshow == 'NotDefined')
853  {
854  print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>';
855  }
856  else print $accountoshow;
857  print "</td>";
858  // Subledger account
859  print "<td>";
860  print '</td>';
861  $companystatic->id = $tabcompany[$key]['id'];
862  $companystatic->name = $tabcompany[$key]['name'];
863  print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>";
864  print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
865  print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
866  print "</tr>";
867  //}
868  }
869 
870  // VAT
871  $listoftax = array(0, 1, 2);
872  foreach ($listoftax as $numtax)
873  {
874  $arrayofvat = $tabtva;
875  if ($numtax == 1) $arrayofvat = $tablocaltax1;
876  if ($numtax == 2) $arrayofvat = $tablocaltax2;
877 
878  foreach ( $arrayofvat[$key] as $k => $mt ) {
879  if ($mt) {
880  print '<tr class="oddeven">';
881  print "<td><!-- VAT --></td>";
882  print "<td>" . $date . "</td>";
883  print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
884  // Account
885  print "<td>";
886  $accountoshow = length_accountg($k);
887  if (empty($accountoshow) || $accountoshow == 'NotDefined')
888  {
889  print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Sale").')'.'</span>';
890  }
891  else print $accountoshow;
892  print "</td>";
893  // Subledger account
894  print "<td>";
895  print '</td>';
896  print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
897  print "</td>";
898  print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
899  print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
900  print "</tr>";
901  }
902  }
903  }
904  }
905 
906  print "</table>";
907  print '</div>';
908 
909  // End of page
910  llxFooter();
911 }
912 
913 $db->close();
img_warning($titlealt='default', $moreatt='')
Show warning logo.
llxFooter()
Empty footer.
Definition: wrapper.php:56
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
const TYPE_STANDARD
Standard invoice.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage customers or prospects.
const TYPE_REPLACEMENT
Replacement invoice.
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get vat main information from Id.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:453
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
const TYPE_SITUATION
Situation invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage Ledger (General Ledger and Subledger)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting a parameter.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Class to manage third parties objects (customers, suppliers, prospects...)
llxHeader()
Empty header.
Definition: wrapper.php:44
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
if(GETPOST('cancel', 'alpha')) if(! GETPOST( 'confirmmassaction', 'alpha') &&$massaction !='presend' &&$massaction !='confirm_presend')
Draft customers invoices.
Definition: list.php:156
dol_now($mode='gmt')
Return date for now.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
const TYPE_DEPOSIT
Deposit invoice.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:467
Class to manage accounting accounts.
Class to manage accounting accounts.
Class to manage invoices.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a VAT report.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
Class to manage invoice lines.