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];
229 $vatdata_cache[$tax_id] = $vatdata;
231 $compta_tva = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
232 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
233 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
236 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
237 $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.
')' :
''));
241 $situation_ratio = 1;
243 if ($obj->situation_cycle_ref) {
245 if ($obj->situation_percent == 0) {
246 $situation_ratio = 0;
249 $line->fetch($obj->fdid);
252 $prev_progress = $line->get_prev_progress($obj->rowid);
254 $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
259 $revenuestamp = (float)
price2num($obj->revenuestamp,
'MT');
262 $tabfac[$obj->rowid][
"date"] = $db->jdate($obj->df);
263 $tabfac[$obj->rowid][
"datereg"] = $db->jdate($obj->dlr);
264 $tabfac[$obj->rowid][
"ref"] = $obj->ref;
265 $tabfac[$obj->rowid][
"type"] = $obj->type;
266 $tabfac[$obj->rowid][
"description"] = $obj->label_compte;
267 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
268 $tabfac[$obj->rowid][
"revenuestamp"] = $revenuestamp;
272 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
273 $tabttc[$obj->rowid][$compta_soc] = 0;
275 if (!isset($tabht[$obj->rowid][$compta_prod])) {
276 $tabht[$obj->rowid][$compta_prod] = 0;
278 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
279 $tabtva[$obj->rowid][$compta_tva] = 0;
281 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
282 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
284 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
285 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
294 $total_ttc = $obj->total_ttc * $situation_ratio;
296 $total_ttc = $obj->total_ttc;
300 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) {
301 $retained_warranty = (float)
price2num($total_ttc * $obj->retained_warranty / 100,
'MT');
302 $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
303 $total_ttc -= $retained_warranty;
306 $tabttc[$obj->rowid][$compta_soc] += $total_ttc;
307 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
308 $tva_npr = ((($obj->info_bits & 1) == 1) ? 1 : 0);
311 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
312 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
313 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
315 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
316 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
317 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
321 $compta_revenuestamp =
'NotDefined';
322 if (!empty($revenuestamp)) {
323 $sqlrevenuestamp =
"SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX.
"c_revenuestamp";
324 $sqlrevenuestamp .=
" WHERE fk_pays = ".((int) $mysoc->country_id);
325 $sqlrevenuestamp .=
" AND taux = ".((float) $revenuestamp);
326 $sqlrevenuestamp .=
" AND active = 1";
327 $resqlrevenuestamp = $db->query($sqlrevenuestamp);
329 if ($resqlrevenuestamp) {
330 $num_rows_revenuestamp = $db->num_rows($resqlrevenuestamp);
331 if ($num_rows_revenuestamp > 1) {
332 dol_print_error($db,
'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
334 $objrevenuestamp = $db->fetch_object($resqlrevenuestamp);
335 if ($objrevenuestamp) {
336 $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
342 if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
344 $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
345 $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
348 $tabcompany[$obj->rowid] = array(
350 'name' => $obj->name,
351 'code_client' => $obj->code_client,
352 'code_compta' => $compta_soc
358 if ($i >
getDolGlobalInt(
'ACCOUNTANCY_MAX_TOO_MANY_LINES_TO_PROCESS', 10000)) {
360 setEventMessages(
"ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
371$errorforinvoice = array();
397 COUNT(fd.rowid) as nb
399 ".MAIN_DB_PREFIX.
"facturedet as fd
402 AND fd.fk_code_ventilation <= 0
403 AND fd.total_ttc <> 0
404 AND fk_facture IN (".$db->sanitize(implode(
",", array_keys($tabfac))).
")
407$resql = $db->query($sql);
409 $num = $db->num_rows($resql);
412 $obj = $db->fetch_object($resql);
414 $errorforinvoice[$obj->fk_facture_fourn] =
'somelinesarenotbound';
422if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
426 $companystatic =
new Societe($db);
427 $invoicestatic =
new Facture($db);
430 $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 (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
477 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
482 if (isset($tabwarranty[$key]) && 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 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
592 $accountingaccount->fetch(0, $k,
true);
593 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
595 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
598 $label_account = $accountingaccount->label;
601 if ($accountingaccount->id > 0) {
603 $bookkeeping->doc_date = $val[
"date"];
604 $bookkeeping->date_lim_reglement = $val[
"datereg"];
605 $bookkeeping->doc_ref = $val[
"ref"];
606 $bookkeeping->date_creation = $now;
607 $bookkeeping->doc_type =
'customer_invoice';
608 $bookkeeping->fk_doc = $key;
609 $bookkeeping->fk_docdet = 0;
610 $bookkeeping->thirdparty_code = $companystatic->code_client;
614 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
615 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
617 $bookkeeping->subledger_account =
'';
618 $bookkeeping->subledger_label =
'';
621 $bookkeeping->subledger_account =
'';
622 $bookkeeping->subledger_label =
'';
625 $bookkeeping->numero_compte = $k;
626 $bookkeeping->label_compte = $label_account;
628 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$label_account;
629 $bookkeeping->montant = $mt;
630 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
631 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
632 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
633 $bookkeeping->code_journal = $journal;
634 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
635 $bookkeeping->fk_user_author = $user->id;
636 $bookkeeping->entity = $conf->entity;
638 $totaldebit += $bookkeeping->debit;
639 $totalcredit += $bookkeeping->credit;
641 $result = $bookkeeping->create($user);
643 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
646 $errorforinvoice[$key] =
'alreadyjournalized';
651 $errorforinvoice[$key] =
'other';
660 if (!$errorforline) {
661 $listoftax = array(0, 1, 2);
662 foreach ($listoftax as $numtax) {
663 $arrayofvat = $tabtva;
665 $arrayofvat = $tablocaltax1;
668 $arrayofvat = $tablocaltax2;
671 foreach ($arrayofvat[$key] as $k => $mt) {
673 $accountingaccount->fetch(
null, $k,
true);
674 $label_account = $accountingaccount->label;
677 $bookkeeping->doc_date = $val[
"date"];
678 $bookkeeping->date_lim_reglement = $val[
"datereg"];
679 $bookkeeping->doc_ref = $val[
"ref"];
680 $bookkeeping->date_creation = $now;
681 $bookkeeping->doc_type =
'customer_invoice';
682 $bookkeeping->fk_doc = $key;
683 $bookkeeping->fk_docdet = 0;
684 $bookkeeping->thirdparty_code = $companystatic->code_client;
686 $bookkeeping->subledger_account =
'';
687 $bookkeeping->subledger_label =
'';
689 $bookkeeping->numero_compte = $k;
690 $bookkeeping->label_compte = $label_account;
693 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref;
694 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
695 $bookkeeping->label_operation .=
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
696 $bookkeeping->label_operation .= ($numtax ?
' - Localtax '.$numtax :
'');
698 $bookkeeping->montant = $mt;
699 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
700 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
701 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
702 $bookkeeping->code_journal = $journal;
703 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
704 $bookkeeping->fk_user_author = $user->id;
705 $bookkeeping->entity = $conf->entity;
707 $totaldebit += $bookkeeping->debit;
708 $totalcredit += $bookkeeping->credit;
710 $result = $bookkeeping->create($user);
712 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
715 $errorforinvoice[$key] =
'alreadyjournalized';
720 $errorforinvoice[$key] =
'other';
730 if (!$errorforline) {
731 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
732 foreach ($tabrevenuestamp[$key] as $k => $mt) {
734 $accountingaccount->fetch(
null, $k,
true);
735 $label_account = $accountingaccount->label;
738 $bookkeeping->doc_date = $val[
"date"];
739 $bookkeeping->date_lim_reglement = $val[
"datereg"];
740 $bookkeeping->doc_ref = $val[
"ref"];
741 $bookkeeping->date_creation = $now;
742 $bookkeeping->doc_type =
'customer_invoice';
743 $bookkeeping->fk_doc = $key;
744 $bookkeeping->fk_docdet = 0;
745 $bookkeeping->thirdparty_code = $companystatic->code_client;
747 $bookkeeping->subledger_account =
'';
748 $bookkeeping->subledger_label =
'';
750 $bookkeeping->numero_compte = $k;
751 $bookkeeping->label_compte = $label_account;
753 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp");
754 $bookkeeping->montant = $mt;
755 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
756 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
757 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
758 $bookkeeping->code_journal = $journal;
759 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
760 $bookkeeping->fk_user_author = $user->id;
761 $bookkeeping->entity = $conf->entity;
763 $totaldebit += $bookkeeping->debit;
764 $totalcredit += $bookkeeping->credit;
766 $result = $bookkeeping->create($user);
768 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
771 $errorforinvoice[$key] =
'alreadyjournalized';
776 $errorforinvoice[$key] =
'other';
786 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
789 $errorforinvoice[$key] =
'amountsnotbalanced';
790 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
793 if (!$errorforline) {
799 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
807 if (empty($error) && count($tabpay) > 0) {
809 } elseif (count($tabpay) == $error) {
812 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
818 if (count($tabpay) != $error) {
819 $param =
'id_journal='.$id_journal;
820 $param .=
'&date_startday='.$date_startday;
821 $param .=
'&date_startmonth='.$date_startmonth;
822 $param .=
'&date_startyear='.$date_startyear;
823 $param .=
'&date_endday='.$date_endday;
824 $param .=
'&date_endmonth='.$date_endmonth;
825 $param .=
'&date_endyear='.$date_endyear;
826 $param .=
'&in_bookkeeping='.$in_bookkeeping;
827 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
838$form =
new Form($db);
841if ($action ==
'exportcsv' && !$error) {
845 $filename =
'journal';
846 $type_export =
'journal';
847 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
849 $companystatic =
new Client($db);
850 $invoicestatic =
new Facture($db);
852 foreach ($tabfac as $key => $val) {
853 $companystatic->id = $tabcompany[$key][
'id'];
854 $companystatic->name = $tabcompany[$key][
'name'];
855 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
856 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
857 $companystatic->code_client = $tabcompany[$key][
'code_client'];
858 $companystatic->client = 3;
860 $invoicestatic->id = $key;
861 $invoicestatic->ref = (string) $val[
"ref"];
862 $invoicestatic->type = $val[
"type"];
863 $invoicestatic->close_code = $val[
"close_code"];
868 $replacedinvoice = 0;
869 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
870 $replacedinvoice = 1;
871 $alreadydispatched = $invoicestatic->getVentilExportCompta();
872 if ($alreadydispatched) {
873 $replacedinvoice = 2;
878 if ($replacedinvoice == 1) {
883 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
884 foreach ($tabwarranty[$key] as $k => $mt) {
886 print
'"'.$key.
'"'.$sep;
887 print
'"'.$date.
'"'.$sep;
888 print
'"'.$val[
"ref"].
'"'.$sep;
889 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
890 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
891 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).
'"'.$sep;
892 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
893 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
894 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"RetainedWarranty").
'"'.$sep;
895 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
896 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
897 print
'"'.$journal.
'"';
904 foreach ($tabttc[$key] as $k => $mt) {
906 print
'"'.$key.
'"'.$sep;
907 print
'"'.$date.
'"'.$sep;
908 print
'"'.$val[
"ref"].
'"'.$sep;
909 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
910 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
911 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')).
'"'.$sep;
912 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
913 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
914 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
915 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
916 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
917 print
'"'.$journal.
'"';
923 foreach ($tabht[$key] as $k => $mt) {
925 $accountingaccount->fetch(
null, $k,
true);
927 print
'"'.$key.
'"'.$sep;
928 print
'"'.$date.
'"'.$sep;
929 print
'"'.$val[
"ref"].
'"'.$sep;
930 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
931 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
932 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
934 print
'"'.mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1').
'"'.$sep;
935 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
936 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
937 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
938 print
'"'.$journal.
'"';
944 $listoftax = array(0, 1, 2);
945 foreach ($listoftax as $numtax) {
946 $arrayofvat = $tabtva;
948 $arrayofvat = $tablocaltax1;
951 $arrayofvat = $tablocaltax2;
954 foreach ($arrayofvat[$key] as $k => $mt) {
956 print
'"'.$key.
'"'.$sep;
957 print
'"'.$date.
'"'.$sep;
958 print
'"'.$val[
"ref"].
'"'.$sep;
959 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
960 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
961 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
963 print
'"'.$langs->trans(
"VAT").
' - '.implode(
', ', $def_tva[$key][$k]).
' %"'.$sep;
964 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;
965 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
966 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
967 print
'"'.$journal.
'"';
974 if (isset($tabrevenuestamp[$key])) {
975 foreach ($tabrevenuestamp[$key] as $k => $mt) {
977 print
'"'.$key.
'"'.$sep;
978 print
'"'.$date.
'"'.$sep;
979 print
'"'.$val[
"ref"].
'"'.$sep;
980 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
981 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
982 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
984 print
'"'.$langs->trans(
"RevenueStamp").
'"'.$sep;
985 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"RevenueStamp").
'"'.$sep;
986 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
987 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
988 print
'"'.$journal.
'"';
998if (empty($action) || $action ==
'view') {
999 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1000 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
1008 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1010 $description .= $langs->trans(
"DepositsAreNotIncluded");
1012 $description .= $langs->trans(
"DepositsAreIncluded");
1015 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
1016 $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);
1017 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1019 $varlink =
'id_journal='.$id_journal;
1021 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
1026 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
1027 $resql = $db->query($sql);
1029 $obj = $db->fetch_object($resql);
1030 if ($obj->nb == 0) {
1031 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1032 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1033 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1043 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
1044 if ($acctCustomerNotConfigured) {
1045 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1046 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1047 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1051 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1052 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1053 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1055 if ($acctCustomerNotConfigured) {
1056 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1058 if ($in_bookkeeping ==
'notyet') {
1059 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1061 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1068 <script type="text/javascript">
1069 function launch_export() {
1070 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1071 $("div.fiche form input[type=\"submit\"]").click();
1072 $("div.fiche form input[name=\"action\"]").val("");
1074 function writebookkeeping() {
1075 console.log("click on writebookkeeping");
1076 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1077 $("div.fiche form input[type=\"submit\"]").click();
1078 $("div.fiche form input[name=\"action\"]").val("");
1087 print
'<div class="div-table-responsive">';
1088 print
"<table class=\"noborder\" width=\"100%\">";
1089 print
"<tr class=\"liste_titre\">";
1090 print
"<td>".$langs->trans(
"Date").
"</td>";
1091 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1092 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1093 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1094 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1095 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1096 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1101 $companystatic =
new Client($db);
1102 $invoicestatic =
new Facture($db);
1104 foreach ($tabfac as $key => $val) {
1105 $companystatic->id = $tabcompany[$key][
'id'];
1106 $companystatic->name = $tabcompany[$key][
'name'];
1107 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1108 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1109 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1110 $companystatic->client = 3;
1112 $invoicestatic->id = $key;
1113 $invoicestatic->ref = (string) $val[
"ref"];
1114 $invoicestatic->type = $val[
"type"];
1115 $invoicestatic->close_code = $val[
"close_code"];
1120 $replacedinvoice = 0;
1121 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1122 $replacedinvoice = 1;
1123 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1124 if ($alreadydispatched) {
1125 $replacedinvoice = 2;
1130 if ($replacedinvoice == 1) {
1131 print
'<tr class="oddeven">';
1132 print
"<!-- Replaced invoice -->";
1133 print
"<td>".$date.
"</td>";
1134 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1137 print $langs->trans(
"Replaced");
1144 print
'<td class="right"></td>';
1145 print
'<td class="right"></td>';
1151 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
1152 print
'<tr class="oddeven">';
1153 print
"<!-- Some lines are not bound -->";
1154 print
"<td>".$date.
"</td>";
1155 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1158 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1165 print
'<td class="right"></td>';
1166 print
'<td class="right"></td>';
1173 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
1174 foreach ($tabwarranty[$key] as $k => $mt) {
1175 print
'<tr class="oddeven">';
1176 print
"<!-- Thirdparty warranty -->";
1177 print
"<td>" . $date .
"</td>";
1178 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1182 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1183 print
'<span class="error">' . $langs->trans(
"MainAccountForRetainedWarrantyNotDefined") .
'</span>';
1185 print $accountoshow;
1191 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1192 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1194 print $accountoshow;
1197 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RetainedWarranty") .
"</td>";
1198 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1199 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1205 foreach ($tabttc[$key] as $k => $mt) {
1206 print
'<tr class="oddeven">';
1207 print
"<!-- Thirdparty -->";
1208 print
"<td>".$date.
"</td>";
1209 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1213 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1214 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1216 print $accountoshow;
1222 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1223 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1225 print $accountoshow;
1228 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1229 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1230 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1237 foreach ($tabht[$key] as $k => $mt) {
1238 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
1240 $accountingaccount->fetch(0, $k,
true);
1241 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1243 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
1246 print
'<tr class="oddeven">';
1247 print
"<!-- Product -->";
1248 print
"<td>".$date.
"</td>";
1249 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1253 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1254 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1256 print $accountoshow;
1265 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1266 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1269 $companystatic->id = $tabcompany[$key][
'id'];
1270 $companystatic->name = $tabcompany[$key][
'name'];
1271 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$accountingaccount->label.
"</td>";
1272 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1273 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1280 $listoftax = array(0, 1, 2);
1281 foreach ($listoftax as $numtax) {
1282 $arrayofvat = $tabtva;
1284 $arrayofvat = $tablocaltax1;
1287 $arrayofvat = $tablocaltax2;
1291 foreach ($arrayofvat[$key] as $k => $mt) {
1293 print
'<tr class="oddeven">';
1294 print
"<!-- VAT -->";
1295 print
"<td>".$date.
"</td>";
1296 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1300 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1301 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1303 print $accountoshow;
1309 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref;
1312 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
1313 print
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1314 print($numtax ?
' - Localtax '.$numtax :
'');
1316 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1317 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1326 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
1327 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1328 print
'<tr class="oddeven">';
1329 print
"<!-- Thirdparty revenuestamp -->";
1330 print
"<td>" . $date .
"</td>";
1331 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1335 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1336 print
'<span class="error">' . $langs->trans(
"MainAccountForRevenueStampSaleNotDefined") .
'</span>';
1338 print $accountoshow;
1344 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp") .
"</td>";
1345 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1346 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1353 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.