33require
'../../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
54$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"errors"));
57$action =
GETPOST(
'action',
'aZ09');
59$date_startmonth =
GETPOSTINT(
'date_startmonth');
65$in_bookkeeping =
GETPOST(
'in_bookkeeping');
66if ($in_bookkeeping ==
'') {
67 $in_bookkeeping =
'notyet';
72$hookmanager->initHooks(array(
'purchasesjournal'));
79if ($user->socid > 0) {
82if (!$user->hasRight(
'accounting',
'bind',
'write')) {
92$tablocaltax1 = array();
93$tablocaltax2 = array();
95$tabrclocaltax1 = array();
96$tabrclocaltax2 = array();
99$cptcli =
'NotDefined';
100$cptfour =
'NotDefined';
106$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
112$accountingjournalstatic->fetch($id_journal);
113$journal = $accountingjournalstatic->code;
114$journal_label = $accountingjournalstatic->label;
117$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
120$pastmonthyear =
null;
122if (empty($date_startmonth)) {
126 $pastmonthyear = $dates[
'pastmonthyear'];
127 $pastmonth = $dates[
'pastmonth'];
129if (empty($date_endmonth)) {
132 $date_end = $dates[
'date_end'];
133 $pastmonthyear = $dates[
'pastmonthyear'];
134 $pastmonth = $dates[
'pastmonth'];
137if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
139 $date_end =
dol_get_last_day((
int) $pastmonthyear, (
int) $pastmonth,
false);
142$sql =
"SELECT f.rowid, f.ref 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,";
143$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.localtax1_tx, fd.localtax2_tx, fd.total_ttc, fd.vat_src_code, fd.info_bits,";
144$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,";
145$sql .=
" co.code as country_code, co.label as country_label,";
146$sql .=
" s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.fk_pays,";
148 $sql .=
" spe.accountancy_code_customer_general,";
149 $sql .=
" spe.accountancy_code_customer as code_compta,";
150 $sql .=
" spe.accountancy_code_supplier_general,";
151 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
153 $sql .=
" s.accountancy_code_customer_general,";
154 $sql .=
" s.code_compta as code_compta,";
155 $sql .=
" s.accountancy_code_supplier_general,";
156 $sql .=
" s.code_compta_fournisseur,";
159 $sql .=
" ppe.accountancy_code_buy,";
161 $sql .=
" p.accountancy_code_buy,";
163$sql .=
" aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
164$parameters = array();
165$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
166$sql .= $hookmanager->resPrint;
167$sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn_det as fd";
168$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
170 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int)
$conf->entity);
172$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
173$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
174$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
175$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = s.fk_pays ";
177 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int)
$conf->entity);
179$parameters = array();
180$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
181$sql .= $hookmanager->resPrint;
182$sql .=
" WHERE f.fk_statut > 0";
183$sql .=
" AND fd.fk_code_ventilation > 0";
184$sql .=
" AND f.entity IN (".getEntity(
'facture_fourn', 0).
")";
190if ($date_start && $date_end) {
191 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".
$db->idate($date_end).
"'";
195 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalInt(
'ACCOUNTING_DATE_START_BINDING')).
"'";
198if ($in_bookkeeping ==
'already') {
199 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
201if ($in_bookkeeping ==
'notyet') {
202 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
204$parameters = array();
205$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
206$sql .= $hookmanager->resPrint;
207$sql .=
" ORDER BY f.datef";
209dol_syslog(
'accountancy/journal/purchasesjournal.php', LOG_DEBUG);
215$tablocaltax1 = array();
216$tablocaltax2 = array();
217$tabcompany = array();
220$tabrclocaltax1 = array();
221$tabrclocaltax2 = array();
222$vatdata_cache = array();
227$rcctva =
getDolGlobalString(
'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT',
'NotDefined');
228$rcdtva =
getDolGlobalString(
'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT',
'NotDefined');
230$rcclocaltax1 =
getDolGlobalString(
'ACCOUNTING_LT1_BUY_REVERSE_CHARGES_CREDIT',
'NotDefined');
231$rcdlocaltax1 =
getDolGlobalString(
'ACCOUNTING_LT1_BUY_REVERSE_CHARGES_DEBIT',
'NotDefined');
233$rcclocaltax2 =
getDolGlobalString(
'ACCOUNTING_LT2_BUY_REVERSE_CHARGES_CREDIT',
'NotDefined');
234$rcdlocaltax2 =
getDolGlobalString(
'ACCOUNTING_LT2_BUY_REVERSE_CHARGES_DEBIT',
'NotDefined');
235$noTaxDispatchingKeepWithLines =
getDolGlobalInt(
'ACCOUNTING_PURCHASES_DO_NOT_DISPATCH_TAXES');
238$result =
$db->query($sql);
240 $num =
$db->num_rows($result);
244 $obj =
$db->fetch_object($result);
247 $accountancy_code_supplier_general = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $cptfour;
248 $compta_soc = ($obj->code_compta_fournisseur !=
"") ? $obj->code_compta_fournisseur : $cptfour;
250 $compta_prod = $obj->compte;
251 if (empty($compta_prod)) {
252 if ($obj->product_type == 0) {
259 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
260 if (array_key_exists($tax_id, $vatdata_cache)) {
261 $vatdata = $vatdata_cache[$tax_id];
264 $vatdata_cache[$tax_id] = $vatdata;
266 $compta_tva = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
267 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cptlocaltax1);
268 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cptlocaltax2);
269 $compta_counterpart_tva_npr =
getDolGlobalString(
'ACCOUNTING_COUNTERPART_VAT_NPR',
'NotDefined');
272 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
273 $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.
')' :
''));
274 if ($obj->localtax1_tx > 0.0) {
275 $def_tva[$obj->rowid][$compta_localtax1][
vatrate($obj->localtax1_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
'').
' LT1'] = (
vatrate($obj->localtax1_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''));
277 if ($obj->localtax2_tx > 0.0) {
278 $def_tva[$obj->rowid][$compta_localtax2][
vatrate($obj->localtax2_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
'').
' LT2'] = (
vatrate($obj->localtax2_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''));
286 if (!array_key_exists($obj->rowid, $tabfac)) {
287 $tabfac[$obj->rowid] = array();
288 $tabttc[$obj->rowid] = array();
289 $tabht[$obj->rowid] = array();
290 $tabtva[$obj->rowid] = array();
291 $tablocaltax1[$obj->rowid] = array();
292 $tablocaltax2[$obj->rowid] = array();
294 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
295 $tabttc[$obj->rowid][$compta_soc] = 0;
297 if (!isset($tabht[$obj->rowid][$compta_prod])) {
298 $tabht[$obj->rowid][$compta_prod] = 0;
300 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
301 $tabtva[$obj->rowid][$compta_tva] = 0;
303 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
304 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
306 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
307 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
310 $tabfac[$obj->rowid][
"date"] =
$db->jdate($obj->df);
311 $tabfac[$obj->rowid][
"datereg"] =
$db->jdate($obj->dlr);
312 $tabfac[$obj->rowid][
"ref"] = $obj->ref_supplier.
' ('.$obj->ref.
')';
313 $tabfac[$obj->rowid][
"refsologest"] = $obj->ref;
314 $tabfac[$obj->rowid][
"refsuppliersologest"] = $obj->ref_supplier;
315 $tabfac[$obj->rowid][
"type"] = $obj->type;
316 $tabfac[$obj->rowid][
"description"] = $obj->description;
317 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
321 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) ||
getDolGlobalString(
'ACCOUNTING_REVERSE_CHARGE_ALSO_NON_EEC'))) {
322 $rcvatdata =
getTaxesFromId($obj->product_buy_vat . ($obj->product_buy_default_vat_code ?
' (' . $obj->product_buy_default_vat_code .
')' :
''),
$mysoc,
$mysoc, 0);
323 $rcc_compta_tva = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcctva);
324 $rcd_compta_tva = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
325 $rcc_compta_localtax1 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcclocaltax1);
326 $rcd_compta_localtax1 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdlocaltax1);
327 $rcc_compta_localtax2 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcclocaltax2);
328 $rcd_compta_localtax2 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdlocaltax2);
329 if (
price2num($obj->product_buy_vat) || !empty($obj->product_buy_default_vat_code)) {
330 $vat_key =
vatrate($obj->product_buy_vat) . ($obj->product_buy_default_vat_code ?
' (' . $obj->product_buy_default_vat_code .
')' :
'');
331 $val_value = $vat_key;
332 $def_tva[$obj->rowid][$rcc_compta_tva][$vat_key] = $val_value;
333 $def_tva[$obj->rowid][$rcd_compta_tva][$vat_key] = $val_value;
336 if (!array_key_exists($obj->rowid, $tabrctva)) {
337 $tabrctva[$obj->rowid] = array();
338 $tabrclocaltax1[$obj->rowid] = array();
339 $tabrclocaltax2[$obj->rowid] = array();
341 if (!isset($tabrctva[$obj->rowid][$rcc_compta_tva])) {
342 $tabrctva[$obj->rowid][$rcc_compta_tva] = 0;
344 if (!isset($tabrctva[$obj->rowid][$rcd_compta_tva])) {
345 $tabrctva[$obj->rowid][$rcd_compta_tva] = 0;
347 if (!isset($tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1])) {
348 $tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] = 0;
350 if (!isset($tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1])) {
351 $tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] = 0;
353 if (!isset($tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2])) {
354 $tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] = 0;
356 if (!isset($tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2])) {
357 $tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] = 0;
360 $rcvat = (float)
price2num($obj->total_ttc * $obj->product_buy_vat / 100,
'MT');
361 $rclocalvat1 = (float)
price2num($obj->total_ttc * $obj->product_buy_localvat1 / 100,
'MT');
362 $rclocalvat2 = (float)
price2num($obj->total_ttc * $obj->product_buy_localvat2 / 100,
'MT');
364 $tabrctva[$obj->rowid][$rcd_compta_tva] += $rcvat;
365 $tabrctva[$obj->rowid][$rcc_compta_tva] -= $rcvat;
366 $tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] += $rclocalvat1;
367 $tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] -= $rclocalvat1;
368 $tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] += $rclocalvat2;
369 $tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] -= $rclocalvat2;
372 $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
374 if ($noTaxDispatchingKeepWithLines) {
375 $tabht[$obj->rowid][$compta_prod] += $obj->total_ttc;
377 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
378 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
379 $tva_npr = ((($obj->info_bits & 1) == 1) ? 1 : 0);
381 if (!array_key_exists($obj->rowid, $tabother)) {
382 $tabother[$obj->rowid] = array();
384 if (!array_key_exists($compta_counterpart_tva_npr, $tabother[$obj->rowid])) {
385 $tabother[$obj->rowid][$compta_counterpart_tva_npr] = 0;
387 $tabother[$obj->rowid][$compta_counterpart_tva_npr] += (float) $obj->total_tva;
389 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
390 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
392 $tabcompany[$obj->rowid] = array(
394 'name' => $obj->name,
395 'code_fournisseur' => $obj->code_fournisseur,
396 'accountancy_code_supplier_general' => $accountancy_code_supplier_general,
397 'code_compta_fournisseur' => $compta_soc
403 if ($i >
getDolGlobalInt(
'ACCOUNTANCY_MAX_TOO_MANY_LINES_TO_PROCESS', 10000)) {
405 setEventMessages(
"ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
413$errorforinvoice = array();
436if (!empty($tabfac)) {
440 COUNT(fd.rowid) as nb
442 " . MAIN_DB_PREFIX .
"facture_fourn_det as fd
445 AND fd.fk_code_ventilation <= 0
446 AND fd.total_ttc <> 0
447 AND fk_facture_fourn IN (".$db->sanitize(implode(
",", array_keys($tabfac))).
")
448 GROUP BY fk_facture_fourn
450 $resql =
$db->query($sql);
452 $num =
$db->num_rows($resql);
455 $obj =
$db->fetch_object($resql);
457 $errorforinvoice[$obj->fk_facture_fourn] =
'somelinesarenotbound';
464if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
473 $accountingaccountsupplier->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'),
true);
475 foreach ($tabfac as $key => $val) {
483 $companystatic->id = $tabcompany[$key][
'id'];
484 $companystatic->name = $tabcompany[$key][
'name'];
485 $companystatic->accountancy_code_supplier_general = $tabcompany[$key][
'accountancy_code_supplier_general'];
486 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
487 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
488 $companystatic->fournisseur = 1;
490 $invoicestatic->id = (int) $key;
491 $invoicestatic->ref = (
string) $val[
"refsologest"];
492 $invoicestatic->ref_supplier = (
string) $val[
"refsuppliersologest"];
493 $invoicestatic->type = $val[
"type"];
494 $invoicestatic->description = html_entity_decode(
dol_trunc((
string) $val[
"description"], 32));
495 $invoicestatic->close_code = (
string) $val[
"close_code"];
500 $replacedinvoice = 0;
501 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
502 $replacedinvoice = 1;
503 $alreadydispatched = $invoicestatic->getVentilExportCompta();
504 if ($alreadydispatched) {
505 $replacedinvoice = 2;
510 if ($replacedinvoice == 1) {
516 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
519 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
523 if (!$errorforline) {
524 foreach ($tabttc[$key] as $k => $mt) {
526 $bookkeeping->doc_date = $val[
"date"];
527 $bookkeeping->date_lim_reglement = $val[
"datereg"];
528 $bookkeeping->doc_ref = $val[
"refsologest"];
529 $bookkeeping->date_creation = $now;
530 $bookkeeping->doc_type =
'supplier_invoice';
531 $bookkeeping->fk_doc = (int) $key;
532 $bookkeeping->fk_docdet = 0;
533 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
535 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta_fournisseur'];
536 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
538 $bookkeeping->numero_compte = $tabcompany[$key][
'accountancy_code_supplier_general'];
539 $bookkeeping->label_compte = $accountingaccountsupplier->label;
541 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref_supplier, $langs->trans(
"SubledgerAccount"));
542 $bookkeeping->montant = $mt;
543 $bookkeeping->sens = ($mt >= 0) ?
'C' :
'D';
544 $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
545 $bookkeeping->credit = ($mt > 0) ? $mt : 0;
546 $bookkeeping->code_journal = $journal;
547 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
548 $bookkeeping->fk_user_author = $user->id;
549 $bookkeeping->entity =
$conf->entity;
551 $totaldebit += $bookkeeping->debit;
552 $totalcredit += $bookkeeping->credit;
554 $result = $bookkeeping->create($user);
556 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
559 $errorforinvoice[$key] =
'alreadyjournalized';
564 $errorforinvoice[$key] =
'other';
569 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
572 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
579 if (!$errorforline) {
580 foreach ($tabht[$key] as $k => $mt) {
581 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
583 $accountingaccount->fetch(0, $k,
true);
584 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
586 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
589 $label_account = $accountingaccount->label;
592 if ($accountingaccount->id > 0) {
594 $bookkeeping->doc_date = $val[
"date"];
595 $bookkeeping->date_lim_reglement = $val[
"datereg"];
596 $bookkeeping->doc_ref = $val[
"refsologest"];
597 $bookkeeping->date_creation = $now;
598 $bookkeeping->doc_type =
'supplier_invoice';
599 $bookkeeping->fk_doc = (int) $key;
600 $bookkeeping->fk_docdet = 0;
601 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
605 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta_fournisseur'];
606 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
608 $bookkeeping->subledger_account =
'';
609 $bookkeeping->subledger_label =
'';
612 $bookkeeping->subledger_account =
'';
613 $bookkeeping->subledger_label =
'';
616 $bookkeeping->numero_compte = $k;
617 $bookkeeping->label_compte = $label_account;
619 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref_supplier, $label_account);
620 $bookkeeping->montant = $mt;
621 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
622 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
623 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
624 $bookkeeping->code_journal = $journal;
625 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
626 $bookkeeping->fk_user_author = $user->id;
627 $bookkeeping->entity =
$conf->entity;
629 $totaldebit += $bookkeeping->debit;
630 $totalcredit += $bookkeeping->credit;
632 $result = $bookkeeping->create($user);
634 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
637 $errorforinvoice[$key] =
'alreadyjournalized';
642 $errorforinvoice[$key] =
'other';
652 if (!$errorforline) {
653 $listoftax = array(0, 1, 2);
654 foreach ($listoftax as $numtax) {
655 $arrayofvat = $tabtva;
657 $arrayofvat = $tablocaltax1;
660 $arrayofvat = $tablocaltax2;
666 foreach ($arrayofvat[$key] as $k => $mt) {
673 $arrayofvat = $tabrctva;
675 $arrayofvat = $tabrclocaltax1;
678 $arrayofvat = $tabrclocaltax2;
680 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
681 $arrayofvat[$key] = array();
686 foreach ($arrayofvat[$key] as $k => $mt) {
688 if (empty(
$conf->cache[
'accountingaccountincurrententity_vat'][$k])) {
690 $accountingaccount->fetch(0, $k,
true);
691 $conf->cache[
'accountingaccountincurrententity_vat'][$k] = $accountingaccount;
693 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_vat'][$k];
696 $label_account = $accountingaccount->label;
699 $bookkeeping->doc_date = $val[
"date"];
700 $bookkeeping->date_lim_reglement = $val[
"datereg"];
701 $bookkeeping->doc_ref = $val[
"refsologest"];
702 $bookkeeping->date_creation = $now;
703 $bookkeeping->doc_type =
'supplier_invoice';
704 $bookkeeping->fk_doc = (int) $key;
705 $bookkeeping->fk_docdet = 0;
706 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
708 $bookkeeping->subledger_account =
'';
709 $bookkeeping->subledger_label =
'';
711 $bookkeeping->numero_compte = $k;
712 $bookkeeping->label_compte = $label_account;
714 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
715 $labelvataccount = $langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
716 $labelvataccount .= ($numtax ?
' - Localtax '.$numtax :
'');
717 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref_supplier, $labelvataccount);
719 $bookkeeping->montant = $mt;
720 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
721 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
722 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
723 $bookkeeping->code_journal = $journal;
724 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
725 $bookkeeping->fk_user_author = $user->id;
726 $bookkeeping->entity =
$conf->entity;
728 $totaldebit += $bookkeeping->debit;
729 $totalcredit += $bookkeeping->credit;
731 $result = $bookkeeping->create($user);
733 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
736 $errorforinvoice[$key] =
'alreadyjournalized';
741 $errorforinvoice[$key] =
'other';
752 if (!$errorforline && isset($tabother[$key]) && is_array($tabother[$key])) {
753 foreach ($tabother[$key] as $k => $mt) {
756 $bookkeeping->doc_date = $val[
"date"];
757 $bookkeeping->date_lim_reglement = $val[
"datereg"];
758 $bookkeeping->doc_ref = $val[
"refsologest"];
759 $bookkeeping->date_creation = $now;
760 $bookkeeping->doc_type =
'supplier_invoice';
761 $bookkeeping->fk_doc = (int) $key;
762 $bookkeeping->fk_docdet = 0;
763 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
765 $bookkeeping->subledger_account =
'';
766 $bookkeeping->subledger_label =
'';
768 $bookkeeping->numero_compte = $k;
770 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref_supplier, $langs->trans(
"VAT").
' NPR');
771 $bookkeeping->montant = $mt;
772 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
773 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
774 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
775 $bookkeeping->code_journal = $journal;
776 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
777 $bookkeeping->fk_user_author = $user->id;
778 $bookkeeping->entity =
$conf->entity;
780 $totaldebit += $bookkeeping->debit;
781 $totalcredit += $bookkeeping->credit;
783 $result = $bookkeeping->create($user);
785 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
788 $errorforinvoice[$key] =
'alreadyjournalized';
793 $errorforinvoice[$key] =
'other';
802 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
805 $errorforinvoice[$key] =
'amountsnotbalanced';
806 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
809 if (!$errorforline) {
815 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
823 if (empty($error) && count($tabpay) > 0) {
825 } elseif (count($tabpay) == $error) {
828 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
834 if (count($tabpay) != $error) {
835 $param =
'id_journal='.$id_journal;
836 $param .=
'&date_startday='.$date_startday;
837 $param .=
'&date_startmonth='.$date_startmonth;
838 $param .=
'&date_startyear='.$date_startyear;
839 $param .=
'&date_endday='.$date_endday;
840 $param .=
'&date_endmonth='.$date_endmonth;
841 $param .=
'&date_endyear='.$date_endyear;
842 $param .=
'&in_bookkeeping='.$in_bookkeeping;
843 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
855if ($action ==
'exportcsv' && !$error) {
858 $filename =
'journal';
859 $type_export =
'journal';
860 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
866 foreach ($tabfac as $key => $val) {
867 $companystatic->id = $tabcompany[$key][
'id'];
868 $companystatic->name = $tabcompany[$key][
'name'];
869 $companystatic->accountancy_code_supplier_general = !empty($tabcompany[$key][
'accountancy_code_supplier_general']) ? $tabcompany[$key][
'accountancy_code_supplier_general'] : $cptfour;
870 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
871 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
872 $companystatic->fournisseur = 1;
874 $invoicestatic->id = (int) $key;
875 $invoicestatic->ref = (
string) $val[
"refsologest"];
876 $invoicestatic->ref_supplier = (
string) $val[
"refsuppliersologest"];
877 $invoicestatic->type = $val[
"type"];
878 $invoicestatic->description =
dol_trunc(html_entity_decode((
string) $val[
"description"]), 32);
879 $invoicestatic->close_code = (
string) $val[
"close_code"];
884 $replacedinvoice = 0;
885 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
886 $replacedinvoice = 1;
887 $alreadydispatched = $invoicestatic->getVentilExportCompta();
888 if ($alreadydispatched) {
889 $replacedinvoice = 2;
894 if ($replacedinvoice == 1) {
899 foreach ($tabttc[$key] as $k => $mt) {
901 print
'"'.$key.
'"'.$sep;
902 print
'"'.$date.
'"'.$sep;
903 print
'"'.((string) $val[
"refsologest"]).
'"'.$sep;
904 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
905 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
906 print
'"'.length_accountg($companystatic->accountancy_code_supplier_general).
'"'.$sep;
907 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
908 print
'"'.$langs->trans(
"ThirdParty").
'"'.$sep;
909 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $val[
"refsuppliersologest"], $langs->trans(
"ThirdParty"))).
'"'.$sep;
910 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
911 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
912 print
'"'.$journal.
'"';
918 foreach ($tabht[$key] as $k => $mt) {
920 $accountingaccount->fetch(0, $k,
true);
922 print
'"'.$key.
'"'.$sep;
923 print
'"'.$date.
'"'.$sep;
924 print
'"'.((string) $val[
"refsologest"]).
'"'.$sep;
925 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
926 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
927 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
929 print
'"'.csvClean(
dol_trunc($accountingaccount->label, 32)).
'"'.$sep;
930 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $val[
"refsuppliersologest"], $accountingaccount->label)).
'"'.$sep;
931 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
932 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
933 print
'"'.$journal.
'"';
939 $listoftax = array(0, 1, 2);
940 foreach ($listoftax as $numtax) {
941 $arrayofvat = $tabtva;
943 $arrayofvat = $tablocaltax1;
946 $arrayofvat = $tablocaltax2;
952 foreach ($arrayofvat[$key] as $k => $mt) {
959 $arrayofvat = $tabrctva;
961 $arrayofvat = $tabrclocaltax1;
964 $arrayofvat = $tabrclocaltax2;
966 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
967 $arrayofvat[$key] = array();
972 foreach ($arrayofvat[$key] as $k => $mt) {
974 print
'"'.$key.
'"'.$sep;
975 print
'"'.$date.
'"'.$sep;
976 print
'"'.((string) $val[
"refsologest"]).
'"'.$sep;
977 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
978 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
979 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
981 print
'"'.$langs->trans(
"VAT").
' - '.implode(
', ', $def_tva[$key][$k]).
' %"'.$sep;
982 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $val[
"refsuppliersologest"], $langs->trans(
"VAT").implode($def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
''))).
'"'.$sep;
983 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
984 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
985 print
'"'.$journal.
'"';
991 if (isset($tabother[$key]) && is_array($tabother[$key])) {
992 foreach ($tabother[$key] as $k => $mt) {
994 print
'"'.$key.
'"'.$sep;
995 print
'"'.$date.
'"'.$sep;
996 print
'"'.((string) $val[
"refsologest"]).
'"'.$sep;
997 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
998 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
999 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1000 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1001 print
'"'.$langs->trans(
"ThirdParty").
'"'.$sep;
1002 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $val[
"refsuppliersologest"], $langs->trans(
"VAT").
' NPR')).
'"'.$sep;
1003 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1004 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1005 print
'"'.$journal.
'"';
1014if (empty($action) || $action ==
'view') {
1015 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1016 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
1017 llxHeader(
'',
dol_string_nohtmltag($title), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-generation page-purchasesjournal');
1024 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1026 $description .= $langs->trans(
"DepositsAreNotIncluded");
1028 $description .= $langs->trans(
"DepositsAreIncluded");
1031 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
1032 $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);
1033 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1035 $varlink =
'id_journal='.$id_journal;
1037 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
1042 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int)
$conf->entity);
1043 $resql =
$db->query($sql);
1045 $obj =
$db->fetch_object($resql);
1046 if ($obj->nb == 0) {
1047 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1048 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1049 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1059 $acctSupplierNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'), [
'',
'-1']);
1060 if ($acctSupplierNotConfigured) {
1061 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1062 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1063 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1067 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1068 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1069 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1071 if ($acctSupplierNotConfigured) {
1072 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1074 if ($in_bookkeeping ==
'notyet') {
1075 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1077 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1084 <script type="text/javascript">
1085 function launch_export() {
1086 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1087 $("div.fiche form input[type=\"submit\"]").click();
1088 $("div.fiche form input[name=\"action\"]").val("");
1090 function writebookkeeping() {
1091 console.log("click on writebookkeeping");
1092 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1093 $("div.fiche form input[type=\"submit\"]").click();
1094 $("div.fiche form input[name=\"action\"]").val("");
1103 print
'<div class="div-table-responsive">';
1104 print
"<table class=\"noborder\" width=\"100%\">";
1105 print
"<tr class=\"liste_titre\">";
1106 print
"<td>".$langs->trans(
"Date").
"</td>";
1107 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1108 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1109 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1110 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1111 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1112 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1121 foreach ($tabfac as $key => $val) {
1122 $companystatic->id = $tabcompany[$key][
'id'];
1123 $companystatic->name = $tabcompany[$key][
'name'];
1124 $companystatic->accountancy_code_supplier_general = !empty($tabcompany[$key][
'accountancy_code_supplier_general']) ? $tabcompany[$key][
'accountancy_code_supplier_general'] : $cptfour;
1125 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
1126 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
1127 $companystatic->fournisseur = 1;
1129 $invoicestatic->id = (int) $key;
1130 $invoicestatic->ref = (
string) $val[
"refsologest"];
1131 $invoicestatic->ref_supplier = (
string) $val[
"refsuppliersologest"];
1132 $invoicestatic->type = $val[
"type"];
1133 $invoicestatic->description =
dol_trunc(html_entity_decode((
string) $val[
"description"]), 32);
1134 $invoicestatic->close_code = (
string) $val[
"close_code"];
1139 $replacedinvoice = 0;
1140 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
1141 $replacedinvoice = 1;
1142 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1143 if ($alreadydispatched) {
1144 $replacedinvoice = 2;
1149 if ($replacedinvoice == 1) {
1150 print
'<tr class="oddeven">';
1151 print
"<!-- Replaced invoice -->";
1152 print
"<td>".$date.
"</td>";
1153 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1156 print $langs->trans(
"Replaced");
1163 print
'<td class="right"></td>';
1164 print
'<td class="right"></td>';
1170 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
1171 print
'<tr class="oddeven">';
1172 print
"<!-- Some lines are not bound -->";
1173 print
"<td>".$date.
"</td>";
1174 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1177 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1184 print
'<td class="right"></td>';
1185 print
'<td class="right"></td>';
1192 foreach ($tabttc[$key] as $k => $mt) {
1193 print
'<tr class="oddeven">';
1194 print
"<!-- Thirdparty -->";
1195 print
"<td>".$date.
"</td>";
1196 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1199 $accountoshow =
length_accountg(!empty($tabcompany[$key][
'accountancy_code_supplier_general']) ? $tabcompany[$key][
'accountancy_code_supplier_general'] : $cptfour);
1200 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1201 print
'<span class="error">'.$langs->trans(
"MainAccountForSuppliersNotDefined").
'</span>';
1203 print $accountoshow;
1209 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1210 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1212 print $accountoshow;
1215 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'supplier'), $invoicestatic->ref_supplier, $langs->trans(
"SubledgerAccount"), 1) .
"</td>";
1216 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1217 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1224 foreach ($tabht[$key] as $k => $mt) {
1225 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1227 $accountingaccount->fetch(0, $k,
true);
1228 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1230 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1233 print
'<tr class="oddeven">';
1234 print
"<!-- Product -->";
1235 print
"<td>".$date.
"</td>";
1236 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1240 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1241 print
'<span class="error">'.$langs->trans(
"ProductAccountNotDefined").
'</span>';
1243 print $accountoshow;
1252 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1253 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1256 $companystatic->id = $tabcompany[$key][
'id'];
1257 $companystatic->name = $tabcompany[$key][
'name'];
1258 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'supplier'), $invoicestatic->ref_supplier, $accountingaccount->label, 1) .
"</td>";
1259 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1260 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1267 $listoftax = array(0, 1, 2);
1268 foreach ($listoftax as $numtax) {
1269 $arrayofvat = $tabtva;
1271 $arrayofvat = $tablocaltax1;
1274 $arrayofvat = $tablocaltax2;
1280 foreach ($arrayofvat[$key] as $k => $mt) {
1287 $arrayofvat = $tabrctva;
1289 $arrayofvat = $tabrclocaltax1;
1292 $arrayofvat = $tabrclocaltax2;
1294 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
1295 $arrayofvat[$key] = array();
1300 foreach ($arrayofvat[$key] as $k => $mt) {
1302 print
'<tr class="oddeven">';
1303 print
"<!-- VAT -->";
1304 print
"<td>".$date.
"</td>";
1305 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1309 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1310 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType3").
')</span>';
1312 print $accountoshow;
1318 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
1319 $labelvatrate = $langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1320 $labelvatrate .= ($numtax ?
' - Localtax '.$numtax :
'');
1321 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'supplier'), $invoicestatic->ref_supplier, $labelvatrate, 1) .
"</td>";
1322 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1323 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1332 if (isset($tabother[$key]) && is_array($tabother[$key])) {
1333 foreach ($tabother[$key] as $k => $mt) {
1335 print
'<tr class="oddeven">';
1336 print
'<!-- VAT counterpart NPR -->';
1337 print
"<td>".$date.
"</td>";
1338 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1342 if ($accountoshow ==
'' || $accountoshow ==
'NotDefined') {
1343 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"NPR counterpart").
'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>';
1345 print $accountoshow;
1351 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'supplier'), $invoicestatic->ref_supplier, $langs->trans(
"VAT").
" NPR (counterpart)", 1) .
"</td>";
1352 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1353 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1363 print
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='', $moreoptions=array())
Show header of a page used to transfer/dispatch data in accounting.
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage accounting accounts.
Class to manage accounting journals.
Class to manage Ledger (General Ledger and Subledger)
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.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.