34 public $element =
'accounting_journal';
39 public $table_element =
'accounting_journal';
44 public $fk_element =
'';
49 public $picto =
'generic';
79 public static $accounting_account_cached = array();
84 public static $nature_maps = array(
85 1 =>
'variousoperations',
89 5 =>
'expensereports',
103 $this->ismultientitymanaged = 0;
113 public function fetch($rowid =
null, $journal_code =
null)
117 if ($rowid || $journal_code) {
118 $sql =
"SELECT rowid, code, label, nature, active";
119 $sql .=
" FROM ".MAIN_DB_PREFIX.
"accounting_journal";
122 $sql .=
" rowid = ".((int) $rowid);
123 } elseif ($journal_code) {
124 $sql .=
" code = '".$this->db->escape($journal_code).
"'";
125 $sql .=
" AND entity = ".$conf->entity;
128 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
129 $result = $this->db->query(
$sql);
131 $obj = $this->db->fetch_object($result);
134 $this->
id = $obj->rowid;
135 $this->
rowid = $obj->rowid;
137 $this->
code = $obj->code;
138 $this->
ref = $obj->code;
139 $this->label = $obj->label;
140 $this->nature = $obj->nature;
141 $this->active = $obj->active;
148 $this->error =
"Error ".$this->db->lasterror();
149 $this->errors[] =
"Error ".$this->db->lasterror();
165 public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle =
'', $notooltip = 0)
167 global $langs, $conf, $hookmanager;
169 if (!empty($conf->dol_no_mouse_hover)) {
175 $url = DOL_URL_ROOT.
'/accountancy/admin/journals_list.php?id=35';
177 $label =
'<u>'.$langs->trans(
"ShowAccountingJournal").
'</u>';
178 if (!empty($this->
code)) {
179 $label .=
'<br><b>'.$langs->trans(
'Code').
':</b> '.$this->code;
181 if (!empty($this->label)) {
182 $label .=
'<br><b>'.$langs->trans(
'Label').
':</b> '.$langs->transnoentities($this->label);
185 $label .=
' - '.$moretitle;
189 if (empty($notooltip)) {
191 $label = $langs->trans(
"ShowAccountingJournal");
192 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
194 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
195 $linkclose .=
' class="classfortooltip"';
198 $linkstart =
'<a href="'.$url.
'"';
199 $linkstart .= $linkclose.
'>';
208 $label_link = $this->code;
209 if ($withlabel == 1 && !empty($this->label)) {
210 $label_link .=
' - '.($nourl ?
'<span class="opacitymedium">' :
'').$langs->transnoentities($this->label).($nourl ?
'</span>' :
'');
212 if ($withlabel == 2 && !empty($this->nature)) {
213 $key = $langs->trans(
"AccountingJournalType".$this->nature);
214 $transferlabel = ($this->nature && $key !=
"AccountingJournalType".strtoupper($langs->trans($this->nature)) ? $key : $this->label);
215 $label_link .=
' - '.($nourl ?
'<span class="opacitymedium">' :
'').$transferlabel.($nourl ?
'</span>' :
'');
218 $result .= $linkstart;
220 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
222 if ($withpicto != 2) {
223 $result .= $label_link;
228 $hookmanager->initHooks(array(
'accountingjournaldao'));
229 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
230 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
232 $result = $hookmanager->resPrint;
234 $result .= $hookmanager->resPrint;
247 return $this->
LibType($this->nature, $mode);
263 $langs->loadLangs(array(
"accountancy"));
268 return $langs->trans(
'AccountingJournalType9');
269 } elseif ($nature == 5) {
270 return $langs->trans(
'AccountingJournalType5');
271 } elseif ($nature == 4) {
272 return $langs->trans(
'AccountingJournalType4');
273 } elseif ($nature == 3) {
274 return $langs->trans(
'AccountingJournalType3');
275 } elseif ($nature == 2) {
276 return $langs->trans(
'AccountingJournalType2');
277 } elseif ($nature == 1) {
278 return $langs->trans(
'AccountingJournalType1');
280 } elseif ($mode == 1) {
282 return $langs->trans(
'AccountingJournalType9');
283 } elseif ($nature == 5) {
284 return $langs->trans(
'AccountingJournalType5');
285 } elseif ($nature == 4) {
286 return $langs->trans(
'AccountingJournalType4');
287 } elseif ($nature == 3) {
288 return $langs->trans(
'AccountingJournalType3');
289 } elseif ($nature == 2) {
290 return $langs->trans(
'AccountingJournalType2');
291 } elseif ($nature == 1) {
292 return $langs->trans(
'AccountingJournalType1');
309 public function getData(
User $user, $type =
'view', $date_start =
null, $date_end =
null, $in_bookkeeping =
'notyet')
317 if (empty($in_bookkeeping)) {
318 $in_bookkeeping =
'notyet';
323 $hookmanager->initHooks(array(
'accountingjournaldao'));
324 $parameters = array(
'data' => &$data,
'user' => $user,
'type' => $type,
'date_start' => $date_start,
'date_end' => $date_end,
'in_bookkeeping' => $in_bookkeeping);
325 $reshook = $hookmanager->executeHooks(
'getData', $parameters, $this);
327 $this->error = $hookmanager->error;
328 $this->errors = $hookmanager->errors;
330 } elseif (empty($reshook)) {
331 switch ($this->nature) {
333 $data = $this->
getAssetData($user, $type, $date_start, $date_end, $in_bookkeeping);
357 public function getAssetData(
User $user, $type =
'view', $date_start =
null, $date_end =
null, $in_bookkeeping =
'notyet')
359 global $conf, $langs;
365 require_once DOL_DOCUMENT_ROOT .
'/core/lib/accounting.lib.php';
366 require_once DOL_DOCUMENT_ROOT .
'/asset/class/asset.class.php';
367 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetaccountancycodes.class.php';
368 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetdepreciationoptions.class.php';
370 $langs->loadLangs(array(
"assets"));
376 if (empty($in_bookkeeping)) {
377 $in_bookkeeping =
'notyet';
381 $sql .=
"SELECT ad.fk_asset AS rowid, a.ref AS asset_ref, a.label AS asset_label, a.acquisition_value_ht AS asset_acquisition_value_ht";
382 $sql .=
", a.disposal_date AS asset_disposal_date, a.disposal_amount_ht AS asset_disposal_amount_ht, a.disposal_subject_to_vat AS asset_disposal_subject_to_vat";
383 $sql .=
", ad.rowid AS depreciation_id, ad.depreciation_mode, ad.ref AS depreciation_ref, ad.depreciation_date, ad.depreciation_ht, ad.accountancy_code_debit, ad.accountancy_code_credit";
384 $sql .=
" FROM " . MAIN_DB_PREFIX .
"asset_depreciation as ad";
385 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"asset as a ON a.rowid = ad.fk_asset";
386 $sql .=
" WHERE a.entity IN (" .
getEntity(
'asset', 0) .
')';
387 if ($in_bookkeeping ==
'already') {
388 $sql .=
" AND EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX .
"accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')";
389 } elseif ($in_bookkeeping ==
'notyet') {
390 $sql .=
" AND NOT EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX .
"accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')";
392 $sql .=
" AND ad.ref != ''";
393 if ($date_start && $date_end) {
394 $sql .=
" AND ad.depreciation_date >= '" . $this->db->idate($date_start) .
"' AND ad.depreciation_date <= '" . $this->db->idate($date_end) .
"'";
398 $sql .=
" AND ad.depreciation_date >= '" . $this->db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')) .
"'";
400 $sql .=
" ORDER BY ad.depreciation_date";
403 $resql = $this->db->query(
$sql);
405 $this->errors[] = $this->db->lasterror();
410 'elements' => array(),
412 while ($obj = $this->db->fetch_object($resql)) {
413 if (!isset($pre_data[
'elements'][$obj->rowid])) {
414 $pre_data[
'elements'][$obj->rowid] = array(
415 'ref' => $obj->asset_ref,
416 'label' => $obj->asset_label,
417 'acquisition_value_ht' => $obj->asset_acquisition_value_ht,
418 'depreciation' => array(),
422 if (isset($obj->asset_disposal_date)) {
423 $pre_data[
'elements'][$obj->rowid][
'disposal'] = array(
424 'date' => $this->db->jdate($obj->asset_disposal_date),
425 'amount' => $obj->asset_disposal_amount_ht,
426 'subject_to_vat' => !empty($obj->asset_disposal_subject_to_vat),
431 $compta_debit = empty($obj->accountancy_code_debit) ?
'NotDefined' : $obj->accountancy_code_debit;
432 $compta_credit = empty($obj->accountancy_code_credit) ?
'NotDefined' : $obj->accountancy_code_credit;
434 $pre_data[
'elements'][$obj->rowid][
'depreciation'][$obj->depreciation_id] = array(
435 'date' => $this->db->jdate($obj->depreciation_date),
436 'ref' => $obj->depreciation_ref,
438 $compta_debit => -$obj->depreciation_ht,
439 $compta_credit => $obj->depreciation_ht,
444 $disposal_ref = $langs->transnoentitiesnoconv(
'AssetDisposal');
445 $journal = $this->code;
446 $journal_label = $this->label;
447 $journal_label_formatted = $langs->transnoentities($journal_label);
450 $element_static =
new Asset($this->db);
452 $journal_data = array();
453 foreach ($pre_data[
'elements'] as $pre_data_id => $pre_data_info) {
454 $element_static->id = $pre_data_id;
455 $element_static->ref = (string) $pre_data_info[
"ref"];
456 $element_static->label = (string) $pre_data_info[
"label"];
457 $element_static->acquisition_value_ht = $pre_data_info[
"acquisition_value_ht"];
458 $element_link = $element_static->getNomUrl(1,
'with_label');
460 $element_name_formatted_0 =
dol_trunc($element_static->label, 16);
461 $label_operation = $element_static->getNomUrl(0,
'label', 16);
464 'ref' =>
dol_trunc($element_static->ref, 16,
'right',
'UTF-8', 1),
465 'error' => $pre_data_info[
'error'],
471 foreach ($pre_data_info[
'depreciation'] as $depreciation_id => $line) {
472 $depreciation_ref = $line[
"ref"];
473 $depreciation_date = $line[
"date"];
474 $depreciation_date_formatted =
dol_print_date($depreciation_date,
'day');
478 foreach ($line[
'lines'] as $account => $mt) {
481 if ($type ==
'view') {
483 if (($account_to_show ==
"") || $account_to_show ==
'NotDefined') {
484 $account_to_show =
'<span class="error">' . $langs->trans(
"AssetInAccountNotDefined") .
'</span>';
488 'date' => $depreciation_date_formatted,
489 'piece' => $element_link,
490 'account_accounting' => $account_to_show,
491 'subledger_account' =>
'',
492 'label_operation' => $label_operation .
' - ' . $depreciation_ref,
493 'debit' => $mt < 0 ?
price(-$mt) :
'',
494 'credit' => $mt >= 0 ?
price($mt) :
'',
496 } elseif ($type ==
'bookkeeping') {
497 if ($account_infos[
'found']) {
499 'doc_date' => $depreciation_date,
500 'date_lim_reglement' =>
'',
501 'doc_ref' => $element_static->ref,
502 'date_creation' => $now,
503 'doc_type' =>
'asset',
504 'fk_doc' => $element_static->id,
505 'fk_docdet' => $depreciation_id,
506 'thirdparty_code' =>
'',
507 'subledger_account' =>
'',
508 'subledger_label' =>
'',
509 'numero_compte' => $account,
510 'label_compte' => $account_infos[
'label'],
511 'label_operation' => $element_name_formatted_0 .
' - ' . $depreciation_ref,
513 'sens' => $mt < 0 ?
'D' :
'C',
514 'debit' => $mt < 0 ? -$mt : 0,
515 'credit' => $mt >= 0 ? $mt : 0,
516 'code_journal' => $journal,
517 'journal_label' => $journal_label_formatted,
520 'fk_user_author' => $user->id,
521 'entity' => $conf->entity,
527 $element_static->ref,
528 $account_infos[
'code_formatted_1'],
529 $element_name_formatted_0 .
' - ' . $depreciation_ref,
530 $mt < 0 ?
price(-$mt) :
'',
531 $mt >= 0 ?
price($mt) :
'',
535 $element[
'blocks'][] = $blocks;
540 if (!empty($pre_data_info[
'disposal'])) {
541 $disposal_date = $pre_data_info[
'disposal'][
'date'];
543 if ((!($date_start && $date_end) || ($date_start <= $disposal_date && $disposal_date <= $date_end)) &&
546 $disposal_amount = $pre_data_info[
'disposal'][
'amount'];
547 $disposal_subject_to_vat = $pre_data_info[
'disposal'][
'subject_to_vat'];
553 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetaccountancycodes.class.php';
555 $result = $accountancy_codes->fetchAccountancyCodes($element_static->id);
557 $element[
'error'] = $accountancy_codes->errorsToString();
560 $element_static->fetchDepreciationLines();
561 foreach ($element_static->depreciation_lines as $mode_key => $depreciation_lines) {
562 $accountancy_codes_list = $accountancy_codes->accountancy_codes[$mode_key];
564 if (!isset($accountancy_codes_list[
'value_asset_sold'])) {
568 $accountancy_code_value_asset_sold = empty($accountancy_codes_list[
'value_asset_sold']) ?
'NotDefined' : $accountancy_codes_list[
'value_asset_sold'];
569 $accountancy_code_depreciation_asset = empty($accountancy_codes_list[
'depreciation_asset']) ?
'NotDefined' : $accountancy_codes_list[
'depreciation_asset'];
570 $accountancy_code_asset = empty($accountancy_codes_list[
'asset']) ?
'NotDefined' : $accountancy_codes_list[
'asset'];
571 $accountancy_code_receivable_on_assignment = empty($accountancy_codes_list[
'receivable_on_assignment']) ?
'NotDefined' : $accountancy_codes_list[
'receivable_on_assignment'];
572 $accountancy_code_vat_collected = empty($accountancy_codes_list[
'vat_collected']) ?
'NotDefined' : $accountancy_codes_list[
'vat_collected'];
573 $accountancy_code_proceeds_from_sales = empty($accountancy_codes_list[
'proceeds_from_sales']) ?
'NotDefined' : $accountancy_codes_list[
'proceeds_from_sales'];
575 $last_cumulative_amount_ht = 0;
576 $depreciated_ids = array_keys($pre_data_info[
'depreciation']);
577 foreach ($depreciation_lines as $line) {
578 $last_cumulative_amount_ht = $line[
'cumulative_depreciation_ht'];
579 if (!in_array($line[
'id'], $depreciated_ids) && empty($line[
'bookkeeping']) && !empty($line[
'ref'])) {
585 $lines[0][$accountancy_code_value_asset_sold] = -($element_static->acquisition_value_ht - $last_cumulative_amount_ht);
586 $lines[0][$accountancy_code_depreciation_asset] = -$last_cumulative_amount_ht;
587 $lines[0][$accountancy_code_asset] = $element_static->acquisition_value_ht;
589 $disposal_amount_vat = $disposal_subject_to_vat ? (
float)
price2num($disposal_amount * $disposal_vat / 100,
'MT') : 0;
590 $lines[1][$accountancy_code_receivable_on_assignment] = -($disposal_amount + $disposal_amount_vat);
591 if ($disposal_subject_to_vat) {
592 $lines[1][$accountancy_code_vat_collected] = $disposal_amount_vat;
594 $lines[1][$accountancy_code_proceeds_from_sales] = $disposal_amount;
596 foreach ($lines as $lines_block) {
598 foreach ($lines_block as $account => $mt) {
601 if ($type ==
'view') {
603 if (($account_to_show ==
"") || $account_to_show ==
'NotDefined') {
604 $account_to_show =
'<span class="error">' . $langs->trans(
"AssetInAccountNotDefined") .
'</span>';
608 'date' => $disposal_date_formatted,
609 'piece' => $element_link,
610 'account_accounting' => $account_to_show,
611 'subledger_account' =>
'',
612 'label_operation' => $label_operation .
' - ' . $disposal_ref,
613 'debit' => $mt < 0 ?
price(-$mt) :
'',
614 'credit' => $mt >= 0 ?
price($mt) :
'',
616 } elseif ($type ==
'bookkeeping') {
617 if ($account_infos[
'found']) {
619 'doc_date' => $disposal_date,
620 'date_lim_reglement' =>
'',
621 'doc_ref' => $element_static->ref,
622 'date_creation' => $now,
623 'doc_type' =>
'asset',
624 'fk_doc' => $element_static->id,
626 'thirdparty_code' =>
'',
627 'subledger_account' =>
'',
628 'subledger_label' =>
'',
629 'numero_compte' => $account,
630 'label_compte' => $account_infos[
'label'],
631 'label_operation' => $element_name_formatted_0 .
' - ' . $disposal_ref,
633 'sens' => $mt < 0 ?
'D' :
'C',
634 'debit' => $mt < 0 ? -$mt : 0,
635 'credit' => $mt >= 0 ? $mt : 0,
636 'code_journal' => $journal,
637 'journal_label' => $journal_label_formatted,
640 'fk_user_author' => $user->id,
641 'entity' => $conf->entity,
647 $element_static->ref,
648 $account_infos[
'code_formatted_1'],
649 $element_name_formatted_0 .
' - ' . $disposal_ref,
650 $mt < 0 ?
price(-$mt) :
'',
651 $mt >= 0 ?
price($mt) :
'',
655 $element[
'blocks'][] = $blocks;
662 $journal_data[(int) $pre_data_id] = $element;
666 return $journal_data;
714 global $conf, $langs, $hookmanager;
715 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/bookkeeping.class.php';
719 $hookmanager->initHooks(array(
'accountingjournaldao'));
720 $parameters = array(
'journal_data' => &$journal_data);
721 $reshook = $hookmanager->executeHooks(
'writeBookkeeping', $parameters, $this);
723 $this->error = $hookmanager->error;
724 $this->errors = $hookmanager->errors;
726 } elseif (empty($reshook)) {
728 $journal_data = is_array($journal_data) ? $journal_data : array();
730 foreach ($journal_data as $element_id => $element) {
737 if ($element[
'error'] ==
'somelinesarenotbound') {
740 $this->errors[] = $langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $element[
'ref']);
743 if (!$error_for_line) {
744 foreach ($element[
'blocks'] as $lines) {
745 foreach ($lines as $line) {
747 $bookkeeping->doc_date = $line[
'doc_date'];
748 $bookkeeping->date_lim_reglement = $line[
'date_lim_reglement'];
749 $bookkeeping->doc_ref = $line[
'doc_ref'];
750 $bookkeeping->date_creation = $line[
'date_creation'];
751 $bookkeeping->doc_type = $line[
'doc_type'];
752 $bookkeeping->fk_doc = $line[
'fk_doc'];
753 $bookkeeping->fk_docdet = $line[
'fk_docdet'];
754 $bookkeeping->thirdparty_code = $line[
'thirdparty_code'];
755 $bookkeeping->subledger_account = $line[
'subledger_account'];
756 $bookkeeping->subledger_label = $line[
'subledger_label'];
757 $bookkeeping->numero_compte = $line[
'numero_compte'];
758 $bookkeeping->label_compte = $line[
'label_compte'];
759 $bookkeeping->label_operation = $line[
'label_operation'];
760 $bookkeeping->montant = $line[
'montant'];
761 $bookkeeping->sens = $line[
'sens'];
762 $bookkeeping->debit = $line[
'debit'];
763 $bookkeeping->credit = $line[
'credit'];
764 $bookkeeping->code_journal = $line[
'code_journal'];
765 $bookkeeping->journal_label = $line[
'journal_label'];
766 $bookkeeping->piece_num = $line[
'piece_num'];
767 $bookkeeping->import_key = $line[
'import_key'];
768 $bookkeeping->fk_user_author = $user->id;
769 $bookkeeping->entity = $conf->entity;
771 $total_debit += $bookkeeping->debit;
772 $total_credit += $bookkeeping->credit;
774 $result = $bookkeeping->create($user);
776 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
779 $journal_data[$element_id][
'error'] =
'alreadyjournalized';
783 $journal_data[$element_id][
'error'] =
'other';
784 $this->errors[] = $bookkeeping->errorsToString();
802 if ($error_for_line) {
809 if (!$error_for_line && (
price2num($total_debit,
'MT') !=
price2num($total_credit,
'MT'))) {
812 $journal_data[$element_id][
'error'] =
'amountsnotbalanced';
813 $this->errors[] =
'Try to insert a non balanced transaction in book for ' . $element[
'blocks'] .
'. Canceled. Surely a bug.';
816 if (!$error_for_line) {
819 $this->db->rollback();
821 if ($error >= $max_nb_errors) {
822 $this->errors[] = $langs->trans(
"ErrorTooManyErrorsProcessStopped");
829 return $error ? -$error : 1;
853 public function exportCsv(&$journal_data = array(), $search_date_end = 0, $sep =
'')
855 global $conf, $langs, $hookmanager;
863 $hookmanager->initHooks(array(
'accountingjournaldao'));
864 $parameters = array(
'journal_data' => &$journal_data,
'search_date_end' => &$search_date_end,
'sep' => &$sep,
'out' => &$out);
865 $reshook = $hookmanager->executeHooks(
'exportCsv', $parameters, $this);
867 $this->error = $hookmanager->error;
868 $this->errors = $hookmanager->errors;
870 } elseif (empty($reshook)) {
872 $journal_data = is_array($journal_data) ? $journal_data : array();
876 if ($this->nature == 4) {
878 $langs->transnoentitiesnoconv(
"BankId"),
879 $langs->transnoentitiesnoconv(
"Date"),
880 $langs->transnoentitiesnoconv(
"PaymentMode"),
881 $langs->transnoentitiesnoconv(
"AccountAccounting"),
882 $langs->transnoentitiesnoconv(
"LedgerAccount"),
883 $langs->transnoentitiesnoconv(
"SubledgerAccount"),
884 $langs->transnoentitiesnoconv(
"Label"),
885 $langs->transnoentitiesnoconv(
"AccountingDebit"),
886 $langs->transnoentitiesnoconv(
"AccountingCredit"),
887 $langs->transnoentitiesnoconv(
"Journal"),
888 $langs->transnoentitiesnoconv(
"Note"),
890 } elseif ($this->nature == 5) {
892 $langs->transnoentitiesnoconv(
"Date"),
893 $langs->transnoentitiesnoconv(
"Piece"),
894 $langs->transnoentitiesnoconv(
"AccountAccounting"),
895 $langs->transnoentitiesnoconv(
"LabelOperation"),
896 $langs->transnoentitiesnoconv(
"AccountingDebit"),
897 $langs->transnoentitiesnoconv(
"AccountingCredit"),
899 } elseif ($this->nature == 1) {
901 $langs->transnoentitiesnoconv(
"Date"),
902 $langs->transnoentitiesnoconv(
"Piece"),
903 $langs->transnoentitiesnoconv(
"AccountAccounting"),
904 $langs->transnoentitiesnoconv(
"LabelOperation"),
905 $langs->transnoentitiesnoconv(
"AccountingDebit"),
906 $langs->transnoentitiesnoconv(
"AccountingCredit"),
910 if (!empty($header)) {
911 $out .=
'"' . implode(
'"' . $sep .
'"', $header) .
'"' .
"\n";
913 foreach ($journal_data as $element_id => $element) {
914 foreach ($element[
'blocks'] as $lines) {
915 foreach ($lines as $line) {
916 $out .=
'"' . implode(
'"' . $sep .
'"', $line) .
'"' .
"\n";
933 if (!isset(self::$accounting_account_cached[$account])) {
934 require_once DOL_DOCUMENT_ROOT .
'/core/lib/accounting.lib.php';
935 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/accountingaccount.class.php';
937 $result = $accountingaccount->fetch(
null, $account,
true);
939 self::$accounting_account_cached[$account] = array(
941 'label' => $accountingaccount->label,
943 'label_formatted_1' => mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1'),
944 'label_formatted_2' =>
dol_trunc($accountingaccount->label, 32),
947 self::$accounting_account_cached[$account] = array(
951 'label_formatted_1' =>
'',
952 'label_formatted_2' =>
'',
957 return self::$accounting_account_cached[$account];
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
Class to manage accounting accounts.
Class to manage accounting journals.
writeIntoBookkeeping(User $user, &$journal_data=array(), $max_nb_errors=10)
Write bookkeeping.
getData(User $user, $type='view', $date_start=null, $date_end=null, $in_bookkeeping='notyet')
Get journal data.
exportCsv(&$journal_data=array(), $search_date_end=0, $sep='')
Export journal CSV ISO and not UTF8 !
getNomUrl($withpicto=0, $withlabel=0, $nourl=0, $moretitle='', $notooltip=0)
Return clickable name (with picto eventually)
__construct($db)
Constructor.
LibType($nature, $mode=0)
Return type of an accounting journal.
getAccountingAccountInfos($account)
Get accounting account infos.
fetch($rowid=null, $journal_code=null)
Load an object from database.
getAssetData(User $user, $type='view', $date_start=null, $date_end=null, $in_bookkeeping='notyet')
Get asset data for various journal.
getLibType($mode=0)
Return the label of the status.
Class for AssetAccountancyCodes.
Class to manage Ledger (General Ledger and Subledger)
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Class to manage Dolibarr users.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
div float
Buy price without taxes.
print *****$script_file(".$version.") pid code
1: frais de port 2: ecotaxe 3: option line (when qty = 0)