35require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
46$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"errors"));
49$action =
GETPOST(
'action',
'aZ09');
51$date_startmonth =
GETPOST(
'date_startmonth');
52$date_startday =
GETPOST(
'date_startday');
53$date_startyear =
GETPOST(
'date_startyear');
54$date_endmonth =
GETPOST(
'date_endmonth');
55$date_endday =
GETPOST(
'date_endday');
56$date_endyear =
GETPOST(
'date_endyear');
57$in_bookkeeping =
GETPOST(
'in_bookkeeping');
58if ($in_bookkeeping ==
'') {
59 $in_bookkeeping =
'notyet';
64$hookmanager->initHooks(array(
'sellsjournal'));
68if (!isModEnabled(
'accounting')) {
71if ($user->socid > 0) {
74if (!$user->hasRight(
'accounting',
'bind',
'write')) {
85$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
91$accountingjournalstatic->fetch($id_journal);
92$journal = $accountingjournalstatic->code;
93$journal_label = $accountingjournalstatic->label;
95$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
96$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
98if (empty($date_startmonth)) {
101 $date_start = $dates[
'date_start'];
102 $pastmonthyear = $dates[
'pastmonthyear'];
103 $pastmonth = $dates[
'pastmonth'];
105if (empty($date_endmonth)) {
108 $date_end = $dates[
'date_end'];
109 $pastmonthyear = $dates[
'pastmonthyear'];
110 $pastmonth = $dates[
'pastmonth'];
116if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
121$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,";
122$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,";
123$sql .=
" s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
125 $sql .=
" spe.accountancy_code_customer as code_compta,";
126 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
128 $sql .=
" s.code_compta as code_compta,";
129 $sql .=
" s.code_compta_fournisseur,";
131$sql .=
" p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
133 $sql .=
" ppe.accountancy_code_sell";
135 $sql .=
" p.accountancy_code_sell";
137$parameters = array();
138$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
139$sql .= $hookmanager->resPrint;
140$sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as fd";
141$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
143 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
145$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
146$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture as f ON f.rowid = fd.fk_facture";
147$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
149 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
151$parameters = array();
152$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
153$sql .= $hookmanager->resPrint;
154$sql .=
" WHERE fd.fk_code_ventilation > 0";
155$sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
')';
156$sql .=
" AND f.fk_statut > 0";
162$sql .=
" AND fd.product_type IN (0,1)";
163if ($date_start && $date_end) {
164 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".$db->idate($date_end).
"'";
168 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
171if ($in_bookkeeping ==
'already') {
172 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
175if ($in_bookkeeping ==
'notyet') {
176 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
179$parameters = array();
180$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
181$sql .= $hookmanager->resPrint;
182$sql .=
" ORDER BY f.datef, f.ref";
185dol_syslog(
'accountancy/journal/sellsjournal.php', LOG_DEBUG);
186$result = $db->query($sql);
192 $tabwarranty = array();
193 $tabrevenuestamp = array();
195 $tablocaltax1 = array();
196 $tablocaltax2 = array();
197 $tabcompany = array();
198 $vatdata_cache = array();
200 $num = $db->num_rows($result);
208 $obj = $db->fetch_object($result);
211 $compta_soc = (!empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
213 $compta_prod = $obj->compte;
214 if (empty($compta_prod)) {
215 if ($obj->product_type == 0) {
224 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
225 if (array_key_exists($tax_id, $vatdata_cache)) {
226 $vatdata = $vatdata_cache[$tax_id];
231 $buyer->fetch($obj->socid);
237 $vatdata_cache[$tax_id] = $vatdata;
239 $compta_tva = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
240 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
241 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
244 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
245 $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.
')' :
''));
249 $situation_ratio = 1;
251 if ($obj->situation_cycle_ref) {
253 if ($obj->situation_percent == 0) {
254 $situation_ratio = 0;
257 $line->fetch($obj->fdid);
260 $prev_progress = $line->get_prev_progress($obj->rowid);
262 $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
267 $revenuestamp = (float)
price2num($obj->revenuestamp,
'MT');
270 $tabfac[$obj->rowid][
"date"] = $db->jdate($obj->df);
271 $tabfac[$obj->rowid][
"datereg"] = $db->jdate($obj->dlr);
272 $tabfac[$obj->rowid][
"ref"] = $obj->ref;
273 $tabfac[$obj->rowid][
"type"] = $obj->type;
274 $tabfac[$obj->rowid][
"description"] = $obj->label_compte;
275 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
276 $tabfac[$obj->rowid][
"revenuestamp"] = $revenuestamp;
280 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
281 $tabttc[$obj->rowid][$compta_soc] = 0;
283 if (!isset($tabht[$obj->rowid][$compta_prod])) {
284 $tabht[$obj->rowid][$compta_prod] = 0;
286 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
287 $tabtva[$obj->rowid][$compta_tva] = 0;
289 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
290 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
292 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
293 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
302 $total_ttc = $obj->total_ttc * $situation_ratio;
304 $total_ttc = $obj->total_ttc;
308 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) {
309 $retained_warranty = (float)
price2num($total_ttc * $obj->retained_warranty / 100,
'MT');
310 $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
311 $total_ttc -= $retained_warranty;
314 $tabttc[$obj->rowid][$compta_soc] += $total_ttc;
315 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
316 $tva_npr = ((($obj->info_bits & 1) == 1) ? 1 : 0);
319 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
320 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
321 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
323 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
324 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
325 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
329 $compta_revenuestamp =
'NotDefined';
330 if (!empty($revenuestamp)) {
331 $sqlrevenuestamp =
"SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX.
"c_revenuestamp";
332 $sqlrevenuestamp .=
" WHERE fk_pays = ".((int) $mysoc->country_id);
333 $sqlrevenuestamp .=
" AND taux = ".((float) $revenuestamp);
334 $sqlrevenuestamp .=
" AND active = 1";
335 $resqlrevenuestamp = $db->query($sqlrevenuestamp);
337 if ($resqlrevenuestamp) {
338 $num_rows_revenuestamp = $db->num_rows($resqlrevenuestamp);
339 if ($num_rows_revenuestamp > 1) {
340 dol_print_error($db,
'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
342 $objrevenuestamp = $db->fetch_object($resqlrevenuestamp);
343 if ($objrevenuestamp) {
344 $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
350 if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
352 $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
353 $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
356 $tabcompany[$obj->rowid] = array(
358 'name' => $obj->name,
359 'code_client' => $obj->code_client,
360 'code_compta' => $compta_soc
366 if ($i >
getDolGlobalInt(
'ACCOUNTANCY_MAX_TOO_MANY_LINES_TO_PROCESS', 10000)) {
368 setEventMessages(
"ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
379$errorforinvoice = array();
401if (!empty($tabfac)) {
405 COUNT(fd.rowid) as nb
407 ".MAIN_DB_PREFIX.
"facturedet as fd
410 AND fd.fk_code_ventilation <= 0
411 AND fd.total_ttc <> 0
412 AND fk_facture IN (".$db->sanitize(implode(
",", array_keys($tabfac))).
")
415 $resql = $db->query($sql);
417 $num = $db->num_rows($resql);
420 $obj = $db->fetch_object($resql);
422 $errorforinvoice[$obj->fk_facture] =
'somelinesarenotbound';
431if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
435 $companystatic =
new Societe($db);
436 $invoicestatic =
new Facture($db);
439 $accountingaccountcustomer->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
442 $accountingaccountcustomerwarranty->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'),
true);
444 foreach ($tabfac as $key => $val) {
452 $companystatic->id = $tabcompany[$key][
'id'];
453 $companystatic->name = $tabcompany[$key][
'name'];
454 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
455 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
456 $companystatic->code_client = $tabcompany[$key][
'code_client'];
457 $companystatic->client = 3;
459 $invoicestatic->id = $key;
460 $invoicestatic->ref = (string) $val[
"ref"];
461 $invoicestatic->type = $val[
"type"];
462 $invoicestatic->close_code = $val[
"close_code"];
467 $replacedinvoice = 0;
468 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
469 $replacedinvoice = 1;
470 $alreadydispatched = $invoicestatic->getVentilExportCompta();
471 if ($alreadydispatched) {
472 $replacedinvoice = 2;
477 if ($replacedinvoice == 1) {
483 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
486 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
491 if (isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
492 foreach ($tabwarranty[$key] as $k => $mt) {
494 $bookkeeping->doc_date = $val[
"date"];
495 $bookkeeping->date_lim_reglement = $val[
"datereg"];
496 $bookkeeping->doc_ref = $val[
"ref"];
497 $bookkeeping->date_creation = $now;
498 $bookkeeping->doc_type =
'customer_invoice';
499 $bookkeeping->fk_doc = $key;
500 $bookkeeping->fk_docdet = 0;
501 $bookkeeping->thirdparty_code = $companystatic->code_client;
503 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
504 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
506 $bookkeeping->numero_compte =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
507 $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
509 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RetainedWarranty");
510 $bookkeeping->montant = $mt;
511 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
512 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
513 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
514 $bookkeeping->code_journal = $journal;
515 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
516 $bookkeeping->fk_user_author = $user->id;
517 $bookkeeping->entity = $conf->entity;
519 $totaldebit += $bookkeeping->debit;
520 $totalcredit += $bookkeeping->credit;
522 $result = $bookkeeping->create($user);
524 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
527 $errorforinvoice[$key] =
'alreadyjournalized';
532 $errorforinvoice[$key] =
'other';
541 if (!$errorforline) {
542 foreach ($tabttc[$key] as $k => $mt) {
544 $bookkeeping->doc_date = $val[
"date"];
545 $bookkeeping->date_lim_reglement = $val[
"datereg"];
546 $bookkeeping->doc_ref = $val[
"ref"];
547 $bookkeeping->date_creation = $now;
548 $bookkeeping->doc_type =
'customer_invoice';
549 $bookkeeping->fk_doc = $key;
550 $bookkeeping->fk_docdet = 0;
551 $bookkeeping->thirdparty_code = $companystatic->code_client;
553 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
554 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
557 $bookkeeping->label_compte = $accountingaccountcustomer->label;
559 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount");
560 $bookkeeping->montant = $mt;
561 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
562 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
563 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
564 $bookkeeping->code_journal = $journal;
565 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
566 $bookkeeping->fk_user_author = $user->id;
567 $bookkeeping->entity = $conf->entity;
569 $totaldebit += $bookkeeping->debit;
570 $totalcredit += $bookkeeping->credit;
572 $result = $bookkeeping->create($user);
574 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
577 $errorforinvoice[$key] =
'alreadyjournalized';
582 $errorforinvoice[$key] =
'other';
587 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
590 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
597 if (!$errorforline) {
598 foreach ($tabht[$key] as $k => $mt) {
599 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
601 $accountingaccount->fetch(0, $k,
true);
602 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
604 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
607 $label_account = $accountingaccount->label;
610 if ($accountingaccount->id > 0) {
612 $bookkeeping->doc_date = $val[
"date"];
613 $bookkeeping->date_lim_reglement = $val[
"datereg"];
614 $bookkeeping->doc_ref = $val[
"ref"];
615 $bookkeeping->date_creation = $now;
616 $bookkeeping->doc_type =
'customer_invoice';
617 $bookkeeping->fk_doc = $key;
618 $bookkeeping->fk_docdet = 0;
619 $bookkeeping->thirdparty_code = $companystatic->code_client;
623 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
624 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
626 $bookkeeping->subledger_account =
'';
627 $bookkeeping->subledger_label =
'';
630 $bookkeeping->subledger_account =
'';
631 $bookkeeping->subledger_label =
'';
634 $bookkeeping->numero_compte = $k;
635 $bookkeeping->label_compte = $label_account;
637 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$label_account;
638 $bookkeeping->montant = $mt;
639 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
640 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
641 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
642 $bookkeeping->code_journal = $journal;
643 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
644 $bookkeeping->fk_user_author = $user->id;
645 $bookkeeping->entity = $conf->entity;
647 $totaldebit += $bookkeeping->debit;
648 $totalcredit += $bookkeeping->credit;
650 $result = $bookkeeping->create($user);
652 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
655 $errorforinvoice[$key] =
'alreadyjournalized';
660 $errorforinvoice[$key] =
'other';
669 if (!$errorforline) {
670 $listoftax = array(0, 1, 2);
671 foreach ($listoftax as $numtax) {
672 $arrayofvat = $tabtva;
674 $arrayofvat = $tablocaltax1;
677 $arrayofvat = $tablocaltax2;
680 foreach ($arrayofvat[$key] as $k => $mt) {
682 $accountingaccount->fetch(
null, $k,
true);
683 $label_account = $accountingaccount->label;
686 $bookkeeping->doc_date = $val[
"date"];
687 $bookkeeping->date_lim_reglement = $val[
"datereg"];
688 $bookkeeping->doc_ref = $val[
"ref"];
689 $bookkeeping->date_creation = $now;
690 $bookkeeping->doc_type =
'customer_invoice';
691 $bookkeeping->fk_doc = $key;
692 $bookkeeping->fk_docdet = 0;
693 $bookkeeping->thirdparty_code = $companystatic->code_client;
695 $bookkeeping->subledger_account =
'';
696 $bookkeeping->subledger_label =
'';
698 $bookkeeping->numero_compte = $k;
699 $bookkeeping->label_compte = $label_account;
702 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref;
703 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
704 $bookkeeping->label_operation .=
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
705 $bookkeeping->label_operation .= ($numtax ?
' - Localtax '.$numtax :
'');
707 $bookkeeping->montant = $mt;
708 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
709 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
710 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
711 $bookkeeping->code_journal = $journal;
712 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
713 $bookkeeping->fk_user_author = $user->id;
714 $bookkeeping->entity = $conf->entity;
716 $totaldebit += $bookkeeping->debit;
717 $totalcredit += $bookkeeping->credit;
719 $result = $bookkeeping->create($user);
721 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
724 $errorforinvoice[$key] =
'alreadyjournalized';
729 $errorforinvoice[$key] =
'other';
739 if (!$errorforline) {
740 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
741 foreach ($tabrevenuestamp[$key] as $k => $mt) {
743 $accountingaccount->fetch(
null, $k,
true);
744 $label_account = $accountingaccount->label;
747 $bookkeeping->doc_date = $val[
"date"];
748 $bookkeeping->date_lim_reglement = $val[
"datereg"];
749 $bookkeeping->doc_ref = $val[
"ref"];
750 $bookkeeping->date_creation = $now;
751 $bookkeeping->doc_type =
'customer_invoice';
752 $bookkeeping->fk_doc = $key;
753 $bookkeeping->fk_docdet = 0;
754 $bookkeeping->thirdparty_code = $companystatic->code_client;
756 $bookkeeping->subledger_account =
'';
757 $bookkeeping->subledger_label =
'';
759 $bookkeeping->numero_compte = $k;
760 $bookkeeping->label_compte = $label_account;
762 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp");
763 $bookkeeping->montant = $mt;
764 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
765 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
766 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
767 $bookkeeping->code_journal = $journal;
768 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
769 $bookkeeping->fk_user_author = $user->id;
770 $bookkeeping->entity = $conf->entity;
772 $totaldebit += $bookkeeping->debit;
773 $totalcredit += $bookkeeping->credit;
775 $result = $bookkeeping->create($user);
777 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
780 $errorforinvoice[$key] =
'alreadyjournalized';
785 $errorforinvoice[$key] =
'other';
795 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
798 $errorforinvoice[$key] =
'amountsnotbalanced';
799 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
802 if (!$errorforline) {
808 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
816 if (empty($error) && count($tabpay) > 0) {
818 } elseif (count($tabpay) == $error) {
821 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
827 if (count($tabpay) != $error) {
828 $param =
'id_journal='.$id_journal;
829 $param .=
'&date_startday='.$date_startday;
830 $param .=
'&date_startmonth='.$date_startmonth;
831 $param .=
'&date_startyear='.$date_startyear;
832 $param .=
'&date_endday='.$date_endday;
833 $param .=
'&date_endmonth='.$date_endmonth;
834 $param .=
'&date_endyear='.$date_endyear;
835 $param .=
'&in_bookkeeping='.$in_bookkeeping;
836 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
847$form =
new Form($db);
850if ($action ==
'exportcsv' && !$error) {
854 $filename =
'journal';
855 $type_export =
'journal';
856 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
858 $companystatic =
new Client($db);
859 $invoicestatic =
new Facture($db);
861 foreach ($tabfac as $key => $val) {
862 $companystatic->id = $tabcompany[$key][
'id'];
863 $companystatic->name = $tabcompany[$key][
'name'];
864 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
865 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
866 $companystatic->code_client = $tabcompany[$key][
'code_client'];
867 $companystatic->client = 3;
869 $invoicestatic->id = $key;
870 $invoicestatic->ref = (string) $val[
"ref"];
871 $invoicestatic->type = $val[
"type"];
872 $invoicestatic->close_code = $val[
"close_code"];
877 $replacedinvoice = 0;
878 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
879 $replacedinvoice = 1;
880 $alreadydispatched = $invoicestatic->getVentilExportCompta();
881 if ($alreadydispatched) {
882 $replacedinvoice = 2;
887 if ($replacedinvoice == 1) {
892 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
893 foreach ($tabwarranty[$key] as $k => $mt) {
895 print
'"'.$key.
'"'.$sep;
896 print
'"'.$date.
'"'.$sep;
897 print
'"'.$val[
"ref"].
'"'.$sep;
898 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
899 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
900 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).
'"'.$sep;
901 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
902 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
903 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"RetainedWarranty").
'"'.$sep;
904 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
905 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
906 print
'"'.$journal.
'"';
913 foreach ($tabttc[$key] as $k => $mt) {
915 print
'"'.$key.
'"'.$sep;
916 print
'"'.$date.
'"'.$sep;
917 print
'"'.$val[
"ref"].
'"'.$sep;
918 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
919 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
920 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')).
'"'.$sep;
921 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
922 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
923 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
924 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
925 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
926 print
'"'.$journal.
'"';
932 foreach ($tabht[$key] as $k => $mt) {
934 $accountingaccount->fetch(
null, $k,
true);
936 print
'"'.$key.
'"'.$sep;
937 print
'"'.$date.
'"'.$sep;
938 print
'"'.$val[
"ref"].
'"'.$sep;
939 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
940 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
941 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
943 print
'"'.mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1').
'"'.$sep;
944 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
945 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
946 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
947 print
'"'.$journal.
'"';
953 $listoftax = array(0, 1, 2);
954 foreach ($listoftax as $numtax) {
955 $arrayofvat = $tabtva;
957 $arrayofvat = $tablocaltax1;
960 $arrayofvat = $tablocaltax2;
963 foreach ($arrayofvat[$key] as $k => $mt) {
965 print
'"'.$key.
'"'.$sep;
966 print
'"'.$date.
'"'.$sep;
967 print
'"'.$val[
"ref"].
'"'.$sep;
968 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
969 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
970 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
972 print
'"'.$langs->trans(
"VAT").
' - '.implode(
', ', $def_tva[$key][$k]).
' %"'.$sep;
973 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"VAT").implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'').
'"'.$sep;
974 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
975 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
976 print
'"'.$journal.
'"';
983 if (isset($tabrevenuestamp[$key])) {
984 foreach ($tabrevenuestamp[$key] as $k => $mt) {
986 print
'"'.$key.
'"'.$sep;
987 print
'"'.$date.
'"'.$sep;
988 print
'"'.$val[
"ref"].
'"'.$sep;
989 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
990 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
991 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
993 print
'"'.$langs->trans(
"RevenueStamp").
'"'.$sep;
994 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"RevenueStamp").
'"'.$sep;
995 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
996 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
997 print
'"'.$journal.
'"';
1007if (empty($action) || $action ==
'view') {
1008 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1009 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
1017 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1019 $description .= $langs->trans(
"DepositsAreNotIncluded");
1021 $description .= $langs->trans(
"DepositsAreIncluded");
1024 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
1025 $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);
1026 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1028 $varlink =
'id_journal='.$id_journal;
1030 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
1035 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
1036 $resql = $db->query($sql);
1038 $obj = $db->fetch_object($resql);
1039 if ($obj->nb == 0) {
1040 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1041 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1042 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1052 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
1053 if ($acctCustomerNotConfigured) {
1054 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1055 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1056 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1060 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1061 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1062 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1064 if ($acctCustomerNotConfigured) {
1065 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1067 if ($in_bookkeeping ==
'notyet') {
1068 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1070 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1077 <script type="text/javascript">
1078 function launch_export() {
1079 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1080 $("div.fiche form input[type=\"submit\"]").click();
1081 $("div.fiche form input[name=\"action\"]").val("");
1083 function writebookkeeping() {
1084 console.log("click on writebookkeeping");
1085 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1086 $("div.fiche form input[type=\"submit\"]").click();
1087 $("div.fiche form input[name=\"action\"]").val("");
1096 print
'<div class="div-table-responsive">';
1097 print
"<table class=\"noborder\" width=\"100%\">";
1098 print
"<tr class=\"liste_titre\">";
1099 print
"<td>".$langs->trans(
"Date").
"</td>";
1100 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1101 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1102 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1103 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1104 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1105 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1110 $companystatic =
new Client($db);
1111 $invoicestatic =
new Facture($db);
1113 foreach ($tabfac as $key => $val) {
1114 $companystatic->id = $tabcompany[$key][
'id'];
1115 $companystatic->name = $tabcompany[$key][
'name'];
1116 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1117 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1118 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1119 $companystatic->client = 3;
1121 $invoicestatic->id = $key;
1122 $invoicestatic->ref = (string) $val[
"ref"];
1123 $invoicestatic->type = $val[
"type"];
1124 $invoicestatic->close_code = $val[
"close_code"];
1129 $replacedinvoice = 0;
1130 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1131 $replacedinvoice = 1;
1132 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1133 if ($alreadydispatched) {
1134 $replacedinvoice = 2;
1139 if ($replacedinvoice == 1) {
1140 print
'<tr class="oddeven">';
1141 print
"<!-- Replaced invoice -->";
1142 print
"<td>".$date.
"</td>";
1143 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1146 print $langs->trans(
"Replaced");
1153 print
'<td class="right"></td>';
1154 print
'<td class="right"></td>';
1160 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
1161 print
'<tr class="oddeven">';
1162 print
"<!-- Some lines are not bound -->";
1163 print
"<td>".$date.
"</td>";
1164 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1167 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1174 print
'<td class="right"></td>';
1175 print
'<td class="right"></td>';
1182 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
1183 foreach ($tabwarranty[$key] as $k => $mt) {
1184 print
'<tr class="oddeven">';
1185 print
"<!-- Thirdparty warranty -->";
1186 print
"<td>" . $date .
"</td>";
1187 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1191 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1192 print
'<span class="error">' . $langs->trans(
"MainAccountForRetainedWarrantyNotDefined") .
'</span>';
1194 print $accountoshow;
1200 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1201 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1203 print $accountoshow;
1206 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RetainedWarranty") .
"</td>";
1207 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1208 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1214 foreach ($tabttc[$key] as $k => $mt) {
1215 print
'<tr class="oddeven">';
1216 print
"<!-- Thirdparty -->";
1217 print
"<td>".$date.
"</td>";
1218 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1222 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1223 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1225 print $accountoshow;
1231 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1232 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1234 print $accountoshow;
1237 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1238 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1239 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1246 foreach ($tabht[$key] as $k => $mt) {
1247 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
1249 $accountingaccount->fetch(0, $k,
true);
1250 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1252 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
1255 print
'<tr class="oddeven">';
1256 print
"<!-- Product -->";
1257 print
"<td>".$date.
"</td>";
1258 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1262 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1263 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1265 print $accountoshow;
1274 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1275 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1278 $companystatic->id = $tabcompany[$key][
'id'];
1279 $companystatic->name = $tabcompany[$key][
'name'];
1280 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$accountingaccount->label.
"</td>";
1281 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1282 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1289 $listoftax = array(0, 1, 2);
1290 foreach ($listoftax as $numtax) {
1291 $arrayofvat = $tabtva;
1293 $arrayofvat = $tablocaltax1;
1296 $arrayofvat = $tablocaltax2;
1300 foreach ($arrayofvat[$key] as $k => $mt) {
1302 print
'<tr class="oddeven">';
1303 print
"<!-- VAT -->";
1304 print
"<td>".$date.
"</td>";
1305 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1309 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1310 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1312 print $accountoshow;
1318 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref;
1321 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
1322 print
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1323 print($numtax ?
' - Localtax '.$numtax :
'');
1325 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1326 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1335 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
1336 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1337 print
'<tr class="oddeven">';
1338 print
"<!-- Thirdparty revenuestamp -->";
1339 print
"<td>" . $date .
"</td>";
1340 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1344 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1345 print
'<span class="error">' . $langs->trans(
"MainAccountForRevenueStampSaleNotDefined") .
'</span>';
1347 print $accountoshow;
1353 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp") .
"</td>";
1354 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1355 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1362 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)
journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='', $moreoptions=array())
Show header of a page used to transfer/dispatch data in accounting.
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
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 information (by default a local PHP server timestamp) Rep...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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 '.
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_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' 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.