[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 16/73: Currency : add a check , upgrade versi
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 16/73: Currency : add a check , upgrade version of DB |
Date: |
Fri, 28 May 2021 05:26:23 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 47bf11652f3ba0cd4a25f196eecab6544dafd159
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Apr 11 12:22:24 2021 +0200
Currency : add a check , upgrade version of DB
---
include/class/acc_ledger.class.php | 63 +++++++++++++++++------------
include/class/acc_ledger_purchase.class.php | 1 +
include/class/acc_ledger_sold.class.php | 1 +
include/constant.php | 2 +-
include/sql/patch/upgrade155.sql | 55 +++++++++++++++++++++++++
5 files changed, 96 insertions(+), 26 deletions(-)
diff --git a/include/class/acc_ledger.class.php
b/include/class/acc_ledger.class.php
index 6a2dee0..4869437 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -1094,30 +1094,7 @@ class Acc_Ledger extends jrn_def_sql
$currency_code=$http->extract($p_array,"p_currency_code","number");
$currency=new Acc_Currency($this->db,$currency_code);
- if ( $p_currency_code == -1 )
- {
- throw new Exception(_('Devise inconnue'), 3);
- }
-
- /* -- check the accounting for error of exchange -*/
- if ($p_currency_code > 0 )
- {
- $poste=new
Acc_Account($this->db,$g_parameter->MY_DEFAULT_ROUND_ERROR_DEB);
- if ($poste->get_parameter("id") == -1 )
- {
- throw new Exception(
- sprintf(_("Dans COMPANY, vous n'avez pas paramétré
correctement ".
- " le compte de débit %s pour les erreurs de
conversion"),$g_parameter->MY_DEFAULT_ROUND_ERROR_DEB), 3);
- }
- $poste=new
Acc_Account($this->db,$g_parameter->MY_DEFAULT_ROUND_ERROR_CRED);
- if ($poste->get_parameter("id") == -1 )
- {
- throw new Exception(
- sprintf(_("Dans COMPANY, vous n'avez pas paramétré
correctement ".
- " le compte de crédit %s pour les erreurs de
conversion"),$g_parameter->MY_DEFAULT_ROUND_ERROR_CRED), 3);
- }
-
- }
+ $this->check_currency_setting($currency_code);
/* check if we can write into this ledger */
if ($g_user->check_jrn($p_jrn)!='W')
@@ -1751,7 +1728,43 @@ class Acc_Ledger extends jrn_def_sql
return false;
throw new Exception("Valeur invalid ".__FILE__.':'.__LINE__);
}
-
+ /**
+ * Check that the currency code does exist and the setting of the folder
is correct
+ *
+ * @param int $p_currency_code
+ * @throws Exception
+ */
+ function check_currency_setting ($p_currency_code)
+ {
+ global $g_parameter;
+ if ( $p_currency_code == -1 )
+ {
+ throw new Exception(_('Devise inconnue'), 3);
+ }
+ /* -- check the accounting for error of exchange -*/
+ if ($p_currency_code > 0 )
+ {
+ $poste=new
Acc_Account($this->db,$g_parameter->MY_DEFAULT_ROUND_ERROR_DEB);
+
+ if ($poste->get_parameter("id") == -1 )
+ {
+ throw new Exception(
+ sprintf(_("Dans COMPANY, vous n'avez pas paramétré
correctement ".
+ " le compte de débit %s pour les erreurs de
conversion"),
+ $g_parameter->MY_DEFAULT_ROUND_ERROR_DEB), 3);
+ }
+
+ $poste=new
Acc_Account($this->db,$g_parameter->MY_DEFAULT_ROUND_ERROR_CRED);
+ if ($poste->get_parameter("id") == -1 )
+ {
+ throw new Exception(
+ sprintf(_("Dans COMPANY, vous n'avez pas paramétré
correctement ".
+ " le compte de crédit %s pour les erreurs de
conversion"),
+ $g_parameter->MY_DEFAULT_ROUND_ERROR_CRED), 3);
+ }
+
+ }
+ }
/**
* When we write a record for the payment at the same time as a sale or a
purchase, to have a
* bank saldo reliable , all the bank operation must be in the same
currency
diff --git a/include/class/acc_ledger_purchase.class.php
b/include/class/acc_ledger_purchase.class.php
index b3d9ebf..b6164ca 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -287,6 +287,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
if ( isNumber($p_currency_rate) == 0 || $p_currency_rate <=0 ) {
throw new Exception(_('Taux devise invalide'),15);
}
+ $this->check_currency_setting($p_currency_code);
}
/**
* Compute the ND amount thanks the attribute of the concerned card. The
object
diff --git a/include/class/acc_ledger_sold.class.php
b/include/class/acc_ledger_sold.class.php
index 4d49624..ae42b10 100644
--- a/include/class/acc_ledger_sold.class.php
+++ b/include/class/acc_ledger_sold.class.php
@@ -245,6 +245,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
if ( isNumber($p_currency_rate) == 0 || $p_currency_rate <=0 ) {
throw new Exception(_('Taux devise invalide'),15);
}
+ $this->check_currency_setting($p_currency_code);
}
/*!\brief insert into the database, it calls first the verify function,
diff --git a/include/constant.php b/include/constant.php
index 75363be..8a19d10 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -110,7 +110,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
if ( ! defined ("SYSINFO_DISPLAY")) {
define ("SYSINFO_DISPLAY",TRUE);
}
-define ("DBVERSION",155);
+define ("DBVERSION",156);
define ("MONO_DATABASE",25);
define ("DBVERSIONREPO",19);
define ('NOTFOUND','--not found--');
diff --git a/include/sql/patch/upgrade155.sql b/include/sql/patch/upgrade155.sql
new file mode 100644
index 0000000..d6063bc
--- /dev/null
+++ b/include/sql/patch/upgrade155.sql
@@ -0,0 +1,55 @@
+begin;
+
+create or replace function tmp_1 () returns void
+as
+$fct$
+declare
+ sCountry text;
+ nOhada int;
+begin
+
+-- set my_country for OHADA
+select count(*) into nOhada from tmp_pcmn where pcm_val='886' ;
+
+if nOhada = 1 then
+ update parameter set pr_value='AF' where pr_id='MY_COUNTRY';
+end if;
+
+select pr_value into sCountry from parameter where pr_id='MY_COUNTRY';
+
+if sCountry = 'BE' then
+ insert into tmp_pcmn
(pcm_val,pcm_lib,pcm_val_parent,pcm_type,pcm_direct_use)
+values ('755','Ecart de conversion','75','PRO','Y') on conflict do nothing;
+ insert into tmp_pcmn
(pcm_val,pcm_lib,pcm_val_parent,pcm_type,pcm_direct_use)
+values ('655','Ecart de conversion','65','CHA','Y') on conflict do nothing;
+
+ update public."parameter" set pr_value = '755' where pr_id=
'MY_DEFAULT_ROUND_ERROR_CRED';
+ update public."parameter" set pr_value = '655' where pr_id=
'MY_DEFAULT_ROUND_ERROR_DEB';
+
+
+end if;
+
+if sCountry = 'FR' then
+ insert into tmp_pcmn
(pcm_val,pcm_lib,pcm_val_parent,pcm_type,pcm_direct_use)
+values ('758','Ecart de conversion','75','PRO','Y') on conflict do nothing;
+ insert into tmp_pcmn
(pcm_val,pcm_lib,pcm_val_parent,pcm_type,pcm_direct_use)
+values ('658','Ecart de conversion ','65','CHA','Y') on conflict do nothing;
+
+ update public."parameter" set pr_value = '758' where pr_id=
'MY_DEFAULT_ROUND_ERROR_CRED';
+ update public."parameter" set pr_value = '658' where pr_id=
'MY_DEFAULT_ROUND_ERROR_DEB';
+
+end if;
+
+
+
+end;
+$fct$
+language plpgsql;
+
+select tmp_1();
+
+drop function tmp_1;
+insert into version (val,v_description) values (156,'insert default
accounting');
+
+
+commit;
\ No newline at end of file
- [Noalyss-commit] [noalyss] 30/73: Historic : search on currency, (continued)
- [Noalyss-commit] [noalyss] 30/73: Historic : search on currency, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 26/73: Cosmetic : select_box for javascript , display the selected option, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 25/73: Cosmetic : icon in dialog box, lightblue when hover, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 46/73: Improve Sort Table ,, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 27/73: Javascript : waiting box display when exporting in PDF or CSV, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 37/73: Cosmetic improve smoke dg box, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 39/73: Bug #0001971: erreur calcul dans champ prix/unité htva, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 06/73: Cosmetic, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 08/73: Warning if PHPVERSION < 7.2, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 10/73: Cosmetic : update fontello, button inplace_edit, doc, logo and dashboad, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 16/73: Currency : add a check , upgrade version of DB,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 24/73: Bug Select_Box = problem with DIV id, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 29/73: Cosmetic : display properly currency in detail operation, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 34/73: javascript : test and improve cosmetic, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 36/73: improve captcha, replace the global variable by a "DEFINE" constant, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 41/73: Cosmetic : Card History, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 47/73: Fix block problem with font, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 49/73: Improve function display_row_custom for the custom sort key see Sorttable.js, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 50/73: Improve Manage_Table_SQL, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 55/73: Manage_Table_SQL : typo, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 56/73: Output_HTML adapt to bootstrap navbar, Dany De Bontridder, 2021/05/28