From 74795b87e543cf566b9e277d60ce23f871d7c7e8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 31 Jan 2021 12:46:54 +0100 Subject: [PATCH 1/4] FIX avoid undefined url and missing token --- htdocs/core/js/lib_head.js.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 382f12840d7..7d2888e870e 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -529,6 +529,7 @@ function hideMessage(fieldId,message) { * @param string token Token */ function setConstant(url, code, input, entity, strict, forcereload, userid, token) { + var $url = url; /* avoid undefined url */ $.post( url, { action: "set", name: code, @@ -573,11 +574,12 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke $.each(data, function(key, value) { $("#set_" + key).hide(); $("#del_" + key).show(); - $.get( url, { + $.post( $url, { action: "set", name: key, value: value, - entity: entity + entity: entity, + token: token }); }); } @@ -602,6 +604,7 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke * @param string token Token */ function delConstant(url, code, input, entity, strict, forcereload, userid, token) { + var $url = url; /* avoid undefined url */ $.post( url, { action: "del", name: code, @@ -643,10 +646,11 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke $.each(data, function(key, value) { $("#del_" + value).hide(); $("#set_" + value).show(); - $.get( url, { + $.get( $url, { action: "del", name: value, - entity: entity + entity: entity, + token: token }); }); } From 5217a38359ebc0498ddfac53f74778b8106823e5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 31 Jan 2021 12:51:13 +0100 Subject: [PATCH 2/4] FIX use post instead get --- htdocs/core/js/lib_head.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 7d2888e870e..151c15f3f48 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -646,7 +646,7 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke $.each(data, function(key, value) { $("#del_" + value).hide(); $("#set_" + value).show(); - $.get( $url, { + $.post( $url, { action: "del", name: value, entity: entity, From 0a3d1ab92ef1016d36c70a45fbc37f3c0a01f32e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 23 Feb 2021 16:56:45 +0100 Subject: [PATCH 3/4] FIX use var "saved_url" instead global var "$url" --- htdocs/core/js/lib_head.js.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 83a161e35d6..c0d4f0f3829 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -530,7 +530,7 @@ function hideMessage(fieldId,message) { * @param string token Token */ function setConstant(url, code, input, entity, strict, forcereload, userid, token) { - var $url = url; /* avoid undefined url */ + var saved_url = url; /* avoid undefined url */ $.post( url, { action: "set", name: code, @@ -575,7 +575,7 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke $.each(data, function(key, value) { $("#set_" + key).hide(); $("#del_" + key).show(); - $.post( url, { + $.post( saved_url, { action: "set", name: key, value: value, @@ -605,7 +605,7 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke * @param string token Token */ function delConstant(url, code, input, entity, strict, forcereload, userid, token) { - var $url = url; /* avoid undefined url */ + var saved_url = url; /* avoid undefined url */ $.post( url, { action: "del", name: code, @@ -647,7 +647,7 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke $.each(data, function(key, value) { $("#del_" + value).hide(); $("#set_" + value).show(); - $.post( url, { + $.post( saved_url, { action: "del", name: value, entity: entity, From d5566dbf8f4d5d71fe655f923506fbb550941f11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Feb 2021 19:18:03 +0100 Subject: [PATCH 4/4] FIX #16431 --- .../bookkeeping/balancebymonth.php | 136 ------------------ .../thirdparty_lettering_customer.php | 2 +- .../thirdparty_lettering_supplier.php | 2 +- .../class/accountancyexport.class.php | 64 ++++----- .../accountancy/class/bookkeeping.class.php | 26 ++-- htdocs/core/modules/modAccounting.class.php | 6 +- .../install/mysql/migration/12.0.0-13.0.0.sql | 5 + .../tables/llx_accounting_bookkeeping.sql | 2 +- 8 files changed, 61 insertions(+), 182 deletions(-) delete mode 100644 htdocs/accountancy/bookkeeping/balancebymonth.php diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php deleted file mode 100644 index f27d535f57c..00000000000 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ /dev/null @@ -1,136 +0,0 @@ - - * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2015 Jean-François Ferry - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * \file htdocs/accountancy/bookkeeping/balancebymonth.php - * \ingroup Accountancy (Double entries) - * \brief Balance by month - */ -require '../../main.inc.php'; - -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("bills", "compta", "accountancy", "other")); - -// Filter -$year = GETPOST("year", 'int'); -if ($year == 0) { - $year_current = strftime("%Y", time()); - $year_start = $year_current; -} else { - $year_current = $year; - $year_start = $year; -} - - -/* - * View - */ - -llxHeader('', $langs->trans("Bookkeeping")); - -$textprevyear = ''.img_previous().''; -$textnextyear = ' '.img_next().''; - -print load_fiche_titre($langs->trans("AccountBalanceByMonth").' '.$textprevyear.' '.$langs->trans("Year").' '.$year_start.' '.$textnextyear); - -$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd"; -$sql .= " , ".MAIN_DB_PREFIX."facture as f"; -$sql .= " WHERE fd.fk_code_ventilation = 0"; -$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;"; - -dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql); -$result = $db->query($sql); -if ($result) { - $row = $db->fetch_row($result); - $nbfac = $row[0]; - - $db->free($result); -} - -$y = $year_current; - -print ''; -print ''; -print ''; -for ($i = 1; $i <= 12; $i++) -{ - print ''; -} -print ''; -print ''; - -$sql = "SELECT bk.numero_compte AS 'compte',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=1,bk.montant,0)),2) AS 'Janvier',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=2,bk.montant,0)),2) AS 'Fevrier',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=3,bk.montant,0)),2) AS 'Mars',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=4,bk.montant,0)),2) AS 'Avril',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=5,bk.montant,0)),2) AS 'Mai',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=6,bk.montant,0)),2) AS 'Juin',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=7,bk.montant,0)),2) AS 'Juillet',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=8,bk.montant,0)),2) AS 'Aout',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=9,bk.montant,0)),2) AS 'Septembre',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',"; -$sql .= " ROUND(SUM(bk.montant),2) as 'Total'"; -$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; -$sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; -$sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; -$sql .= " GROUP BY bk.numero_compte"; - -$resql = $db->query($sql); -if ($resql) { - $i = 0; - $num = $db->num_rows($resql); - - while ($i < $num) { - $row = $db->fetch_row($resql); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $i++; - } - $db->free($resql); -} else { - print $db->lasterror(); -} -print "
'.$langs->trans("Label").''.$langs->trans("MonthShort".sprintf("%02s", $i)).''.$langs->trans("Total").'
'.length_accountg($row[0]).''.price($row[1]).''.price($row[2]).''.price($row[3]).''.price($row[4]).''.price($row[5]).''.price($row[6]).''.price($row[7]).''.price($row[8]).''.price($row[9]).''.price($row[10]).''.price($row[11]).''.price($row[12]).''.price($row[13]).'
\n"; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index e831e21f814..8635946ad38 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -145,7 +145,7 @@ print dol_get_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; -$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code "; +$sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)."' )"; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index b5620f3ec25..1558fe9b288 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -144,7 +144,7 @@ print dol_get_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; -$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated "; +$sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code, bk.date_validated "; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta_fournisseur)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)."' )"; if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 3e8aab64479..25bea39f22f 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -359,7 +359,7 @@ class AccountancyExport print length_accountg($line->numero_compte).$separator; print length_accounta($line->subledger_account).$separator; print $line->sens.$separator; - print price2fec(abs($line->montant)).$separator; + print price2fec(abs($line->debit - $line->credit)).$separator; print dol_string_unaccent($line->label_operation).$separator; print dol_string_unaccent($line->doc_ref); print $end_line; @@ -387,11 +387,11 @@ class AccountancyExport print $line->label_operation.$separator; print $date.$separator; if ($line->sens == 'D') { - print price($line->montant).$separator; + print price($line->debit).$separator; print ''.$separator; } elseif ($line->sens == 'C') { print ''.$separator; - print price($line->montant).$separator; + print price($line->credit).$separator; } print $line->doc_ref.$separator; print $line->label_operation.$separator; @@ -492,7 +492,7 @@ class AccountancyExport $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25); - $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); + $Tab['montant'] = str_pad(abs($data->debit - $data->credit), 13, ' ', STR_PAD_LEFT); $Tab['type_montant'] = str_pad($data->sens, 1); $Tab['vide'] = str_repeat(' ', 18); $Tab['intitule_compte'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 34), 34); @@ -539,6 +539,7 @@ class AccountancyExport $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20); // Credit invoice - invert sens + /* if ($data->montant < 0) { if ($data->sens == 'C') { $Tab['sens'] = 'D'; @@ -549,10 +550,12 @@ class AccountancyExport } else { $Tab['sens'] = $data->sens; // C or D $Tab['signe_montant'] = '+'; - } - + }*/ + $Tab['sens'] = $data->sens; // C or D + $Tab['signe_montant'] = '+'; + // The amount must be in centimes without decimal points. - $Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); + $Tab['montant'] = str_pad(abs(($data->debit - $abs->credit) * 100), 12, '0', STR_PAD_LEFT); $Tab['contrepartie'] = str_repeat(' ', 8); // Force date format : %d%m%y @@ -637,13 +640,13 @@ class AccountancyExport $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0'); if ($data->sens == 'D') { - $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + $Tab['montant_debit'] = str_pad(number_format($data->debit, 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); } else { $Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); - $Tab['montant_crebit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + $Tab['montant_crebit'] = str_pad(number_format($data->credit), 2, ',', ''), 13, ' ', STR_PAD_LEFT); } $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 30), 30); @@ -704,7 +707,7 @@ class AccountancyExport //print substr(length_accountg($line->numero_compte), 0, 2) . $separator; print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator; print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator; - print price2num(abs($line->montant)).$separator; + print price2num(abs($line->debit - $line->credit)).$separator; print $line->sens.$separator; print $date.$separator; //print 'EUR'; @@ -744,7 +747,7 @@ class AccountancyExport print self::toAnsi($line->doc_ref).$separator; print price($line->debit).$separator; print price($line->credit).$separator; - print price($line->montant).$separator; + print price(abs($line->debit - $line->credit)).$separator; print $line->sens.$separator; print $line->lettering_code.$separator; print $line->code_journal; @@ -807,7 +810,7 @@ class AccountancyExport $tab[] = length_accounta($line->subledger_account); $tab[] = price2num($line->debit); $tab[] = price2num($line->credit); - $tab[] = price2num($line->montant); + $tab[] = price2num($line->debit - $line->credit); $tab[] = $line->code_journal; print implode($separator, $tab).$this->end_line; @@ -849,7 +852,7 @@ class AccountancyExport foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d'); @@ -950,7 +953,7 @@ class AccountancyExport foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d'); @@ -1105,12 +1108,7 @@ class AccountancyExport // Code print '""'.$this->separator; // Netto - if ($line->montant >= 0) - { - print $line->montant.$this->separator; - } else { - print ($line->montant * -1).$this->separator; - } + print abs($line->debit - $line->credit).$this->separator; // Steuer print "0.00".$this->separator; // FW-Betrag @@ -1190,13 +1188,13 @@ class AccountancyExport print $date_lim_reglement.$separator; // CNPI if ($line->doc_type == 'supplier_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) > 0) { $nature_piece = 'AF'; } else { $nature_piece = 'FF'; } } elseif ($line->doc_type == 'customer_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) < 0) { $nature_piece = 'AC'; } else { $nature_piece = 'FC'; @@ -1220,7 +1218,7 @@ class AccountancyExport print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead // MONT - print price(abs($line->montant), 0, '', 1, 2, 2).$separator; + print price(abs($line->debit - $line->credit), 0, '', 1, 2, 2).$separator; // CODC print $line->sens.$separator; // CPTG @@ -1452,13 +1450,13 @@ class AccountancyExport print $date_lim_reglement.$separator; // CNPI if ($line->doc_type == 'supplier_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) > 0) { $nature_piece = 'AF'; } else { $nature_piece = 'FF'; } } elseif ($line->doc_type == 'customer_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) < 0) { $nature_piece = 'AC'; } else { $nature_piece = 'FC'; @@ -1482,7 +1480,7 @@ class AccountancyExport print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead // MONT - print price(abs($line->montant), 0, '', 1, 2).$separator; + print price(abs($line->debit - $line->credit), 0, '', 1, 2).$separator; // CODC print $line->sens.$separator; // CPTG @@ -1602,7 +1600,7 @@ class AccountancyExport print self::trunc($line->label_compte, 60).$separator; //Account label print self::trunc($line->doc_ref, 20).$separator; //Piece print self::trunc($line->label_operation, 60).$separator; //Operation label - print price(abs($line->montant)).$separator; //Amount + print price(abs($line->debit - $line->credit)).$separator; //Amount print $line->sens.$separator; //Direction print $separator; //Analytic print $separator; //Analytic @@ -1631,7 +1629,7 @@ class AccountancyExport $supplier_invoices_infos = array(); foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date = dol_print_date($line->doc_date, '%d/%m/%Y'); @@ -1699,8 +1697,8 @@ class AccountancyExport print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator; //Devise print 'EUR' . $this->separator; - //Montant - print price2num(abs($line->montant)) . $this->separator; + //Amount + print price2num(abs($line->debit - $line->credit)) . $this->separator; //Sens print $line->sens . $this->separator; //Code lettrage @@ -1726,14 +1724,14 @@ class AccountancyExport foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date = dol_print_date($line->doc_date, '%d%m%Y'); print $line->id . $this->separator; print $date . $this->separator; print substr($line->code_journal, 0, 4) . $this->separator; - if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { + if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { // TODO No hard code value print length_accountg($line->subledger_account) . $this->separator; } else { print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; @@ -1742,7 +1740,7 @@ class AccountancyExport //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; print '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"' . $this->separator; print '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"' . $this->separator; - print price2num($line->montant) . $this->separator; + print price2num(abs($line->debit - $line->credit)) . $this->separator; print $line->sens . $this->separator; print $date . $this->separator; print $this->separator; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0c7dd333901..957259c946c 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -135,6 +135,7 @@ class BookKeeping extends CommonObject /** * @var float FEC:Amount (Not necessary) + * @deprecated No more used */ public $amount; @@ -239,6 +240,9 @@ class BookKeeping extends CommonObject if (isset($this->montant)) { $this->montant = (float) $this->montant; } + if (isset($this->amount)) { + $this->amount = (float) $this->amount; + } if (isset($this->sens)) { $this->sens = trim($this->sens); } @@ -554,6 +558,9 @@ class BookKeeping extends CommonObject if (isset($this->montant)) { $this->montant = trim($this->montant); } + if (isset($this->amount)) { + $this->amount = trim($this->amount); + } if (isset($this->sens)) { $this->sens = trim($this->sens); } @@ -695,7 +702,7 @@ class BookKeeping extends CommonObject $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; - $sql .= " t.montant,"; + $sql .= " t.montant as amount,"; $sql .= " t.sens,"; $sql .= " t.fk_user_author,"; $sql .= " t.import_key,"; @@ -734,7 +741,8 @@ class BookKeeping extends CommonObject $this->label_operation = $obj->label_operation; $this->debit = $obj->debit; $this->credit = $obj->credit; - $this->montant = $obj->montant; + $this->montant = $obj->amount; + $this->amount = $obj->amount; $this->sens = $obj->sens; $this->fk_user_author = $obj->fk_user_author; $this->import_key = $obj->import_key; @@ -1197,8 +1205,8 @@ class BookKeeping extends CommonObject if (isset($this->credit)) { $this->credit = trim($this->credit); } - if (isset($this->montant)) { - $this->montant = trim($this->montant); + if (isset($this->amount)) { + $this->amount = trim($this->amount); } if (isset($this->sens)) { $this->sens = trim($this->sens); @@ -1641,7 +1649,7 @@ class BookKeeping extends CommonObject $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; - $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation"; + $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " WHERE piece_num = ".$piecenum; $sql .= " AND entity IN (".getEntity('accountancy').")"; @@ -1667,7 +1675,8 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->montant; + $line->montant = $obj->amount; + $line->amount = $obj->amount; $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->journal_label = $obj->journal_label; @@ -1700,7 +1709,7 @@ class BookKeeping extends CommonObject $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; - $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; + $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE entity IN (".getEntity('accountancy').")"; @@ -1730,7 +1739,8 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->montant; + $line->montant = $obj->amount; + $line->amount = $obj->amount; $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 811dd57544e..057122ec648 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -292,7 +292,8 @@ class modAccounting extends DolibarrModules 'b.subledger_label'=>'SubledgerAccountLabel', 'b.label_operation'=>'LabelOperation', 'b.debit'=>"Debit", - 'b.credit'=>"Credit" + 'b.credit'=>"Credit", + 'b.sens'=>'Direction' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit ); $this->import_fieldshidden_array[$r] = array('b.doc_type'=>'const-import_from_external', 'b.fk_doc'=>'const-0', 'b.fk_docdet'=>'const-0', 'b.fk_user_author'=>'user->id', 'b.date_creation'=>'const-'.dol_print_date(dol_now(), 'standard')); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r] = array('b.doc_date'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); @@ -309,7 +310,8 @@ class modAccounting extends DolibarrModules 'b.subledger_label'=>'', 'b.label_operation'=>"Sale of ABC", 'b.debit'=>"0", - 'b.credit'=>"100" + 'b.credit'=>"100", + 'b.sens'=>'C' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit ); // Chart of accounts diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index a19f8d34279..cc0bb4224b2 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -579,3 +579,8 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 6,'AC_EMAIL_IN','system','reception Email',NULL, 1, 4); + +-- VMYSQL4.3 ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant double(24,8) NULL; +-- VPGSQL8.2 ALTER TABLE llx_accounting_bookkeeping ALTER COLUMN montant DROP NOT NULL; + + diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index cf7897bf7a2..90de3fd02fe 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -35,7 +35,7 @@ CREATE TABLE llx_accounting_bookkeeping label_operation varchar(255), -- FEC:EcritureLib | label of the operation debit double(24,8) NOT NULL, -- FEC:Debit credit double(24,8) NOT NULL, -- FEC:Credit - montant double(24,8) NOT NULL, -- FEC:Montant (Not necessary) + montant double(24,8) NULL, -- FEC:Montant (Not necessary) sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary) multicurrency_amount double(24,8), -- FEC:Montantdevise multicurrency_code varchar(255), -- FEC:Idevise