32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
44$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"errors"));
47$action =
GETPOST(
'action',
'aZ09');
49$date_startmonth =
GETPOST(
'date_startmonth');
50$date_startday =
GETPOST(
'date_startday');
51$date_startyear =
GETPOST(
'date_startyear');
52$date_endmonth =
GETPOST(
'date_endmonth');
53$date_endday =
GETPOST(
'date_endday');
54$date_endyear =
GETPOST(
'date_endyear');
55$in_bookkeeping =
GETPOST(
'in_bookkeeping');
56if ($in_bookkeeping ==
'') {
57 $in_bookkeeping =
'notyet';
62$hookmanager->initHooks(array(
'purchasesjournal'));
66if (!isModEnabled(
'accounting')) {
69if ($user->socid > 0) {
72if (!$user->hasRight(
'accounting',
'bind',
'write')) {
83$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
89$accountingjournalstatic->fetch($id_journal);
90$journal = $accountingjournalstatic->code;
91$journal_label = $accountingjournalstatic->label;
93$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
94$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
96if (empty($date_startmonth)) {
99 $date_start = $dates[
'date_start'];
100 $pastmonthyear = $dates[
'pastmonthyear'];
101 $pastmonth = $dates[
'pastmonth'];
103if (empty($date_endmonth)) {
106 $date_end = $dates[
'date_end'];
107 $pastmonthyear = $dates[
'pastmonthyear'];
108 $pastmonth = $dates[
'pastmonth'];
111if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
116$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,";
117$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,";
118$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,";
119$sql .=
" co.code as country_code, co.label as country_label,";
120$sql .=
" s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.fk_pays,";
122 $sql .=
" spe.accountancy_code_customer as code_compta,";
123 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
125 $sql .=
" s.code_compta as code_compta,";
126 $sql .=
" s.code_compta_fournisseur,";
129 $sql .=
" ppe.accountancy_code_buy,";
131 $sql .=
" p.accountancy_code_buy,";
133$sql .=
" aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
134$parameters = array();
135$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
136$sql .= $hookmanager->resPrint;
137$sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn_det as fd";
138$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
140 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
142$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
143$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
144$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
145$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = s.fk_pays ";
147 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
149$parameters = array();
150$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
151$sql .= $hookmanager->resPrint;
152$sql .=
" WHERE f.fk_statut > 0";
153$sql .=
" AND fd.fk_code_ventilation > 0";
154$sql .=
" AND f.entity IN (".getEntity(
'facture_fourn', 0).
")";
160if ($date_start && $date_end) {
161 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".$db->idate($date_end).
"'";
165 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
168if ($in_bookkeeping ==
'already') {
169 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
171if ($in_bookkeeping ==
'notyet') {
172 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
174$parameters = array();
175$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
176$sql .= $hookmanager->resPrint;
177$sql .=
" ORDER BY f.datef";
179dol_syslog(
'accountancy/journal/purchasesjournal.php', LOG_DEBUG);
180$result = $db->query($sql);
187 $tablocaltax1 = array();
188 $tablocaltax2 = array();
189 $tabcompany = array();
192 $tabrclocaltax1 = array();
193 $tabrclocaltax2 = array();
194 $vatdata_cache = array();
196 $num = $db->num_rows($result);
201 $rcctva =
getDolGlobalString(
'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT',
'NotDefined');
202 $rcdtva =
getDolGlobalString(
'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT',
'NotDefined');
207 $obj = $db->fetch_object($result);
210 $compta_soc = ($obj->code_compta_fournisseur !=
"") ? $obj->code_compta_fournisseur : $cptfour;
212 $compta_prod = $obj->compte;
213 if (empty($compta_prod)) {
214 if ($obj->product_type == 0) {
221 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
222 if (array_key_exists($tax_id, $vatdata_cache)) {
223 $vatdata = $vatdata_cache[$tax_id];
226 $vatdata_cache[$tax_id] = $vatdata;
228 $compta_tva = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
229 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
230 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
231 $compta_counterpart_tva_npr =
getDolGlobalString(
'ACCOUNTING_COUNTERPART_VAT_NPR',
'NotDefined');
234 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
235 $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.
')' :
''));
241 $tabfac[$obj->rowid][
"date"] = $db->jdate($obj->df);
242 $tabfac[$obj->rowid][
"datereg"] = $db->jdate($obj->dlr);
243 $tabfac[$obj->rowid][
"ref"] = $obj->ref_supplier.
' ('.$obj->ref.
')';
244 $tabfac[$obj->rowid][
"refsologest"] = $obj->ref;
245 $tabfac[$obj->rowid][
"refsuppliersologest"] = $obj->ref_supplier;
246 $tabfac[$obj->rowid][
"type"] = $obj->type;
247 $tabfac[$obj->rowid][
"description"] = $obj->description;
248 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
252 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
253 $tabttc[$obj->rowid][$compta_soc] = 0;
255 if (!isset($tabht[$obj->rowid][$compta_prod])) {
256 $tabht[$obj->rowid][$compta_prod] = 0;
258 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
259 $tabtva[$obj->rowid][$compta_tva] = 0;
261 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
262 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
264 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
265 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
269 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)) {
270 $rcvatdata =
getTaxesFromId($obj->product_buy_vat . ($obj->product_buy_default_vat_code ?
' (' . $obj->product_buy_default_vat_code .
')' :
''), $mysoc, $mysoc, 0);
271 $rcc_compta_tva = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcctva);
272 $rcd_compta_tva = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
273 $rcc_compta_localtax1 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcctva);
274 $rcd_compta_localtax1 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
275 $rcc_compta_localtax2 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcctva);
276 $rcd_compta_localtax2 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
277 if (
price2num($obj->product_buy_vat) || !empty($obj->product_buy_default_vat_code)) {
278 $vat_key =
vatrate($obj->product_buy_vat) . ($obj->product_buy_default_vat_code ?
' (' . $obj->product_buy_default_vat_code .
')' :
'');
279 $val_value = $vat_key;
280 $def_tva[$obj->rowid][$rcc_compta_tva][$vat_key] = $val_value;
281 $def_tva[$obj->rowid][$rcd_compta_tva][$vat_key] = $val_value;
284 if (!isset($tabrctva[$obj->rowid][$rcc_compta_tva])) {
285 $tabrctva[$obj->rowid][$rcc_compta_tva] = 0;
287 if (!isset($tabrctva[$obj->rowid][$rcd_compta_tva])) {
288 $tabrctva[$obj->rowid][$rcd_compta_tva] = 0;
290 if (!isset($tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1])) {
291 $tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] = 0;
293 if (!isset($tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1])) {
294 $tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] = 0;
296 if (!isset($tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2])) {
297 $tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] = 0;
299 if (!isset($tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2])) {
300 $tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] = 0;
303 $rcvat = (float)
price2num($obj->total_ttc * $obj->product_buy_vat / 100,
'MT');
304 $rclocalvat1 = (float)
price2num($obj->total_ttc * $obj->product_buy_localvat1 / 100,
'MT');
305 $rclocalvat2 = (float)
price2num($obj->total_ttc * $obj->product_buy_localvat2 / 100,
'MT');
307 $tabrctva[$obj->rowid][$rcd_compta_tva] += $rcvat;
308 $tabrctva[$obj->rowid][$rcc_compta_tva] -= $rcvat;
309 $tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] += $rclocalvat1;
310 $tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] -= $rclocalvat1;
311 $tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] += $rclocalvat2;
312 $tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] -= $rclocalvat2;
315 $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
316 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
317 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
318 $tva_npr = ((($obj->info_bits & 1) == 1) ? 1 : 0);
320 $tabother[$obj->rowid][$compta_counterpart_tva_npr] += $obj->total_tva;
322 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
323 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
324 $tabcompany[$obj->rowid] = array(
326 'name' => $obj->name,
327 'code_fournisseur' => $obj->code_fournisseur,
328 'code_compta_fournisseur' => $compta_soc
334 if ($i >
getDolGlobalInt(
'ACCOUNTANCY_MAX_TOO_MANY_LINES_TO_PROCESS', 10000)) {
336 setEventMessages(
"ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
344$errorforinvoice = array();
366if (!empty($tabfac)) {
370 COUNT(fd.rowid) as nb
372 " . MAIN_DB_PREFIX .
"facture_fourn_det as fd
375 AND fd.fk_code_ventilation <= 0
376 AND fd.total_ttc <> 0
377 AND fk_facture_fourn IN (".$db->sanitize(implode(
",", array_keys($tabfac))).
")
378 GROUP BY fk_facture_fourn
380 $resql = $db->query($sql);
382 $num = $db->num_rows($resql);
385 $obj = $db->fetch_object($resql);
387 $errorforinvoice[$obj->fk_facture_fourn] =
'somelinesarenotbound';
397if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
401 $companystatic =
new Societe($db);
405 $accountingaccountsupplier->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'),
true);
407 foreach ($tabfac as $key => $val) {
415 $companystatic->id = $tabcompany[$key][
'id'];
416 $companystatic->name = $tabcompany[$key][
'name'];
417 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
418 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
419 $companystatic->fournisseur = 1;
421 $invoicestatic->id = $key;
422 $invoicestatic->ref = (string) $val[
"refsologest"];
423 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
424 $invoicestatic->type = $val[
"type"];
425 $invoicestatic->description = html_entity_decode(
dol_trunc($val[
"description"], 32));
426 $invoicestatic->close_code = $val[
"close_code"];
431 $replacedinvoice = 0;
432 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
433 $replacedinvoice = 1;
434 $alreadydispatched = $invoicestatic->getVentilExportCompta();
435 if ($alreadydispatched) {
436 $replacedinvoice = 2;
441 if ($replacedinvoice == 1) {
447 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
450 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
454 if (!$errorforline) {
455 foreach ($tabttc[$key] as $k => $mt) {
457 $bookkeeping->doc_date = $val[
"date"];
458 $bookkeeping->date_lim_reglement = $val[
"datereg"];
459 $bookkeeping->doc_ref = $val[
"refsologest"];
460 $bookkeeping->date_creation = $now;
461 $bookkeeping->doc_type =
'supplier_invoice';
462 $bookkeeping->fk_doc = $key;
463 $bookkeeping->fk_docdet = 0;
464 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
466 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta_fournisseur'];
467 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
470 $bookkeeping->label_compte = $accountingaccountsupplier->label;
472 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"SubledgerAccount");
473 $bookkeeping->montant = $mt;
474 $bookkeeping->sens = ($mt >= 0) ?
'C' :
'D';
475 $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
476 $bookkeeping->credit = ($mt > 0) ? $mt : 0;
477 $bookkeeping->code_journal = $journal;
478 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
479 $bookkeeping->fk_user_author = $user->id;
480 $bookkeeping->entity = $conf->entity;
482 $totaldebit += $bookkeeping->debit;
483 $totalcredit += $bookkeeping->credit;
485 $result = $bookkeeping->create($user);
487 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
490 $errorforinvoice[$key] =
'alreadyjournalized';
495 $errorforinvoice[$key] =
'other';
500 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
503 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
510 if (!$errorforline) {
511 foreach ($tabht[$key] as $k => $mt) {
512 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
514 $accountingaccount->fetch(0, $k,
true);
515 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
517 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
520 $label_account = $accountingaccount->label;
523 if ($accountingaccount->id > 0) {
525 $bookkeeping->doc_date = $val[
"date"];
526 $bookkeeping->date_lim_reglement = $val[
"datereg"];
527 $bookkeeping->doc_ref = $val[
"refsologest"];
528 $bookkeeping->date_creation = $now;
529 $bookkeeping->doc_type =
'supplier_invoice';
530 $bookkeeping->fk_doc = $key;
531 $bookkeeping->fk_docdet = 0;
532 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
536 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
537 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
539 $bookkeeping->subledger_account =
'';
540 $bookkeeping->subledger_label =
'';
543 $bookkeeping->subledger_account =
'';
544 $bookkeeping->subledger_label =
'';
547 $bookkeeping->numero_compte = $k;
548 $bookkeeping->label_compte = $label_account;
550 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$label_account;
551 $bookkeeping->montant = $mt;
552 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
553 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
554 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
555 $bookkeeping->code_journal = $journal;
556 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
557 $bookkeeping->fk_user_author = $user->id;
558 $bookkeeping->entity = $conf->entity;
560 $totaldebit += $bookkeeping->debit;
561 $totalcredit += $bookkeeping->credit;
563 $result = $bookkeeping->create($user);
565 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
568 $errorforinvoice[$key] =
'alreadyjournalized';
573 $errorforinvoice[$key] =
'other';
583 if (!$errorforline) {
584 $listoftax = array(0, 1, 2);
585 foreach ($listoftax as $numtax) {
586 $arrayofvat = $tabtva;
588 $arrayofvat = $tablocaltax1;
591 $arrayofvat = $tablocaltax2;
595 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
597 foreach ($arrayofvat[$key] as $k => $mt) {
604 $arrayofvat = $tabrctva;
606 $arrayofvat = $tabrclocaltax1;
609 $arrayofvat = $tabrclocaltax2;
611 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
612 $arrayofvat[$key] = array();
617 foreach ($arrayofvat[$key] as $k => $mt) {
619 if (empty($conf->cache[
'accountingaccountincurrententity_vat'][$k])) {
621 $accountingaccount->fetch(0, $k,
true);
622 $conf->cache[
'accountingaccountincurrententity_vat'][$k] = $accountingaccount;
624 $accountingaccount = $conf->cache[
'accountingaccountincurrententity_vat'][$k];
627 $label_account = $accountingaccount->label;
630 $bookkeeping->doc_date = $val[
"date"];
631 $bookkeeping->date_lim_reglement = $val[
"datereg"];
632 $bookkeeping->doc_ref = $val[
"refsologest"];
633 $bookkeeping->date_creation = $now;
634 $bookkeeping->doc_type =
'supplier_invoice';
635 $bookkeeping->fk_doc = $key;
636 $bookkeeping->fk_docdet = 0;
637 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
639 $bookkeeping->subledger_account =
'';
640 $bookkeeping->subledger_label =
'';
642 $bookkeeping->numero_compte = $k;
643 $bookkeeping->label_compte = $label_account;
645 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
646 $bookkeeping->montant = $mt;
647 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
648 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
649 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
650 $bookkeeping->code_journal = $journal;
651 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
652 $bookkeeping->fk_user_author = $user->id;
653 $bookkeeping->entity = $conf->entity;
655 $totaldebit += $bookkeeping->debit;
656 $totalcredit += $bookkeeping->credit;
658 $result = $bookkeeping->create($user);
660 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
663 $errorforinvoice[$key] =
'alreadyjournalized';
668 $errorforinvoice[$key] =
'other';
679 if (!$errorforline && isset($tabother[$key]) && is_array($tabother[$key])) {
680 foreach ($tabother[$key] as $k => $mt) {
683 $bookkeeping->doc_date = $val[
"date"];
684 $bookkeeping->date_lim_reglement = $val[
"datereg"];
685 $bookkeeping->doc_ref = $val[
"refsologest"];
686 $bookkeeping->date_creation = $now;
687 $bookkeeping->doc_type =
'supplier_invoice';
688 $bookkeeping->fk_doc = $key;
689 $bookkeeping->fk_docdet = 0;
690 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
692 $bookkeeping->subledger_account =
'';
693 $bookkeeping->subledger_label =
'';
695 $bookkeeping->numero_compte = $k;
697 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' NPR';
698 $bookkeeping->montant = $mt;
699 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
700 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
701 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
702 $bookkeeping->code_journal = $journal;
703 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
704 $bookkeeping->fk_user_author = $user->id;
705 $bookkeeping->entity = $conf->entity;
707 $totaldebit += $bookkeeping->debit;
708 $totalcredit += $bookkeeping->credit;
710 $result = $bookkeeping->create($user);
712 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
715 $errorforinvoice[$key] =
'alreadyjournalized';
720 $errorforinvoice[$key] =
'other';
729 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
732 $errorforinvoice[$key] =
'amountsnotbalanced';
733 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
736 if (!$errorforline) {
742 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
750 if (empty($error) && count($tabpay) > 0) {
752 } elseif (count($tabpay) == $error) {
755 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
761 if (count($tabpay) != $error) {
762 $param =
'id_journal='.$id_journal;
763 $param .=
'&date_startday='.$date_startday;
764 $param .=
'&date_startmonth='.$date_startmonth;
765 $param .=
'&date_startyear='.$date_startyear;
766 $param .=
'&date_endday='.$date_endday;
767 $param .=
'&date_endmonth='.$date_endmonth;
768 $param .=
'&date_endyear='.$date_endyear;
769 $param .=
'&in_bookkeeping='.$in_bookkeeping;
770 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
779$form =
new Form($db);
782if ($action ==
'exportcsv' && !$error) {
785 $filename =
'journal';
786 $type_export =
'journal';
787 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
792 foreach ($tabfac as $key => $val) {
793 $companystatic->id = $tabcompany[$key][
'id'];
794 $companystatic->name = $tabcompany[$key][
'name'];
795 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
796 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
797 $companystatic->fournisseur = 1;
799 $invoicestatic->id = $key;
800 $invoicestatic->ref = $val[
"refsologest"];
801 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
802 $invoicestatic->type = $val[
"type"];
803 $invoicestatic->description =
dol_trunc(html_entity_decode($val[
"description"]), 32);
804 $invoicestatic->close_code = $val[
"close_code"];
809 $replacedinvoice = 0;
810 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
811 $replacedinvoice = 1;
812 $alreadydispatched = $invoicestatic->getVentilExportCompta();
813 if ($alreadydispatched) {
814 $replacedinvoice = 2;
819 if ($replacedinvoice == 1) {
824 foreach ($tabttc[$key] as $k => $mt) {
826 print
'"'.$key.
'"'.$sep;
827 print
'"'.$date.
'"'.$sep;
828 print
'"'.$val[
"refsologest"].
'"'.$sep;
829 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
830 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
831 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER')).
'"'.$sep;
832 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
833 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
834 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
835 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
836 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
837 print
'"'.$journal.
'"';
843 foreach ($tabht[$key] as $k => $mt) {
845 $accountingaccount->fetch(
null, $k,
true);
847 print
'"'.$key.
'"'.$sep;
848 print
'"'.$date.
'"'.$sep;
849 print
'"'.$val[
"refsologest"].
'"'.$sep;
850 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
851 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
852 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
854 print
'"'.mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1').
'"'.$sep;
855 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
856 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
857 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
858 print
'"'.$journal.
'"';
864 $listoftax = array(0, 1, 2);
865 foreach ($listoftax as $numtax) {
866 $arrayofvat = $tabtva;
868 $arrayofvat = $tablocaltax1;
871 $arrayofvat = $tablocaltax2;
875 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
877 foreach ($arrayofvat[$key] as $k => $mt) {
884 $arrayofvat = $tabrctva;
886 $arrayofvat = $tabrclocaltax1;
889 $arrayofvat = $tabrclocaltax2;
891 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
892 $arrayofvat[$key] = array();
897 foreach ($arrayofvat[$key] as $k => $mt) {
899 print
'"'.$key.
'"'.$sep;
900 print
'"'.$date.
'"'.$sep;
901 print
'"'.$val[
"refsologest"].
'"'.$sep;
902 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
903 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
904 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
906 print
'"'.$langs->trans(
"VAT").
' - '.implode(
', ', $def_tva[$key][$k]).
' %"'.$sep;
907 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"VAT").implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'').
'"'.$sep;
908 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
909 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
910 print
'"'.$journal.
'"';
916 if (isset($tabother[$key]) && is_array($tabother[$key])) {
917 foreach ($tabother[$key] as $k => $mt) {
919 print
'"'.$key.
'"'.$sep;
920 print
'"'.$date.
'"'.$sep;
921 print
'"'.$val[
"refsologest"].
'"'.$sep;
922 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
923 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
924 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
925 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
926 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
927 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"VAT").
' NPR"'.$sep;
928 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
929 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
930 print
'"'.$journal.
'"';
939if (empty($action) || $action ==
'view') {
940 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
941 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
942 llxHeader(
'',
dol_string_nohtmltag($title), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-generation page-purchasesjournal');
949 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
951 $description .= $langs->trans(
"DepositsAreNotIncluded");
953 $description .= $langs->trans(
"DepositsAreIncluded");
956 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
957 $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);
958 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
960 $varlink =
'id_journal='.$id_journal;
962 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
967 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
968 $resql = $db->query($sql);
970 $obj = $db->fetch_object($resql);
972 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
973 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
974 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
984 $acctSupplierNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'), [
'',
'-1']);
985 if ($acctSupplierNotConfigured) {
986 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
987 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
988 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
992 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
993 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
994 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
996 if ($acctSupplierNotConfigured) {
997 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
999 if ($in_bookkeeping ==
'notyet') {
1000 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1002 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1009 <script type="text/javascript">
1010 function launch_export() {
1011 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1012 $("div.fiche form input[type=\"submit\"]").click();
1013 $("div.fiche form input[name=\"action\"]").val("");
1015 function writebookkeeping() {
1016 console.log("click on writebookkeeping");
1017 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1018 $("div.fiche form input[type=\"submit\"]").click();
1019 $("div.fiche form input[name=\"action\"]").val("");
1028 print
'<div class="div-table-responsive">';
1029 print
"<table class=\"noborder\" width=\"100%\">";
1030 print
"<tr class=\"liste_titre\">";
1031 print
"<td>".$langs->trans(
"Date").
"</td>";
1032 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1033 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1034 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1035 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1036 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1037 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1045 foreach ($tabfac as $key => $val) {
1046 $companystatic->id = $tabcompany[$key][
'id'];
1047 $companystatic->name = $tabcompany[$key][
'name'];
1048 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
1049 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
1050 $companystatic->fournisseur = 1;
1052 $invoicestatic->id = $key;
1053 $invoicestatic->ref = $val[
"refsologest"];
1054 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
1055 $invoicestatic->type = $val[
"type"];
1056 $invoicestatic->description =
dol_trunc(html_entity_decode($val[
"description"]), 32);
1057 $invoicestatic->close_code = $val[
"close_code"];
1062 $replacedinvoice = 0;
1063 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
1064 $replacedinvoice = 1;
1065 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1066 if ($alreadydispatched) {
1067 $replacedinvoice = 2;
1072 if ($replacedinvoice == 1) {
1073 print
'<tr class="oddeven">';
1074 print
"<!-- Replaced invoice -->";
1075 print
"<td>".$date.
"</td>";
1076 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1079 print $langs->trans(
"Replaced");
1086 print
'<td class="right"></td>';
1087 print
'<td class="right"></td>';
1093 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
1094 print
'<tr class="oddeven">';
1095 print
"<!-- Some lines are not bound -->";
1096 print
"<td>".$date.
"</td>";
1097 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1100 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1107 print
'<td class="right"></td>';
1108 print
'<td class="right"></td>';
1115 foreach ($tabttc[$key] as $k => $mt) {
1116 print
'<tr class="oddeven">';
1117 print
"<!-- Thirdparty -->";
1118 print
"<td>".$date.
"</td>";
1119 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1123 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1124 print
'<span class="error">'.$langs->trans(
"MainAccountForSuppliersNotDefined").
'</span>';
1126 print $accountoshow;
1132 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1133 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1135 print $accountoshow;
1138 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1139 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1140 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1147 foreach ($tabht[$key] as $k => $mt) {
1148 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
1150 $accountingaccount->fetch(0, $k,
true);
1151 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1153 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
1156 print
'<tr class="oddeven">';
1157 print
"<!-- Product -->";
1158 print
"<td>".$date.
"</td>";
1159 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1163 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1164 print
'<span class="error">'.$langs->trans(
"ProductAccountNotDefined").
'</span>';
1166 print $accountoshow;
1175 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1176 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1179 $companystatic->id = $tabcompany[$key][
'id'];
1180 $companystatic->name = $tabcompany[$key][
'name'];
1181 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$accountingaccount->label.
"</td>";
1182 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1183 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1190 $listoftax = array(0, 1, 2);
1191 foreach ($listoftax as $numtax) {
1192 $arrayofvat = $tabtva;
1194 $arrayofvat = $tablocaltax1;
1197 $arrayofvat = $tablocaltax2;
1201 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
1203 foreach ($arrayofvat[$key] as $k => $mt) {
1210 $arrayofvat = $tabrctva;
1212 $arrayofvat = $tabrclocaltax1;
1215 $arrayofvat = $tabrclocaltax2;
1217 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
1218 $arrayofvat[$key] = array();
1223 foreach ($arrayofvat[$key] as $k => $mt) {
1225 print
'<tr class="oddeven">';
1226 print
"<!-- VAT -->";
1227 print
"<td>".$date.
"</td>";
1228 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1232 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1233 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType3").
')</span>';
1235 print $accountoshow;
1242 print $companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
1244 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1245 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1254 if (isset($tabother[$key]) && is_array($tabother[$key])) {
1255 foreach ($tabother[$key] as $k => $mt) {
1257 print
'<tr class="oddeven">';
1258 print
'<!-- VAT counterpart NPR -->';
1259 print
"<td>".$date.
"</td>";
1260 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1264 if ($accountoshow ==
'' || $accountoshow ==
'NotDefined') {
1265 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"NPR counterpart").
'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>';
1267 print $accountoshow;
1273 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
" NPR (counterpart)</td>";
1274 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1275 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1285 print
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='', $moreoptions=array())
Show header of a page used to transfer/dispatch data in accounting.
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
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 information (by default a local PHP server timestamp) Rep...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
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).
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return 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.