Small performance enhancement for transfer in accountancy.
This commit is contained in:
parent
2a47128e2d
commit
9c0d4dd86b
@ -547,7 +547,7 @@ if (!$error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
$accountingaccount->fetch(null, $k, true); // $k is accounting bank account. TODO We should use a cache here to avoid this fetch
|
||||
$bookkeeping->label_compte = $accountingaccount->label;
|
||||
|
||||
$bookkeeping->label_operation = $reflabel;
|
||||
|
||||
@ -206,6 +206,9 @@ if ($action == 'writebookkeeping') {
|
||||
$now = dol_now();
|
||||
$error = 0;
|
||||
|
||||
$accountingaccountexpense = new AccountingAccount($db);
|
||||
$accountingaccountexpense->fetch(null, $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT, true);
|
||||
|
||||
foreach ($taber as $key => $val) { // Loop on each expense report
|
||||
$errorforline = 0;
|
||||
|
||||
@ -227,10 +230,9 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->fk_docdet = $val["fk_expensereportdet"];
|
||||
$bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code'];
|
||||
$bookkeeping->subledger_label = $tabuser[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
|
||||
$accountingaccount->fetch(null, $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT, true);
|
||||
$bookkeeping->label_compte = $accountingaccount->label;
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
$bookkeeping->label_compte = $accountingaccountexpense->label;
|
||||
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'];
|
||||
$bookkeeping->montant = $mt;
|
||||
|
||||
@ -248,7 +248,7 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice
|
||||
$sql = "SELECT COUNT(fd.rowid) as nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd";
|
||||
$sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
|
||||
$sql .= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key;
|
||||
$sql .= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".((int) $key);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
@ -270,6 +270,9 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
$companystatic = new Societe($db);
|
||||
$invoicestatic = new FactureFournisseur($db);
|
||||
$accountingaccountsupplier = new AccountingAccount($db);
|
||||
|
||||
$accountingaccountsupplier->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true);
|
||||
|
||||
foreach ($tabfac as $key => $val) { // Loop on each invoice
|
||||
$errorforline = 0;
|
||||
@ -333,10 +336,9 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
|
||||
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||
|
||||
$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true);
|
||||
$bookkeeping->label_compte = $accountingaccount->label;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||
$bookkeeping->label_compte = $accountingaccountsupplier->label;
|
||||
|
||||
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount");
|
||||
$bookkeeping->montant = $mt;
|
||||
|
||||
@ -148,7 +148,7 @@ if ($in_bookkeeping == 'notyet') {
|
||||
// $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account
|
||||
}
|
||||
$sql .= " ORDER BY f.datef";
|
||||
//print $sql;
|
||||
//print $sql; exit;
|
||||
|
||||
dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
@ -264,7 +264,7 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice
|
||||
$sql = "SELECT COUNT(fd.rowid) as nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
|
||||
$sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
|
||||
$sql .= " AND fd.total_ttc <> 0 AND fk_facture = ".$key;
|
||||
$sql .= " AND fd.total_ttc <> 0 AND fk_facture = ".((int) $key);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
@ -285,6 +285,9 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
$companystatic = new Societe($db);
|
||||
$invoicestatic = new Facture($db);
|
||||
$accountingaccountcustomer = new AccountingAccount($db);
|
||||
|
||||
$accountingaccountcustomer->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
|
||||
|
||||
foreach ($tabfac as $key => $val) { // Loop on each invoice
|
||||
$errorforline = 0;
|
||||
@ -346,10 +349,9 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->thirdparty_code = $companystatic->code_client;
|
||||
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
|
||||
$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
|
||||
$bookkeeping->label_compte = $accountingaccount->label;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
$bookkeeping->label_compte = $accountingaccountcustomer->label;
|
||||
|
||||
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount");
|
||||
$bookkeeping->montant = $mt;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user