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();
97$cptcli =
'NotDefined';
103$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
109$accountingjournalstatic->fetch($id_journal);
110$journal = $accountingjournalstatic->code;
111$journal_label = $accountingjournalstatic->label;
114$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
117$pastmonthyear =
null;
119if (empty($date_startmonth)) {
123 $pastmonthyear = $dates[
'pastmonthyear'];
124 $pastmonth = $dates[
'pastmonth'];
126if (empty($date_endmonth)) {
129 $date_end = $dates[
'date_end'];
130 $pastmonthyear = $dates[
'pastmonthyear'];
131 $pastmonth = $dates[
'pastmonth'];
137if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
139 $date_end =
dol_get_last_day((
int) $pastmonthyear, (
int) $pastmonth,
false);
142$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,";
143$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,";
144$sql .=
" s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.fk_pays,";
146 $sql .=
" spe.accountancy_code_customer_general,";
147 $sql .=
" spe.accountancy_code_customer as code_compta_client,";
148 $sql .=
" spe.accountancy_code_supplier_general,";
149 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
151 $sql .=
" s.accountancy_code_customer_general,";
152 $sql .=
" s.code_compta as code_compta_client,";
153 $sql .=
" s.accountancy_code_supplier_general,";
154 $sql .=
" s.code_compta_fournisseur,";
156$sql .=
" p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
158 $sql .=
" ppe.accountancy_code_sell";
160 $sql .=
" p.accountancy_code_sell";
162$parameters = array();
163$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
164$sql .= $hookmanager->resPrint;
165$sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as fd";
166$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
168 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int)
$conf->entity);
170$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
171$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture as f ON f.rowid = fd.fk_facture";
172$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
174 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int)
$conf->entity);
176$parameters = array();
177$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
178$sql .= $hookmanager->resPrint;
179$sql .=
" WHERE fd.fk_code_ventilation > 0";
180$sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
')';
181$sql .=
" AND f.fk_statut > 0";
187$sql .=
" AND fd.product_type IN (0,1)";
188if ($date_start && $date_end) {
189 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".
$db->idate($date_end).
"'";
192 $sql .=
" AND (f.module_source IS NULL OR f.module_source <> 'takepos')";
196 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalInt(
'ACCOUNTING_DATE_START_BINDING')).
"'";
199if ($in_bookkeeping ==
'already') {
200 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
203if ($in_bookkeeping ==
'notyet') {
204 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
207$parameters = array();
208$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
209$sql .= $hookmanager->resPrint;
210$sql .=
" ORDER BY f.datef, f.ref";
213dol_syslog(
'accountancy/journal/sellsjournal.php', LOG_DEBUG);
218$tabwarranty = array();
219$tabrevenuestamp = array();
221$tablocaltax1 = array();
222$tablocaltax2 = array();
223$tabcompany = array();
224$vatdata_cache = array();
232$result =
$db->query($sql);
234 $num =
$db->num_rows($result);
238 $obj =
$db->fetch_object($result);
241 $accountancy_code_customer_general = (!empty($obj->accountancy_code_customer_general) && $obj->accountancy_code_customer_general !=
'-1') ? $obj->accountancy_code_customer_general : $cptcli;
242 $compta_soc = (!empty($obj->code_compta_client)) ? $obj->code_compta_client : $cptcli;
244 $compta_prod = $obj->compte;
245 if (empty($compta_prod)) {
246 if ($obj->product_type == 0) {
255 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
259 $vatdata_cache_key = $tax_id.
'_'.(int) $obj->fk_pays;
261 $vatdata_cache_key = $tax_id;
263 if (array_key_exists($vatdata_cache_key, $vatdata_cache)) {
264 $vatdata = $vatdata_cache[$vatdata_cache_key];
268 $buyer->fetch($obj->socid);
274 $vatdata_cache[$vatdata_cache_key] = $vatdata;
276 $compta_tva = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
277 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cptlocaltax1);
278 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cptlocaltax2);
281 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
282 $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.
')' :
''));
283 if ($obj->localtax1_tx > 0.0) {
284 $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.
')' :
''));
286 if ($obj->localtax2_tx > 0.0) {
287 $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.
')' :
''));
292 $situation_ratio = 1;
294 if ($obj->situation_cycle_ref) {
296 if ($obj->situation_percent == 0) {
297 $situation_ratio = 0;
300 $line->fetch($obj->fdid);
303 $prev_progress = $line->get_prev_progress($obj->rowid);
305 $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
310 $revenuestamp = (float)
price2num($obj->revenuestamp,
'MT');
313 $tabfac[$obj->rowid][
"date"] =
$db->jdate($obj->df);
314 $tabfac[$obj->rowid][
"datereg"] =
$db->jdate($obj->dlr);
315 $tabfac[$obj->rowid][
"ref"] = $obj->ref;
316 $tabfac[$obj->rowid][
"type"] = $obj->type;
317 $tabfac[$obj->rowid][
"description"] = $obj->label_compte;
318 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
319 $tabfac[$obj->rowid][
"revenuestamp"] = $revenuestamp;
323 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
324 $tabttc[$obj->rowid][$compta_soc] = 0;
326 if (!isset($tabht[$obj->rowid][$compta_prod])) {
327 $tabht[$obj->rowid][$compta_prod] = 0;
329 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
330 $tabtva[$obj->rowid][$compta_tva] = 0;
332 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
333 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
335 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
336 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
345 $total_ttc = $obj->total_ttc * $situation_ratio;
347 $total_ttc = $obj->total_ttc;
351 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0 && (!
getDolGlobalString(
'INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION') || !empty($obj->situation_final))) {
352 $retained_warranty = (float)
price2num($total_ttc * $obj->retained_warranty / 100,
'MT');
353 $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
354 $total_ttc -= $retained_warranty;
357 $tabttc[$obj->rowid][$compta_soc] += $total_ttc;
358 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
359 $tva_npr = ((($obj->info_bits & 1) == 1) ? 1 : 0);
362 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
363 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
364 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
366 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
367 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
368 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
372 $compta_revenuestamp =
'NotDefined';
373 if (!empty($revenuestamp)) {
374 $sqlrevenuestamp =
"SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX.
"c_revenuestamp";
375 $sqlrevenuestamp .=
" WHERE fk_pays = ".((int)
$mysoc->country_id);
376 $sqlrevenuestamp .=
" AND taux = ".((float) $revenuestamp);
377 $sqlrevenuestamp .=
" AND active = 1";
378 $resqlrevenuestamp =
$db->query($sqlrevenuestamp);
380 if ($resqlrevenuestamp) {
381 $num_rows_revenuestamp =
$db->num_rows($resqlrevenuestamp);
382 if ($num_rows_revenuestamp > 1) {
383 dol_print_error(
$db,
'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
385 $objrevenuestamp =
$db->fetch_object($resqlrevenuestamp);
386 if ($objrevenuestamp) {
387 $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
393 if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
395 $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
396 $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
399 $tabcompany[$obj->rowid] = array(
401 'name' => $obj->name,
402 'code_client' => $obj->code_client,
403 'accountancy_code_customer_general' => $accountancy_code_customer_general,
404 'code_compta' => $compta_soc
410 'tabfac' => &$tabfac,
412 'tabtva' => &$tabtva,
413 'def_tva' => &$def_tva,
414 'tabwarranty' => &$tabwarranty,
415 'tabrevenuestamp' => &$tabrevenuestamp,
416 'tabttc' => &$tabttc,
417 'tablocaltax1' => &$tablocaltax1,
418 'tablocaltax2' => &$tablocaltax2,
419 'tabcompany' => &$tabcompany,
420 'vatdata_cache' => &$vatdata_cache,
422 $reshook = $hookmanager->executeHooks(
'processingJournalData', $parameters);
427 if ($i >
getDolGlobalInt(
'ACCOUNTANCY_MAX_TOO_MANY_LINES_TO_PROCESS', 10000)) {
429 setEventMessages(
"ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
436 'tabfac' => &$tabfac,
438 'tabtva' => &$tabtva,
439 'def_tva' => &$def_tva,
440 'tabwarranty' => &$tabwarranty,
441 'tabrevenuestamp' => &$tabrevenuestamp,
442 'tabttc' => &$tabttc,
443 'tablocaltax1' => &$tablocaltax1,
444 'tablocaltax2' => &$tablocaltax2,
445 'tabcompany' => &$tabcompany,
446 'vatdata_cache' => &$vatdata_cache,
448 $reshook = $hookmanager->executeHooks(
'processedJournalData', $parameters);
454$errorforinvoice = array();
476if (!empty($tabfac)) {
480 COUNT(fd.rowid) as nb
482 ".MAIN_DB_PREFIX.
"facturedet as fd
485 AND fd.fk_code_ventilation <= 0
486 AND fd.total_ttc <> 0
487 AND fk_facture IN (".
$db->sanitize(implode(
",", array_keys($tabfac))).
")
490 $resql =
$db->query($sql);
492 $num =
$db->num_rows($resql);
495 $obj =
$db->fetch_object($resql);
497 $errorforinvoice[$obj->fk_facture] =
'somelinesarenotbound';
506if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
515 $accountingaccountcustomer->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
518 $accountingaccountcustomerwarranty->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'),
true);
520 foreach ($tabfac as $key => $val) {
528 $companystatic->id = $tabcompany[$key][
'id'];
529 $companystatic->name = $tabcompany[$key][
'name'];
530 $companystatic->accountancy_code_customer_general = $tabcompany[$key][
'accountancy_code_customer_general'];
531 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
532 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
533 $companystatic->code_client = $tabcompany[$key][
'code_client'];
534 $companystatic->client = 3;
536 $invoicestatic->id = (int) $key;
537 $invoicestatic->ref = (
string) $val[
"ref"];
538 $invoicestatic->type = $val[
"type"];
539 $invoicestatic->close_code = $val[
"close_code"];
544 $replacedinvoice = 0;
545 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
546 $replacedinvoice = 1;
547 $alreadydispatched = $invoicestatic->getVentilExportCompta();
548 if ($alreadydispatched) {
549 $replacedinvoice = 2;
554 if ($replacedinvoice == 1) {
560 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
563 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
568 if (isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
569 foreach ($tabwarranty[$key] as $k => $mt) {
571 $bookkeeping->doc_date = $val[
"date"];
572 $bookkeeping->date_lim_reglement = $val[
"datereg"];
573 $bookkeeping->doc_ref = $val[
"ref"];
574 $bookkeeping->date_creation = $now;
575 $bookkeeping->doc_type =
'customer_invoice';
576 $bookkeeping->fk_doc = (int) $key;
577 $bookkeeping->fk_docdet = 0;
578 $bookkeeping->thirdparty_code = $companystatic->code_client;
580 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
581 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
583 $bookkeeping->numero_compte =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
584 $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
586 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RetainedWarranty"));
587 $bookkeeping->montant = $mt;
588 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
589 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
590 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
591 $bookkeeping->code_journal = $journal;
592 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
593 $bookkeeping->fk_user_author = $user->id;
594 $bookkeeping->entity =
$conf->entity;
596 $totaldebit += $bookkeeping->debit;
597 $totalcredit += $bookkeeping->credit;
599 $result = $bookkeeping->create($user);
601 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
604 $errorforinvoice[$key] =
'alreadyjournalized';
609 $errorforinvoice[$key] =
'other';
618 if (!$errorforline) {
619 foreach ($tabttc[$key] as $k => $mt) {
621 $bookkeeping->doc_date = $val[
"date"];
622 $bookkeeping->date_lim_reglement = $val[
"datereg"];
623 $bookkeeping->doc_ref = $val[
"ref"];
624 $bookkeeping->date_creation = $now;
625 $bookkeeping->doc_type =
'customer_invoice';
626 $bookkeeping->fk_doc = (int) $key;
627 $bookkeeping->fk_docdet = 0;
628 $bookkeeping->thirdparty_code = $companystatic->code_client;
630 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
631 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
633 $bookkeeping->numero_compte = (!empty($tabcompany[$key][
'accountancy_code_customer_general']) && $tabcompany[$key][
'accountancy_code_customer_general'] !=
'-1') ? $tabcompany[$key][
'accountancy_code_customer_general'] : $cptcli;
634 $bookkeeping->label_compte = $accountingaccountcustomer->label;
636 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"SubledgerAccount"));
637 $bookkeeping->montant = $mt;
638 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
639 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
640 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
641 $bookkeeping->code_journal = $journal;
642 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
643 $bookkeeping->fk_user_author = $user->id;
644 $bookkeeping->entity =
$conf->entity;
646 $totaldebit += $bookkeeping->debit;
647 $totalcredit += $bookkeeping->credit;
649 $result = $bookkeeping->create($user);
651 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
654 $errorforinvoice[$key] =
'alreadyjournalized';
659 $errorforinvoice[$key] =
'other';
664 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
667 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
674 if (!$errorforline) {
675 foreach ($tabht[$key] as $k => $mt) {
676 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
678 $accountingaccount->fetch(0, $k,
true);
679 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
681 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
684 $label_account = $accountingaccount->label;
687 if ($accountingaccount->id > 0) {
689 $bookkeeping->doc_date = $val[
"date"];
690 $bookkeeping->date_lim_reglement = $val[
"datereg"];
691 $bookkeeping->doc_ref = $val[
"ref"];
692 $bookkeeping->date_creation = $now;
693 $bookkeeping->doc_type =
'customer_invoice';
694 $bookkeeping->fk_doc = (int) $key;
695 $bookkeeping->fk_docdet = 0;
696 $bookkeeping->thirdparty_code = $companystatic->code_client;
700 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
701 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
703 $bookkeeping->subledger_account =
'';
704 $bookkeeping->subledger_label =
'';
707 $bookkeeping->subledger_account =
'';
708 $bookkeeping->subledger_label =
'';
711 $bookkeeping->numero_compte = $k;
712 $bookkeeping->label_compte = $label_account;
714 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $label_account);
715 $bookkeeping->montant = $mt;
716 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
717 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
718 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
719 $bookkeeping->code_journal = $journal;
720 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
721 $bookkeeping->fk_user_author = $user->id;
722 $bookkeeping->entity =
$conf->entity;
724 $totaldebit += $bookkeeping->debit;
725 $totalcredit += $bookkeeping->credit;
727 $result = $bookkeeping->create($user);
729 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
732 $errorforinvoice[$key] =
'alreadyjournalized';
737 $errorforinvoice[$key] =
'other';
746 if (!$errorforline) {
747 $listoftax = array(0, 1, 2);
748 foreach ($listoftax as $numtax) {
749 $arrayofvat = $tabtva;
751 $arrayofvat = $tablocaltax1;
754 $arrayofvat = $tablocaltax2;
757 foreach ($arrayofvat[$key] as $k => $mt) {
759 if (empty(
$conf->cache[
'accountingaccountincurrententity_vat'][$k])) {
761 $accountingaccount->fetch(0, $k,
true);
762 $conf->cache[
'accountingaccountincurrententity_vat'][$k] = $accountingaccount;
764 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_vat'][$k];
767 $label_account = $accountingaccount->label;
770 $bookkeeping->doc_date = $val[
"date"];
771 $bookkeeping->date_lim_reglement = $val[
"datereg"];
772 $bookkeeping->doc_ref = $val[
"ref"];
773 $bookkeeping->date_creation = $now;
774 $bookkeeping->doc_type =
'customer_invoice';
775 $bookkeeping->fk_doc = (int) $key;
776 $bookkeeping->fk_docdet = 0;
777 $bookkeeping->thirdparty_code = $companystatic->code_client;
779 $bookkeeping->subledger_account =
'';
780 $bookkeeping->subledger_label =
'';
782 $bookkeeping->numero_compte = $k;
783 $bookkeeping->label_compte = $label_account;
786 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
787 $labelvataccount = $langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
788 $labelvataccount .= ($numtax ?
' - Localtax '.$numtax :
'');
789 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $labelvataccount);
791 $bookkeeping->montant = $mt;
792 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
793 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
794 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
795 $bookkeeping->code_journal = $journal;
796 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
797 $bookkeeping->fk_user_author = $user->id;
798 $bookkeeping->entity =
$conf->entity;
800 $totaldebit += $bookkeeping->debit;
801 $totalcredit += $bookkeeping->credit;
803 $result = $bookkeeping->create($user);
805 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
808 $errorforinvoice[$key] =
'alreadyjournalized';
813 $errorforinvoice[$key] =
'other';
823 if (!$errorforline) {
824 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
825 foreach ($tabrevenuestamp[$key] as $k => $mt) {
827 if (empty(
$conf->cache[
'accountingaccountincurrententity_rs'][$k])) {
829 $accountingaccount->fetch(0, $k,
true);
830 $conf->cache[
'accountingaccountincurrententity_rs'][$k] = $accountingaccount;
832 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_rs'][$k];
835 $label_account = $accountingaccount->label;
838 $bookkeeping->doc_date = $val[
"date"];
839 $bookkeeping->date_lim_reglement = $val[
"datereg"];
840 $bookkeeping->doc_ref = $val[
"ref"];
841 $bookkeeping->date_creation = $now;
842 $bookkeeping->doc_type =
'customer_invoice';
843 $bookkeeping->fk_doc = (int) $key;
844 $bookkeeping->fk_docdet = 0;
845 $bookkeeping->thirdparty_code = $companystatic->code_client;
847 $bookkeeping->subledger_account =
'';
848 $bookkeeping->subledger_label =
'';
850 $bookkeeping->numero_compte = $k;
851 $bookkeeping->label_compte = $label_account;
853 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RevenueStamp"));
854 $bookkeeping->montant = $mt;
855 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
856 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
857 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
858 $bookkeeping->code_journal = $journal;
859 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
860 $bookkeeping->fk_user_author = $user->id;
861 $bookkeeping->entity =
$conf->entity;
863 $totaldebit += $bookkeeping->debit;
864 $totalcredit += $bookkeeping->credit;
866 $result = $bookkeeping->create($user);
868 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
871 $errorforinvoice[$key] =
'alreadyjournalized';
876 $errorforinvoice[$key] =
'other';
886 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
889 $errorforinvoice[$key] =
'amountsnotbalanced';
890 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
893 if (!$errorforline) {
899 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
907 if (empty($error) && count($tabpay) > 0) {
909 } elseif (count($tabpay) == $error) {
912 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
918 if (count($tabpay) != $error) {
919 $param =
'id_journal='.$id_journal;
920 $param .=
'&date_startday='.$date_startday;
921 $param .=
'&date_startmonth='.$date_startmonth;
922 $param .=
'&date_startyear='.$date_startyear;
923 $param .=
'&date_endday='.$date_endday;
924 $param .=
'&date_endmonth='.$date_endmonth;
925 $param .=
'&date_endyear='.$date_endyear;
926 $param .=
'&in_bookkeeping='.$in_bookkeeping;
927 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
941if ($action ==
'exportcsv' && !$error) {
945 $filename =
'journal';
946 $type_export =
'journal';
947 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
953 foreach ($tabfac as $key => $val) {
954 $companystatic->id = $tabcompany[$key][
'id'];
955 $companystatic->name = $tabcompany[$key][
'name'];
956 $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;
957 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
958 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
959 $companystatic->code_client = $tabcompany[$key][
'code_client'];
960 $companystatic->client = 3;
962 $invoicestatic->id = (int) $key;
963 $invoicestatic->ref = (
string) $val[
"ref"];
964 $invoicestatic->type = $val[
"type"];
965 $invoicestatic->close_code = $val[
"close_code"];
970 $replacedinvoice = 0;
971 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
972 $replacedinvoice = 1;
973 $alreadydispatched = $invoicestatic->getVentilExportCompta();
974 if ($alreadydispatched) {
975 $replacedinvoice = 2;
980 if ($replacedinvoice == 1) {
985 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
986 foreach ($tabwarranty[$key] as $k => $mt) {
988 print
'"'.$key.
'"'.$sep;
989 print
'"'.$date.
'"'.$sep;
990 print
'"'.$val[
"ref"].
'"'.$sep;
991 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
992 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
993 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).
'"'.$sep;
994 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
995 print
'"'.$langs->trans(
"ThirdParty").
'"'.$sep;
996 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RetainedWarranty"))).
'"'.$sep;
997 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
998 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
999 print
'"'.$journal.
'"';
1006 foreach ($tabttc[$key] as $k => $mt) {
1008 print
'"'.$key.
'"'.$sep;
1009 print
'"'.$date.
'"'.$sep;
1010 print
'"'.$val[
"ref"].
'"'.$sep;
1011 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1012 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1013 print
'"'.length_accountg($companystatic->accountancy_code_customer_general).
'"'.$sep;
1014 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1015 print
'"'.$langs->trans(
"ThirdParty").
'"'.$sep;
1016 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"ThirdParty"))).
'"'.$sep;
1017 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1018 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1019 print
'"'.$journal.
'"';
1025 foreach ($tabht[$key] as $k => $mt) {
1027 $accountingaccount->fetch(0, $k,
true);
1029 print
'"'.$key.
'"'.$sep;
1030 print
'"'.$date.
'"'.$sep;
1031 print
'"'.$val[
"ref"].
'"'.$sep;
1032 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1033 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1034 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1036 print
'"'.csvClean(
dol_trunc($accountingaccount->label, 32)).
'"'.$sep;
1037 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $accountingaccount->label)).
'"'.$sep;
1038 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1039 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1040 print
'"'.$journal.
'"';
1046 $listoftax = array(0, 1, 2);
1047 foreach ($listoftax as $numtax) {
1048 $arrayofvat = $tabtva;
1050 $arrayofvat = $tablocaltax1;
1053 $arrayofvat = $tablocaltax2;
1056 foreach ($arrayofvat[$key] as $k => $mt) {
1058 print
'"'.$key.
'"'.$sep;
1059 print
'"'.$date.
'"'.$sep;
1060 print
'"'.$val[
"ref"].
'"'.$sep;
1061 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1062 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1063 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1065 print
'"'.$langs->trans(
"VAT").
' - '.implode(
', ', $def_tva[$key][$k]).
' %"'.$sep;
1066 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"VAT").implode($def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
''))).
'"'.$sep;
1067 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1068 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1069 print
'"'.$journal.
'"';
1076 if (isset($tabrevenuestamp[$key])) {
1077 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1079 print
'"'.$key.
'"'.$sep;
1080 print
'"'.$date.
'"'.$sep;
1081 print
'"'.$val[
"ref"].
'"'.$sep;
1082 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1083 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1084 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1086 print
'"'.$langs->trans(
"RevenueStamp").
'"'.$sep;
1087 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RevenueStamp"))).
'"'.$sep;
1088 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1089 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1090 print
'"'.$journal.
'"';
1100if (empty($action) || $action ==
'view') {
1101 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1102 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
1110 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1112 $description .= $langs->trans(
"DepositsAreNotIncluded");
1114 $description .= $langs->trans(
"DepositsAreIncluded");
1117 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
1118 $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);
1119 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1121 $varlink =
'id_journal='.$id_journal;
1123 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
1128 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int)
$conf->entity);
1129 $resql =
$db->query($sql);
1131 $obj =
$db->fetch_object($resql);
1132 if ($obj->nb == 0) {
1133 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1134 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1135 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1145 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
1146 if ($acctCustomerNotConfigured) {
1147 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1148 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1149 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1153 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1154 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1155 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1157 if ($acctCustomerNotConfigured) {
1158 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1160 if ($in_bookkeeping ==
'notyet') {
1161 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1163 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1170 <script type="text/javascript">
1171 function launch_export() {
1172 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1173 $("div.fiche form input[type=\"submit\"]").click();
1174 $("div.fiche form input[name=\"action\"]").val("");
1176 function writebookkeeping() {
1177 console.log("click on writebookkeeping");
1178 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1179 $("div.fiche form input[type=\"submit\"]").click();
1180 $("div.fiche form input[name=\"action\"]").val("");
1189 print
'<div class="div-table-responsive">';
1190 print
"<table class=\"noborder\" width=\"100%\">";
1191 print
"<tr class=\"liste_titre\">";
1192 print
"<td>".$langs->trans(
"Date").
"</td>";
1193 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1194 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1195 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1196 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1197 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1198 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1207 foreach ($tabfac as $key => $val) {
1208 $companystatic->id = $tabcompany[$key][
'id'];
1209 $companystatic->name = $tabcompany[$key][
'name'];
1210 $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;
1211 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1212 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1213 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1214 $companystatic->client = 3;
1216 $invoicestatic->id = (int) $key;
1217 $invoicestatic->ref = (
string) $val[
"ref"];
1218 $invoicestatic->type = $val[
"type"];
1219 $invoicestatic->close_code = $val[
"close_code"];
1224 $replacedinvoice = 0;
1225 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1226 $replacedinvoice = 1;
1227 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1228 if ($alreadydispatched) {
1229 $replacedinvoice = 2;
1234 if ($replacedinvoice == 1) {
1235 print
'<tr class="oddeven">';
1236 print
"<!-- Replaced invoice -->";
1237 print
"<td>".$date.
"</td>";
1238 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1241 print $langs->trans(
"Replaced");
1248 print
'<td class="right"></td>';
1249 print
'<td class="right"></td>';
1255 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
1256 print
'<tr class="oddeven">';
1257 print
"<!-- Some lines are not bound -->";
1258 print
"<td>".$date.
"</td>";
1259 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1262 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1269 print
'<td class="right"></td>';
1270 print
'<td class="right"></td>';
1277 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
1278 foreach ($tabwarranty[$key] as $k => $mt) {
1279 print
'<tr class="oddeven">';
1280 print
"<!-- Thirdparty warranty -->";
1281 print
"<td>" . $date .
"</td>";
1282 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1286 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1287 print
'<span class="error">' . $langs->trans(
"MainAccountForRetainedWarrantyNotDefined") .
'</span>';
1289 print $accountoshow;
1295 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1296 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1298 print $accountoshow;
1301 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans(
"RetainedWarranty"), 1) .
"</td>";
1302 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1303 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1309 foreach ($tabttc[$key] as $k => $mt) {
1310 print
'<tr class="oddeven">';
1311 print
"<!-- Thirdparty -->";
1312 print
"<td>".$date.
"</td>";
1313 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1316 $accountoshow =
length_accountg($companystatic->accountancy_code_customer_general);
1317 if (($accountoshow ==
"") || $accountoshow ==
"-1" || $accountoshow ==
'NotDefined') {
1318 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1320 print $accountoshow;
1326 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1327 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1329 print $accountoshow;
1332 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"SubledgerAccount"), 1) .
"</td>";
1333 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1334 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1341 foreach ($tabht[$key] as $k => $mt) {
1342 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1344 $accountingaccount->fetch(0, $k,
true);
1345 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1347 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1350 print
'<tr class="oddeven">';
1351 print
"<!-- Product -->";
1352 print
"<td>".$date.
"</td>";
1353 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1357 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1358 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1360 print $accountoshow;
1369 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1370 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1373 $companystatic->id = $tabcompany[$key][
'id'];
1374 $companystatic->name = $tabcompany[$key][
'name'];
1375 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $accountingaccount->label, 1) .
"</td>";
1376 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1377 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1384 $listoftax = array(0, 1, 2);
1385 foreach ($listoftax as $numtax) {
1386 $arrayofvat = $tabtva;
1388 $arrayofvat = $tablocaltax1;
1391 $arrayofvat = $tablocaltax2;
1395 foreach ($arrayofvat[$key] as $k => $mt) {
1397 print
'<tr class="oddeven">';
1398 print
"<!-- VAT -->";
1399 print
"<td>".$date.
"</td>";
1400 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1404 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1405 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1407 print $accountoshow;
1415 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
1416 $labelvatrate = $langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1417 $labelvatrate .= ($numtax ?
' - Localtax '.$numtax :
'');
1418 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $labelvatrate, 1) .
"</td>";
1419 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1420 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1429 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
1430 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1431 print
'<tr class="oddeven">';
1432 print
"<!-- Thirdparty revenuestamp -->";
1433 print
"<td>" . $date .
"</td>";
1434 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1438 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1439 print
'<span class="error">' . $langs->trans(
"MainAccountForRevenueStampSaleNotDefined") .
'</span>';
1441 print $accountoshow;
1447 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"RevenueStamp"), 1) .
"</td>";
1448 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1449 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1456 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 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.
$date_start
Variables from include:
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.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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.