[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 106/218: Currency : adapt for bank saldo
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 106/218: Currency : adapt for bank saldo |
Date: |
Thu, 12 Sep 2019 15:58:49 -0400 (EDT) |
sparkyx pushed a commit to branch entreprise
in repository noalyss.
commit dd8bc6750f9a89dd03897655b3610d4103ea9285
Author: Dany De Bontridder <address@hidden>
Date: Fri Nov 30 15:19:36 2018 +0100
Currency : adapt for bank saldo
---
include/class/acc_ledger_fin.class.php | 11 ++++++--
include/class/fiche.class.php | 48 ++++++++++++++++++++++++++++++++--
include/compta_fin_saldo.inc.php | 27 ++++++++++++++++++-
3 files changed, 81 insertions(+), 5 deletions(-)
diff --git a/include/class/acc_ledger_fin.class.php
b/include/class/acc_ledger_fin.class.php
index 30206fa..6d3c119 100644
--- a/include/class/acc_ledger_fin.class.php
+++ b/include/class/acc_ledger_fin.class.php
@@ -848,7 +848,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
$acc_operation->date = $e_date;
$sposte = $fBank->strAttribut(ATTR_DEF_ACCOUNT);
- // if 2 accounts
+ // if 2 accounts, use the first one if DEB
otherwise the second one
if (strpos($sposte, ',') != 0)
{
$array = explode(',', $sposte);
@@ -869,7 +869,14 @@ class Acc_Ledger_Fin extends Acc_Ledger
$acc_operation->type = 'd';
$acc_operation->periode = $tperiode;
$acc_operation->qcode = $e_bank_account;
- $acc_operation->insert_jrnx();
+ $j_id=$acc_operation->insert_jrnx();
+
+ $operation_currency = new
Operation_currency_SQL($this->db);
+ $operation_currency->oc_amount=$amount_input;
+ $operation_currency->oc_vat_amount=0;
+
$operation_currency->oc_price_unit=$amount_input;
+ $operation_currency->j_id=$j_id;
+ $operation_currency->insert();
if (sql_string(${"e_other$i" . "_comment"}) ==
null)
diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php
index 00d1a00..8cf6ac6 100644
--- a/include/class/fiche.class.php
+++ b/include/class/fiche.class.php
@@ -29,6 +29,7 @@ require_once NOALYSS_INCLUDE.'/class/fiche_def.class.php';
require_once NOALYSS_INCLUDE.'/lib/iposte.class.php';
require_once NOALYSS_INCLUDE.'/class/acc_operation.class.php';
require_once NOALYSS_INCLUDE.'/class/acc_account.class.php';
+require_once NOALYSS_INCLUDE.'/class/acc_ledger_fin.class.php';
/*! \file
* \brief define Class fiche, this class are using
@@ -77,7 +78,7 @@ class Fiche
global $g_user;
$sql_ledger=$g_user->get_ledger_sql('FIN',3);
$avail=$this->cn->get_array("select jrn_def_id,jrn_def_name,"
- . "jrn_def_bank,jrn_def_description from jrn_def where
jrn_def_type='FIN' and $sql_ledger
+ . "jrn_def_bank,jrn_def_description,currency_id from jrn_def
where jrn_def_type='FIN' and $sql_ledger
order by jrn_def_name");
if ( count($avail) == 0 )
@@ -1664,7 +1665,32 @@ class Fiche
'solde'=>abs($r['sum_deb']-$r['sum_cred']));
}
/**
- *get the bank balance with receipt or not
+ * Get the sum in Currency
+ * @param string $p_cond
+ * @return type
+ * @throws Exception
+ */
+ function get_bk_balance_currency($p_cond="")
+ {
+ if ( $this->id == 0 ) throw new Exception('fiche->id est nul');
+
+ if ( $p_cond != "") $p_cond=" and ".$p_cond;
+
+ $sql = "
+ select sum(oc_amount)
+ from
+ Operation_currency
+ join jrnx using (j_id)
+ join jrn on (jr_grpt_id=j_grpt)
+ where f_id=$1
+ $p_cond";
+ $val=$this->cn->get_value($sql,[$this->id]);
+
+ return $val;
+
+ }
+ /**
+ *get the bank balance with receipt or not in Euro
*
*/
function get_bk_balance($p_cond="")
@@ -2238,6 +2264,24 @@ class Fiche
function filter_history($p_table_id) {
return _('Cherche').' '.HtmlInput::filter_table($p_table_id,
'0,1,2,3,4,5,6,7,8,9,10', 1);
}
+ /**
+ * Returns the Acc_Ledger_Fin ledger for which the card is the default
bank account or null if no ledger is found.
+ */
+ function get_bank_ledger()
+ {
+ try {
+ $id=$this->cn->get_value("select jrn_def_id from jrn_def where
jrn_def_bank = $1 ",[$this->id]);
+ if ($id == "") { return NULL;}
+ $ledger=new Acc_Ledger_Fin($this->cn,$id);
+ $ledger->load();
+ return $ledger;
+ }
+ catch (Exception $e) {
+ record_log(__FILE__.":".__LINE__);
+ record_log($e->getMessage());
+ throw $e;
+ }
+ }
}
?>
diff --git a/include/compta_fin_saldo.inc.php b/include/compta_fin_saldo.inc.php
index 42b6e9b..520b9f4 100644
--- a/include/compta_fin_saldo.inc.php
+++ b/include/compta_fin_saldo.inc.php
@@ -48,6 +48,8 @@ echo tr(th('Quick Code', ' class=" sorttable_sorted"',
.th(_('Compte en banque'), ' style="text-align:left"')
.th(_('Journal'), ' style="text-align:center"')
.th(_('Description'), ' style="text-align:center"')
+ .th(_("Devise"))
+ .th(_("Montant Devise"))
.th(_('solde opération'),
' style="text-align:right" class="sorttable_numeric"')
.th(_('solde extrait/relevé'),
@@ -74,17 +76,36 @@ for ($i=0; $i<count($array); $i++)
echo '</tr>';
continue;
}
+
+
// get the saldo
$m=$array[$i]->get_solde_detail($filter_year);
- $solde=$m['debit']-$m['credit'];
+ $solde=bcsub($m['debit'],$m['credit']);
// print the result if the saldo is not equal to 0
if ($m['debit']!=0.0||$m['credit']!=0.0)
{
+ // Get it in currency
+ $ledger=$array[$i]->get_bank_ledger();
+ $currency_code=$ledger->get_currency()->get_code();
+
+ /**
+ * if we don't use the defaut currency
+ */
+ if ( $ledger->get_currency()->get_id() == 0)
+ {
+ $currency_amount=$solde;
+ }
+ else
+ {
+ $currency_amount=$array[$i]->get_bk_balance_currency();
+
+ }
/* get saldo for not reconcilied operations */
$saldo_not_reconcilied=$array[$i]->get_bk_balance($filter_year." and
(trim(jr_pj_number) ='' or jr_pj_number is null)");
+
/* get saldo for reconcilied operation */
$saldo_reconcilied=$array[$i]->get_bk_balance($filter_year." and (
trim(jr_pj_number) != '' and jr_pj_number is not null)");
@@ -110,6 +131,10 @@ for ($i=0; $i<count($array); $i++)
"</TD>".
td(h($array[$i]->ledger_name)).
td(h($array[$i]->ledger_description)).
+ td($currency_code).
+ '<TD class="sorttable_numeric"
sorttable_customkey="'.$currency_amount.'" style="text-align:right">'.
+ nbm($currency_amount).
+ '</td>'.
'<TD class="sorttable_numeric" sorttable_customkey="'.$solde.'"
style="text-align:right">'.
nbm($solde).
"</TD>".
- [Noalyss-commit] [noalyss] 88/218: FIN : cosmetic : bug due the currency feature in the input there are 2 supplementary rows for total in EUR and CURRENCY. Those rows don't exist for FIN, (continued)
- [Noalyss-commit] [noalyss] 88/218: FIN : cosmetic : bug due the currency feature in the input there are 2 supplementary rows for total in EUR and CURRENCY. Those rows don't exist for FIN, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 85/218: Currency : financial ledger can be set to a specific currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 102/218: Version DB 131, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 101/218: Currency : SQL quant_fin is adapted, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 103/218: reverse for quant_fin, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 100/218: Currency : financial use the rate depending of the operation date, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 94/218: acc_ledger_fin : cosmetic : input, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 99/218: Modify quant_fin , we add a column j_id to have a fk to jrnx and operation_currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 108/218: acc_ledger_fin . translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 111/218: Currency : sales in listing mode, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 106/218: Currency : adapt for bank saldo,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 112/218: currency : sale extended html , csv, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 110/218: Currency : All ledger's listing mode , html , csv and pdf, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 119/218: currency : adapt middle of payment, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 107/218: Currency : export PDF and CSV with currency for printing financial ledger listing(oneline), Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 130/218: typo doc, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 129/218: Esthetic with button "Add accounting", Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 114/218: Currency : purchase oneline + extended html and csv, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 125/218: Merge branch 'master' into r700-currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 128/218: Missing bracket, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 127/218: Merge commit '3f53de417dd89e9a90a386404f93f8648155e046' into r700-currency, Dany De Bontridder, 2019/09/12