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