[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 29/218: Task #448 : currency_id = 0 for the d
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 29/218: Task #448 : currency_id = 0 for the default currency + display currency rate in confirm operation |
Date: |
Thu, 12 Sep 2019 15:58:34 -0400 (EDT) |
sparkyx pushed a commit to branch entreprise
in repository noalyss.
commit 05305dfeab8df8ebd6627a022cf38f0ee0ab11c5
Author: Dany De Bontridder <address@hidden>
Date: Fri May 11 20:46:40 2018 +0200
Task #448 : currency_id = 0 for the default currency + display currency
rate in confirm operation
---
include/class/acc_currency.class.php | 3 +--
include/class/acc_ledger_purchase.class.php | 13 +++++++++----
include/class/acc_ledger_sold.class.php | 16 ++++++++++++----
include/class/currency_mtable.class.php | 9 +++++++--
sql/upgrade.sql | 2 +-
5 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/include/class/acc_currency.class.php
b/include/class/acc_currency.class.php
index 1581013..3012916 100644
--- a/include/class/acc_currency.class.php
+++ b/include/class/acc_currency.class.php
@@ -108,8 +108,7 @@ class Acc_Currency
function select_currency()
{
$select=new ISelect('p_currency_code');
- $a_currency[0]=["value"=>-1,"label"=>"EUR"];
- $a_currency+=$this->cn->make_array("select currency_id,cr_code_iso
from v_currency_last_value order by cr_code_iso");
+ $a_currency=$this->cn->make_array("select currency_id,cr_code_iso from
v_currency_last_value order by cr_code_iso");
$select->value=$a_currency;
$select->selected=$this->currency->cr_code_iso;
diff --git a/include/class/acc_ledger_purchase.class.php
b/include/class/acc_ledger_purchase.class.php
index f72c258..3bfa1de 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -1367,7 +1367,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
// Currency
$currency_select = $this->CurrencyInput("currency_code",
"p_currency_rate" , "p_currency_euro");
-
$currency_select->selected=$http->request('p_currency_code','string',-1);
+
$currency_select->selected=$http->request('p_currency_code','string',0);
$currency_input=new INum("p_currency_rate");
$currency_input->id="p_currency_rate";
@@ -1662,7 +1662,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
// Get currency code
$str_code='EUR';
- if ( $p_currency_code != -1 ) {
+ if ( $p_currency_code != 0 ) {
$acc_currency=new Acc_Currency($this->db);
$acc_currency->set_id($p_currency_code);
$str_code=$acc_currency->get_code();
@@ -1688,6 +1688,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger
{$tot} {$str_code}
</td>
</tr>
+EOF;
+ if ($p_currency_code !=0) {
+ $rate=_("Taux ");
+$r.=<<<EOF
<tr class="highlight">
{$decalage}
<td>
@@ -1697,14 +1701,15 @@ class Acc_Ledger_Purchase extends Acc_Ledger
</td>
<td class="num">
-
+ {$rate} {$p_currency_rate}
</td>
<td class="num">
{$tot_eur} EUR
</td>
</tr>
EOF;
- } else {
+ }
+ }else {
$r.=<<<EOF
<tr class="highlight">
{$decalage}
diff --git a/include/class/acc_ledger_sold.class.php
b/include/class/acc_ledger_sold.class.php
index 65f8793..bc1ac28 100644
--- a/include/class/acc_ledger_sold.class.php
+++ b/include/class/acc_ledger_sold.class.php
@@ -923,7 +923,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
// Get currency code
$str_code='EUR';
- if ( $p_currency_code != -1 ) {
+ if ( $p_currency_code != 0 ) {
$acc_currency=new Acc_Currency($this->db);
$acc_currency->set_id($p_currency_code);
$str_code=$acc_currency->get_code();
@@ -949,7 +949,11 @@ if ( $g_parameter->MY_TVA_USE=="Y") {
{$tot} {$str_code}
</td>
</tr>
- <tr class="highlight">
+EOF;
+ if ($p_currency_code !=0) {
+ $rate=_("Taux ");
+$r.=<<<EOF
+<tr class="highlight">
{$decalage}
<td>
@@ -958,13 +962,15 @@ if ( $g_parameter->MY_TVA_USE=="Y") {
</td>
<td class="num">
-
+ {$rate} {$p_currency_rate}
</td>
<td class="num">
{$tot_eur} EUR
</td>
</tr>
EOF;
+ }
+
} else {
$r.=<<<EOF
<tr class="highlight">
@@ -987,8 +993,10 @@ EOF;
<td>
</td>
<td>
+
</td>
<td>
+ {$rate} {$p_currency_rate}
</td>
<td class="num">
{$tot} {$str_code}
@@ -1453,7 +1461,7 @@ EOF;
// Currency
$currency_select = $this->CurrencyInput("currency_code",
"p_currency_rate" , "p_currency_euro");
-
$currency_select->selected=$http->request('p_currency_code','string',-1);
+
$currency_select->selected=$http->request('p_currency_code','string',0);
$currency_input=new INum("p_currency_rate");
$currency_input->id="p_currency_rate";
diff --git a/include/class/currency_mtable.class.php
b/include/class/currency_mtable.class.php
index de3afad..89ddf5a 100644
--- a/include/class/currency_mtable.class.php
+++ b/include/class/currency_mtable.class.php
@@ -30,6 +30,7 @@ require_once
NOALYSS_INCLUDE.'/database/currency_history_sql.class.php';
/**
* Manage the configuration of currency , add currency, rate, remove and
update
* Concerned tables are v_currency_last_value _SQL , Currency_SQL ,
Currency_History_SQL
+ * currency_id = 0 for the default currency , -1 for a new one
*/
class Currency_MTable extends Manage_Table_SQL
{
@@ -110,13 +111,17 @@ class Currency_MTable extends Manage_Table_SQL
* - Date of the rate
* - code iso is max 10 char
* - name is max 80
- *
+ * Default currency (id=0) cannot be changed
*/
function check()
{
global $cn;
$table=$this->get_table();
$is_error=0;
+ if ( $table->currency_id == 0) {
+ $is_error++;
+ $this->set_error("cr_code_iso", _("Devise par défaut ne peut être
changée"));
+ }
// ------ cr_code_iso can not be empty
if (trim($table->cr_code_iso)=="")
{
@@ -292,7 +297,7 @@ class Currency_MTable extends Manage_Table_SQL
*/
function display_row($p_row)
{
- if ($p_row['currency_id']==-1)
+ if ($p_row['currency_id']==0)
{
return;
}
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 29bfa60..73bbfe57 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -94,7 +94,7 @@ COMMENT ON COLUMN public.operation_currency.oc_vat_amount IS
'vat amount in curr
COMMENT ON COLUMN public.operation_currency.oc_price_unit IS 'unit price in
currency' ;
COMMENT ON COLUMN public.operation_currency.j_id IS 'fk to jrnx' ;
-alter table jrn add currency_id bigint default -1;
+alter table jrn add currency_id bigint default 0;
alter table jrn add currency_rate numeric (20,6) default 1;
alter table jrn add currency_rate_ref numeric(20,6) default 1;
ALTER TABLE public.jrn ADD CONSTRAINT jrn_currency_fk FOREIGN KEY
(currency_id) REFERENCES public.currency(id) ON DELETE RESTRICT ON UPDATE
RESTRICT;
- [Noalyss-commit] [noalyss] 18/218: task #448 : Currency : display currency info into operation detail, (continued)
- [Noalyss-commit] [noalyss] 18/218: task #448 : Currency : display currency info into operation detail, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 20/218: Task #448 : check currency rate > 0 and payment in eur, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 23/218: Display the balance difference, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 25/218: Task #448 : payment method VEN, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 30/218: remove debug info, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 32/218: Task #448 : SQL integrated into upgrade128, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 35/218: Task #448 : correct bug when saving into quant_purchase, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 36/218: Bug in QUANT_PURCHASE , dp_dep_priv is not saved, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 42/218: remove debug, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 55/218: integrate fix for bug in insert_quant_purchase which cannot save private fee Conflicts: include/sql/patch/upgrade128.sql, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 29/218: Task #448 : currency_id = 0 for the default currency + display currency rate in confirm operation,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 34/218: Task #448 : Currency : purchase, fix bug for autoreverse VAT, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 40/218: Fix bug quant_purchase , private fee not saved, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 45/218: Fix todo_list : if list empty , gets an error in php 7.2, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 49/218: Update documentation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 54/218: Bug 1600 : alphanumeric accounting must be case insensitive, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 59/218: Security fix : f_id is a number, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 67/218: Documentation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 62/218: translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 61/218: Task #1619 : CFGLED change label for "Donner ici la fiche du compte en banque", Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 58/218: Fix : security fixes see rapport exakat (Damien Seguy), Dany De Bontridder, 2019/09/12