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();
365if (!empty($tabfac)) {
369 COUNT(fd.rowid) as nb
371 llx_facture_fourn_det as fd
374 AND fd.fk_code_ventilation <= 0
375 AND fd.total_ttc <> 0
376 AND fk_facture_fourn IN (".$db->sanitize(join(
",", array_keys($tabfac))).
")
377 GROUP BY fk_facture_fourn
379 $resql = $db->query($sql);
381 $num = $db->num_rows($resql);
384 $obj = $db->fetch_object($resql);
386 $errorforinvoice[$obj->fk_facture_fourn] =
'somelinesarenotbound';
396if ($action ==
'writebookkeeping' && !$error) {
400 $companystatic =
new Societe($db);
404 $accountingaccountsupplier->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'),
true);
406 foreach ($tabfac as $key => $val) {
414 $companystatic->id = $tabcompany[$key][
'id'];
415 $companystatic->name = $tabcompany[$key][
'name'];
416 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
417 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
418 $companystatic->fournisseur = 1;
420 $invoicestatic->id = $key;
421 $invoicestatic->ref = (string) $val[
"refsologest"];
422 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
423 $invoicestatic->type = $val[
"type"];
424 $invoicestatic->description = html_entity_decode(
dol_trunc($val[
"description"], 32));
425 $invoicestatic->close_code = $val[
"close_code"];
430 $replacedinvoice = 0;
431 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
432 $replacedinvoice = 1;
433 $alreadydispatched = $invoicestatic->getVentilExportCompta();
434 if ($alreadydispatched) {
435 $replacedinvoice = 2;
440 if ($replacedinvoice == 1) {
446 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
449 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
453 if (!$errorforline) {
454 foreach ($tabttc[$key] as $k => $mt) {
456 $bookkeeping->doc_date = $val[
"date"];
457 $bookkeeping->date_lim_reglement = $val[
"datereg"];
458 $bookkeeping->doc_ref = $val[
"refsologest"];
459 $bookkeeping->date_creation = $now;
460 $bookkeeping->doc_type =
'supplier_invoice';
461 $bookkeeping->fk_doc = $key;
462 $bookkeeping->fk_docdet = 0;
463 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
465 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta_fournisseur'];
466 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
469 $bookkeeping->label_compte = $accountingaccountsupplier->label;
471 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"SubledgerAccount");
472 $bookkeeping->montant = $mt;
473 $bookkeeping->sens = ($mt >= 0) ?
'C' :
'D';
474 $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
475 $bookkeeping->credit = ($mt > 0) ? $mt : 0;
476 $bookkeeping->code_journal = $journal;
477 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
478 $bookkeeping->fk_user_author = $user->id;
479 $bookkeeping->entity = $conf->entity;
481 $totaldebit += $bookkeeping->debit;
482 $totalcredit += $bookkeeping->credit;
484 $result = $bookkeeping->create($user);
486 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
489 $errorforinvoice[$key] =
'alreadyjournalized';
494 $errorforinvoice[$key] =
'other';
499 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
502 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
509 if (!$errorforline) {
510 foreach ($tabht[$key] as $k => $mt) {
511 $resultfetch = $accountingaccount->fetch(
null, $k,
true);
512 $label_account = $accountingaccount->label;
515 if ($resultfetch > 0) {
517 $bookkeeping->doc_date = $val[
"date"];
518 $bookkeeping->date_lim_reglement = $val[
"datereg"];
519 $bookkeeping->doc_ref = $val[
"refsologest"];
520 $bookkeeping->date_creation = $now;
521 $bookkeeping->doc_type =
'supplier_invoice';
522 $bookkeeping->fk_doc = $key;
523 $bookkeeping->fk_docdet = 0;
524 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
528 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
529 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
531 $bookkeeping->subledger_account =
'';
532 $bookkeeping->subledger_label =
'';
535 $bookkeeping->subledger_account =
'';
536 $bookkeeping->subledger_label =
'';
539 $bookkeeping->numero_compte = $k;
540 $bookkeeping->label_compte = $label_account;
542 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$label_account;
543 $bookkeeping->montant = $mt;
544 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
545 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
546 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
547 $bookkeeping->code_journal = $journal;
548 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
549 $bookkeeping->fk_user_author = $user->id;
550 $bookkeeping->entity = $conf->entity;
552 $totaldebit += $bookkeeping->debit;
553 $totalcredit += $bookkeeping->credit;
555 $result = $bookkeeping->create($user);
557 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
560 $errorforinvoice[$key] =
'alreadyjournalized';
565 $errorforinvoice[$key] =
'other';
575 if (!$errorforline) {
576 $listoftax = array(0, 1, 2);
577 foreach ($listoftax as $numtax) {
578 $arrayofvat = $tabtva;
580 $arrayofvat = $tablocaltax1;
583 $arrayofvat = $tablocaltax2;
587 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
589 foreach ($arrayofvat[$key] as $k => $mt) {
596 $arrayofvat = $tabrctva;
598 $arrayofvat = $tabrclocaltax1;
601 $arrayofvat = $tabrclocaltax2;
603 if (!is_array($arrayofvat[$key])) {
604 $arrayofvat[$key] = array();
609 foreach ($arrayofvat[$key] as $k => $mt) {
611 $accountingaccount->fetch(
null, $k,
true);
612 $label_account = $accountingaccount->label;
615 $bookkeeping->doc_date = $val[
"date"];
616 $bookkeeping->date_lim_reglement = $val[
"datereg"];
617 $bookkeeping->doc_ref = $val[
"refsologest"];
618 $bookkeeping->date_creation = $now;
619 $bookkeeping->doc_type =
'supplier_invoice';
620 $bookkeeping->fk_doc = $key;
621 $bookkeeping->fk_docdet = 0;
622 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
624 $bookkeeping->subledger_account =
'';
625 $bookkeeping->subledger_label =
'';
627 $bookkeeping->numero_compte = $k;
628 $bookkeeping->label_compte = $label_account;
630 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' '.join(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
631 $bookkeeping->montant = $mt;
632 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
633 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
634 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
635 $bookkeeping->code_journal = $journal;
636 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
637 $bookkeeping->fk_user_author = $user->id;
638 $bookkeeping->entity = $conf->entity;
640 $totaldebit += $bookkeeping->debit;
641 $totalcredit += $bookkeeping->credit;
643 $result = $bookkeeping->create($user);
645 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
648 $errorforinvoice[$key] =
'alreadyjournalized';
653 $errorforinvoice[$key] =
'other';
664 if (!$errorforline && is_array($tabother[$key])) {
665 foreach ($tabother[$key] as $k => $mt) {
668 $bookkeeping->doc_date = $val[
"date"];
669 $bookkeeping->date_lim_reglement = $val[
"datereg"];
670 $bookkeeping->doc_ref = $val[
"refsologest"];
671 $bookkeeping->date_creation = $now;
672 $bookkeeping->doc_type =
'supplier_invoice';
673 $bookkeeping->fk_doc = $key;
674 $bookkeeping->fk_docdet = 0;
675 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
677 $bookkeeping->subledger_account =
'';
678 $bookkeeping->subledger_label =
'';
680 $bookkeeping->numero_compte = $k;
682 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' NPR';
683 $bookkeeping->montant = $mt;
684 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
685 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
686 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
687 $bookkeeping->code_journal = $journal;
688 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
689 $bookkeeping->fk_user_author = $user->id;
690 $bookkeeping->entity = $conf->entity;
692 $totaldebit += $bookkeeping->debit;
693 $totalcredit += $bookkeeping->credit;
695 $result = $bookkeeping->create($user);
697 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
700 $errorforinvoice[$key] =
'alreadyjournalized';
705 $errorforinvoice[$key] =
'other';
714 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
717 $errorforinvoice[$key] =
'amountsnotbalanced';
718 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
721 if (!$errorforline) {
727 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
735 if (empty($error) && count($tabpay) > 0) {
737 } elseif (count($tabpay) == $error) {
740 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
746 if (count($tabpay) != $error) {
747 $param =
'id_journal='.$id_journal;
748 $param .=
'&date_startday='.$date_startday;
749 $param .=
'&date_startmonth='.$date_startmonth;
750 $param .=
'&date_startyear='.$date_startyear;
751 $param .=
'&date_endday='.$date_endday;
752 $param .=
'&date_endmonth='.$date_endmonth;
753 $param .=
'&date_endyear='.$date_endyear;
754 $param .=
'&in_bookkeeping='.$in_bookkeeping;
755 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
764$form =
new Form($db);
767if ($action ==
'exportcsv' && !$error) {
770 $filename =
'journal';
771 $type_export =
'journal';
772 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
777 foreach ($tabfac as $key => $val) {
778 $companystatic->id = $tabcompany[$key][
'id'];
779 $companystatic->name = $tabcompany[$key][
'name'];
780 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
781 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
782 $companystatic->fournisseur = 1;
784 $invoicestatic->id = $key;
785 $invoicestatic->ref = $val[
"refsologest"];
786 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
787 $invoicestatic->type = $val[
"type"];
788 $invoicestatic->description =
dol_trunc(html_entity_decode($val[
"description"]), 32);
789 $invoicestatic->close_code = $val[
"close_code"];
794 $replacedinvoice = 0;
795 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
796 $replacedinvoice = 1;
797 $alreadydispatched = $invoicestatic->getVentilExportCompta();
798 if ($alreadydispatched) {
799 $replacedinvoice = 2;
804 if ($replacedinvoice == 1) {
809 foreach ($tabttc[$key] as $k => $mt) {
811 print
'"'.$key.
'"'.$sep;
812 print
'"'.$date.
'"'.$sep;
813 print
'"'.$val[
"refsologest"].
'"'.$sep;
814 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
815 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
816 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER')).
'"'.$sep;
817 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
818 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
819 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
820 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
821 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
822 print
'"'.$journal.
'"';
828 foreach ($tabht[$key] as $k => $mt) {
830 $accountingaccount->fetch(
null, $k,
true);
832 print
'"'.$key.
'"'.$sep;
833 print
'"'.$date.
'"'.$sep;
834 print
'"'.$val[
"refsologest"].
'"'.$sep;
835 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
836 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
837 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
839 print
'"'.mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1').
'"'.$sep;
840 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
841 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
842 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
843 print
'"'.$journal.
'"';
849 $listoftax = array(0, 1, 2);
850 foreach ($listoftax as $numtax) {
851 $arrayofvat = $tabtva;
853 $arrayofvat = $tablocaltax1;
856 $arrayofvat = $tablocaltax2;
860 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
862 foreach ($arrayofvat[$key] as $k => $mt) {
869 $arrayofvat = $tabrctva;
871 $arrayofvat = $tabrclocaltax1;
874 $arrayofvat = $tabrclocaltax2;
876 if (!is_array($arrayofvat[$key])) {
877 $arrayofvat[$key] = array();
882 foreach ($arrayofvat[$key] as $k => $mt) {
884 print
'"'.$key.
'"'.$sep;
885 print
'"'.$date.
'"'.$sep;
886 print
'"'.$val[
"refsologest"].
'"'.$sep;
887 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
888 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
889 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
891 print
'"'.$langs->trans(
"VAT").
' - '.join(
', ', $def_tva[$key][$k]).
' %"'.$sep;
892 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;
893 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
894 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
895 print
'"'.$journal.
'"';
901 if (is_array($tabother[$key])) {
902 foreach ($tabother[$key] as $k => $mt) {
904 print
'"'.$key.
'"'.$sep;
905 print
'"'.$date.
'"'.$sep;
906 print
'"'.$val[
"refsologest"].
'"'.$sep;
907 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
908 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
909 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
910 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
911 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
912 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"VAT").
' NPR"'.$sep;
913 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
914 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
915 print
'"'.$journal.
'"';
924if (empty($action) || $action ==
'view') {
925 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
934 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
936 $description .= $langs->trans(
"DepositsAreNotIncluded");
938 $description .= $langs->trans(
"DepositsAreIncluded");
941 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
942 $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);
943 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
945 $varlink =
'id_journal='.$id_journal;
947 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
952 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
953 $resql = $db->query($sql);
955 $obj = $db->fetch_object($resql);
957 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
958 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
959 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
969 $acctSupplierNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'), [
'',
'-1']);
970 if ($acctSupplierNotConfigured) {
971 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
972 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
973 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
977 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
978 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
979 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
981 if ($acctSupplierNotConfigured) {
982 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
984 if ($in_bookkeeping ==
'notyet') {
985 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
987 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
994 <script type="text/javascript">
995 function launch_export() {
996 $("div.fiche form input[name=\"action\"]").val("exportcsv");
997 $("div.fiche form input[type=\"submit\"]").click();
998 $("div.fiche form input[name=\"action\"]").val("");
1000 function writebookkeeping() {
1001 console.log("click on writebookkeeping");
1002 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1003 $("div.fiche form input[type=\"submit\"]").click();
1004 $("div.fiche form input[name=\"action\"]").val("");
1013 print
'<div class="div-table-responsive">';
1014 print
"<table class=\"noborder\" width=\"100%\">";
1015 print
"<tr class=\"liste_titre\">";
1016 print
"<td>".$langs->trans(
"Date").
"</td>";
1017 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1018 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1019 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1020 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1021 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1022 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1030 foreach ($tabfac as $key => $val) {
1031 $companystatic->id = $tabcompany[$key][
'id'];
1032 $companystatic->name = $tabcompany[$key][
'name'];
1033 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
1034 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
1035 $companystatic->fournisseur = 1;
1037 $invoicestatic->id = $key;
1038 $invoicestatic->ref = $val[
"refsologest"];
1039 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
1040 $invoicestatic->type = $val[
"type"];
1041 $invoicestatic->description =
dol_trunc(html_entity_decode($val[
"description"]), 32);
1042 $invoicestatic->close_code = $val[
"close_code"];
1047 $replacedinvoice = 0;
1048 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
1049 $replacedinvoice = 1;
1050 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1051 if ($alreadydispatched) {
1052 $replacedinvoice = 2;
1057 if ($replacedinvoice == 1) {
1058 print
'<tr class="oddeven">';
1059 print
"<!-- Replaced invoice -->";
1060 print
"<td>".$date.
"</td>";
1061 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1064 print $langs->trans(
"Replaced");
1071 print
'<td class="right"></td>';
1072 print
'<td class="right"></td>';
1078 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
1079 print
'<tr class="oddeven">';
1080 print
"<!-- Some lines are not bound -->";
1081 print
"<td>".$date.
"</td>";
1082 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1085 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1092 print
'<td class="right"></td>';
1093 print
'<td class="right"></td>';
1100 foreach ($tabttc[$key] as $k => $mt) {
1101 print
'<tr class="oddeven">';
1102 print
"<!-- Thirdparty -->";
1103 print
"<td>".$date.
"</td>";
1104 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1108 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1109 print
'<span class="error">'.$langs->trans(
"MainAccountForSuppliersNotDefined").
'</span>';
1111 print $accountoshow;
1117 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1118 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1120 print $accountoshow;
1123 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1124 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1125 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1132 foreach ($tabht[$key] as $k => $mt) {
1134 $accountingaccount->fetch(
null, $k,
true);
1136 print
'<tr class="oddeven">';
1137 print
"<!-- Product -->";
1138 print
"<td>".$date.
"</td>";
1139 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1143 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1144 print
'<span class="error">'.$langs->trans(
"ProductAccountNotDefined").
'</span>';
1146 print $accountoshow;
1155 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1156 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1159 $companystatic->id = $tabcompany[$key][
'id'];
1160 $companystatic->name = $tabcompany[$key][
'name'];
1161 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$accountingaccount->label.
"</td>";
1162 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1163 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1170 $listoftax = array(0, 1, 2);
1171 foreach ($listoftax as $numtax) {
1172 $arrayofvat = $tabtva;
1174 $arrayofvat = $tablocaltax1;
1177 $arrayofvat = $tablocaltax2;
1181 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
1183 foreach ($arrayofvat[$key] as $k => $mt) {
1190 $arrayofvat = $tabrctva;
1192 $arrayofvat = $tabrclocaltax1;
1195 $arrayofvat = $tabrclocaltax2;
1197 if (!is_array($arrayofvat[$key])) {
1198 $arrayofvat[$key] = array();
1203 foreach ($arrayofvat[$key] as $k => $mt) {
1205 print
'<tr class="oddeven">';
1206 print
"<!-- VAT -->";
1207 print
"<td>".$date.
"</td>";
1208 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1212 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1213 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType3").
')</span>';
1215 print $accountoshow;
1222 print $companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' '.join(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
1224 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1225 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1234 if (is_array($tabother[$key])) {
1235 foreach ($tabother[$key] as $k => $mt) {
1237 print
'<tr class="oddeven">';
1238 print
'<!-- VAT counterpart NPR -->';
1239 print
"<td>".$date.
"</td>";
1240 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1244 if ($accountoshow ==
'' || $accountoshow ==
'NotDefined') {
1245 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"NPR counterpart").
'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>';
1247 print $accountoshow;
1253 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
" NPR (counterpart)</td>";
1254 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1255 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1265 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.