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];
228 $vatdata_cache[$tax_id] = $vatdata;
230 $compta_tva = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
231 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
232 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
235 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
236 $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.
')' :
''));
240 $situation_ratio = 1;
242 if ($obj->situation_cycle_ref) {
244 if ($obj->situation_percent == 0) {
245 $situation_ratio = 0;
248 $line->fetch($obj->fdid);
251 $prev_progress = $line->get_prev_progress($obj->rowid);
253 $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
258 $revenuestamp = (float)
price2num($obj->revenuestamp,
'MT');
261 $tabfac[$obj->rowid][
"date"] = $db->jdate($obj->df);
262 $tabfac[$obj->rowid][
"datereg"] = $db->jdate($obj->dlr);
263 $tabfac[$obj->rowid][
"ref"] = $obj->ref;
264 $tabfac[$obj->rowid][
"type"] = $obj->type;
265 $tabfac[$obj->rowid][
"description"] = $obj->label_compte;
266 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
267 $tabfac[$obj->rowid][
"revenuestamp"] = $revenuestamp;
271 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
272 $tabttc[$obj->rowid][$compta_soc] = 0;
274 if (!isset($tabht[$obj->rowid][$compta_prod])) {
275 $tabht[$obj->rowid][$compta_prod] = 0;
277 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
278 $tabtva[$obj->rowid][$compta_tva] = 0;
280 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
281 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
283 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
284 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
293 $total_ttc = $obj->total_ttc * $situation_ratio;
295 $total_ttc = $obj->total_ttc;
299 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) {
300 $retained_warranty = (float)
price2num($total_ttc * $obj->retained_warranty / 100,
'MT');
301 $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
302 $total_ttc -= $retained_warranty;
305 $tabttc[$obj->rowid][$compta_soc] += $total_ttc;
306 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
307 $tva_npr = (($obj->info_bits & 1 == 1) ? 1 : 0);
309 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
311 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
312 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
314 $compta_revenuestamp =
'NotDefined';
315 if (!empty($revenuestamp)) {
316 $sqlrevenuestamp =
"SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX.
"c_revenuestamp";
317 $sqlrevenuestamp .=
" WHERE fk_pays = ".((int) $mysoc->country_id);
318 $sqlrevenuestamp .=
" AND taux = ".((float) $revenuestamp);
319 $sqlrevenuestamp .=
" AND active = 1";
320 $resqlrevenuestamp = $db->query($sqlrevenuestamp);
322 if ($resqlrevenuestamp) {
323 $num_rows_revenuestamp = $db->num_rows($resqlrevenuestamp);
324 if ($num_rows_revenuestamp > 1) {
325 dol_print_error($db,
'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
327 $objrevenuestamp = $db->fetch_object($resqlrevenuestamp);
328 if ($objrevenuestamp) {
329 $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
335 if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
337 $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
338 $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
341 $tabcompany[$obj->rowid] = array(
343 'name' => $obj->name,
344 'code_client' => $obj->code_client,
345 'code_compta' => $compta_soc
357if (count($tabfac) > 10000) {
359 setEventMessages(
"TooManyInvoicesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
362$errorforinvoice = array();
388 COUNT(fd.rowid) as nb
390 ".MAIN_DB_PREFIX.
"facturedet as fd
393 AND fd.fk_code_ventilation <= 0
394 AND fd.total_ttc <> 0
395 AND fk_facture IN (".$db->sanitize(join(
",", array_keys($tabfac))).
")
398$resql = $db->query($sql);
400 $num = $db->num_rows($resql);
403 $obj = $db->fetch_object($resql);
405 $errorforinvoice[$obj->fk_facture_fourn] =
'somelinesarenotbound';
413if ($action ==
'writebookkeeping' && !$error) {
417 $companystatic =
new Societe($db);
418 $invoicestatic =
new Facture($db);
421 $accountingaccountcustomer->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
425 $accountingaccountcustomerwarranty->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'),
true);
427 foreach ($tabfac as $key => $val) {
435 $companystatic->id = $tabcompany[$key][
'id'];
436 $companystatic->name = $tabcompany[$key][
'name'];
437 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
438 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
439 $companystatic->code_client = $tabcompany[$key][
'code_client'];
440 $companystatic->client = 3;
442 $invoicestatic->id = $key;
443 $invoicestatic->ref = (string) $val[
"ref"];
444 $invoicestatic->type = $val[
"type"];
445 $invoicestatic->close_code = $val[
"close_code"];
450 $replacedinvoice = 0;
451 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
452 $replacedinvoice = 1;
453 $alreadydispatched = $invoicestatic->getVentilExportCompta();
454 if ($alreadydispatched) {
455 $replacedinvoice = 2;
460 if ($replacedinvoice == 1) {
466 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
469 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
473 if (!$errorforline &&
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
474 if (is_array($tabwarranty[$key])) {
475 foreach ($tabwarranty[$key] as $k => $mt) {
477 $bookkeeping->doc_date = $val[
"date"];
478 $bookkeeping->date_lim_reglement = $val[
"datereg"];
479 $bookkeeping->doc_ref = $val[
"ref"];
480 $bookkeeping->date_creation = $now;
481 $bookkeeping->doc_type =
'customer_invoice';
482 $bookkeeping->fk_doc = $key;
483 $bookkeeping->fk_docdet = 0;
484 $bookkeeping->thirdparty_code = $companystatic->code_client;
486 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
487 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
489 $bookkeeping->numero_compte =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
490 $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
492 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"Retainedwarranty");
493 $bookkeeping->montant = $mt;
494 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
495 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
496 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
497 $bookkeeping->code_journal = $journal;
498 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
499 $bookkeeping->fk_user_author = $user->id;
500 $bookkeeping->entity = $conf->entity;
502 $totaldebit += $bookkeeping->debit;
503 $totalcredit += $bookkeeping->credit;
505 $result = $bookkeeping->create($user);
507 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
510 $errorforinvoice[$key] =
'alreadyjournalized';
515 $errorforinvoice[$key] =
'other';
524 if (!$errorforline) {
525 foreach ($tabttc[$key] as $k => $mt) {
527 $bookkeeping->doc_date = $val[
"date"];
528 $bookkeeping->date_lim_reglement = $val[
"datereg"];
529 $bookkeeping->doc_ref = $val[
"ref"];
530 $bookkeeping->date_creation = $now;
531 $bookkeeping->doc_type =
'customer_invoice';
532 $bookkeeping->fk_doc = $key;
533 $bookkeeping->fk_docdet = 0;
534 $bookkeeping->thirdparty_code = $companystatic->code_client;
536 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
537 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
540 $bookkeeping->label_compte = $accountingaccountcustomer->label;
542 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount");
543 $bookkeeping->montant = $mt;
544 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
545 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
546 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
547 $bookkeeping->code_journal = $journal;
548 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
549 $bookkeeping->fk_user_author = $user->id;
550 $bookkeeping->entity = $conf->entity;
552 $totaldebit += $bookkeeping->debit;
553 $totalcredit += $bookkeeping->credit;
555 $result = $bookkeeping->create($user);
557 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
560 $errorforinvoice[$key] =
'alreadyjournalized';
565 $errorforinvoice[$key] =
'other';
570 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
573 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
580 if (!$errorforline) {
581 foreach ($tabht[$key] as $k => $mt) {
582 $resultfetch = $accountingaccount->fetch(
null, $k,
true);
583 $label_account = $accountingaccount->label;
586 if ($resultfetch > 0) {
588 $bookkeeping->doc_date = $val[
"date"];
589 $bookkeeping->date_lim_reglement = $val[
"datereg"];
590 $bookkeeping->doc_ref = $val[
"ref"];
591 $bookkeeping->date_creation = $now;
592 $bookkeeping->doc_type =
'customer_invoice';
593 $bookkeeping->fk_doc = $key;
594 $bookkeeping->fk_docdet = 0;
595 $bookkeeping->thirdparty_code = $companystatic->code_client;
599 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
600 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
602 $bookkeeping->subledger_account =
'';
603 $bookkeeping->subledger_label =
'';
606 $bookkeeping->subledger_account =
'';
607 $bookkeeping->subledger_label =
'';
610 $bookkeeping->numero_compte = $k;
611 $bookkeeping->label_compte = $label_account;
613 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$label_account;
614 $bookkeeping->montant = $mt;
615 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
616 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
617 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
618 $bookkeeping->code_journal = $journal;
619 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
620 $bookkeeping->fk_user_author = $user->id;
621 $bookkeeping->entity = $conf->entity;
623 $totaldebit += $bookkeeping->debit;
624 $totalcredit += $bookkeeping->credit;
626 $result = $bookkeeping->create($user);
628 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
631 $errorforinvoice[$key] =
'alreadyjournalized';
636 $errorforinvoice[$key] =
'other';
645 if (!$errorforline) {
646 $listoftax = array(0, 1, 2);
647 foreach ($listoftax as $numtax) {
648 $arrayofvat = $tabtva;
650 $arrayofvat = $tablocaltax1;
653 $arrayofvat = $tablocaltax2;
656 foreach ($arrayofvat[$key] as $k => $mt) {
658 $accountingaccount->fetch(
null, $k,
true);
659 $label_account = $accountingaccount->label;
662 $bookkeeping->doc_date = $val[
"date"];
663 $bookkeeping->date_lim_reglement = $val[
"datereg"];
664 $bookkeeping->doc_ref = $val[
"ref"];
665 $bookkeeping->date_creation = $now;
666 $bookkeeping->doc_type =
'customer_invoice';
667 $bookkeeping->fk_doc = $key;
668 $bookkeeping->fk_docdet = 0;
669 $bookkeeping->thirdparty_code = $companystatic->code_client;
671 $bookkeeping->subledger_account =
'';
672 $bookkeeping->subledger_label =
'';
674 $bookkeeping->numero_compte = $k;
675 $bookkeeping->label_compte = $label_account;
678 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref;
679 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : join(
', ', $def_tva[$key][$k]));
680 $bookkeeping->label_operation .=
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
681 $bookkeeping->label_operation .= ($numtax ?
' - Localtax '.$numtax :
'');
683 $bookkeeping->montant = $mt;
684 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
685 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
686 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
687 $bookkeeping->code_journal = $journal;
688 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
689 $bookkeeping->fk_user_author = $user->id;
690 $bookkeeping->entity = $conf->entity;
692 $totaldebit += $bookkeeping->debit;
693 $totalcredit += $bookkeeping->credit;
695 $result = $bookkeeping->create($user);
697 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
700 $errorforinvoice[$key] =
'alreadyjournalized';
705 $errorforinvoice[$key] =
'other';
715 if (!$errorforline) {
716 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
717 foreach ($tabrevenuestamp[$key] as $k => $mt) {
719 $accountingaccount->fetch(
null, $k,
true);
720 $label_account = $accountingaccount->label;
723 $bookkeeping->doc_date = $val[
"date"];
724 $bookkeeping->date_lim_reglement = $val[
"datereg"];
725 $bookkeeping->doc_ref = $val[
"ref"];
726 $bookkeeping->date_creation = $now;
727 $bookkeeping->doc_type =
'customer_invoice';
728 $bookkeeping->fk_doc = $key;
729 $bookkeeping->fk_docdet = 0;
730 $bookkeeping->thirdparty_code = $companystatic->code_client;
732 $bookkeeping->subledger_account =
'';
733 $bookkeeping->subledger_label =
'';
735 $bookkeeping->numero_compte = $k;
736 $bookkeeping->label_compte = $label_account;
738 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp");
739 $bookkeeping->montant = $mt;
740 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
741 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
742 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
743 $bookkeeping->code_journal = $journal;
744 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
745 $bookkeeping->fk_user_author = $user->id;
746 $bookkeeping->entity = $conf->entity;
748 $totaldebit += $bookkeeping->debit;
749 $totalcredit += $bookkeeping->credit;
751 $result = $bookkeeping->create($user);
753 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
756 $errorforinvoice[$key] =
'alreadyjournalized';
761 $errorforinvoice[$key] =
'other';
771 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
774 $errorforinvoice[$key] =
'amountsnotbalanced';
775 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
778 if (!$errorforline) {
784 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
792 if (empty($error) && count($tabpay) > 0) {
794 } elseif (count($tabpay) == $error) {
797 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
803 if (count($tabpay) != $error) {
804 $param =
'id_journal='.$id_journal;
805 $param .=
'&date_startday='.$date_startday;
806 $param .=
'&date_startmonth='.$date_startmonth;
807 $param .=
'&date_startyear='.$date_startyear;
808 $param .=
'&date_endday='.$date_endday;
809 $param .=
'&date_endmonth='.$date_endmonth;
810 $param .=
'&date_endyear='.$date_endyear;
811 $param .=
'&in_bookkeeping='.$in_bookkeeping;
812 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
823$form =
new Form($db);
826if ($action ==
'exportcsv' && !$error) {
830 $filename =
'journal';
831 $type_export =
'journal';
832 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
834 $companystatic =
new Client($db);
835 $invoicestatic =
new Facture($db);
837 foreach ($tabfac as $key => $val) {
838 $companystatic->id = $tabcompany[$key][
'id'];
839 $companystatic->name = $tabcompany[$key][
'name'];
840 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
841 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
842 $companystatic->code_client = $tabcompany[$key][
'code_client'];
843 $companystatic->client = 3;
845 $invoicestatic->id = $key;
846 $invoicestatic->ref = (string) $val[
"ref"];
847 $invoicestatic->type = $val[
"type"];
848 $invoicestatic->close_code = $val[
"close_code"];
853 $replacedinvoice = 0;
854 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
855 $replacedinvoice = 1;
856 $alreadydispatched = $invoicestatic->getVentilExportCompta();
857 if ($alreadydispatched) {
858 $replacedinvoice = 2;
863 if ($replacedinvoice == 1) {
868 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
869 foreach ($tabwarranty[$key] as $k => $mt) {
871 print
'"'.$key.
'"'.$sep;
872 print
'"'.$date.
'"'.$sep;
873 print
'"'.$val[
"ref"].
'"'.$sep;
874 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
875 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
876 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).
'"'.$sep;
877 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
878 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
879 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Retainedwarranty").
'"'.$sep;
880 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
881 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
882 print
'"'.$journal.
'"';
889 foreach ($tabttc[$key] as $k => $mt) {
891 print
'"'.$key.
'"'.$sep;
892 print
'"'.$date.
'"'.$sep;
893 print
'"'.$val[
"ref"].
'"'.$sep;
894 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
895 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
896 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')).
'"'.$sep;
897 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
898 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
899 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
900 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
901 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
902 print
'"'.$journal.
'"';
908 foreach ($tabht[$key] as $k => $mt) {
910 $accountingaccount->fetch(
null, $k,
true);
912 print
'"'.$key.
'"'.$sep;
913 print
'"'.$date.
'"'.$sep;
914 print
'"'.$val[
"ref"].
'"'.$sep;
915 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
916 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
917 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
919 print
'"'.mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1').
'"'.$sep;
920 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
921 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
922 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
923 print
'"'.$journal.
'"';
929 $listoftax = array(0, 1, 2);
930 foreach ($listoftax as $numtax) {
931 $arrayofvat = $tabtva;
933 $arrayofvat = $tablocaltax1;
936 $arrayofvat = $tablocaltax2;
939 foreach ($arrayofvat[$key] as $k => $mt) {
941 print
'"'.$key.
'"'.$sep;
942 print
'"'.$date.
'"'.$sep;
943 print
'"'.$val[
"ref"].
'"'.$sep;
944 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
945 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
946 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
948 print
'"'.$langs->trans(
"VAT").
' - '.join(
', ', $def_tva[$key][$k]).
' %"'.$sep;
949 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;
950 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
951 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
952 print
'"'.$journal.
'"';
959 if (isset($tabrevenuestamp[$key])) {
960 foreach ($tabrevenuestamp[$key] as $k => $mt) {
962 print
'"'.$key.
'"'.$sep;
963 print
'"'.$date.
'"'.$sep;
964 print
'"'.$val[
"ref"].
'"'.$sep;
965 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
966 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
967 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
969 print
'"'.$langs->trans(
"RevenueStamp").
'"'.$sep;
970 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"RevenueStamp").
'"'.$sep;
971 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
972 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
973 print
'"'.$journal.
'"';
983if (empty($action) || $action ==
'view') {
984 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
993 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
995 $description .= $langs->trans(
"DepositsAreNotIncluded");
997 $description .= $langs->trans(
"DepositsAreIncluded");
1000 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
1001 $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);
1002 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1004 $varlink =
'id_journal='.$id_journal;
1006 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
1011 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
1012 $resql = $db->query($sql);
1014 $obj = $db->fetch_object($resql);
1015 if ($obj->nb == 0) {
1016 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1017 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1018 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1028 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
1029 if ($acctCustomerNotConfigured) {
1030 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1031 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1032 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1036 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1037 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1038 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1040 if ($acctCustomerNotConfigured) {
1041 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1043 if ($in_bookkeeping ==
'notyet') {
1044 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1046 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1053 <script type="text/javascript">
1054 function launch_export() {
1055 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1056 $("div.fiche form input[type=\"submit\"]").click();
1057 $("div.fiche form input[name=\"action\"]").val("");
1059 function writebookkeeping() {
1060 console.log("click on writebookkeeping");
1061 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1062 $("div.fiche form input[type=\"submit\"]").click();
1063 $("div.fiche form input[name=\"action\"]").val("");
1072 print
'<div class="div-table-responsive">';
1073 print
"<table class=\"noborder\" width=\"100%\">";
1074 print
"<tr class=\"liste_titre\">";
1075 print
"<td>".$langs->trans(
"Date").
"</td>";
1076 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1077 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1078 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1079 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1080 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1081 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1086 $companystatic =
new Client($db);
1087 $invoicestatic =
new Facture($db);
1089 foreach ($tabfac as $key => $val) {
1090 $companystatic->id = $tabcompany[$key][
'id'];
1091 $companystatic->name = $tabcompany[$key][
'name'];
1092 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1093 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1094 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1095 $companystatic->client = 3;
1097 $invoicestatic->id = $key;
1098 $invoicestatic->ref = (string) $val[
"ref"];
1099 $invoicestatic->type = $val[
"type"];
1100 $invoicestatic->close_code = $val[
"close_code"];
1105 $replacedinvoice = 0;
1106 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1107 $replacedinvoice = 1;
1108 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1109 if ($alreadydispatched) {
1110 $replacedinvoice = 2;
1115 if ($replacedinvoice == 1) {
1116 print
'<tr class="oddeven">';
1117 print
"<!-- Replaced invoice -->";
1118 print
"<td>".$date.
"</td>";
1119 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1122 print $langs->trans(
"Replaced");
1129 print
'<td class="right"></td>';
1130 print
'<td class="right"></td>';
1136 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
1137 print
'<tr class="oddeven">';
1138 print
"<!-- Some lines are not bound -->";
1139 print
"<td>".$date.
"</td>";
1140 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1143 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1150 print
'<td class="right"></td>';
1151 print
'<td class="right"></td>';
1158 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
1159 foreach ($tabwarranty[$key] as $k => $mt) {
1160 print
'<tr class="oddeven">';
1161 print
"<!-- Thirdparty warranty -->";
1162 print
"<td>" . $date .
"</td>";
1163 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1167 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1168 print
'<span class="error">' . $langs->trans(
"MainAccountForRetainedWarrantyNotDefined") .
'</span>';
1170 print $accountoshow;
1176 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1177 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1179 print $accountoshow;
1182 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"Retainedwarranty") .
"</td>";
1183 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1184 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1190 foreach ($tabttc[$key] as $k => $mt) {
1191 print
'<tr class="oddeven">';
1192 print
"<!-- Thirdparty -->";
1193 print
"<td>".$date.
"</td>";
1194 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1198 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1199 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1201 print $accountoshow;
1207 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1208 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1210 print $accountoshow;
1213 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1214 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1215 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1222 foreach ($tabht[$key] as $k => $mt) {
1224 $accountingaccount->fetch(
null, $k,
true);
1226 print
'<tr class="oddeven">';
1227 print
"<!-- Product -->";
1228 print
"<td>".$date.
"</td>";
1229 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1233 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1234 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1236 print $accountoshow;
1245 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1246 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1249 $companystatic->id = $tabcompany[$key][
'id'];
1250 $companystatic->name = $tabcompany[$key][
'name'];
1251 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$accountingaccount->label.
"</td>";
1252 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1253 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1260 $listoftax = array(0, 1, 2);
1261 foreach ($listoftax as $numtax) {
1262 $arrayofvat = $tabtva;
1264 $arrayofvat = $tablocaltax1;
1267 $arrayofvat = $tablocaltax2;
1271 foreach ($arrayofvat[$key] as $k => $mt) {
1273 print
'<tr class="oddeven">';
1274 print
"<!-- VAT -->";
1275 print
"<td>".$date.
"</td>";
1276 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1280 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1281 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1283 print $accountoshow;
1289 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref;
1292 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : join(
', ', $def_tva[$key][$k]));
1293 print
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1294 print($numtax ?
' - Localtax '.$numtax :
'');
1296 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1297 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1306 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
1307 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1308 print
'<tr class="oddeven">';
1309 print
"<!-- Thirdparty revenuestamp -->";
1310 print
"<td>" . $date .
"</td>";
1311 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1315 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1316 print
'<span class="error">' . $langs->trans(
"MainAccountForRevenueStampSaleNotDefined") .
'</span>';
1318 print $accountoshow;
1324 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp") .
"</td>";
1325 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1326 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1333 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.