$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; $bookkeeping->date_create = $now; $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $langs->trans("VAT"); $bookkeeping->montant = $mt; $bookkeeping->sens = $mt < 0 ? 'D' : 'C'; $bookkeeping->debit = $mt < 0 ? $mt : 0; $bookkeeping->credit = $mt >= 0 ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; $result = $bookkeeping->create(); if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } } } if (empty($error)) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } } // Export if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); $resultmid = $db->query($sqlmid); if ($resultmid) { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->facnumber; } $bookkeeping->code_tiers = $k; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; } else { $bookkeeping->doc_ref = $k; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; } } } } $result = $bookkeeping->create($user); if ($result < 0) { $error++; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } } if (empty($error)) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } } // Export if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; $companystatic = new Client($db);
$bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; $bookkeeping->date_create = $now; $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = ''; $bookkeeping->label_compte = $langs->trans("VAT"); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = $mt < 0 ? 'C' : 'D'; $bookkeeping->debit = $mt > 0 ? $mt : 0; $bookkeeping->credit = $mt <= 0 ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->create(); } } } } /* * View */ $companystatic = new Societe($db); // Export if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $purchase_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; header('Content-Type: text/csv'); header('Content-Disposition: attachment;filename=journal_achats.csv'); if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {