This commit is contained in:
Alexandre SPANGARO 2018-10-16 06:32:55 +02:00
parent 3a6824da68
commit a971a2afe6
3 changed files with 52 additions and 48 deletions

View File

@ -150,13 +150,14 @@ $paymentvariousstatic = new PaymentVarious($db);
$paymentloanstatic = new PaymentLoan($db);
$accountLinestatic=new AccountLine($db);
$accountingaccount = new AccountingAccount($db);
// Get code of finance journal
$accountingjournalstatic = new AccountingJournal($db);
$accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code;
$journal_label = $accountingjournalstatic->label;
$accountingaccountstatic = new AccountingAccount($db);
dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
$result = $db->query($sql);
@ -465,9 +466,8 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->numero_compte = $k;
$accountingaccountstatic->fetch('',$k,1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch(null, $k, true);
$bookkeeping->label_compte = $accountingaccount->label;
$bookkeeping->label_operation = $reflabel;
$bookkeeping->montant = $mt;
@ -540,33 +540,29 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
$accountingaccountstatic->fetch('',$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER,1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
$bookkeeping->label_compte = $accountingaccount->label;
} else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
$accountingaccountstatic->fetch('',$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER,1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true);
$bookkeeping->label_compte = $accountingaccount->label;
} else if ($tabtype[$key] == 'payment_expensereport') {
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
$bookkeeping->subledger_label = $tabuser[$key]['name'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$accountingaccountstatic->fetch('',$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT,1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch(null ,$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT, true);
$bookkeeping->label_compte = $accountingaccount->label;
} else if ($tabtype[$key] == 'payment_salary') {
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
$bookkeeping->subledger_label = $tabuser[$key]['name'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$accountingaccountstatic->fetch('',$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT,1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch(null ,$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT, true);
$bookkeeping->label_compte = $accountingaccount->label;
} else if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
@ -577,41 +573,36 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$accountingaccountstatic->fetch($k,'',1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch($k, null, true);
$bookkeeping->label_compte = $accountingaccount->label;
} else if ($tabtype[$key] == 'payment_donation') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$accountingaccountstatic->fetch($k,'',1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch($k, null, true);
$bookkeeping->label_compte = $accountingaccount->label;
} else if ($tabtype[$key] == 'payment_loan') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$accountingaccountstatic->fetch($k,'',1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch($k, null, true);
$bookkeeping->label_compte = $accountingaccount->label;
} else if ($tabtype[$key] == 'payment_various') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$accountingaccountstatic->fetch($k,'',1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch($k, null, true);
$bookkeeping->label_compte = $accountingaccount->label;
} else if ($tabtype[$key] == 'banktransfert') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$accountingaccountstatic->fetch($k,'',1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch($k, null, true);
$bookkeeping->label_compte = $accountingaccount->label;
} else {
if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty.
{
@ -620,9 +611,8 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE;
$accountingaccountstatic->fetch('',$conf->global->ACCOUNTING_ACCOUNT_SUSPENSE,1);
$accountingaccount_label = $accountingaccountstatic->label;
$bookkeeping->label_compte = $accountingaccount_label;
$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE, true);
$bookkeeping->label_compte = $accountingaccount->label;
}
}
$bookkeeping->label_operation = $reflabel;

View File

@ -3,7 +3,7 @@
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
@ -61,6 +61,7 @@ if ($user->societe_id > 0)
/*
* Actions
*/
$accountingaccount = new AccountingAccount($db);
// Get informations of journal
$accountingjournalstatic = new AccountingJournal($db);
@ -210,6 +211,10 @@ if ($action == 'writebookkeeping') {
$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->label_operation = $tabuser[$key]['name'];
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
@ -248,7 +253,6 @@ if ($action == 'writebookkeeping') {
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
$accountingaccount = new AccountingAccount($db);
if ($accountingaccount->fetch(null, $k, true)) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
@ -260,6 +264,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
$bookkeeping->label_operation = $accountingaccount->label;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
@ -316,6 +321,10 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$accountingaccount->fetch($k, null, true);
$bookkeeping->label_compte = $accountingaccount->label;
$bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %';
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';

View File

@ -1,11 +1,11 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -66,10 +66,7 @@ $parameters=array();
*/
$reshook=$hookmanager->executeHooks('doActions',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks
/*
* Views
*/
$accountingaccount = new AccountingAccount($db);
// Get informations of journal
$accountingjournalstatic = new AccountingJournal($db);
@ -312,6 +309,10 @@ if ($action == 'writebookkeeping') {
$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->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("SubledgerAccount");
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
@ -352,7 +353,6 @@ if ($action == 'writebookkeeping') {
foreach ( $tabht[$key] as $k => $mt ) {
//if ($mt) {
// get compte id and label
$accountingaccount = new AccountingAccount($db);
if ($accountingaccount->fetch(null, $k, true)) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
@ -366,6 +366,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $accountingaccount->label;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
@ -426,6 +427,10 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$accountingaccount->fetch($k, null, true);
$bookkeeping->label_compte = $accountingaccount->label;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'');
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';