[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 29/31: Task #448 : currency_id = 0 for the de
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 29/31: Task #448 : currency_id = 0 for the default currency + display currency rate in confirm operation |
Date: |
Sat, 21 Jul 2018 07:47:11 -0400 (EDT) |
sparkyx pushed a commit to annotated tag r700-currency-001
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] 24/31: Task #448 : rounded value for VEN, (continued)
- [Noalyss-commit] [noalyss] 24/31: Task #448 : rounded value for VEN, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 21/31: Task #448 : issue with reconciliation amount, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 27/31: Task #448 : delete unused currency, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 14/31: INum : add function onchange with inplace edit, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 15/31: insert_jrnx : add debug, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 07/31: Currency : add menu for currency, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 19/31: Task #448 : currency : cosmetic operation detail, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 30/31: remove debug info, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 28/31: Task #448 : currency , EUR cannot be changed and not display, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 04/31: Currency : add test file + database file + mtable, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 29/31: Task #448 : currency_id = 0 for the default currency + display currency rate in confirm operation,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 26/31: Task #448 : rounded problem add debug info, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 31/31: task #448 : currency always used and remove parameter 'use_currency' from parameters, add SQL script, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 20/31: Task #448 : check currency rate > 0 and payment in eur, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 16/31: Currency : insert operation with currency in VEN and ACH, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 22/31: Task #448 : identical operation with currency, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 18/31: task #448 : Currency : display currency info into operation detail, Dany De Bontridder, 2018/07/21
- [Noalyss-commit] [noalyss] 25/31: Task #448 : payment method VEN, Dany De Bontridder, 2018/07/21