36require
'../../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
55$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"errors"));
58$action =
GETPOST(
'action',
'aZ09');
60$date_startmonth =
GETPOSTINT(
'date_startmonth');
66$in_bookkeeping =
GETPOST(
'in_bookkeeping');
67if ($in_bookkeeping ==
'') {
68 $in_bookkeeping =
'notyet';
73$hookmanager->initHooks(array(
'sellsjournal'));
80if ($user->socid > 0) {
83if (!$user->hasRight(
'accounting',
'bind',
'write')) {
92$tabwarranty = array();
94$tablocaltax1 = array();
95$tablocaltax2 = array();
96$tabCustomerDiscountHT = array();
97$tabCustomerDiscountVAT = array();
98$tabCustomerDiscountTTC = array();
100$manageCustomerDepositInInvoice =
getDolGlobalInt(
'ACCOUNTING_MANAGE_CUSTOMER_DEPOSIT_IN_INVOICE');
101$labelCustomerDiscountExtension =
' (AC)';
103$cptcli =
'NotDefined';
104$accountCustomerDeposit =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT',
'NotDefined');
105$accountCustomerDepositVAT =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT_FOR_VAT',
'NotDefined');
111$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
117$accountingjournalstatic->fetch($id_journal);
118$journal = $accountingjournalstatic->code;
119$journal_label = $accountingjournalstatic->label;
122$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
125$pastmonthyear =
null;
127if (empty($date_startmonth)) {
131 $pastmonthyear = $dates[
'pastmonthyear'];
132 $pastmonth = $dates[
'pastmonth'];
134if (empty($date_endmonth)) {
137 $date_end = $dates[
'date_end'];
138 $pastmonthyear = $dates[
'pastmonthyear'];
139 $pastmonth = $dates[
'pastmonth'];
145if (!
GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
147 $date_end =
dol_get_last_day((
int) $pastmonthyear, (
int) $pastmonth,
false);
150$sql =
"SELECT f.rowid, f.ref, f.type, f.module_source, 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, f.situation_final,";
151$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.localtax1_tx, fd.localtax2_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
152$sql .=
" s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.fk_pays,";
154 $sql .=
" spe.accountancy_code_customer_general,";
155 $sql .=
" spe.accountancy_code_customer as code_compta_client,";
156 $sql .=
" spe.accountancy_code_supplier_general,";
157 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
159 $sql .=
" s.accountancy_code_customer_general,";
160 $sql .=
" s.code_compta as code_compta_client,";
161 $sql .=
" s.accountancy_code_supplier_general,";
162 $sql .=
" s.code_compta_fournisseur,";
164$sql .=
" p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
166 $sql .=
" ppe.accountancy_code_sell";
168 $sql .=
" p.accountancy_code_sell";
170$parameters = array();
171$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
172$sql .= $hookmanager->resPrint;
173$sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as fd";
174$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
176 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int)
$conf->entity);
178$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
179$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture as f ON f.rowid = fd.fk_facture";
180$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
182 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int)
$conf->entity);
184$parameters = array();
185$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
186$sql .= $hookmanager->resPrint;
187$sql .=
" WHERE fd.fk_code_ventilation > 0";
188$sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
')';
189$sql .=
" AND f.fk_statut > 0";
195$sql .=
" AND fd.product_type IN (0,1)";
196if ($date_start && $date_end) {
197 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".
$db->idate($date_end).
"'";
200 $sql .=
" AND (f.module_source IS NULL OR f.module_source <> 'takepos')";
204 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalInt(
'ACCOUNTING_DATE_START_BINDING')).
"'";
207if ($in_bookkeeping ==
'already') {
208 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
211if ($in_bookkeeping ==
'notyet') {
212 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
215if ($manageCustomerDepositInInvoice) {
216 $sql .=
" AND (fd.description != '(DEPOSIT)' OR COALESCE(fd.fk_remise_except, 0) = 0)";
218$parameters = array();
219$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
220$sql .= $hookmanager->resPrint;
221$sql .=
" ORDER BY f.datef, f.ref";
224dol_syslog(
'accountancy/journal/sellsjournal.php', LOG_DEBUG);
229$tabwarranty = array();
230$tabrevenuestamp = array();
232$tablocaltax1 = array();
233$tablocaltax2 = array();
234$tabcompany = array();
235$vatdata_cache = array();
236$tabCustomerDiscountHT = array();
237$tabCustomerDiscountVAT = array();
238$tabCustomerDiscountTTC = array();
246$result =
$db->query($sql);
248 $num =
$db->num_rows($result);
252 $obj =
$db->fetch_object($result);
255 $accountancy_code_customer_general = (!empty($obj->accountancy_code_customer_general) && $obj->accountancy_code_customer_general !=
'-1') ? $obj->accountancy_code_customer_general : $cptcli;
256 $compta_soc = (!empty($obj->code_compta_client)) ? $obj->code_compta_client : $cptcli;
258 $compta_prod = $obj->compte;
259 if (empty($compta_prod)) {
260 if ($obj->product_type == 0) {
269 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
273 $vatdata_cache_key = $tax_id.
'_'.(int) $obj->fk_pays;
275 $vatdata_cache_key = $tax_id;
277 if (array_key_exists($vatdata_cache_key, $vatdata_cache)) {
278 $vatdata = $vatdata_cache[$vatdata_cache_key];
282 $buyer->fetch($obj->socid);
288 $vatdata_cache[$vatdata_cache_key] = $vatdata;
292 $compta_tva = $accountCustomerDepositVAT;
294 $compta_tva = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
296 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cptlocaltax1);
297 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cptlocaltax2);
300 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
301 $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.
')' :
''));
302 if ($obj->localtax1_tx > 0.0) {
303 $def_tva[$obj->rowid][$compta_localtax1][
vatrate($obj->localtax1_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
'').
' LT1'] = (
vatrate($obj->localtax1_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''));
305 if ($obj->localtax2_tx > 0.0) {
306 $def_tva[$obj->rowid][$compta_localtax2][
vatrate($obj->localtax2_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
'').
' LT2'] = (
vatrate($obj->localtax2_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''));
311 $situation_ratio = 1;
313 if ($obj->situation_cycle_ref) {
315 if ($obj->situation_percent == 0) {
316 $situation_ratio = 0;
319 $line->fetch($obj->fdid);
322 $prev_progress = $line->get_prev_progress($obj->rowid);
324 $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
329 $revenuestamp = (float)
price2num($obj->revenuestamp,
'MT');
331 if ($manageCustomerDepositInInvoice && $obj->type ==
Facture::TYPE_STANDARD && !isset($tabfac[$obj->rowid])) {
333 $sql2 =
"SELECT re.rowid";
334 $sql2 .=
" FROM " .
$db->prefix() .
"societe_remise_except as re";
335 $sql2 .=
" WHERE (re.fk_facture = " . ((int) $obj->rowid);
336 $sql2 .=
" OR re.fk_facture_line IN (SELECT rowid FROM " .
$db->prefix() .
"facturedet WHERE fk_facture = " . ((int) $obj->rowid) .
")";
339 $resql2 =
$db->query($sql2);
341 if (
$db->num_rows($resql2) > 0) {
342 if (!isset($tabCustomerDiscountHT[$obj->rowid][$accountCustomerDeposit])) {
343 $tabCustomerDiscountHT[$obj->rowid][$accountCustomerDeposit] = 0;
345 if (!isset($tabCustomerDiscountVAT[$obj->rowid][$accountCustomerDepositVAT])) {
346 $tabCustomerDiscountVAT[$obj->rowid][$accountCustomerDepositVAT] = 0;
348 if (!isset($tabCustomerDiscountTTC[$obj->rowid][$compta_soc])) {
349 $tabCustomerDiscountTTC[$obj->rowid][$compta_soc] = 0;
352 while ($obj2 =
$db->fetch_object($resql2)) {
354 $customerDiscount->fetch($obj2->rowid);
355 $tabCustomerDiscountHT[$obj->rowid][$accountCustomerDeposit] = -$customerDiscount->total_ht;
356 $tabCustomerDiscountVAT[$obj->rowid][$accountCustomerDepositVAT] = -$customerDiscount->total_tva;
357 $tabCustomerDiscountTTC[$obj->rowid][$compta_soc] = -$customerDiscount->total_ttc;
367 $tabfac[$obj->rowid][
"date"] =
$db->jdate($obj->df);
368 $tabfac[$obj->rowid][
"datereg"] =
$db->jdate($obj->dlr);
369 $tabfac[$obj->rowid][
"ref"] = $obj->ref;
370 $tabfac[$obj->rowid][
"type"] = $obj->type;
371 $tabfac[$obj->rowid][
"description"] = $obj->label_compte;
372 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
373 $tabfac[$obj->rowid][
"revenuestamp"] = $revenuestamp;
377 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
378 $tabttc[$obj->rowid][$compta_soc] = 0;
380 if (!isset($tabht[$obj->rowid][$compta_prod])) {
381 $tabht[$obj->rowid][$compta_prod] = 0;
383 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
384 $tabtva[$obj->rowid][$compta_tva] = 0;
386 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
387 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
389 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
390 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
399 $total_ttc = $obj->total_ttc * $situation_ratio;
401 $total_ttc = $obj->total_ttc;
405 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0 && (!
getDolGlobalString(
'INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION') || !empty($obj->situation_final))) {
406 $retained_warranty = (float)
price2num($total_ttc * $obj->retained_warranty / 100,
'MT');
407 $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
408 $total_ttc -= $retained_warranty;
411 $tabttc[$obj->rowid][$compta_soc] += $total_ttc;
412 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
413 $tva_npr = ((($obj->info_bits & 1) == 1) ? 1 : 0);
416 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
417 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
418 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
420 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
421 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
422 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
426 $compta_revenuestamp =
'NotDefined';
427 if (!empty($revenuestamp)) {
428 $sqlrevenuestamp =
"SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX.
"c_revenuestamp";
429 $sqlrevenuestamp .=
" WHERE fk_pays = ".((int)
$mysoc->country_id);
430 $sqlrevenuestamp .=
" AND taux = ".((float) $revenuestamp);
431 $sqlrevenuestamp .=
" AND active = 1";
432 $resqlrevenuestamp =
$db->query($sqlrevenuestamp);
434 if ($resqlrevenuestamp) {
435 $num_rows_revenuestamp =
$db->num_rows($resqlrevenuestamp);
436 if ($num_rows_revenuestamp > 1) {
437 dol_print_error(
$db,
'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
439 $objrevenuestamp =
$db->fetch_object($resqlrevenuestamp);
440 if ($objrevenuestamp) {
441 $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
447 if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
449 $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
450 $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
453 $tabcompany[$obj->rowid] = array(
455 'name' => $obj->name,
456 'code_client' => $obj->code_client,
457 'accountancy_code_customer_general' => $accountancy_code_customer_general,
458 'code_compta' => $compta_soc
464 'tabfac' => &$tabfac,
466 'tabtva' => &$tabtva,
467 'def_tva' => &$def_tva,
468 'tabwarranty' => &$tabwarranty,
469 'tabrevenuestamp' => &$tabrevenuestamp,
470 'tabttc' => &$tabttc,
471 'tablocaltax1' => &$tablocaltax1,
472 'tablocaltax2' => &$tablocaltax2,
473 'tabcompany' => &$tabcompany,
474 'vatdata_cache' => &$vatdata_cache,
476 $reshook = $hookmanager->executeHooks(
'processingJournalData', $parameters);
481 if ($i >
getDolGlobalInt(
'ACCOUNTANCY_MAX_TOO_MANY_LINES_TO_PROCESS', 10000)) {
483 setEventMessages(
"ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
490 'tabfac' => &$tabfac,
492 'tabtva' => &$tabtva,
493 'def_tva' => &$def_tva,
494 'tabwarranty' => &$tabwarranty,
495 'tabrevenuestamp' => &$tabrevenuestamp,
496 'tabttc' => &$tabttc,
497 'tablocaltax1' => &$tablocaltax1,
498 'tablocaltax2' => &$tablocaltax2,
499 'tabcompany' => &$tabcompany,
500 'vatdata_cache' => &$vatdata_cache,
502 $reshook = $hookmanager->executeHooks(
'processedJournalData', $parameters);
508$errorforinvoice = array();
530if (!empty($tabfac)) {
534 COUNT(fd.rowid) as nb
536 ".MAIN_DB_PREFIX.
"facturedet as fd
539 AND fd.fk_code_ventilation <= 0
540 AND fd.total_ttc <> 0
541 AND fk_facture IN (".
$db->sanitize(implode(
",", array_keys($tabfac))).
")
544 $resql =
$db->query($sql);
546 $num =
$db->num_rows($resql);
549 $obj =
$db->fetch_object($resql);
551 $errorforinvoice[$obj->fk_facture] =
'somelinesarenotbound';
560if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
569 $accountingaccountcustomer->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
572 $accountingaccountcustomerwarranty->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'),
true);
574 foreach ($tabfac as $key => $val) {
582 $companystatic->id = $tabcompany[$key][
'id'];
583 $companystatic->name = $tabcompany[$key][
'name'];
584 $companystatic->accountancy_code_customer_general = $tabcompany[$key][
'accountancy_code_customer_general'];
585 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
586 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
587 $companystatic->code_client = $tabcompany[$key][
'code_client'];
588 $companystatic->client = 3;
590 $invoicestatic->id = (int) $key;
591 $invoicestatic->ref = (
string) $val[
"ref"];
592 $invoicestatic->type = (int) ($val[
"type"] ?? 0);
593 $invoicestatic->close_code = (
string) ($val[
"close_code"] ??
'');
598 $replacedinvoice = 0;
599 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
600 $replacedinvoice = 1;
601 $alreadydispatched = $invoicestatic->getVentilExportCompta();
602 if ($alreadydispatched) {
603 $replacedinvoice = 2;
608 if ($replacedinvoice == 1) {
614 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
617 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', (
string) ($val[
'ref'] ??
'')),
null,
'errors');
622 if (isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
623 foreach ($tabwarranty[$key] as $k => $mt) {
625 $bookkeeping->doc_date = $val[
"date"];
626 $bookkeeping->date_lim_reglement = $val[
"datereg"];
627 $bookkeeping->doc_ref = $val[
"ref"];
628 $bookkeeping->date_creation = $now;
629 $bookkeeping->doc_type =
'customer_invoice';
630 $bookkeeping->fk_doc = (int) $key;
631 $bookkeeping->fk_docdet = 0;
632 $bookkeeping->thirdparty_code = $companystatic->code_client;
634 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
635 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
637 $bookkeeping->numero_compte =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
638 $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
640 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RetainedWarranty"));
641 $bookkeeping->montant = $mt;
642 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
643 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
644 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
645 $bookkeeping->code_journal = $journal;
646 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
647 $bookkeeping->fk_user_author = $user->id;
648 $bookkeeping->entity =
$conf->entity;
650 $totaldebit += $bookkeeping->debit;
651 $totalcredit += $bookkeeping->credit;
653 $result = $bookkeeping->create($user);
655 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
658 $errorforinvoice[$key] =
'alreadyjournalized';
663 $errorforinvoice[$key] =
'other';
672 if (!$errorforline) {
673 foreach ($tabttc[$key] as $k => $mt) {
675 $bookkeeping->doc_date = $val[
"date"];
676 $bookkeeping->date_lim_reglement = $val[
"datereg"];
677 $bookkeeping->doc_ref = $val[
"ref"];
678 $bookkeeping->date_creation = $now;
679 $bookkeeping->doc_type =
'customer_invoice';
680 $bookkeeping->fk_doc = (int) $key;
681 $bookkeeping->fk_docdet = 0;
682 $bookkeeping->thirdparty_code = $companystatic->code_client;
684 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
685 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
687 $bookkeeping->numero_compte = (!empty($tabcompany[$key][
'accountancy_code_customer_general']) && $tabcompany[$key][
'accountancy_code_customer_general'] !=
'-1') ? $tabcompany[$key][
'accountancy_code_customer_general'] : $cptcli;
688 $bookkeeping->label_compte = $accountingaccountcustomer->label;
690 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"SubledgerAccount"));
691 $bookkeeping->montant = $mt;
692 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
693 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
694 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
695 $bookkeeping->code_journal = $journal;
696 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
697 $bookkeeping->fk_user_author = $user->id;
698 $bookkeeping->entity =
$conf->entity;
700 $totaldebit += $bookkeeping->debit;
701 $totalcredit += $bookkeeping->credit;
703 $result = $bookkeeping->create($user);
705 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
708 $errorforinvoice[$key] =
'alreadyjournalized';
713 $errorforinvoice[$key] =
'other';
718 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
721 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
728 if (!$errorforline) {
729 foreach ($tabht[$key] as $k => $mt) {
730 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
732 $accountingaccount->fetch(0, $k,
true);
733 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
735 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
738 $label_account = $accountingaccount->label;
741 if ($accountingaccount->id > 0) {
743 $bookkeeping->doc_date = $val[
"date"];
744 $bookkeeping->date_lim_reglement = $val[
"datereg"];
745 $bookkeeping->doc_ref = $val[
"ref"];
746 $bookkeeping->date_creation = $now;
747 $bookkeeping->doc_type =
'customer_invoice';
748 $bookkeeping->fk_doc = (int) $key;
749 $bookkeeping->fk_docdet = 0;
750 $bookkeeping->thirdparty_code = $companystatic->code_client;
754 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
755 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
757 $bookkeeping->subledger_account =
'';
758 $bookkeeping->subledger_label =
'';
761 $bookkeeping->subledger_account =
'';
762 $bookkeeping->subledger_label =
'';
765 $bookkeeping->numero_compte = $k;
766 $bookkeeping->label_compte = $label_account;
768 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $label_account);
769 $bookkeeping->montant = $mt;
770 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
771 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
772 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
773 $bookkeeping->code_journal = $journal;
774 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
775 $bookkeeping->fk_user_author = $user->id;
776 $bookkeeping->entity =
$conf->entity;
778 $totaldebit += $bookkeeping->debit;
779 $totalcredit += $bookkeeping->credit;
781 $result = $bookkeeping->create($user);
783 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
786 $errorforinvoice[$key] =
'alreadyjournalized';
791 $errorforinvoice[$key] =
'other';
800 if (!$errorforline) {
801 $listoftax = array(0, 1, 2);
802 foreach ($listoftax as $numtax) {
803 $arrayofvat = $tabtva;
805 $arrayofvat = $tablocaltax1;
808 $arrayofvat = $tablocaltax2;
811 foreach ($arrayofvat[$key] as $k => $mt) {
813 if (empty(
$conf->cache[
'accountingaccountincurrententity_vat'][$k])) {
815 $accountingaccount->fetch(0, $k,
true);
816 $conf->cache[
'accountingaccountincurrententity_vat'][$k] = $accountingaccount;
818 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_vat'][$k];
821 $label_account = $accountingaccount->label;
824 $bookkeeping->doc_date = $val[
"date"];
825 $bookkeeping->date_lim_reglement = $val[
"datereg"];
826 $bookkeeping->doc_ref = $val[
"ref"];
827 $bookkeeping->date_creation = $now;
828 $bookkeeping->doc_type =
'customer_invoice';
829 $bookkeeping->fk_doc = (int) $key;
830 $bookkeeping->fk_docdet = 0;
831 $bookkeeping->thirdparty_code = $companystatic->code_client;
833 $bookkeeping->subledger_account =
'';
834 $bookkeeping->subledger_label =
'';
836 $bookkeeping->numero_compte = $k;
837 $bookkeeping->label_compte = $label_account;
840 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
841 $labelvataccount = $langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
842 $labelvataccount .= ($numtax ?
' - Localtax '.$numtax :
'');
843 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $labelvataccount);
845 $bookkeeping->montant = $mt;
846 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
847 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
848 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
849 $bookkeeping->code_journal = $journal;
850 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
851 $bookkeeping->fk_user_author = $user->id;
852 $bookkeeping->entity =
$conf->entity;
854 $totaldebit += $bookkeeping->debit;
855 $totalcredit += $bookkeeping->credit;
857 $result = $bookkeeping->create($user);
859 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
862 $errorforinvoice[$key] =
'alreadyjournalized';
867 $errorforinvoice[$key] =
'other';
877 if (!$errorforline) {
878 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
879 foreach ($tabrevenuestamp[$key] as $k => $mt) {
881 if (empty(
$conf->cache[
'accountingaccountincurrententity_rs'][$k])) {
883 $accountingaccount->fetch(0, $k,
true);
884 $conf->cache[
'accountingaccountincurrententity_rs'][$k] = $accountingaccount;
886 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_rs'][$k];
889 $label_account = $accountingaccount->label;
892 $bookkeeping->doc_date = $val[
"date"];
893 $bookkeeping->date_lim_reglement = $val[
"datereg"];
894 $bookkeeping->doc_ref = $val[
"ref"];
895 $bookkeeping->date_creation = $now;
896 $bookkeeping->doc_type =
'customer_invoice';
897 $bookkeeping->fk_doc = (int) $key;
898 $bookkeeping->fk_docdet = 0;
899 $bookkeeping->thirdparty_code = $companystatic->code_client;
901 $bookkeeping->subledger_account =
'';
902 $bookkeeping->subledger_label =
'';
904 $bookkeeping->numero_compte = $k;
905 $bookkeeping->label_compte = $label_account;
907 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RevenueStamp"));
908 $bookkeeping->montant = $mt;
909 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
910 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
911 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
912 $bookkeeping->code_journal = $journal;
913 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
914 $bookkeeping->fk_user_author = $user->id;
915 $bookkeeping->entity =
$conf->entity;
917 $totaldebit += $bookkeeping->debit;
918 $totalcredit += $bookkeeping->credit;
920 $result = $bookkeeping->create($user);
922 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
925 $errorforinvoice[$key] =
'alreadyjournalized';
930 $errorforinvoice[$key] =
'other';
939 if ($manageCustomerDepositInInvoice) {
941 if (!$errorforline && isset($tabCustomerDiscountTTC[$key])) {
942 foreach ($tabCustomerDiscountTTC[$key] as $k => $mt) {
944 $bookkeeping->doc_date = $val[
"date"];
945 $bookkeeping->date_lim_reglement = $val[
"datereg"];
946 $bookkeeping->doc_ref = $val[
"ref"];
947 $bookkeeping->date_creation = $now;
948 $bookkeeping->doc_type =
'customer_invoice';
949 $bookkeeping->fk_doc = $key;
950 $bookkeeping->fk_docdet = 0;
951 $bookkeeping->thirdparty_code = $companystatic->code_client;
953 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
954 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
958 $bookkeeping->label_compte = $accountingaccountcustomer->label;
960 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"SubledgerAccount") . $labelCustomerDiscountExtension);
961 $bookkeeping->montant = $mt;
962 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
963 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
964 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
965 $bookkeeping->code_journal = $journal;
966 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
967 $bookkeeping->fk_user_author = $user->id;
968 $bookkeeping->entity =
$conf->entity;
970 $totaldebit += $bookkeeping->debit;
971 $totalcredit += $bookkeeping->credit;
973 $result = $bookkeeping->create($user);
975 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
978 $errorforinvoice[$key] =
'alreadyjournalized';
982 $errorforinvoice[$key] =
'other';
987 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
990 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
997 if (!$errorforline && isset($tabCustomerDiscountHT[$key])) {
998 foreach ($tabCustomerDiscountHT[$key] as $k => $mt) {
999 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1001 $accountingaccount->fetch(0, $k,
true);
1002 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1004 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1007 $label_account = $accountingaccount->label;
1010 if ($accountingaccount->id > 0) {
1012 $bookkeeping->doc_date = $val[
"date"];
1013 $bookkeeping->date_lim_reglement = $val[
"datereg"];
1014 $bookkeeping->doc_ref = $val[
"ref"];
1015 $bookkeeping->date_creation = $now;
1016 $bookkeeping->doc_type =
'customer_invoice';
1017 $bookkeeping->fk_doc = $key;
1018 $bookkeeping->fk_docdet = 0;
1019 $bookkeeping->thirdparty_code = $companystatic->code_client;
1023 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
1024 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
1026 $bookkeeping->subledger_account =
'';
1027 $bookkeeping->subledger_label =
'';
1030 $bookkeeping->subledger_account =
'';
1031 $bookkeeping->subledger_label =
'';
1034 $bookkeeping->numero_compte = $k;
1035 $bookkeeping->label_compte = $label_account;
1037 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $label_account) . $labelCustomerDiscountExtension;
1038 $bookkeeping->montant = $mt;
1039 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
1040 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
1041 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
1042 $bookkeeping->code_journal = $journal;
1043 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
1044 $bookkeeping->fk_user_author = $user->id;
1045 $bookkeeping->entity =
$conf->entity;
1047 $totaldebit += $bookkeeping->debit;
1048 $totalcredit += $bookkeeping->credit;
1050 $result = $bookkeeping->create($user);
1052 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
1055 $errorforinvoice[$key] =
'alreadyjournalized';
1059 $errorforinvoice[$key] =
'other';
1068 if (!$errorforline && isset($tabCustomerDiscountVAT[$key])) {
1069 foreach ($tabCustomerDiscountVAT[$key] as $k => $mt) {
1070 if (empty(
$conf->cache[
'accountingaccountincurrententity_vat'][$k])) {
1072 $accountingaccount->fetch(0, $k,
true);
1073 $conf->cache[
'accountingaccountincurrententity_vat'][$k] = $accountingaccount;
1075 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_vat'][$k];
1078 $label_account = $accountingaccount->label;
1081 $bookkeeping->doc_date = $val[
"date"];
1082 $bookkeeping->date_lim_reglement = $val[
"datereg"];
1083 $bookkeeping->doc_ref = $val[
"ref"];
1084 $bookkeeping->date_creation = $now;
1085 $bookkeeping->doc_type =
'customer_invoice';
1086 $bookkeeping->fk_doc = $key;
1087 $bookkeeping->fk_docdet = 0;
1088 $bookkeeping->thirdparty_code = $companystatic->code_client;
1090 $bookkeeping->subledger_account =
'';
1091 $bookkeeping->subledger_label =
'';
1093 $bookkeeping->numero_compte = $k;
1094 $bookkeeping->label_compte = $label_account;
1096 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
1097 $labelvataccount = $langs->trans(
"Taxes") .
' ' . $tmpvatrate .
' %';
1098 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $labelvataccount) . $labelCustomerDiscountExtension;
1100 $bookkeeping->montant = $mt;
1101 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
1102 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
1103 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
1104 $bookkeeping->code_journal = $journal;
1105 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
1106 $bookkeeping->fk_user_author = $user->id;
1107 $bookkeeping->entity =
$conf->entity;
1109 $totaldebit += $bookkeeping->debit;
1110 $totalcredit += $bookkeeping->credit;
1112 $result = $bookkeeping->create($user);
1114 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
1117 $errorforinvoice[$key] =
'alreadyjournalized';
1121 $errorforinvoice[$key] =
'other';
1130 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
1133 $errorforinvoice[$key] =
'amountsnotbalanced';
1134 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
1137 if (!$errorforline) {
1143 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
1151 if (empty($error) && count($tabpay) > 0) {
1153 } elseif (count($tabpay) == $error) {
1156 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
1162 if (count($tabpay) != $error) {
1163 $param =
'id_journal='.$id_journal;
1164 $param .=
'&date_startday='.$date_startday;
1165 $param .=
'&date_startmonth='.$date_startmonth;
1166 $param .=
'&date_startyear='.$date_startyear;
1167 $param .=
'&date_endday='.$date_endday;
1168 $param .=
'&date_endmonth='.$date_endmonth;
1169 $param .=
'&date_endyear='.$date_endyear;
1170 $param .=
'&in_bookkeeping='.$in_bookkeeping;
1171 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
1185if ($action ==
'exportcsv' && !$error) {
1189 $filename =
'journal';
1190 $type_export =
'journal';
1191 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
1197 foreach ($tabfac as $key => $val) {
1198 $companystatic->id = $tabcompany[$key][
'id'];
1199 $companystatic->name = $tabcompany[$key][
'name'];
1200 $companystatic->accountancy_code_customer_general = (!empty($tabcompany[$key][
'accountancy_code_customer_general']) && $tabcompany[$key][
'accountancy_code_customer_general'] !=
'-1') ? $tabcompany[$key][
'accountancy_code_customer_general'] : $cptcli;
1201 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1202 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1203 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1204 $companystatic->client = 3;
1206 $invoicestatic->id = (int) $key;
1207 $invoicestatic->ref = (
string) $val[
"ref"];
1208 $invoicestatic->type = (int) ($val[
"type"] ?? 0);
1209 $invoicestatic->close_code = (
string) ($val[
"close_code"] ??
'');
1214 $replacedinvoice = 0;
1215 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1216 $replacedinvoice = 1;
1217 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1218 if ($alreadydispatched) {
1219 $replacedinvoice = 2;
1224 if ($replacedinvoice == 1) {
1229 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
1230 foreach ($tabwarranty[$key] as $k => $mt) {
1232 print
'"'.$key.
'"'.$sep;
1233 print
'"'.$date.
'"'.$sep;
1234 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1235 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1236 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1237 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).
'"'.$sep;
1238 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1239 print
'"'.$langs->trans(
"ThirdParty").
'"'.$sep;
1240 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RetainedWarranty"))).
'"'.$sep;
1241 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1242 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1243 print
'"'.$journal.
'"';
1250 foreach ($tabttc[$key] as $k => $mt) {
1252 print
'"'.$key.
'"'.$sep;
1253 print
'"'.$date.
'"'.$sep;
1254 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1255 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1256 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1257 print
'"'.length_accountg($companystatic->accountancy_code_customer_general).
'"'.$sep;
1258 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1259 print
'"'.$langs->trans(
"ThirdParty").
'"'.$sep;
1260 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"ThirdParty"))).
'"'.$sep;
1261 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1262 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1263 print
'"'.$journal.
'"';
1269 foreach ($tabht[$key] as $k => $mt) {
1271 $accountingaccount->fetch(0, $k,
true);
1273 print
'"'.$key.
'"'.$sep;
1274 print
'"'.$date.
'"'.$sep;
1275 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1276 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1277 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1278 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1280 print
'"'.csvClean(
dol_trunc($accountingaccount->label, 32)).
'"'.$sep;
1281 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $accountingaccount->label)).
'"'.$sep;
1282 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1283 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1284 print
'"'.$journal.
'"';
1290 $listoftax = array(0, 1, 2);
1291 foreach ($listoftax as $numtax) {
1292 $arrayofvat = $tabtva;
1294 $arrayofvat = $tablocaltax1;
1297 $arrayofvat = $tablocaltax2;
1300 foreach ($arrayofvat[$key] as $k => $mt) {
1302 print
'"'.$key.
'"'.$sep;
1303 print
'"'.$date.
'"'.$sep;
1304 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1305 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1306 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1307 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1309 print
'"'.$langs->trans(
"VAT").
' - '.implode(
', ', $def_tva[$key][$k]).
' %"'.$sep;
1310 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"VAT").implode($def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
''))).
'"'.$sep;
1311 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1312 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1313 print
'"'.$journal.
'"';
1320 if (isset($tabrevenuestamp[$key])) {
1321 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1323 print
'"'.$key.
'"'.$sep;
1324 print
'"'.$date.
'"'.$sep;
1325 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1326 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1327 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1328 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1330 print
'"'.$langs->trans(
"RevenueStamp").
'"'.$sep;
1331 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RevenueStamp"))).
'"'.$sep;
1332 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1333 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1334 print
'"'.$journal.
'"';
1340 if ($manageCustomerDepositInInvoice) {
1342 if (isset($tabCustomerDiscountTTC[$key])) {
1343 foreach ($tabCustomerDiscountTTC[$key] as $k => $mt) {
1345 print
'"' . $key .
'"' . $sep;
1346 print
'"' . $date .
'"' . $sep;
1347 print
'"' . ((
string) ($val[
"ref"] ??
'')) .
'"' . $sep;
1350 print
'"' .
length_accountg($companystatic->accountancy_code_customer_general) .
'"' . $sep;
1352 print
'"' . $langs->trans(
"ThirdParty") .
'"' . $sep;
1353 print
'"' .
csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"ThirdParty")) . $labelCustomerDiscountExtension) .
'"' . $sep;
1354 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
1355 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
1356 print
'"' . $journal .
'"';
1363 if (isset($tabCustomerDiscountHT[$key])) {
1364 foreach ($tabCustomerDiscountHT[$key] as $k => $mt) {
1366 $accountingaccount->fetch(0, $k,
true);
1368 print
'"' . $key .
'"' . $sep;
1369 print
'"' . $date .
'"' . $sep;
1370 print
'"' . ((
string) ($val[
"ref"] ??
'')) .
'"' . $sep;
1376 print
'"' .
csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $accountingaccount->label) . $labelCustomerDiscountExtension) .
'"' . $sep;
1377 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
1378 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
1379 print
'"' . $journal .
'"';
1386 if (isset($tabCustomerDiscountVAT[$key])) {
1387 foreach ($tabCustomerDiscountVAT[$key] as $k => $mt) {
1389 print
'"' . $key .
'"' . $sep;
1390 print
'"' . $date .
'"' . $sep;
1391 print
'"' . ((
string) ($val[
"ref"] ??
'')) .
'"' . $sep;
1396 print
'"' . $langs->trans(
"VAT") .
' - ' . implode(
', ', $def_tva[$key][$k]) .
' %"' . $sep;
1397 print
'"' .
csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"VAT") . implode($def_tva[$key][$k]) .
' %') . $labelCustomerDiscountExtension) .
'"' . $sep;
1398 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
1399 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
1400 print
'"' . $journal .
'"';
1411if (empty($action) || $action ==
'view') {
1412 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1413 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
1421 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1423 $description .= $langs->trans(
"DepositsAreNotIncluded");
1425 $description .= $langs->trans(
"DepositsAreIncluded");
1428 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
1429 $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);
1430 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1432 $varlink =
'id_journal='.$id_journal;
1434 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
1439 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int)
$conf->entity);
1440 $resql =
$db->query($sql);
1442 $obj =
$db->fetch_object($resql);
1443 if ($obj->nb == 0) {
1444 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1445 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1446 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1456 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
1457 if ($acctCustomerNotConfigured) {
1458 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1459 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1460 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1464 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1465 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1466 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1468 if ($acctCustomerNotConfigured) {
1469 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1471 if ($in_bookkeeping ==
'notyet') {
1472 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1474 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1481 <script type="text/javascript">
1482 function launch_export() {
1483 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1484 $("div.fiche form input[type=\"submit\"]").click();
1485 $("div.fiche form input[name=\"action\"]").val("");
1487 function writebookkeeping() {
1488 console.log("click on writebookkeeping");
1489 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1490 $("div.fiche form input[type=\"submit\"]").click();
1491 $("div.fiche form input[name=\"action\"]").val("");
1500 print
'<div class="div-table-responsive">';
1501 print
"<table class=\"noborder\" width=\"100%\">";
1502 print
"<tr class=\"liste_titre\">";
1503 print
"<td>".$langs->trans(
"Date").
"</td>";
1504 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1505 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1506 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1507 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1508 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1509 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1518 foreach ($tabfac as $key => $val) {
1519 $companystatic->id = $tabcompany[$key][
'id'];
1520 $companystatic->name = $tabcompany[$key][
'name'];
1521 $companystatic->accountancy_code_customer_general = (!empty($tabcompany[$key][
'accountancy_code_customer_general']) && $tabcompany[$key][
'accountancy_code_customer_general'] !=
'-1') ? $tabcompany[$key][
'accountancy_code_customer_general'] : $cptcli;
1522 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1523 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1524 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1525 $companystatic->client = 3;
1527 $invoicestatic->id = (int) $key;
1528 $invoicestatic->ref = (
string) $val[
"ref"];
1529 $invoicestatic->type = (int) ($val[
"type"] ?? 0);
1530 $invoicestatic->close_code = (
string) ($val[
"close_code"] ??
'');
1535 $replacedinvoice = 0;
1536 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1537 $replacedinvoice = 1;
1538 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1539 if ($alreadydispatched) {
1540 $replacedinvoice = 2;
1545 if ($replacedinvoice == 1) {
1546 print
'<tr class="oddeven">';
1547 print
"<!-- Replaced invoice -->";
1548 print
"<td>".$date.
"</td>";
1549 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1552 print $langs->trans(
"Replaced");
1559 print
'<td class="right"></td>';
1560 print
'<td class="right"></td>';
1566 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
1567 print
'<tr class="oddeven">';
1568 print
"<!-- Some lines are not bound -->";
1569 print
"<td>".$date.
"</td>";
1570 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1573 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $invoicestatic->ref).
'</span>';
1580 print
'<td class="right"></td>';
1581 print
'<td class="right"></td>';
1588 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
1589 foreach ($tabwarranty[$key] as $k => $mt) {
1590 print
'<tr class="oddeven">';
1591 print
"<!-- Thirdparty warranty -->";
1592 print
"<td>" . $date .
"</td>";
1593 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1597 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1598 print
'<span class="error">' . $langs->trans(
"MainAccountForRetainedWarrantyNotDefined") .
'</span>';
1600 print $accountoshow;
1606 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1607 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1609 print $accountoshow;
1612 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans(
"RetainedWarranty"), 1) .
"</td>";
1613 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1614 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1620 foreach ($tabttc[$key] as $k => $mt) {
1621 print
'<tr class="oddeven">';
1622 print
"<!-- Thirdparty -->";
1623 print
"<td>".$date.
"</td>";
1624 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1627 $accountoshow =
length_accountg($companystatic->accountancy_code_customer_general);
1628 if (($accountoshow ==
"") || $accountoshow ==
"-1" || $accountoshow ==
'NotDefined') {
1629 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1631 print $accountoshow;
1637 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1638 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1640 print $accountoshow;
1643 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"SubledgerAccount"), 1) .
"</td>";
1644 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1645 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1652 foreach ($tabht[$key] as $k => $mt) {
1653 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1655 $accountingaccount->fetch(0, $k,
true);
1656 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1658 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1661 print
'<tr class="oddeven">';
1662 print
"<!-- Product -->";
1663 print
"<td>".$date.
"</td>";
1664 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1668 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1669 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1671 print $accountoshow;
1680 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1681 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1684 $companystatic->id = $tabcompany[$key][
'id'];
1685 $companystatic->name = $tabcompany[$key][
'name'];
1686 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $accountingaccount->label, 1) .
"</td>";
1687 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1688 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1695 $listoftax = array(0, 1, 2);
1696 foreach ($listoftax as $numtax) {
1697 $arrayofvat = $tabtva;
1699 $arrayofvat = $tablocaltax1;
1702 $arrayofvat = $tablocaltax2;
1706 foreach ($arrayofvat[$key] as $k => $mt) {
1708 print
'<tr class="oddeven">';
1709 print
"<!-- VAT -->";
1710 print
"<td>".$date.
"</td>";
1711 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1715 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1716 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1718 print $accountoshow;
1726 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
1727 $labelvatrate = $langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1728 $labelvatrate .= ($numtax ?
' - Localtax '.$numtax :
'');
1729 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $labelvatrate, 1) .
"</td>";
1730 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1731 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1740 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
1741 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1742 print
'<tr class="oddeven">';
1743 print
"<!-- Thirdparty revenuestamp -->";
1744 print
"<td>" . $date .
"</td>";
1745 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1749 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1750 print
'<span class="error">' . $langs->trans(
"MainAccountForRevenueStampSaleNotDefined") .
'</span>';
1752 print $accountoshow;
1758 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"RevenueStamp"), 1) .
"</td>";
1759 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1760 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1765 if ($manageCustomerDepositInInvoice) {
1767 if (isset($tabCustomerDiscountTTC[$key])) {
1768 foreach ($tabCustomerDiscountTTC[$key] as $k => $mt) {
1769 print
'<tr class="oddeven">';
1770 print
"<!-- Discount TTC -->";
1771 print
"<td>" . $date .
"</td>";
1772 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1776 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1777 print
'<span class="error">' . $langs->trans(
"MainAccountForCustomersNotDefined") .
'</span>';
1779 print $accountoshow;
1785 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1786 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1788 print $accountoshow;
1791 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"SubledgerAccount") . $labelCustomerDiscountExtension, 1) .
"</td>";
1792 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1793 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1801 if (isset($tabCustomerDiscountHT[$key])) {
1802 foreach ($tabCustomerDiscountHT[$key] as $k => $mt) {
1803 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1805 $accountingaccount->fetch(0, $k,
true);
1806 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1808 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1811 print
'<tr class="oddeven">';
1812 print
"<!-- Discount HT -->";
1813 print
"<td>" . $date .
"</td>";
1814 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1818 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1819 print
'<span class="error">' . $langs->trans(
"ProductNotDefined") .
'</span>';
1821 print $accountoshow;
1830 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1831 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1834 $companystatic->id = $tabcompany[$key][
'id'];
1835 $companystatic->name = $tabcompany[$key][
'name'];
1836 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $accountingaccount->label, 1) . $labelCustomerDiscountExtension .
"</td>";
1837 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1838 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1846 if (isset($tabCustomerDiscountVAT[$key])) {
1847 foreach ($tabCustomerDiscountVAT[$key] as $k => $mt) {
1848 print
'<tr class="oddeven">';
1849 print
"<!-- Discount VAT -->";
1850 print
"<td>" . $date .
"</td>";
1851 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1855 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1856 print
'<span class="error">' . $langs->trans(
"VATAccountNotDefined") .
' (' . $langs->trans(
"AccountingJournalType2") .
')</span>';
1858 print $accountoshow;
1864 $tmpvatrate = (empty($def_tva[$key][$k]) ?
'' : implode(
', ', $def_tva[$key][$k]));
1865 $labelvatrate = $langs->trans(
"Taxes") .
' ' . $tmpvatrate .
' %';
1866 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $labelvatrate, 1) . $labelCustomerDiscountExtension .
"</td>";
1867 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1868 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1878 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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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 absolute discounts.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard 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.
$date_start
Variables from include:
csvClean($newvalue, $charset='', $separator='')
Clean a cell to respect rules of CSV file cells.
dol_now($mode='gmt')
Return date for now.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.