31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
43$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"errors"));
45$id_journal =
GETPOST(
'id_journal',
'int');
46$action =
GETPOST(
'action',
'aZ09');
48$date_startmonth =
GETPOST(
'date_startmonth');
49$date_startday =
GETPOST(
'date_startday');
50$date_startyear =
GETPOST(
'date_startyear');
51$date_endmonth =
GETPOST(
'date_endmonth');
52$date_endday =
GETPOST(
'date_endday');
53$date_endyear =
GETPOST(
'date_endyear');
54$in_bookkeeping =
GETPOST(
'in_bookkeeping');
55if ($in_bookkeeping ==
'') {
56 $in_bookkeeping =
'notyet';
61$hookmanager->initHooks(array(
'purchasesjournal'));
65if (!isModEnabled(
'accounting')) {
68if ($user->socid > 0) {
71if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
82$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
88$accountingjournalstatic->fetch($id_journal);
89$journal = $accountingjournalstatic->code;
90$journal_label = $accountingjournalstatic->label;
92$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
93$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
95if (empty($date_startmonth)) {
98 $date_start = $dates[
'date_start'];
99 $pastmonthyear = $dates[
'pastmonthyear'];
100 $pastmonth = $dates[
'pastmonth'];
102if (empty($date_endmonth)) {
105 $date_end = $dates[
'date_end'];
106 $pastmonthyear = $dates[
'pastmonthyear'];
107 $pastmonth = $dates[
'pastmonth'];
110if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
115$sql =
"SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle as label, f.ref_supplier, f.date_lim_reglement as dlr, f.close_code, f.vat_reverse_charge,";
116$sql .=
" fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code, fd.info_bits,";
117$sql .=
" p.default_vat_code AS product_buy_default_vat_code, p.tva_tx as product_buy_vat, p.localtax1_tx as product_buy_localvat1, p.localtax2_tx as product_buy_localvat2,";
118$sql .=
" co.code as country_code, co.label as country_label,";
119$sql .=
" s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.fk_pays,";
121 $sql .=
" spe.accountancy_code_customer as code_compta,";
122 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
124 $sql .=
" s.code_compta as code_compta,";
125 $sql .=
" s.code_compta_fournisseur,";
128 $sql .=
" ppe.accountancy_code_buy,";
130 $sql .=
" p.accountancy_code_buy,";
132$sql .=
" aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
133$parameters = array();
134$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
135$sql .= $hookmanager->resPrint;
136$sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn_det as fd";
137$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
139 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
141$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
142$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
143$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
144$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = s.fk_pays ";
146 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
148$parameters = array();
149$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
150$sql .= $hookmanager->resPrint;
151$sql .=
" WHERE f.fk_statut > 0";
152$sql .=
" AND fd.fk_code_ventilation > 0";
153$sql .=
" AND f.entity IN (".getEntity(
'facture_fourn', 0).
")";
159if ($date_start && $date_end) {
160 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".$db->idate($date_end).
"'";
164 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
167if ($in_bookkeeping ==
'already') {
168 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
170if ($in_bookkeeping ==
'notyet') {
171 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
173$parameters = array();
174$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
175$sql .= $hookmanager->resPrint;
176$sql .=
" ORDER BY f.datef";
178dol_syslog(
'accountancy/journal/purchasesjournal.php', LOG_DEBUG);
179$result = $db->query($sql);
186 $tablocaltax1 = array();
187 $tablocaltax2 = array();
188 $tabcompany = array();
191 $tabrclocaltax1 = array();
192 $tabrclocaltax2 = array();
193 $vatdata_cache = array();
195 $num = $db->num_rows($result);
200 $rcctva =
getDolGlobalString(
'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT',
'NotDefined');
201 $rcdtva =
getDolGlobalString(
'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT',
'NotDefined');
206 $obj = $db->fetch_object($result);
209 $compta_soc = ($obj->code_compta_fournisseur !=
"") ? $obj->code_compta_fournisseur : $cptfour;
211 $compta_prod = $obj->compte;
212 if (empty($compta_prod)) {
213 if ($obj->product_type == 0) {
220 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
221 if (array_key_exists($tax_id, $vatdata_cache)) {
222 $vatdata = $vatdata_cache[$tax_id];
225 $vatdata_cache[$tax_id] = $vatdata;
227 $compta_tva = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
228 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
229 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
230 $compta_counterpart_tva_npr =
getDolGlobalString(
'ACCOUNTING_COUNTERPART_VAT_NPR',
'NotDefined');
233 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
234 $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.
')' :
''));
240 $tabfac[$obj->rowid][
"date"] = $db->jdate($obj->df);
241 $tabfac[$obj->rowid][
"datereg"] = $db->jdate($obj->dlr);
242 $tabfac[$obj->rowid][
"ref"] = $obj->ref_supplier.
' ('.$obj->ref.
')';
243 $tabfac[$obj->rowid][
"refsologest"] = $obj->ref;
244 $tabfac[$obj->rowid][
"refsuppliersologest"] = $obj->ref_supplier;
245 $tabfac[$obj->rowid][
"type"] = $obj->type;
246 $tabfac[$obj->rowid][
"description"] = $obj->description;
247 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
251 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
252 $tabttc[$obj->rowid][$compta_soc] = 0;
254 if (!isset($tabht[$obj->rowid][$compta_prod])) {
255 $tabht[$obj->rowid][$compta_prod] = 0;
257 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
258 $tabtva[$obj->rowid][$compta_tva] = 0;
260 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
261 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
263 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
264 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
268 if (($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) && $obj->vat_reverse_charge == 1 && in_array($obj->country_code, $country_code_in_EEC)) {
269 $rcvatdata =
getTaxesFromId($obj->product_buy_vat . ($obj->product_buy_default_vat_code ?
' (' . $obj->product_buy_default_vat_code .
')' :
''), $mysoc, $mysoc, 0);
270 $rcc_compta_tva = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcctva);
271 $rcd_compta_tva = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
272 $rcc_compta_localtax1 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcctva);
273 $rcd_compta_localtax1 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
274 $rcc_compta_localtax2 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcctva);
275 $rcd_compta_localtax2 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
276 if (
price2num($obj->product_buy_vat) || !empty($obj->product_buy_default_vat_code)) {
277 $vat_key =
vatrate($obj->product_buy_vat) . ($obj->product_buy_default_vat_code ?
' (' . $obj->product_buy_default_vat_code .
')' :
'');
278 $val_value = $vat_key;
279 $def_tva[$obj->rowid][$rcc_compta_tva][$vat_key] = $val_value;
280 $def_tva[$obj->rowid][$rcd_compta_tva][$vat_key] = $val_value;
283 if (!isset($tabrctva[$obj->rowid][$rcc_compta_tva])) {
284 $tabrctva[$obj->rowid][$rcc_compta_tva] = 0;
286 if (!isset($tabrctva[$obj->rowid][$rcd_compta_tva])) {
287 $tabrctva[$obj->rowid][$rcd_compta_tva] = 0;
289 if (!isset($tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1])) {
290 $tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] = 0;
292 if (!isset($tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1])) {
293 $tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] = 0;
295 if (!isset($tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2])) {
296 $tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] = 0;
298 if (!isset($tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2])) {
299 $tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] = 0;
302 $rcvat = (float)
price2num($obj->total_ttc * $obj->product_buy_vat / 100,
'MT');
303 $rclocalvat1 = (float)
price2num($obj->total_ttc * $obj->product_buy_localvat1 / 100,
'MT');
304 $rclocalvat2 = (float)
price2num($obj->total_ttc * $obj->product_buy_localvat2 / 100,
'MT');
306 $tabrctva[$obj->rowid][$rcd_compta_tva] += $rcvat;
307 $tabrctva[$obj->rowid][$rcc_compta_tva] -= $rcvat;
308 $tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] += $rclocalvat1;
309 $tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] -= $rclocalvat1;
310 $tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] += $rclocalvat2;
311 $tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] -= $rclocalvat2;
314 $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
315 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
316 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
317 $tva_npr = (($obj->info_bits & 1 == 1) ? 1 : 0);
319 $tabother[$obj->rowid][$compta_counterpart_tva_npr] += $obj->total_tva;
321 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
322 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
323 $tabcompany[$obj->rowid] = array(
325 'name' => $obj->name,
326 'code_fournisseur' => $obj->code_fournisseur,
327 'code_compta_fournisseur' => $compta_soc
337if (count($tabfac) > 10000) {
339 setEventMessages(
"TooManyInvoicesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
342$errorforinvoice = array();
367 COUNT(fd.rowid) as nb
369 llx_facture_fourn_det as fd
372 AND fd.fk_code_ventilation <= 0
373 AND fd.total_ttc <> 0
374 AND fk_facture_fourn IN (".$db->sanitize(join(
",", array_keys($tabfac))).
")
375GROUP BY fk_facture_fourn
377$resql = $db->query($sql);
379$num = $db->num_rows($resql);
382 $obj = $db->fetch_object($resql);
384 $errorforinvoice[$obj->fk_facture_fourn] =
'somelinesarenotbound';
393if ($action ==
'writebookkeeping' && !$error) {
397 $companystatic =
new Societe($db);
401 $accountingaccountsupplier->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'),
true);
403 foreach ($tabfac as $key => $val) {
411 $companystatic->id = $tabcompany[$key][
'id'];
412 $companystatic->name = $tabcompany[$key][
'name'];
413 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
414 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
415 $companystatic->fournisseur = 1;
417 $invoicestatic->id = $key;
418 $invoicestatic->ref = (string) $val[
"refsologest"];
419 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
420 $invoicestatic->type = $val[
"type"];
421 $invoicestatic->description = html_entity_decode(
dol_trunc($val[
"description"], 32));
422 $invoicestatic->close_code = $val[
"close_code"];
427 $replacedinvoice = 0;
428 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
429 $replacedinvoice = 1;
430 $alreadydispatched = $invoicestatic->getVentilExportCompta();
431 if ($alreadydispatched) {
432 $replacedinvoice = 2;
437 if ($replacedinvoice == 1) {
443 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
446 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
450 if (!$errorforline) {
451 foreach ($tabttc[$key] as $k => $mt) {
453 $bookkeeping->doc_date = $val[
"date"];
454 $bookkeeping->date_lim_reglement = $val[
"datereg"];
455 $bookkeeping->doc_ref = $val[
"refsologest"];
456 $bookkeeping->date_creation = $now;
457 $bookkeeping->doc_type =
'supplier_invoice';
458 $bookkeeping->fk_doc = $key;
459 $bookkeeping->fk_docdet = 0;
460 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
462 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta_fournisseur'];
463 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
466 $bookkeeping->label_compte = $accountingaccountsupplier->label;
468 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"SubledgerAccount");
469 $bookkeeping->montant = $mt;
470 $bookkeeping->sens = ($mt >= 0) ?
'C' :
'D';
471 $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
472 $bookkeeping->credit = ($mt > 0) ? $mt : 0;
473 $bookkeeping->code_journal = $journal;
474 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
475 $bookkeeping->fk_user_author = $user->id;
476 $bookkeeping->entity = $conf->entity;
478 $totaldebit += $bookkeeping->debit;
479 $totalcredit += $bookkeeping->credit;
481 $result = $bookkeeping->create($user);
483 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
486 $errorforinvoice[$key] =
'alreadyjournalized';
491 $errorforinvoice[$key] =
'other';
496 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
499 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
506 if (!$errorforline) {
507 foreach ($tabht[$key] as $k => $mt) {
508 $resultfetch = $accountingaccount->fetch(
null, $k,
true);
509 $label_account = $accountingaccount->label;
512 if ($resultfetch > 0) {
514 $bookkeeping->doc_date = $val[
"date"];
515 $bookkeeping->date_lim_reglement = $val[
"datereg"];
516 $bookkeeping->doc_ref = $val[
"refsologest"];
517 $bookkeeping->date_creation = $now;
518 $bookkeeping->doc_type =
'supplier_invoice';
519 $bookkeeping->fk_doc = $key;
520 $bookkeeping->fk_docdet = 0;
521 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
525 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
526 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
528 $bookkeeping->subledger_account =
'';
529 $bookkeeping->subledger_label =
'';
532 $bookkeeping->subledger_account =
'';
533 $bookkeeping->subledger_label =
'';
536 $bookkeeping->numero_compte = $k;
537 $bookkeeping->label_compte = $label_account;
539 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$label_account;
540 $bookkeeping->montant = $mt;
541 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
542 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
543 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
544 $bookkeeping->code_journal = $journal;
545 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
546 $bookkeeping->fk_user_author = $user->id;
547 $bookkeeping->entity = $conf->entity;
549 $totaldebit += $bookkeeping->debit;
550 $totalcredit += $bookkeeping->credit;
552 $result = $bookkeeping->create($user);
554 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
557 $errorforinvoice[$key] =
'alreadyjournalized';
562 $errorforinvoice[$key] =
'other';
572 if (!$errorforline) {
573 $listoftax = array(0, 1, 2);
574 foreach ($listoftax as $numtax) {
575 $arrayofvat = $tabtva;
577 $arrayofvat = $tablocaltax1;
580 $arrayofvat = $tablocaltax2;
584 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
586 foreach ($arrayofvat[$key] as $k => $mt) {
593 $arrayofvat = $tabrctva;
595 $arrayofvat = $tabrclocaltax1;
598 $arrayofvat = $tabrclocaltax2;
600 if (!is_array($arrayofvat[$key])) {
601 $arrayofvat[$key] = array();
606 foreach ($arrayofvat[$key] as $k => $mt) {
608 $accountingaccount->fetch(
null, $k,
true);
609 $label_account = $accountingaccount->label;
612 $bookkeeping->doc_date = $val[
"date"];
613 $bookkeeping->date_lim_reglement = $val[
"datereg"];
614 $bookkeeping->doc_ref = $val[
"refsologest"];
615 $bookkeeping->date_creation = $now;
616 $bookkeeping->doc_type =
'supplier_invoice';
617 $bookkeeping->fk_doc = $key;
618 $bookkeeping->fk_docdet = 0;
619 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
621 $bookkeeping->subledger_account =
'';
622 $bookkeeping->subledger_label =
'';
624 $bookkeeping->numero_compte = $k;
625 $bookkeeping->label_compte = $label_account;
627 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' '.join(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
628 $bookkeeping->montant = $mt;
629 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
630 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
631 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
632 $bookkeeping->code_journal = $journal;
633 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
634 $bookkeeping->fk_user_author = $user->id;
635 $bookkeeping->entity = $conf->entity;
637 $totaldebit += $bookkeeping->debit;
638 $totalcredit += $bookkeeping->credit;
640 $result = $bookkeeping->create($user);
642 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
645 $errorforinvoice[$key] =
'alreadyjournalized';
650 $errorforinvoice[$key] =
'other';
661 if (!$errorforline && is_array($tabother[$key])) {
662 foreach ($tabother[$key] as $k => $mt) {
665 $bookkeeping->doc_date = $val[
"date"];
666 $bookkeeping->date_lim_reglement = $val[
"datereg"];
667 $bookkeeping->doc_ref = $val[
"refsologest"];
668 $bookkeeping->date_creation = $now;
669 $bookkeeping->doc_type =
'supplier_invoice';
670 $bookkeeping->fk_doc = $key;
671 $bookkeeping->fk_docdet = 0;
672 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
674 $bookkeeping->subledger_account =
'';
675 $bookkeeping->subledger_label =
'';
677 $bookkeeping->numero_compte = $k;
679 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' NPR';
680 $bookkeeping->montant = $mt;
681 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
682 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
683 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
684 $bookkeeping->code_journal = $journal;
685 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
686 $bookkeeping->fk_user_author = $user->id;
687 $bookkeeping->entity = $conf->entity;
689 $totaldebit += $bookkeeping->debit;
690 $totalcredit += $bookkeeping->credit;
692 $result = $bookkeeping->create($user);
694 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
697 $errorforinvoice[$key] =
'alreadyjournalized';
702 $errorforinvoice[$key] =
'other';
711 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
714 $errorforinvoice[$key] =
'amountsnotbalanced';
715 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
718 if (!$errorforline) {
724 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
732 if (empty($error) && count($tabpay) > 0) {
734 } elseif (count($tabpay) == $error) {
737 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
743 if (count($tabpay) != $error) {
744 $param =
'id_journal='.$id_journal;
745 $param .=
'&date_startday='.$date_startday;
746 $param .=
'&date_startmonth='.$date_startmonth;
747 $param .=
'&date_startyear='.$date_startyear;
748 $param .=
'&date_endday='.$date_endday;
749 $param .=
'&date_endmonth='.$date_endmonth;
750 $param .=
'&date_endyear='.$date_endyear;
751 $param .=
'&in_bookkeeping='.$in_bookkeeping;
752 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
761$form =
new Form($db);
764if ($action ==
'exportcsv' && !$error) {
767 $filename =
'journal';
768 $type_export =
'journal';
769 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
774 foreach ($tabfac as $key => $val) {
775 $companystatic->id = $tabcompany[$key][
'id'];
776 $companystatic->name = $tabcompany[$key][
'name'];
777 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
778 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
779 $companystatic->fournisseur = 1;
781 $invoicestatic->id = $key;
782 $invoicestatic->ref = $val[
"refsologest"];
783 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
784 $invoicestatic->type = $val[
"type"];
785 $invoicestatic->description =
dol_trunc(html_entity_decode($val[
"description"]), 32);
786 $invoicestatic->close_code = $val[
"close_code"];
791 $replacedinvoice = 0;
792 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
793 $replacedinvoice = 1;
794 $alreadydispatched = $invoicestatic->getVentilExportCompta();
795 if ($alreadydispatched) {
796 $replacedinvoice = 2;
801 if ($replacedinvoice == 1) {
806 foreach ($tabttc[$key] as $k => $mt) {
808 print
'"'.$key.
'"'.$sep;
809 print
'"'.$date.
'"'.$sep;
810 print
'"'.$val[
"refsologest"].
'"'.$sep;
811 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
812 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
813 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER')).
'"'.$sep;
814 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
815 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
816 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
817 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
818 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
819 print
'"'.$journal.
'"';
825 foreach ($tabht[$key] as $k => $mt) {
827 $accountingaccount->fetch(
null, $k,
true);
829 print
'"'.$key.
'"'.$sep;
830 print
'"'.$date.
'"'.$sep;
831 print
'"'.$val[
"refsologest"].
'"'.$sep;
832 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
833 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
834 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
836 print
'"'.mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1').
'"'.$sep;
837 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
838 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
839 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
840 print
'"'.$journal.
'"';
846 $listoftax = array(0, 1, 2);
847 foreach ($listoftax as $numtax) {
848 $arrayofvat = $tabtva;
850 $arrayofvat = $tablocaltax1;
853 $arrayofvat = $tablocaltax2;
857 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
859 foreach ($arrayofvat[$key] as $k => $mt) {
866 $arrayofvat = $tabrctva;
868 $arrayofvat = $tabrclocaltax1;
871 $arrayofvat = $tabrclocaltax2;
873 if (!is_array($arrayofvat[$key])) {
874 $arrayofvat[$key] = array();
879 foreach ($arrayofvat[$key] as $k => $mt) {
881 print
'"'.$key.
'"'.$sep;
882 print
'"'.$date.
'"'.$sep;
883 print
'"'.$val[
"refsologest"].
'"'.$sep;
884 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
885 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
886 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
888 print
'"'.$langs->trans(
"VAT").
' - '.join(
', ', $def_tva[$key][$k]).
' %"'.$sep;
889 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"VAT").join(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'').
'"'.$sep;
890 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
891 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
892 print
'"'.$journal.
'"';
898 if (is_array($tabother[$key])) {
899 foreach ($tabother[$key] as $k => $mt) {
901 print
'"'.$key.
'"'.$sep;
902 print
'"'.$date.
'"'.$sep;
903 print
'"'.$val[
"refsologest"].
'"'.$sep;
904 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
905 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
906 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
907 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
908 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
909 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"VAT").
' NPR"'.$sep;
910 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
911 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
912 print
'"'.$journal.
'"';
921if (empty($action) || $action ==
'view') {
922 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
931 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
933 $description .= $langs->trans(
"DepositsAreNotIncluded");
935 $description .= $langs->trans(
"DepositsAreIncluded");
938 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
939 $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);
940 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
942 $varlink =
'id_journal='.$id_journal;
944 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
949 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
950 $resql = $db->query($sql);
952 $obj = $db->fetch_object($resql);
954 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
955 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
956 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
966 $acctSupplierNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'), [
'',
'-1']);
967 if ($acctSupplierNotConfigured) {
968 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
969 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
970 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
974 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
975 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
976 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
978 if ($acctSupplierNotConfigured) {
979 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
981 if ($in_bookkeeping ==
'notyet') {
982 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
984 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
991 <script type="text/javascript">
992 function launch_export() {
993 $("div.fiche form input[name=\"action\"]").val("exportcsv");
994 $("div.fiche form input[type=\"submit\"]").click();
995 $("div.fiche form input[name=\"action\"]").val("");
997 function writebookkeeping() {
998 console.log("click on writebookkeeping");
999 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1000 $("div.fiche form input[type=\"submit\"]").click();
1001 $("div.fiche form input[name=\"action\"]").val("");
1010 print
'<div class="div-table-responsive">';
1011 print
"<table class=\"noborder\" width=\"100%\">";
1012 print
"<tr class=\"liste_titre\">";
1013 print
"<td>".$langs->trans(
"Date").
"</td>";
1014 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1015 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1016 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1017 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1018 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1019 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1027 foreach ($tabfac as $key => $val) {
1028 $companystatic->id = $tabcompany[$key][
'id'];
1029 $companystatic->name = $tabcompany[$key][
'name'];
1030 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
1031 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
1032 $companystatic->fournisseur = 1;
1034 $invoicestatic->id = $key;
1035 $invoicestatic->ref = $val[
"refsologest"];
1036 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
1037 $invoicestatic->type = $val[
"type"];
1038 $invoicestatic->description =
dol_trunc(html_entity_decode($val[
"description"]), 32);
1039 $invoicestatic->close_code = $val[
"close_code"];
1044 $replacedinvoice = 0;
1045 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
1046 $replacedinvoice = 1;
1047 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1048 if ($alreadydispatched) {
1049 $replacedinvoice = 2;
1054 if ($replacedinvoice == 1) {
1055 print
'<tr class="oddeven">';
1056 print
"<!-- Replaced invoice -->";
1057 print
"<td>".$date.
"</td>";
1058 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1061 print $langs->trans(
"Replaced");
1068 print
'<td class="right"></td>';
1069 print
'<td class="right"></td>';
1075 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
1076 print
'<tr class="oddeven">';
1077 print
"<!-- Some lines are not bound -->";
1078 print
"<td>".$date.
"</td>";
1079 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1082 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1089 print
'<td class="right"></td>';
1090 print
'<td class="right"></td>';
1097 foreach ($tabttc[$key] as $k => $mt) {
1098 print
'<tr class="oddeven">';
1099 print
"<!-- Thirdparty -->";
1100 print
"<td>".$date.
"</td>";
1101 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1105 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1106 print
'<span class="error">'.$langs->trans(
"MainAccountForSuppliersNotDefined").
'</span>';
1108 print $accountoshow;
1114 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1115 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1117 print $accountoshow;
1120 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1121 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1122 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1129 foreach ($tabht[$key] as $k => $mt) {
1131 $accountingaccount->fetch(
null, $k,
true);
1133 print
'<tr class="oddeven">';
1134 print
"<!-- Product -->";
1135 print
"<td>".$date.
"</td>";
1136 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1140 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1141 print
'<span class="error">'.$langs->trans(
"ProductAccountNotDefined").
'</span>';
1143 print $accountoshow;
1152 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1153 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1156 $companystatic->id = $tabcompany[$key][
'id'];
1157 $companystatic->name = $tabcompany[$key][
'name'];
1158 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$accountingaccount->label.
"</td>";
1159 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1160 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1167 $listoftax = array(0, 1, 2);
1168 foreach ($listoftax as $numtax) {
1169 $arrayofvat = $tabtva;
1171 $arrayofvat = $tablocaltax1;
1174 $arrayofvat = $tablocaltax2;
1178 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
1180 foreach ($arrayofvat[$key] as $k => $mt) {
1187 $arrayofvat = $tabrctva;
1189 $arrayofvat = $tabrclocaltax1;
1192 $arrayofvat = $tabrclocaltax2;
1194 if (!is_array($arrayofvat[$key])) {
1195 $arrayofvat[$key] = array();
1200 foreach ($arrayofvat[$key] as $k => $mt) {
1202 print
'<tr class="oddeven">';
1203 print
"<!-- VAT -->";
1204 print
"<td>".$date.
"</td>";
1205 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1209 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1210 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType3").
')</span>';
1212 print $accountoshow;
1219 print $companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' '.join(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
1221 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1222 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1231 if (is_array($tabother[$key])) {
1232 foreach ($tabother[$key] as $k => $mt) {
1234 print
'<tr class="oddeven">';
1235 print
'<!-- VAT counterpart NPR -->';
1236 print
"<td>".$date.
"</td>";
1237 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1241 if ($accountoshow ==
'' || $accountoshow ==
'NotDefined') {
1242 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"NPR counterpart").
'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>';
1244 print $accountoshow;
1250 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
" NPR (counterpart)</td>";
1251 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1252 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1262 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)
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a page used to transfer/dispatch data in accounting.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accounting accounts.
Class to manage accounting journals.
Class to manage Ledger (General Ledger and Subledger)
const TYPE_SITUATION
Situation invoice.
Class to manage suppliers invoices.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const TYPE_REPLACEMENT
Replacement invoice.
Class to manage suppliers.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated 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 '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.