34require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
45$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"errors"));
47$id_journal =
GETPOST(
'id_journal',
'int');
48$action =
GETPOST(
'action',
'aZ09');
50$date_startmonth =
GETPOST(
'date_startmonth');
51$date_startday =
GETPOST(
'date_startday');
52$date_startyear =
GETPOST(
'date_startyear');
53$date_endmonth =
GETPOST(
'date_endmonth');
54$date_endday =
GETPOST(
'date_endday');
55$date_endyear =
GETPOST(
'date_endyear');
56$in_bookkeeping =
GETPOST(
'in_bookkeeping');
57if ($in_bookkeeping ==
'') {
58 $in_bookkeeping =
'notyet';
63$hookmanager->initHooks(array(
'sellsjournal'));
67if (!isModEnabled(
'accounting')) {
70if ($user->socid > 0) {
73if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
84$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
90$accountingjournalstatic->fetch($id_journal);
91$journal = $accountingjournalstatic->code;
92$journal_label = $accountingjournalstatic->label;
94$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
95$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
97if (empty($date_startmonth)) {
100 $date_start = $dates[
'date_start'];
101 $pastmonthyear = $dates[
'pastmonthyear'];
102 $pastmonth = $dates[
'pastmonth'];
104if (empty($date_endmonth)) {
107 $date_end = $dates[
'date_end'];
108 $pastmonthyear = $dates[
'pastmonthyear'];
109 $pastmonth = $dates[
'pastmonth'];
115if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
120$sql =
"SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty, f.revenuestamp,";
121$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, fd.info_bits,";
122$sql .=
" s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
124 $sql .=
" spe.accountancy_code_customer as code_compta,";
125 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
127 $sql .=
" s.code_compta as code_compta,";
128 $sql .=
" s.code_compta_fournisseur,";
130$sql .=
" p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
132 $sql .=
" ppe.accountancy_code_sell";
134 $sql .=
" p.accountancy_code_sell";
136$parameters = array();
137$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
138$sql .= $hookmanager->resPrint;
139$sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as fd";
140$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
142 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
144$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
145$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture as f ON f.rowid = fd.fk_facture";
146$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
148 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
150$parameters = array();
151$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
152$sql .= $hookmanager->resPrint;
153$sql .=
" WHERE fd.fk_code_ventilation > 0";
154$sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
')';
155$sql .=
" AND f.fk_statut > 0";
161$sql .=
" AND fd.product_type IN (0,1)";
162if ($date_start && $date_end) {
163 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".$db->idate($date_end).
"'";
167 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
170if ($in_bookkeeping ==
'already') {
171 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
174if ($in_bookkeeping ==
'notyet') {
175 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
178$parameters = array();
179$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
180$sql .= $hookmanager->resPrint;
181$sql .=
" ORDER BY f.datef, f.ref";
184dol_syslog(
'accountancy/journal/sellsjournal.php', LOG_DEBUG);
185$result = $db->query($sql);
191 $tabwarranty = array();
192 $tabrevenuestamp = array();
194 $tablocaltax1 = array();
195 $tablocaltax2 = array();
196 $tabcompany = array();
197 $vatdata_cache = array();
199 $num = $db->num_rows($result);
207 $obj = $db->fetch_object($result);
210 $compta_soc = (!empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
212 $compta_prod = $obj->compte;
213 if (empty($compta_prod)) {
214 if ($obj->product_type == 0) {
223 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
224 if (array_key_exists($tax_id, $vatdata_cache)) {
225 $vatdata = $vatdata_cache[$tax_id];
230 $buyer->fetch($obj->socid);
236 $vatdata_cache[$tax_id] = $vatdata;
238 $compta_tva = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
239 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
240 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
243 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
244 $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.
')' :
''));
248 $situation_ratio = 1;
250 if ($obj->situation_cycle_ref) {
252 if ($obj->situation_percent == 0) {
253 $situation_ratio = 0;
256 $line->fetch($obj->fdid);
259 $prev_progress = $line->get_prev_progress($obj->rowid);
261 $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
266 $revenuestamp = (float)
price2num($obj->revenuestamp,
'MT');
269 $tabfac[$obj->rowid][
"date"] = $db->jdate($obj->df);
270 $tabfac[$obj->rowid][
"datereg"] = $db->jdate($obj->dlr);
271 $tabfac[$obj->rowid][
"ref"] = $obj->ref;
272 $tabfac[$obj->rowid][
"type"] = $obj->type;
273 $tabfac[$obj->rowid][
"description"] = $obj->label_compte;
274 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
275 $tabfac[$obj->rowid][
"revenuestamp"] = $revenuestamp;
279 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
280 $tabttc[$obj->rowid][$compta_soc] = 0;
282 if (!isset($tabht[$obj->rowid][$compta_prod])) {
283 $tabht[$obj->rowid][$compta_prod] = 0;
285 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
286 $tabtva[$obj->rowid][$compta_tva] = 0;
288 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
289 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
291 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
292 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
301 $total_ttc = $obj->total_ttc * $situation_ratio;
303 $total_ttc = $obj->total_ttc;
307 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) {
308 $retained_warranty = (float)
price2num($total_ttc * $obj->retained_warranty / 100,
'MT');
309 $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
310 $total_ttc -= $retained_warranty;
313 $tabttc[$obj->rowid][$compta_soc] += $total_ttc;
314 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
315 $tva_npr = (($obj->info_bits & 1 == 1) ? 1 : 0);
317 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
319 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
320 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
322 $compta_revenuestamp =
'NotDefined';
323 if (!empty($revenuestamp)) {
324 $sqlrevenuestamp =
"SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX.
"c_revenuestamp";
325 $sqlrevenuestamp .=
" WHERE fk_pays = ".((int) $mysoc->country_id);
326 $sqlrevenuestamp .=
" AND taux = ".((float) $revenuestamp);
327 $sqlrevenuestamp .=
" AND active = 1";
328 $resqlrevenuestamp = $db->query($sqlrevenuestamp);
330 if ($resqlrevenuestamp) {
331 $num_rows_revenuestamp = $db->num_rows($resqlrevenuestamp);
332 if ($num_rows_revenuestamp > 1) {
333 dol_print_error($db,
'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
335 $objrevenuestamp = $db->fetch_object($resqlrevenuestamp);
336 if ($objrevenuestamp) {
337 $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
343 if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
345 $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
346 $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
349 $tabcompany[$obj->rowid] = array(
351 'name' => $obj->name,
352 'code_client' => $obj->code_client,
353 'code_compta' => $compta_soc
365if (count($tabfac) > 10000) {
367 setEventMessages(
"TooManyInvoicesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
370$errorforinvoice = array();
396 COUNT(fd.rowid) as nb
398 ".MAIN_DB_PREFIX.
"facturedet as fd
401 AND fd.fk_code_ventilation <= 0
402 AND fd.total_ttc <> 0
403 AND fk_facture IN (".$db->sanitize(join(
",", array_keys($tabfac))).
")
406$resql = $db->query($sql);
408 $num = $db->num_rows($resql);
411 $obj = $db->fetch_object($resql);
413 $errorforinvoice[$obj->fk_facture_fourn] =
'somelinesarenotbound';
421if ($action ==
'writebookkeeping' && !$error) {
425 $companystatic =
new Societe($db);
426 $invoicestatic =
new Facture($db);
429 $accountingaccountcustomer->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
433 $accountingaccountcustomerwarranty->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'),
true);
435 foreach ($tabfac as $key => $val) {
443 $companystatic->id = $tabcompany[$key][
'id'];
444 $companystatic->name = $tabcompany[$key][
'name'];
445 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
446 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
447 $companystatic->code_client = $tabcompany[$key][
'code_client'];
448 $companystatic->client = 3;
450 $invoicestatic->id = $key;
451 $invoicestatic->ref = (string) $val[
"ref"];
452 $invoicestatic->type = $val[
"type"];
453 $invoicestatic->close_code = $val[
"close_code"];
458 $replacedinvoice = 0;
459 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
460 $replacedinvoice = 1;
461 $alreadydispatched = $invoicestatic->getVentilExportCompta();
462 if ($alreadydispatched) {
463 $replacedinvoice = 2;
468 if ($replacedinvoice == 1) {
474 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
477 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
481 if (!$errorforline &&
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
482 if (is_array($tabwarranty[$key])) {
483 foreach ($tabwarranty[$key] as $k => $mt) {
485 $bookkeeping->doc_date = $val[
"date"];
486 $bookkeeping->date_lim_reglement = $val[
"datereg"];
487 $bookkeeping->doc_ref = $val[
"ref"];
488 $bookkeeping->date_creation = $now;
489 $bookkeeping->doc_type =
'customer_invoice';
490 $bookkeeping->fk_doc = $key;
491 $bookkeeping->fk_docdet = 0;
492 $bookkeeping->thirdparty_code = $companystatic->code_client;
494 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
495 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
497 $bookkeeping->numero_compte =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
498 $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
500 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"Retainedwarranty");
501 $bookkeeping->montant = $mt;
502 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
503 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
504 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
505 $bookkeeping->code_journal = $journal;
506 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
507 $bookkeeping->fk_user_author = $user->id;
508 $bookkeeping->entity = $conf->entity;
510 $totaldebit += $bookkeeping->debit;
511 $totalcredit += $bookkeeping->credit;
513 $result = $bookkeeping->create($user);
515 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
518 $errorforinvoice[$key] =
'alreadyjournalized';
523 $errorforinvoice[$key] =
'other';
532 if (!$errorforline) {
533 foreach ($tabttc[$key] as $k => $mt) {
535 $bookkeeping->doc_date = $val[
"date"];
536 $bookkeeping->date_lim_reglement = $val[
"datereg"];
537 $bookkeeping->doc_ref = $val[
"ref"];
538 $bookkeeping->date_creation = $now;
539 $bookkeeping->doc_type =
'customer_invoice';
540 $bookkeeping->fk_doc = $key;
541 $bookkeeping->fk_docdet = 0;
542 $bookkeeping->thirdparty_code = $companystatic->code_client;
544 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
545 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
548 $bookkeeping->label_compte = $accountingaccountcustomer->label;
550 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount");
551 $bookkeeping->montant = $mt;
552 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
553 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
554 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
555 $bookkeeping->code_journal = $journal;
556 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
557 $bookkeeping->fk_user_author = $user->id;
558 $bookkeeping->entity = $conf->entity;
560 $totaldebit += $bookkeeping->debit;
561 $totalcredit += $bookkeeping->credit;
563 $result = $bookkeeping->create($user);
565 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
568 $errorforinvoice[$key] =
'alreadyjournalized';
573 $errorforinvoice[$key] =
'other';
578 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
581 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
588 if (!$errorforline) {
589 foreach ($tabht[$key] as $k => $mt) {
590 $resultfetch = $accountingaccount->fetch(
null, $k,
true);
591 $label_account = $accountingaccount->label;
594 if ($resultfetch > 0) {
596 $bookkeeping->doc_date = $val[
"date"];
597 $bookkeeping->date_lim_reglement = $val[
"datereg"];
598 $bookkeeping->doc_ref = $val[
"ref"];
599 $bookkeeping->date_creation = $now;
600 $bookkeeping->doc_type =
'customer_invoice';
601 $bookkeeping->fk_doc = $key;
602 $bookkeeping->fk_docdet = 0;
603 $bookkeeping->thirdparty_code = $companystatic->code_client;
607 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
608 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
610 $bookkeeping->subledger_account =
'';
611 $bookkeeping->subledger_label =
'';
614 $bookkeeping->subledger_account =
'';
615 $bookkeeping->subledger_label =
'';
618 $bookkeeping->numero_compte = $k;
619 $bookkeeping->label_compte = $label_account;
621 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$label_account;
622 $bookkeeping->montant = $mt;
623 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
624 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
625 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
626 $bookkeeping->code_journal = $journal;
627 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
628 $bookkeeping->fk_user_author = $user->id;
629 $bookkeeping->entity = $conf->entity;
631 $totaldebit += $bookkeeping->debit;
632 $totalcredit += $bookkeeping->credit;
634 $result = $bookkeeping->create($user);
636 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
639 $errorforinvoice[$key] =
'alreadyjournalized';
644 $errorforinvoice[$key] =
'other';
653 if (!$errorforline) {
654 $listoftax = array(0, 1, 2);
655 foreach ($listoftax as $numtax) {
656 $arrayofvat = $tabtva;
658 $arrayofvat = $tablocaltax1;
661 $arrayofvat = $tablocaltax2;
664 foreach ($arrayofvat[$key] as $k => $mt) {
666 $accountingaccount->fetch(
null, $k,
true);
667 $label_account = $accountingaccount->label;
670 $bookkeeping->doc_date = $val[
"date"];
671 $bookkeeping->date_lim_reglement = $val[
"datereg"];
672 $bookkeeping->doc_ref = $val[
"ref"];
673 $bookkeeping->date_creation = $now;
674 $bookkeeping->doc_type =
'customer_invoice';
675 $bookkeeping->fk_doc = $key;
676 $bookkeeping->fk_docdet = 0;
677 $bookkeeping->thirdparty_code = $companystatic->code_client;
679 $bookkeeping->subledger_account =
'';
680 $bookkeeping->subledger_label =
'';
682 $bookkeeping->numero_compte = $k;
683 $bookkeeping->label_compte = $label_account;
686 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref;
687 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : join(
', ', $def_tva[$key][$k]));
688 $bookkeeping->label_operation .=
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
689 $bookkeeping->label_operation .= ($numtax ?
' - Localtax '.$numtax :
'');
691 $bookkeeping->montant = $mt;
692 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
693 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
694 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
695 $bookkeeping->code_journal = $journal;
696 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
697 $bookkeeping->fk_user_author = $user->id;
698 $bookkeeping->entity = $conf->entity;
700 $totaldebit += $bookkeeping->debit;
701 $totalcredit += $bookkeeping->credit;
703 $result = $bookkeeping->create($user);
705 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
708 $errorforinvoice[$key] =
'alreadyjournalized';
713 $errorforinvoice[$key] =
'other';
723 if (!$errorforline) {
724 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
725 foreach ($tabrevenuestamp[$key] as $k => $mt) {
727 $accountingaccount->fetch(
null, $k,
true);
728 $label_account = $accountingaccount->label;
731 $bookkeeping->doc_date = $val[
"date"];
732 $bookkeeping->date_lim_reglement = $val[
"datereg"];
733 $bookkeeping->doc_ref = $val[
"ref"];
734 $bookkeeping->date_creation = $now;
735 $bookkeeping->doc_type =
'customer_invoice';
736 $bookkeeping->fk_doc = $key;
737 $bookkeeping->fk_docdet = 0;
738 $bookkeeping->thirdparty_code = $companystatic->code_client;
740 $bookkeeping->subledger_account =
'';
741 $bookkeeping->subledger_label =
'';
743 $bookkeeping->numero_compte = $k;
744 $bookkeeping->label_compte = $label_account;
746 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp");
747 $bookkeeping->montant = $mt;
748 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
749 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
750 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
751 $bookkeeping->code_journal = $journal;
752 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
753 $bookkeeping->fk_user_author = $user->id;
754 $bookkeeping->entity = $conf->entity;
756 $totaldebit += $bookkeeping->debit;
757 $totalcredit += $bookkeeping->credit;
759 $result = $bookkeeping->create($user);
761 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
764 $errorforinvoice[$key] =
'alreadyjournalized';
769 $errorforinvoice[$key] =
'other';
779 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
782 $errorforinvoice[$key] =
'amountsnotbalanced';
783 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
786 if (!$errorforline) {
792 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
800 if (empty($error) && count($tabpay) > 0) {
802 } elseif (count($tabpay) == $error) {
805 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
811 if (count($tabpay) != $error) {
812 $param =
'id_journal='.$id_journal;
813 $param .=
'&date_startday='.$date_startday;
814 $param .=
'&date_startmonth='.$date_startmonth;
815 $param .=
'&date_startyear='.$date_startyear;
816 $param .=
'&date_endday='.$date_endday;
817 $param .=
'&date_endmonth='.$date_endmonth;
818 $param .=
'&date_endyear='.$date_endyear;
819 $param .=
'&in_bookkeeping='.$in_bookkeeping;
820 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
831$form =
new Form($db);
834if ($action ==
'exportcsv' && !$error) {
838 $filename =
'journal';
839 $type_export =
'journal';
840 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
842 $companystatic =
new Client($db);
843 $invoicestatic =
new Facture($db);
845 foreach ($tabfac as $key => $val) {
846 $companystatic->id = $tabcompany[$key][
'id'];
847 $companystatic->name = $tabcompany[$key][
'name'];
848 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
849 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
850 $companystatic->code_client = $tabcompany[$key][
'code_client'];
851 $companystatic->client = 3;
853 $invoicestatic->id = $key;
854 $invoicestatic->ref = (string) $val[
"ref"];
855 $invoicestatic->type = $val[
"type"];
856 $invoicestatic->close_code = $val[
"close_code"];
861 $replacedinvoice = 0;
862 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
863 $replacedinvoice = 1;
864 $alreadydispatched = $invoicestatic->getVentilExportCompta();
865 if ($alreadydispatched) {
866 $replacedinvoice = 2;
871 if ($replacedinvoice == 1) {
876 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
877 foreach ($tabwarranty[$key] as $k => $mt) {
879 print
'"'.$key.
'"'.$sep;
880 print
'"'.$date.
'"'.$sep;
881 print
'"'.$val[
"ref"].
'"'.$sep;
882 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
883 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
884 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).
'"'.$sep;
885 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
886 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
887 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Retainedwarranty").
'"'.$sep;
888 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
889 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
890 print
'"'.$journal.
'"';
897 foreach ($tabttc[$key] as $k => $mt) {
899 print
'"'.$key.
'"'.$sep;
900 print
'"'.$date.
'"'.$sep;
901 print
'"'.$val[
"ref"].
'"'.$sep;
902 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
903 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
904 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')).
'"'.$sep;
905 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
906 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
907 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
908 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
909 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
910 print
'"'.$journal.
'"';
916 foreach ($tabht[$key] as $k => $mt) {
918 $accountingaccount->fetch(
null, $k,
true);
920 print
'"'.$key.
'"'.$sep;
921 print
'"'.$date.
'"'.$sep;
922 print
'"'.$val[
"ref"].
'"'.$sep;
923 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
924 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
925 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
927 print
'"'.mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1').
'"'.$sep;
928 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
929 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
930 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
931 print
'"'.$journal.
'"';
937 $listoftax = array(0, 1, 2);
938 foreach ($listoftax as $numtax) {
939 $arrayofvat = $tabtva;
941 $arrayofvat = $tablocaltax1;
944 $arrayofvat = $tablocaltax2;
947 foreach ($arrayofvat[$key] as $k => $mt) {
949 print
'"'.$key.
'"'.$sep;
950 print
'"'.$date.
'"'.$sep;
951 print
'"'.$val[
"ref"].
'"'.$sep;
952 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
953 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
954 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
956 print
'"'.$langs->trans(
"VAT").
' - '.join(
', ', $def_tva[$key][$k]).
' %"'.$sep;
957 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"VAT").join(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'').
'"'.$sep;
958 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
959 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
960 print
'"'.$journal.
'"';
967 if (isset($tabrevenuestamp[$key])) {
968 foreach ($tabrevenuestamp[$key] as $k => $mt) {
970 print
'"'.$key.
'"'.$sep;
971 print
'"'.$date.
'"'.$sep;
972 print
'"'.$val[
"ref"].
'"'.$sep;
973 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
974 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
975 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
977 print
'"'.$langs->trans(
"RevenueStamp").
'"'.$sep;
978 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"RevenueStamp").
'"'.$sep;
979 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
980 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
981 print
'"'.$journal.
'"';
991if (empty($action) || $action ==
'view') {
992 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1001 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1003 $description .= $langs->trans(
"DepositsAreNotIncluded");
1005 $description .= $langs->trans(
"DepositsAreIncluded");
1008 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
1009 $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);
1010 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1012 $varlink =
'id_journal='.$id_journal;
1014 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
1019 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
1020 $resql = $db->query($sql);
1022 $obj = $db->fetch_object($resql);
1023 if ($obj->nb == 0) {
1024 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1025 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1026 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1036 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
1037 if ($acctCustomerNotConfigured) {
1038 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1039 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1040 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1044 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1045 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1046 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1048 if ($acctCustomerNotConfigured) {
1049 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1051 if ($in_bookkeeping ==
'notyet') {
1052 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1054 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1061 <script type="text/javascript">
1062 function launch_export() {
1063 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1064 $("div.fiche form input[type=\"submit\"]").click();
1065 $("div.fiche form input[name=\"action\"]").val("");
1067 function writebookkeeping() {
1068 console.log("click on writebookkeeping");
1069 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1070 $("div.fiche form input[type=\"submit\"]").click();
1071 $("div.fiche form input[name=\"action\"]").val("");
1080 print
'<div class="div-table-responsive">';
1081 print
"<table class=\"noborder\" width=\"100%\">";
1082 print
"<tr class=\"liste_titre\">";
1083 print
"<td>".$langs->trans(
"Date").
"</td>";
1084 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1085 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1086 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1087 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1088 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1089 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1094 $companystatic =
new Client($db);
1095 $invoicestatic =
new Facture($db);
1097 foreach ($tabfac as $key => $val) {
1098 $companystatic->id = $tabcompany[$key][
'id'];
1099 $companystatic->name = $tabcompany[$key][
'name'];
1100 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1101 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1102 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1103 $companystatic->client = 3;
1105 $invoicestatic->id = $key;
1106 $invoicestatic->ref = (string) $val[
"ref"];
1107 $invoicestatic->type = $val[
"type"];
1108 $invoicestatic->close_code = $val[
"close_code"];
1113 $replacedinvoice = 0;
1114 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1115 $replacedinvoice = 1;
1116 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1117 if ($alreadydispatched) {
1118 $replacedinvoice = 2;
1123 if ($replacedinvoice == 1) {
1124 print
'<tr class="oddeven">';
1125 print
"<!-- Replaced invoice -->";
1126 print
"<td>".$date.
"</td>";
1127 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1130 print $langs->trans(
"Replaced");
1137 print
'<td class="right"></td>';
1138 print
'<td class="right"></td>';
1144 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
1145 print
'<tr class="oddeven">';
1146 print
"<!-- Some lines are not bound -->";
1147 print
"<td>".$date.
"</td>";
1148 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1151 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1158 print
'<td class="right"></td>';
1159 print
'<td class="right"></td>';
1166 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
1167 foreach ($tabwarranty[$key] as $k => $mt) {
1168 print
'<tr class="oddeven">';
1169 print
"<!-- Thirdparty warranty -->";
1170 print
"<td>" . $date .
"</td>";
1171 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1175 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1176 print
'<span class="error">' . $langs->trans(
"MainAccountForRetainedWarrantyNotDefined") .
'</span>';
1178 print $accountoshow;
1184 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1185 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1187 print $accountoshow;
1190 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"Retainedwarranty") .
"</td>";
1191 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1192 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1198 foreach ($tabttc[$key] as $k => $mt) {
1199 print
'<tr class="oddeven">';
1200 print
"<!-- Thirdparty -->";
1201 print
"<td>".$date.
"</td>";
1202 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1206 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1207 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1209 print $accountoshow;
1215 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1216 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1218 print $accountoshow;
1221 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1222 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1223 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1230 foreach ($tabht[$key] as $k => $mt) {
1232 $accountingaccount->fetch(
null, $k,
true);
1234 print
'<tr class="oddeven">';
1235 print
"<!-- Product -->";
1236 print
"<td>".$date.
"</td>";
1237 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1241 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1242 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1244 print $accountoshow;
1253 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1254 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1257 $companystatic->id = $tabcompany[$key][
'id'];
1258 $companystatic->name = $tabcompany[$key][
'name'];
1259 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$accountingaccount->label.
"</td>";
1260 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1261 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1268 $listoftax = array(0, 1, 2);
1269 foreach ($listoftax as $numtax) {
1270 $arrayofvat = $tabtva;
1272 $arrayofvat = $tablocaltax1;
1275 $arrayofvat = $tablocaltax2;
1279 foreach ($arrayofvat[$key] as $k => $mt) {
1281 print
'<tr class="oddeven">';
1282 print
"<!-- VAT -->";
1283 print
"<td>".$date.
"</td>";
1284 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1288 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1289 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1291 print $accountoshow;
1297 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref;
1300 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : join(
', ', $def_tva[$key][$k]));
1301 print
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1302 print($numtax ?
' - Localtax '.$numtax :
'');
1304 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1305 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1314 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
1315 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1316 print
'<tr class="oddeven">';
1317 print
"<!-- Thirdparty revenuestamp -->";
1318 print
"<td>" . $date .
"</td>";
1319 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1323 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1324 print
'<span class="error">' . $langs->trans(
"MainAccountForRevenueStampSaleNotDefined") .
'</span>';
1326 print $accountoshow;
1332 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp") .
"</td>";
1333 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1334 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1341 print
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a page used to transfer/dispatch data in accounting.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accounting accounts.
Class to manage accounting journals.
Class to manage Ledger (General Ledger and Subledger)
Class to manage customers or prospects.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_SITUATION
Situation invoice.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage invoice lines.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
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='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.