dolibarr  13.0.2
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@open-dsi.fr>
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 <https://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->socid > 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 $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
82 $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
83 
84 if (empty($date_startmonth) || empty($date_endmonth))
85 {
86  // Period by default on transfer
87  $dates = getDefaultDatesForTransfer();
88  $date_start = $dates['date_start'];
89  $date_end = $dates['date_end'];
90  $pastmonthyear = $dates['pastmonthyear'];
91  $pastmonth = $dates['pastmonth'];
92 }
93 
94 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
95 {
96  $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
97  $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
98 }
99 
100 $sql = "SELECT f.rowid, f.ref, 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('invoice', 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 // Define begin binding date
121 if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
122  $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
123 }
124 // Already in bookkeeping or not
125 if ($in_bookkeeping == 'already')
126 {
127  $sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
128  // $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
129 }
130 if ($in_bookkeeping == 'notyet')
131 {
132  $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
133  // $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
134 }
135 $sql .= " ORDER BY f.datef";
136 //print $sql;
137 
138 dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
139 $result = $db->query($sql);
140 if ($result) {
141  $tabfac = array();
142  $tabht = array();
143  $tabtva = array();
144  $def_tva = array();
145  $tabttc = array();
146  $tablocaltax1 = array();
147  $tablocaltax2 = array();
148  $tabcompany = array();
149 
150  $num = $db->num_rows($result);
151 
152  // Variables
153  $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "")) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined';
154  $cpttva = (!empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined';
155 
156  $i = 0;
157  while ($i < $num) {
158  $obj = $db->fetch_object($result);
159 
160  // Controls
161  $compta_soc = (!empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
162 
163  $compta_prod = $obj->compte;
164  if (empty($compta_prod)) {
165  if ($obj->product_type == 0)
166  $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
167  else {
168  $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
169  }
170  }
171 
172  $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
173  $compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
174  $compta_localtax1 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
175  $compta_localtax2 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
176 
177  // Define array to display all VAT rates that use this accounting account $compta_tva
178  if (price2num($obj->tva_tx) || !empty($obj->vat_src_code))
179  {
180  $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.')' : ''));
181  }
182 
183  $line = new FactureLigne($db);
184  $line->fetch($obj->fdid);
185 
186  // Situation invoices handling
187  $prev_progress = $line->get_prev_progress($obj->rowid);
188 
189  if ($obj->type == Facture::TYPE_SITUATION) {
190  // Avoid divide by 0
191  if ($obj->situation_percent == 0) {
192  $situation_ratio = 0;
193  } else {
194  $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
195  }
196  } else {
197  $situation_ratio = 1;
198  }
199 
200  // Invoice lines
201  $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
202  $tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr);
203  $tabfac[$obj->rowid]["ref"] = $obj->ref;
204  $tabfac[$obj->rowid]["type"] = $obj->type;
205  $tabfac[$obj->rowid]["description"] = $obj->label_compte;
206  $tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
207  //$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
208 
209  // Avoid warnings
210  if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
211  if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
212  if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
213  if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
214  if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
215 
216  $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
217  $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
218  if (empty($line->tva_npr)) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR
219  $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
220  $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
221  $tabcompany[$obj->rowid] = array(
222  'id' => $obj->socid,
223  'name' => $obj->name,
224  'code_client' => $obj->code_client,
225  'code_compta' => $compta_soc
226  );
227 
228  $i++;
229  }
230 } else {
231  dol_print_error($db);
232 }
233 
234 $errorforinvoice = array();
235 
236 // Loop in invoices to detect lines with not binding lines
237 foreach ($tabfac as $key => $val) { // Loop on each invoice
238  $sql = "SELECT COUNT(fd.rowid) as nb";
239  $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
240  $sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
241  $sql .= " AND fd.total_ttc <> 0 AND fk_facture = ".$key;
242  $resql = $db->query($sql);
243  if ($resql)
244  {
245  $obj = $db->fetch_object($resql);
246  if ($obj->nb > 0)
247  {
248  $errorforinvoice[$key] = 'somelinesarenotbound';
249  }
250  } else dol_print_error($db);
251 }
252 //var_dump($errorforinvoice);exit;
253 
254 
255 // Bookkeeping Write
256 if ($action == 'writebookkeeping') {
257  $now = dol_now();
258  $error = 0;
259 
260  $companystatic = new Societe($db);
261  $invoicestatic = new Facture($db);
262 
263  foreach ($tabfac as $key => $val) { // Loop on each invoice
264  $errorforline = 0;
265 
266  $totalcredit = 0;
267  $totaldebit = 0;
268 
269  $db->begin();
270 
271  $companystatic->id = $tabcompany[$key]['id'];
272  $companystatic->name = $tabcompany[$key]['name'];
273  $companystatic->code_compta = $tabcompany[$key]['code_compta'];
274  $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
275  $companystatic->code_client = $tabcompany[$key]['code_client'];
276  $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
277  $companystatic->client = 3;
278 
279  $invoicestatic->id = $key;
280  $invoicestatic->ref = (string) $val["ref"];
281  $invoicestatic->type = $val["type"];
282  $invoicestatic->close_code = $val["close_code"];
283 
284  $date = dol_print_date($val["date"], 'day');
285 
286  // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
287  $replacedinvoice = 0;
288  if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
289  {
290  $replacedinvoice = 1;
291  $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
292  if ($alreadydispatched) $replacedinvoice = 2;
293  }
294 
295  // 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)
296  if ($replacedinvoice == 1)
297  {
298  $db->rollback();
299  continue;
300  }
301 
302  // Error if some lines are not binded/ready to be journalized
303  if ($errorforinvoice[$key] == 'somelinesarenotbound')
304  {
305  $error++;
306  $errorforline++;
307  setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
308  }
309 
310  // Thirdparty
311  if (!$errorforline)
312  {
313  foreach ($tabttc[$key] as $k => $mt) {
314  $bookkeeping = new BookKeeping($db);
315  $bookkeeping->doc_date = $val["date"];
316  $bookkeeping->date_lim_reglement = $val["datereg"];
317  $bookkeeping->doc_ref = $val["ref"];
318  $bookkeeping->date_creation = $now;
319  $bookkeeping->doc_type = 'customer_invoice';
320  $bookkeeping->fk_doc = $key;
321  $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
322  $bookkeeping->thirdparty_code = $companystatic->code_client;
323  $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
324  $bookkeeping->subledger_label = $tabcompany[$key]['name'];
325  $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
326 
327  $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
328  $bookkeeping->label_compte = $accountingaccount->label;
329 
330  $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount");
331  $bookkeeping->montant = $mt;
332  $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
333  $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
334  $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
335  $bookkeeping->code_journal = $journal;
336  $bookkeeping->journal_label = $langs->transnoentities($journal_label);
337  $bookkeeping->fk_user_author = $user->id;
338  $bookkeeping->entity = $conf->entity;
339 
340  $totaldebit += $bookkeeping->debit;
341  $totalcredit += $bookkeeping->credit;
342 
343  $result = $bookkeeping->create($user);
344  if ($result < 0) {
345  if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
346  {
347  $error++;
348  $errorforline++;
349  $errorforinvoice[$key] = 'alreadyjournalized';
350  //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
351  } else {
352  $error++;
353  $errorforline++;
354  $errorforinvoice[$key] = 'other';
355  setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
356  }
357  }
358  }
359  }
360 
361  // Product / Service
362  if (!$errorforline)
363  {
364  foreach ($tabht[$key] as $k => $mt) {
365  // get compte id and label
366  if ($accountingaccount->fetch(null, $k, true)) {
367  $bookkeeping = new BookKeeping($db);
368  $bookkeeping->doc_date = $val["date"];
369  $bookkeeping->date_lim_reglement = $val["datereg"];
370  $bookkeeping->doc_ref = $val["ref"];
371  $bookkeeping->date_creation = $now;
372  $bookkeeping->doc_type = 'customer_invoice';
373  $bookkeeping->fk_doc = $key;
374  $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
375  $bookkeeping->thirdparty_code = $companystatic->code_client;
376  $bookkeeping->subledger_account = '';
377  $bookkeeping->subledger_label = '';
378  $bookkeeping->numero_compte = $k;
379  $bookkeeping->label_compte = $accountingaccount->label;
380  $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label;
381  $bookkeeping->montant = $mt;
382  $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
383  $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
384  $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
385  $bookkeeping->code_journal = $journal;
386  $bookkeeping->journal_label = $langs->transnoentities($journal_label);
387  $bookkeeping->fk_user_author = $user->id;
388  $bookkeeping->entity = $conf->entity;
389 
390  $totaldebit += $bookkeeping->debit;
391  $totalcredit += $bookkeeping->credit;
392 
393  $result = $bookkeeping->create($user);
394  if ($result < 0) {
395  if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
396  {
397  $error++;
398  $errorforline++;
399  $errorforinvoice[$key] = 'alreadyjournalized';
400  //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
401  } else {
402  $error++;
403  $errorforline++;
404  $errorforinvoice[$key] = 'other';
405  setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
406  }
407  }
408  }
409  }
410  }
411 
412  // VAT
413  if (!$errorforline)
414  {
415  $listoftax = array(0, 1, 2);
416  foreach ($listoftax as $numtax)
417  {
418  $arrayofvat = $tabtva;
419  if ($numtax == 1) $arrayofvat = $tablocaltax1;
420  if ($numtax == 2) $arrayofvat = $tablocaltax2;
421 
422  foreach ($arrayofvat[$key] as $k => $mt) {
423  if ($mt) {
424  $bookkeeping = new BookKeeping($db);
425  $bookkeeping->doc_date = $val["date"];
426  $bookkeeping->date_lim_reglement = $val["datereg"];
427  $bookkeeping->doc_ref = $val["ref"];
428  $bookkeeping->date_creation = $now;
429  $bookkeeping->doc_type = 'customer_invoice';
430  $bookkeeping->fk_doc = $key;
431  $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
432  $bookkeeping->thirdparty_code = $companystatic->code_client;
433  $bookkeeping->subledger_account = '';
434  $bookkeeping->subledger_label = '';
435  $bookkeeping->numero_compte = $k;
436 
437  $accountingaccount->fetch($k, null, true);
438  $bookkeeping->label_compte = $accountingaccount->label;
439 
440  $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '');
441  $bookkeeping->montant = $mt;
442  $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
443  $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
444  $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
445  $bookkeeping->code_journal = $journal;
446  $bookkeeping->journal_label = $langs->transnoentities($journal_label);
447  $bookkeeping->fk_user_author = $user->id;
448  $bookkeeping->entity = $conf->entity;
449 
450  $totaldebit += $bookkeeping->debit;
451  $totalcredit += $bookkeeping->credit;
452 
453  $result = $bookkeeping->create($user);
454  if ($result < 0) {
455  if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
456  {
457  $error++;
458  $errorforline++;
459  $errorforinvoice[$key] = 'alreadyjournalized';
460  //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
461  } else {
462  $error++;
463  $errorforline++;
464  $errorforinvoice[$key] = 'other';
465  setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
466  }
467  }
468  }
469  }
470  }
471  }
472 
473  // Protection against a bug on lines before
474  if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')))
475  {
476  $error++;
477  $errorforline++;
478  $errorforinvoice[$key] = 'amountsnotbalanced';
479  setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
480  }
481 
482  if (!$errorforline)
483  {
484  $db->commit();
485  } else {
486  $db->rollback();
487 
488  if ($error >= 10)
489  {
490  setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
491  break; // Break in the foreach
492  }
493  }
494  }
495 
496  $tabpay = $tabfac;
497 
498  if (empty($error) && count($tabpay) > 0) {
499  setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
500  } elseif (count($tabpay) == $error) {
501  setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
502  } else {
503  setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
504  }
505 
506  $action = '';
507 
508  // Must reload data, so we make a redirect
509  if (count($tabpay) != $error)
510  {
511  $param = 'id_journal='.$id_journal;
512  $param .= '&date_startday='.$date_startday;
513  $param .= '&date_startmonth='.$date_startmonth;
514  $param .= '&date_startyear='.$date_startyear;
515  $param .= '&date_endday='.$date_endday;
516  $param .= '&date_endmonth='.$date_endmonth;
517  $param .= '&date_endyear='.$date_endyear;
518  $param .= '&in_bookkeeping='.$in_bookkeeping;
519  header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : ''));
520  exit;
521  }
522 }
523 
524 
525 
526 /*
527  * View
528  */
529 
530 $form = new Form($db);
531 
532 // Export
533 if ($action == 'exportcsv') { // ISO and not UTF8 !
534  $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
535 
536  $filename = 'journal';
537  $type_export = 'journal';
538  include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
539 
540  $companystatic = new Client($db);
541  $invoicestatic = new Facture($db);
542 
543  foreach ($tabfac as $key => $val)
544  {
545  $companystatic->id = $tabcompany[$key]['id'];
546  $companystatic->name = $tabcompany[$key]['name'];
547  $companystatic->code_compta = $tabcompany[$key]['code_compta'];
548  $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
549  $companystatic->code_client = $tabcompany[$key]['code_client'];
550  $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
551  $companystatic->client = 3;
552 
553  $invoicestatic->id = $key;
554  $invoicestatic->ref = (string) $val["ref"];
555  $invoicestatic->type = $val["type"];
556  $invoicestatic->close_code = $val["close_code"];
557 
558  $date = dol_print_date($val["date"], 'day');
559 
560  // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
561  $replacedinvoice = 0;
562  if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
563  {
564  $replacedinvoice = 1;
565  $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
566  if ($alreadydispatched) $replacedinvoice = 2;
567  }
568 
569  // 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)
570  if ($replacedinvoice == 1)
571  {
572  continue;
573  }
574 
575  // Third party
576  foreach ($tabttc[$key] as $k => $mt) {
577  //if ($mt) {
578  print '"'.$key.'"'.$sep;
579  print '"'.$date.'"'.$sep;
580  print '"'.$val["ref"].'"'.$sep;
581  print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
582  print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
583  print '"'.$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER.'"'.$sep;
584  print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
585  print '"'.$langs->trans("Thirdparty").'"'.$sep;
586  print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Thirdparty").'"'.$sep;
587  print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
588  print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
589  print '"'.$journal.'"';
590  print "\n";
591  //}
592  }
593 
594  // Product / Service
595  foreach ($tabht[$key] as $k => $mt) {
596  $accountingaccount = new AccountingAccount($db);
597  $accountingaccount->fetch(null, $k, true);
598  //if ($mt) {
599  print '"'.$key.'"'.$sep;
600  print '"'.$date.'"'.$sep;
601  print '"'.$val["ref"].'"'.$sep;
602  print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
603  print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
604  print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
605  print '""'.$sep;
606  print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep;
607  print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep;
608  print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
609  print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
610  print '"'.$journal.'"';
611  print "\n";
612  //}
613  }
614 
615  // VAT
616  $listoftax = array(0, 1, 2);
617  foreach ($listoftax as $numtax) {
618  $arrayofvat = $tabtva;
619  if ($numtax == 1) $arrayofvat = $tablocaltax1;
620  if ($numtax == 2) $arrayofvat = $tablocaltax2;
621 
622  foreach ($arrayofvat[$key] as $k => $mt) {
623  if ($mt) {
624  print '"'.$key.'"'.$sep;
625  print '"'.$date.'"'.$sep;
626  print '"'.$val["ref"].'"'.$sep;
627  print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
628  print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
629  print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
630  print '""'.$sep;
631  print '"'.$langs->trans("VAT").' - '.join(', ', $def_tva[$key][$k]).' %"'.$sep;
632  print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep;
633  print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
634  print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
635  print '"'.$journal.'"';
636  print "\n";
637  }
638  }
639  }
640  }
641 }
642 
643 
644 
645 if (empty($action) || $action == 'view') {
646  llxHeader('', $langs->trans("SellsJournal"));
647 
648  $nom = $langs->trans("SellsJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
649  $nomlink = '';
650  $periodlink = '';
651  $exportlink = '';
652  $builddate = dol_now();
653  $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
654  if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
655  $description .= $langs->trans("DepositsAreNotIncluded");
656  else {
657  $description .= $langs->trans("DepositsAreIncluded");
658  }
659 
660  $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
661  $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);
662  $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
663 
664  $varlink = 'id_journal='.$id_journal;
665 
666  journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
667 
668  // Button to write into Ledger
669  if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
670  print '<br>';
671  print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
672  print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
673  }
674  print '<div class="tabsAction tabsActionNoBottom">';
675  if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
676  if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
677  print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
678  } else {
679  if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
680  else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
681  }
682  print '</div>';
683 
684  // TODO Avoid using js. We can use a direct link with $param
685  print '
686  <script type="text/javascript">
687  function launch_export() {
688  $("div.fiche form input[name=\"action\"]").val("exportcsv");
689  $("div.fiche form input[type=\"submit\"]").click();
690  $("div.fiche form input[name=\"action\"]").val("");
691  }
692  function writebookkeeping() {
693  console.log("click on writebookkeeping");
694  $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
695  $("div.fiche form input[type=\"submit\"]").click();
696  $("div.fiche form input[name=\"action\"]").val("");
697  }
698  </script>';
699 
700  /*
701  * Show result array
702  */
703  print '<br>';
704 
705  $i = 0;
706  print '<div class="div-table-responsive">';
707  print "<table class=\"noborder\" width=\"100%\">";
708  print "<tr class=\"liste_titre\">";
709  print "<td>".$langs->trans("Date")."</td>";
710  print "<td>".$langs->trans("Piece").' ('.$langs->trans("InvoiceRef").")</td>";
711  print "<td>".$langs->trans("AccountAccounting")."</td>";
712  print "<td>".$langs->trans("SubledgerAccount")."</td>";
713  print "<td>".$langs->trans("LabelOperation")."</td>";
714  print '<td class="center">'.$langs->trans("Debit")."</td>";
715  print '<td class="center">'.$langs->trans("Credit")."</td>";
716  print "</tr>\n";
717 
718  $r = '';
719 
720  $companystatic = new Client($db);
721  $invoicestatic = new Facture($db);
722 
723  foreach ($tabfac as $key => $val)
724  {
725  $companystatic->id = $tabcompany[$key]['id'];
726  $companystatic->name = $tabcompany[$key]['name'];
727  $companystatic->code_compta = $tabcompany[$key]['code_compta'];
728  $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
729  $companystatic->code_client = $tabcompany[$key]['code_client'];
730  $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
731  $companystatic->client = 3;
732 
733  $invoicestatic->id = $key;
734  $invoicestatic->ref = (string) $val["ref"];
735  $invoicestatic->type = $val["type"];
736  $invoicestatic->close_code = $val["close_code"];
737 
738  $date = dol_print_date($val["date"], 'day');
739 
740  // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
741  $replacedinvoice = 0;
742  if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
743  {
744  $replacedinvoice = 1;
745  $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
746  if ($alreadydispatched) $replacedinvoice = 2;
747  }
748 
749  // If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
750  if ($replacedinvoice == 1)
751  {
752  print '<tr class="oddeven">';
753  print "<!-- Replaced invoice -->";
754  print "<td>".$date."</td>";
755  print "<td><strike>".$invoicestatic->getNomUrl(1)."</strike></td>";
756  // Account
757  print "<td>";
758  print $langs->trans("Replaced");
759  print '</td>';
760  // Subledger account
761  print "<td>";
762  print '</td>';
763  print "<td>";
764  print "</td>";
765  print '<td class="right"></td>';
766  print '<td class="right"></td>';
767  print "</tr>";
768 
769  continue;
770  }
771  if ($errorforinvoice[$key] == 'somelinesarenotbound')
772  {
773  print '<tr class="oddeven">';
774  print "<!-- Some lines are not bound -->";
775  print "<td>".$date."</td>";
776  print "<td>".$invoicestatic->getNomUrl(1)."</td>";
777  // Account
778  print "<td>";
779  print '<span class="error">'.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).'</span>';
780  print '</td>';
781  // Subledger account
782  print "<td>";
783  print '</td>';
784  print "<td>";
785  print "</td>";
786  print '<td class="right"></td>';
787  print '<td class="right"></td>';
788  print "</tr>";
789  }
790 
791  // Third party
792  foreach ($tabttc[$key] as $k => $mt)
793  {
794  print '<tr class="oddeven">';
795  print "<!-- Thirdparty -->";
796  print "<td>".$date."</td>";
797  print "<td>".$invoicestatic->getNomUrl(1)."</td>";
798  // Account
799  print "<td>";
800  $accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
801  if (($accountoshow == "") || $accountoshow == 'NotDefined')
802  {
803  print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
804  } else print $accountoshow;
805  print '</td>';
806  // Subledger account
807  print "<td>";
808  $accountoshow = length_accounta($k);
809  if (($accountoshow == "") || $accountoshow == 'NotDefined')
810  {
811  print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
812  } else print $accountoshow;
813  print '</td>';
814  print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount")."</td>";
815  print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
816  print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
817  print "</tr>";
818  }
819 
820  // Product / Service
821  foreach ($tabht[$key] as $k => $mt)
822  {
823  $accountingaccount = new AccountingAccount($db);
824  $accountingaccount->fetch(null, $k, true);
825 
826  print '<tr class="oddeven">';
827  print "<!-- Product -->";
828  print "<td>".$date."</td>";
829  print "<td>".$invoicestatic->getNomUrl(1)."</td>";
830  // Account
831  print "<td>";
832  $accountoshow = length_accountg($k);
833  if (($accountoshow == "") || $accountoshow == 'NotDefined')
834  {
835  print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>';
836  } else print $accountoshow;
837  print "</td>";
838  // Subledger account
839  print "<td>";
840  print '</td>';
841  $companystatic->id = $tabcompany[$key]['id'];
842  $companystatic->name = $tabcompany[$key]['name'];
843  print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label."</td>";
844  print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
845  print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
846  print "</tr>";
847  }
848 
849  // VAT
850  $listoftax = array(0, 1, 2);
851  foreach ($listoftax as $numtax)
852  {
853  $arrayofvat = $tabtva;
854  if ($numtax == 1) $arrayofvat = $tablocaltax1;
855  if ($numtax == 2) $arrayofvat = $tablocaltax2;
856 
857  foreach ($arrayofvat[$key] as $k => $mt) {
858  if ($mt) {
859  print '<tr class="oddeven">';
860  print "<!-- VAT -->";
861  print "<td>".$date."</td>";
862  print "<td>".$invoicestatic->getNomUrl(1)."</td>";
863  // Account
864  print "<td>";
865  $accountoshow = length_accountg($k);
866  if (($accountoshow == "") || $accountoshow == 'NotDefined')
867  {
868  print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Sale").')</span>';
869  } else print $accountoshow;
870  print "</td>";
871  // Subledger account
872  print "<td>";
873  print '</td>';
874  print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '');
875  print "</td>";
876  print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
877  print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
878  print "</tr>";
879  }
880  }
881  }
882  }
883 
884  print "</table>";
885  print '</div>';
886 
887  // End of page
888  llxFooter();
889 }
890 
891 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_now($mode= 'auto')
Return date for now.
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
Class to manage customers or prospects.
const TYPE_REPLACEMENT
Replacement invoice.
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (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:481
journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink= '', $moreparam=array(), $calcmode= '', $varlink= '')
Show header of a page used to transfer/dispatch data in accounting.
const TYPE_SITUATION
Situation invoice.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage Ledger (General Ledger and Subledger)
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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 the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
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:498
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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) ...
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
Class to manage invoice lines.