Maxi debug of accountancy expert module
This commit is contained in:
parent
1e3038d634
commit
31ce725d73
@ -210,11 +210,16 @@ if ($action == 'delbookkeepingyearconfirm') {
|
|||||||
$deljournal=0;
|
$deljournal=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($delyear) || ! empty($deljournal)) {
|
if (! empty($delyear) || ! empty($deljournal))
|
||||||
|
{
|
||||||
$result = $object->deleteByYearAndJournal($delyear,$deljournal);
|
$result = $object->deleteByYearAndJournal($delyear,$deljournal);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages("RecordDeleted", null, 'mesgs');
|
||||||
|
}
|
||||||
Header("Location: list.php");
|
Header("Location: list.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,7 +116,6 @@ class BookKeeping extends CommonObject
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
|
|
||||||
if (isset($this->doc_type)) {
|
if (isset($this->doc_type)) {
|
||||||
$this->doc_type = trim($this->doc_type);
|
$this->doc_type = trim($this->doc_type);
|
||||||
}
|
}
|
||||||
@ -163,6 +162,14 @@ class BookKeeping extends CommonObject
|
|||||||
$this->piece_num = trim($this->piece_num);
|
$this->piece_num = trim($this->piece_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if (empty($this->numero_compte))
|
||||||
|
{
|
||||||
|
$this->errors[]='ErrorFieldAccountNotDefined';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$this->piece_num = 0;
|
$this->piece_num = 0;
|
||||||
@ -174,7 +181,6 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " AND fk_docdet = " . $this->fk_docdet;
|
$sql .= " AND fk_docdet = " . $this->fk_docdet;
|
||||||
$sql .= " AND numero_compte = '" . $this->numero_compte . "'";
|
$sql .= " AND numero_compte = '" . $this->numero_compte . "'";
|
||||||
|
|
||||||
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
@ -274,11 +280,11 @@ class BookKeeping extends CommonObject
|
|||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
} else {
|
} else { // Already exists
|
||||||
$result = - 3;
|
$result = -3;
|
||||||
$error ++;
|
$error++;
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error Transaction for ('.$this->doc_type.', '.$this->doc_ref.', '.$this->fk_docdet.') were already recorded';
|
||||||
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_WARNING);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$result = - 5;
|
$result = - 5;
|
||||||
@ -1012,7 +1018,7 @@ class BookKeeping extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Delete bookkepping by importkey
|
* Delete bookkepping by importkey
|
||||||
*
|
*
|
||||||
* @param string $importkey Import key
|
* @param string $importkey Import key
|
||||||
* @return int Result
|
* @return int Result
|
||||||
*/
|
*/
|
||||||
function deleteByImportkey($importkey) {
|
function deleteByImportkey($importkey) {
|
||||||
@ -1027,10 +1033,7 @@ class BookKeeping extends CommonObject
|
|||||||
|
|
||||||
if (! $resql) {
|
if (! $resql) {
|
||||||
$this->errors[] = "Error " . $this->db->lasterror();
|
$this->errors[] = "Error " . $this->db->lasterror();
|
||||||
foreach ( $this->errors as $errmsg ) {
|
dol_syslog(get_class($this)."::delete Error " . $this->db->lasterror(), LOG_ERR);
|
||||||
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
|
|
||||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
|
||||||
}
|
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return - 1;
|
return - 1;
|
||||||
}
|
}
|
||||||
@ -1042,17 +1045,24 @@ class BookKeeping extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Delete bookkepping by year
|
* Delete bookkepping by year
|
||||||
*
|
*
|
||||||
* @param string $delyear year to delete
|
* @param string $delyear Year to delete
|
||||||
* @return int Result
|
* @param string $journal Journal to delete
|
||||||
|
* @return int Result
|
||||||
*/
|
*/
|
||||||
function deleteByYear($delyear) {
|
function deleteByYearAndJournal($delyear='', $journal='') {
|
||||||
|
if (empty($delyear) && empty($journal))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// first check if line not yet in bookkeeping
|
// first check if line not yet in bookkeeping
|
||||||
$sql = "DELETE";
|
$sql = "DELETE";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
$sql .= " WHERE YEAR(doc_date) = " . $delyear;
|
$sql.= " WHERE 1 = 1";
|
||||||
|
if ($delyear) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between
|
||||||
|
if ($journal) $sql.= " AND code_journal = ".$journal;
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if (! $resql) {
|
if (! $resql) {
|
||||||
@ -1062,7 +1072,7 @@ class BookKeeping extends CommonObject
|
|||||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||||
}
|
}
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return - 1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|||||||
@ -42,6 +42,7 @@ require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
|
||||||
@ -73,9 +74,13 @@ $now = dol_now();
|
|||||||
if ($user->societe_id > 0 && empty($id_bank_account))
|
if ($user->societe_id > 0 && empty($id_bank_account))
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
$year_current = strftime("%Y", dol_now());
|
$year_current = strftime("%Y", dol_now());
|
||||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||||
$pastmonthyear = $year_current;
|
$pastmonthyear = $year_current;
|
||||||
@ -96,8 +101,9 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
|||||||
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
|
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
|
||||||
$idpays = $p[0];
|
$idpays = $p[0];
|
||||||
|
|
||||||
$sql = "SELECT b.rowid , b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, soc.code_compta, ba.courant,";
|
$sql = "SELECT b.rowid , b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, soc.code_compta,";
|
||||||
$sql .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, ba.account_number, bu1.type as typeop";
|
$sql .= " ba.courant, ba.ref as baref, ba.account_number,";
|
||||||
|
$sql .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
|
||||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
|
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
|
||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
|
||||||
@ -138,28 +144,33 @@ if ($result) {
|
|||||||
$account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : $langs->trans("CodeNotDef"));
|
$account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : $langs->trans("CodeNotDef"));
|
||||||
$account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : $langs->trans("CodeNotDef"));
|
$account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : $langs->trans("CodeNotDef"));
|
||||||
|
|
||||||
|
$tabcompany = array();
|
||||||
$tabpay = array ();
|
$tabpay = array ();
|
||||||
$tabbq = array ();
|
$tabbq = array ();
|
||||||
$tabtp = array ();
|
$tabtp = array ();
|
||||||
$tabtype = array ();
|
$tabtype = array ();
|
||||||
|
|
||||||
|
// Loop on each line into bank account. For each line, we should get:
|
||||||
|
// on line tabpay = line into bank
|
||||||
|
// one line for bank jounral = tabbq
|
||||||
|
// one line for thirdparty journal = tabtp
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ( $i < $num ) {
|
while ( $i < $num ) {
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
|
|
||||||
$tabcompany[$obj->rowid] = array (
|
// Set accountancy code (for bank and thirdparty)
|
||||||
'id' => $obj->socid,
|
|
||||||
'name' => $obj->name,
|
|
||||||
'code_client' => $obj->code_compta
|
|
||||||
);
|
|
||||||
|
|
||||||
// Controls
|
|
||||||
$compta_bank = $obj->account_number;
|
$compta_bank = $obj->account_number;
|
||||||
if ($obj->label == '(SupplierInvoicePayment)')
|
if ($obj->label == '(SupplierInvoicePayment)')
|
||||||
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier);
|
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier);
|
||||||
if ($obj->label == '(CustomerInvoicePayment)')
|
if ($obj->label == '(CustomerInvoicePayment)')
|
||||||
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer);
|
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer);
|
||||||
|
|
||||||
|
$tabcompany[$obj->rowid] = array (
|
||||||
|
'id' => $obj->socid,
|
||||||
|
'name' => $obj->name,
|
||||||
|
'code_compta' => $compta_soc,
|
||||||
|
);
|
||||||
|
|
||||||
// Variable bookkeeping
|
// Variable bookkeeping
|
||||||
$tabpay[$obj->rowid]["date"] = $obj->do;
|
$tabpay[$obj->rowid]["date"] = $obj->do;
|
||||||
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type;
|
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type;
|
||||||
@ -174,16 +185,24 @@ if ($result) {
|
|||||||
|
|
||||||
// get_url may return -1 which is not traversable
|
// get_url may return -1 which is not traversable
|
||||||
if (is_array($links)) {
|
if (is_array($links)) {
|
||||||
|
// Now loop on each link of record in bank.
|
||||||
foreach ( $links as $key => $val ) {
|
foreach ( $links as $key => $val ) {
|
||||||
$tabtype[$obj->rowid] = $links[$key]['type'];
|
|
||||||
|
if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat'))) // So we excluded 'company' here
|
||||||
|
{
|
||||||
|
// We save tabtype for a future use, to remember what kind of payment it is
|
||||||
|
$tabtype[$obj->rowid] = $links[$key]['type'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($links[$key]['type'] == 'payment') {
|
if ($links[$key]['type'] == 'payment') {
|
||||||
$paymentstatic->id = $links[$key]['url_id'];
|
$paymentstatic->id = $links[$key]['url_id'];
|
||||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
|
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
|
||||||
|
$tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id;
|
||||||
} else if ($links[$key]['type'] == 'payment_supplier') {
|
} else if ($links[$key]['type'] == 'payment_supplier') {
|
||||||
$paymentsupplierstatic->id = $links[$key]['url_id'];
|
$paymentsupplierstatic->id = $links[$key]['url_id'];
|
||||||
$paymentsupplierstatic->ref = $links[$key]['url_id'];
|
$paymentsupplierstatic->ref = $links[$key]['url_id'];
|
||||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
|
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
|
||||||
|
$tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id;
|
||||||
} else if ($links[$key]['type'] == 'company') {
|
} else if ($links[$key]['type'] == 'company') {
|
||||||
$societestatic->id = $links[$key]['url_id'];
|
$societestatic->id = $links[$key]['url_id'];
|
||||||
$societestatic->name = $links[$key]['label'];
|
$societestatic->name = $links[$key]['label'];
|
||||||
@ -248,6 +267,26 @@ if ($result) {
|
|||||||
|
|
||||||
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
|
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
|
||||||
|
|
||||||
|
|
||||||
|
// Check account number is ok
|
||||||
|
/*if ($action == 'writebookkeeping') // Make test now in such a case
|
||||||
|
{
|
||||||
|
reset($tabbq[$obj->rowid]);
|
||||||
|
$first_key_tabbq = key($tabbq[$obj->rowid]);
|
||||||
|
if (empty($first_key_tabbq))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
setEventMessages($langs->trans('ErrorAccountancyCodeOnBankAccountNotDefined', $obj->baref), null, 'errors');
|
||||||
|
}
|
||||||
|
reset($tabtp[$obj->rowid]);
|
||||||
|
$first_key_tabtp = key($tabtp[$obj->rowid]);
|
||||||
|
if (empty($first_key_tabtp))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
setEventMessages($langs->trans('ErrorAccountancyCodeOnThirdPartyNotDefined'), null, 'errors');
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
|
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
|
||||||
|
|
||||||
$i ++;
|
$i ++;
|
||||||
@ -256,150 +295,182 @@ if ($result) {
|
|||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
var_dump($tabpay);
|
||||||
|
var_dump($tabbq);
|
||||||
|
var_dump($tabtp);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Write bookkeeping
|
// Write bookkeeping
|
||||||
if ($action == 'writebookkeeping') {
|
if (! $error && $action == 'writebookkeeping') {
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
foreach ( $tabpay as $key => $val ) {
|
foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank
|
||||||
|
|
||||||
|
$errorforline = 0;
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
// Bank
|
// Bank
|
||||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
if (! $errorforline)
|
||||||
$bookkeeping = new BookKeeping($db);
|
{
|
||||||
$bookkeeping->doc_date = $val["date"];
|
// Line into bank account
|
||||||
$bookkeeping->doc_ref = $val["ref"];
|
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||||
$bookkeeping->doc_type = 'bank';
|
$bookkeeping = new BookKeeping($db);
|
||||||
$bookkeeping->fk_doc = $key;
|
$bookkeeping->doc_date = $val["date"];
|
||||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
$bookkeeping->doc_ref = $val["ref"];
|
||||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
|
$bookkeeping->doc_type = 'bank';
|
||||||
$bookkeeping->numero_compte = $k;
|
$bookkeeping->fk_doc = $key;
|
||||||
$bookkeeping->label_compte = $compte->label;
|
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
$bookkeeping->numero_compte = $k;
|
||||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
$bookkeeping->label_compte = $compte->label;
|
||||||
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
|
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||||
$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
|
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||||
$bookkeeping->code_journal = $journal;
|
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
|
||||||
$bookkeeping->date_create = $now;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
if ($tabtype[$key] == 'payment') {
|
$bookkeeping->date_create = $now;
|
||||||
|
|
||||||
$sqlmid = 'SELECT fac.facnumber';
|
if ($tabtype[$key] == 'payment') {
|
||||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
|
||||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
|
||||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
$sqlmid = 'SELECT fac.facnumber';
|
||||||
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
||||||
$resultmid = $db->query($sqlmid);
|
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
||||||
if ($resultmid) {
|
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
||||||
$objmid = $db->fetch_object($resultmid);
|
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
$resultmid = $db->query($sqlmid);
|
||||||
}
|
if ($resultmid) {
|
||||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
$objmid = $db->fetch_object($resultmid);
|
||||||
|
$bookkeeping->doc_ref = $objmid->facnumber; // Ref of invoice
|
||||||
$sqlmid = 'SELECT facf.ref_supplier,facf.ref';
|
}
|
||||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
|
||||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
|
||||||
$sqlmid .= " WHERE payf.fk_bank=" . $key;
|
$sqlmid = 'SELECT facf.ref_supplier, facf.ref';
|
||||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||||
$resultmid = $db->query($sqlmid);
|
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||||
if ($resultmid) {
|
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||||
$objmid = $db->fetch_object($resultmid);
|
$sqlmid .= " WHERE payf.fk_bank=" . $key;
|
||||||
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')';
|
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||||
}
|
$resultmid = $db->query($sqlmid);
|
||||||
}
|
if ($resultmid) {
|
||||||
|
$objmid = $db->fetch_object($resultmid);
|
||||||
$result = $bookkeeping->create($user);
|
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; // Ref on invoice
|
||||||
if ($result < 0) {
|
}
|
||||||
$error ++;
|
}
|
||||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
|
||||||
}
|
$result = $bookkeeping->create($user);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
$errorforline++;
|
||||||
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Third party
|
// Third party
|
||||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
if (! $errorforline)
|
||||||
$bookkeeping = new BookKeeping($db);
|
{
|
||||||
$bookkeeping->doc_date = $val["date"];
|
// Line into thirdparty account
|
||||||
$bookkeeping->doc_ref = $val["ref"];
|
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||||
$bookkeeping->doc_type = 'bank';
|
$bookkeeping = new BookKeeping($db);
|
||||||
$bookkeeping->fk_doc = $key;
|
$bookkeeping->doc_date = $val["date"];
|
||||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
$bookkeeping->doc_ref = $val["ref"];
|
||||||
$bookkeeping->label_compte = $tabcompany[$key]['name'];
|
$bookkeeping->doc_type = 'bank';
|
||||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
$bookkeeping->fk_doc = $key;
|
||||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
$bookkeeping->label_compte = $tabcompany[$key]['name'];
|
||||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||||
$bookkeeping->code_journal = $journal;
|
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||||
$bookkeeping->date_create = $now;
|
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||||
|
$bookkeeping->code_journal = $journal;
|
||||||
if ($tabtype[$key] == 'sc') {
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
$bookkeeping->code_tiers = '';
|
$bookkeeping->date_create = $now;
|
||||||
$bookkeeping->numero_compte = $k;
|
|
||||||
} else if ($tabtype[$key] == 'payment') {
|
if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
|
||||||
|
$bookkeeping->code_tiers = '';
|
||||||
$sqlmid = 'SELECT fac.facnumber';
|
$bookkeeping->numero_compte = $k;
|
||||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
} else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
|
||||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
$sqlmid = 'SELECT fac.facnumber';
|
||||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||||
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
||||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
||||||
$resultmid = $db->query($sqlmid);
|
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
||||||
if ($resultmid) {
|
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||||
$objmid = $db->fetch_object($resultmid);
|
$resultmid = $db->query($sqlmid);
|
||||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
if ($resultmid) {
|
||||||
}
|
$objmid = $db->fetch_object($resultmid);
|
||||||
$bookkeeping->code_tiers = $k;
|
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
}
|
||||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
// FIXME Should be
|
||||||
|
//$bookkeeping->code_tiers = $k;
|
||||||
$sqlmid = 'SELECT facf.ref_supplier,facf.ref';
|
//$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
|
||||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
$bookkeeping->numero_compte = $k;
|
||||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
} else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
|
||||||
$sqlmid .= " WHERE payf.fk_bank=" . $key;
|
|
||||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
$sqlmid = 'SELECT facf.ref_supplier,facf.ref';
|
||||||
$resultmid = $db->query($sqlmid);
|
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||||
if ($resultmid) {
|
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||||
$objmid = $db->fetch_object($resultmid);
|
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||||
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')';
|
$sqlmid .= " WHERE payf.fk_bank=" . $key;
|
||||||
}
|
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||||
$bookkeeping->code_tiers = $k;
|
$resultmid = $db->query($sqlmid);
|
||||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
if ($resultmid) {
|
||||||
} else if ($tabtype[$key] == 'company') {
|
$objmid = $db->fetch_object($resultmid);
|
||||||
|
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')';
|
||||||
$sqlmid = 'SELECT fac.facnumber';
|
}
|
||||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
// FIXME Should be
|
||||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
//$bookkeeping->code_tiers = $k;
|
||||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
//$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||||
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
|
||||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
$bookkeeping->numero_compte = $k;
|
||||||
$resultmid = $db->query($sqlmid);
|
} else {
|
||||||
if ($resultmid) {
|
// FIXME Should be a temporary account
|
||||||
$objmid = $db->fetch_object($resultmid);
|
$bookkeeping->doc_ref = $k;
|
||||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
//$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||||
}
|
$bookkeeping->numero_compte = 'CodeNotDef';
|
||||||
$bookkeeping->code_tiers = $k;
|
}
|
||||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
|
||||||
} else {
|
$result = $bookkeeping->create($user);
|
||||||
|
if ($result < 0) {
|
||||||
$bookkeeping->doc_ref = $k;
|
$error++;
|
||||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
$errorforline++;
|
||||||
}
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
|
}
|
||||||
$result = $bookkeeping->create($user);
|
}
|
||||||
if ($result < 0) {
|
}
|
||||||
$error ++;
|
|
||||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
if (! $errorforline)
|
||||||
}
|
{
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error)) {
|
if (empty($error)) {
|
||||||
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
||||||
|
}
|
||||||
|
elseif (count($tabpay) == $error)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("NoRecordSaved"), null, 'warnings');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Export
|
// Export
|
||||||
@ -437,7 +508,6 @@ if ($action == 'export_csv') {
|
|||||||
|
|
||||||
$companystatic->id = $tabcompany[$key]['id'];
|
$companystatic->id = $tabcompany[$key]['id'];
|
||||||
$companystatic->name = $tabcompany[$key]['name'];
|
$companystatic->name = $tabcompany[$key]['name'];
|
||||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
|
||||||
|
|
||||||
// Bank
|
// Bank
|
||||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||||
@ -564,7 +634,9 @@ if ($action == 'export_csv') {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
$invoicestatic = new Facture($db);
|
||||||
|
$invoicesupplierstatic = new FactureFournisseur($db);
|
||||||
|
|
||||||
llxHeader('', $langs->trans("FinanceJournal"));
|
llxHeader('', $langs->trans("FinanceJournal"));
|
||||||
|
|
||||||
$nom = $langs->trans("FinanceJournal") . ' - ' . $bank_code_journal->getNomUrl(1);
|
$nom = $langs->trans("FinanceJournal") . ' - ' . $bank_code_journal->getNomUrl(1);
|
||||||
@ -609,7 +681,7 @@ else {
|
|||||||
print "<tr class=\"liste_titre\">";
|
print "<tr class=\"liste_titre\">";
|
||||||
print "<td>" . $langs->trans("Date") . "</td>";
|
print "<td>" . $langs->trans("Date") . "</td>";
|
||||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||||
print "<td>" . $langs->trans("Account") . "</td>";
|
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||||
print "<td>" . $langs->trans("Type") . "</td>";
|
print "<td>" . $langs->trans("Type") . "</td>";
|
||||||
print "<td>" . $langs->trans("PaymentMode") . "</td>";
|
print "<td>" . $langs->trans("PaymentMode") . "</td>";
|
||||||
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
|
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||||
@ -618,9 +690,9 @@ else {
|
|||||||
$var = true;
|
$var = true;
|
||||||
$r = '';
|
$r = '';
|
||||||
|
|
||||||
foreach ( $tabpay as $key => $val ) {
|
foreach ( $tabpay as $key => $val ) { // $key is rowid in llx_bank
|
||||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||||
|
|
||||||
$reflabel = $val["ref"];
|
$reflabel = $val["ref"];
|
||||||
if ($reflabel == '(SupplierInvoicePayment)') {
|
if ($reflabel == '(SupplierInvoicePayment)') {
|
||||||
$reflabel = $langs->trans('Supplier');
|
$reflabel = $langs->trans('Supplier');
|
||||||
@ -637,10 +709,45 @@ else {
|
|||||||
if ($reflabel == '(SubscriptionPayment)') {
|
if ($reflabel == '(SubscriptionPayment)') {
|
||||||
$reflabel = $langs->trans('SubscriptionPayment');
|
$reflabel = $langs->trans('SubscriptionPayment');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ref=$reflabel;
|
||||||
|
if ($tabtype[$key] == 'payment')
|
||||||
|
{
|
||||||
|
$sqlmid = 'SELECT payfac.fk_facture as id';
|
||||||
|
$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac";
|
||||||
|
$sqlmid .= " WHERE payfac.fk_paiement=" . $val["paymentid"];
|
||||||
|
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||||
|
$resultmid = $db->query($sqlmid);
|
||||||
|
if ($resultmid) {
|
||||||
|
$objmid = $db->fetch_object($resultmid);
|
||||||
|
$invoicestatic->fetch($objmid->id);
|
||||||
|
$ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1);
|
||||||
|
}
|
||||||
|
else dol_print_error($db);
|
||||||
|
}
|
||||||
|
elseif ($tabtype[$key] == 'payment_supplier')
|
||||||
|
{
|
||||||
|
$sqlmid = 'SELECT payfac.fk_facturefourn as id';
|
||||||
|
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac";
|
||||||
|
$sqlmid .= " WHERE payfac.fk_paiementfourn=" . $val["paymentsupplierid"];
|
||||||
|
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||||
|
$resultmid = $db->query($sqlmid);
|
||||||
|
if ($resultmid) {
|
||||||
|
$objmid = $db->fetch_object($resultmid);
|
||||||
|
$invoicesupplierstatic->fetch($objmid->id);
|
||||||
|
$ref=$langs->trans("SupplierInvoice").' '.$invoicesupplierstatic->getNomUrl(1);
|
||||||
|
}
|
||||||
|
else dol_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*$invoicestatic->id = $key;
|
||||||
|
$invoicestatic->ref = $val["ref"];
|
||||||
|
$invoicestatic->type = $val["type"];*/
|
||||||
// Bank
|
// Bank
|
||||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||||
print "<tr " . $bc[$var] . ">";
|
|
||||||
|
print "<tr " . $bc[$var] . ">";
|
||||||
print "<td>" . $date . "</td>";
|
print "<td>" . $date . "</td>";
|
||||||
print "<td>" . $ref . "</td>";
|
print "<td>" . $ref . "</td>";
|
||||||
print "<td>" . length_accountg($k) . "</td>";
|
print "<td>" . length_accountg($k) . "</td>";
|
||||||
@ -690,4 +797,5 @@ else {
|
|||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -168,6 +168,10 @@ if ($action == 'writebookkeeping') {
|
|||||||
|
|
||||||
foreach ($tabfac as $key => $val)
|
foreach ($tabfac as $key => $val)
|
||||||
{
|
{
|
||||||
|
$errorforline = 0;
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$companystatic = new Societe($db);
|
$companystatic = new Societe($db);
|
||||||
$invoicestatic = new FactureFournisseur($db);
|
$invoicestatic = new FactureFournisseur($db);
|
||||||
|
|
||||||
@ -203,8 +207,9 @@ if ($action == 'writebookkeeping') {
|
|||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error++;
|
||||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
$errorforline++;
|
||||||
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +240,8 @@ if ($action == 'writebookkeeping') {
|
|||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error++;
|
||||||
|
$errorforline++;
|
||||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,15 +272,36 @@ if ($action == 'writebookkeeping') {
|
|||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error++;
|
||||||
|
$errorforline++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (! $errorforline)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error)) {
|
if (empty($error)) {
|
||||||
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
||||||
|
}
|
||||||
|
elseif (count($tabpay) == $error)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("NoRecordSaved"), null, 'warnings');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,7 +485,7 @@ if ($action == 'export_csv') {
|
|||||||
// /print "<td>".$langs->trans("JournalNum")."</td>";
|
// /print "<td>".$langs->trans("JournalNum")."</td>";
|
||||||
print "<td>" . $langs->trans("Date") . "</td>";
|
print "<td>" . $langs->trans("Date") . "</td>";
|
||||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||||
print "<td>" . $langs->trans("Account") . "</td>";
|
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||||
print "<t><td>" . $langs->trans("Type") . "</td><td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
|
print "<t><td>" . $langs->trans("Type") . "</td><td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
|||||||
@ -198,7 +198,11 @@ if ($action == 'writebookkeeping') {
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
foreach ( $tabfac as $key => $val ) {
|
foreach ( $tabfac as $key => $val ) {
|
||||||
|
|
||||||
|
$errorforline = 0;
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$companystatic = new Societe($db);
|
$companystatic = new Societe($db);
|
||||||
$invoicestatic = new Facture($db);
|
$invoicestatic = new Facture($db);
|
||||||
|
|
||||||
@ -230,7 +234,8 @@ if ($action == 'writebookkeeping') {
|
|||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error++;
|
||||||
|
$errorforline++;
|
||||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,7 +265,8 @@ if ($action == 'writebookkeeping') {
|
|||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error++;
|
||||||
|
$errorforline++;
|
||||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,15 +296,35 @@ if ($action == 'writebookkeeping') {
|
|||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error++;
|
||||||
|
$errorforline++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (! $errorforline)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error)) {
|
if (empty($error)) {
|
||||||
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
||||||
|
}
|
||||||
|
elseif (count($tabpay) == $error)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("NoRecordSaved"), null, 'warnings');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,7 +501,7 @@ if ($action == 'export_csv') {
|
|||||||
print "<tr class=\"liste_titre\">";
|
print "<tr class=\"liste_titre\">";
|
||||||
print "<td>" . $langs->trans("Date") . "</td>";
|
print "<td>" . $langs->trans("Date") . "</td>";
|
||||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||||
print "<td>" . $langs->trans("Account") . "</td>";
|
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||||
print "<td>" . $langs->trans("Type") . "</td>";
|
print "<td>" . $langs->trans("Type") . "</td>";
|
||||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||||
|
|||||||
@ -1183,14 +1183,18 @@ class Account extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function getNomUrl($withpicto=0, $mode='')
|
function getNomUrl($withpicto=0, $mode='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$result='';
|
$result='';
|
||||||
$label = '<u>' . $langs->trans("ShowAccount") . '</u>';
|
$label = '<u>' . $langs->trans("ShowAccount") . '</u>';
|
||||||
if (! empty($this->label))
|
$label .= '<br><b>' . $langs->trans('BankAccount') . ':</b> ' . $this->label;
|
||||||
$label .= '<br><b>' . $langs->trans('Account') . ':</b> ' . $this->label;
|
$label .= '<br><b>' . $langs->trans('AccountNumber') . ':</b> ' . $this->number;
|
||||||
if (! empty($this->number))
|
if (! empty($conf->accounting->enabled))
|
||||||
$label .= '<br><b>' . $langs->trans('AccountNumber') . ':</b> ' . $this->number;
|
{
|
||||||
|
$langs->load("accountancy");
|
||||||
|
$label .= '<br><b>' . $langs->trans('AccountAccounting') . ':</b> ' . $this->account_number;
|
||||||
|
$label .= '<br><b>' . $langs->trans('AccountancyJournal') . ':</b> ' . $this->accountancy_journal;
|
||||||
|
}
|
||||||
$linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
$linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||||
|
|
||||||
if (empty($mode))
|
if (empty($mode))
|
||||||
|
|||||||
@ -121,6 +121,10 @@ create table llx_product_warehouse_properties
|
|||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|
||||||
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN entity integer DEFAULT 1 NOT NULL;
|
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN entity integer DEFAULT 1 NOT NULL;
|
||||||
|
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN fk_user_modif integer;
|
||||||
|
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_creation datetime;
|
||||||
|
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN tms timestamp;
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE llx_accounting_account ADD INDEX uk_accounting_account (account_number, entity);
|
ALTER TABLE llx_accounting_account ADD INDEX uk_accounting_account (account_number, entity);
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,10 @@ CREATE TABLE llx_accounting_bookkeeping
|
|||||||
credit double NOT NULL,
|
credit double NOT NULL,
|
||||||
montant double NOT NULL,
|
montant double NOT NULL,
|
||||||
sens varchar(1) DEFAULT NULL,
|
sens varchar(1) DEFAULT NULL,
|
||||||
fk_user_author integer NOT NULL,
|
fk_user_author integer NOT NULL, -- user creating
|
||||||
|
fk_user_modif integer, -- user making last change
|
||||||
|
date_creation datetime, -- date de creation
|
||||||
|
tms timestamp, -- date last modification
|
||||||
import_key varchar(14),
|
import_key varchar(14),
|
||||||
code_journal varchar(10) DEFAULT NULL,
|
code_journal varchar(10) DEFAULT NULL,
|
||||||
piece_num integer NOT NULL,
|
piece_num integer NOT NULL,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user