Skip to content

Commit

Permalink
Merge pull request iNextrix#645 from iNextrix/ASTPPCOM-857Error_balan…
Browse files Browse the repository at this point in the history
…ces_change_language

[FIX]Error balances change language
  • Loading branch information
devangn authored Feb 9, 2022
2 parents cf68253 + 61c987d commit 8e4700b
Showing 1 changed file with 77 additions and 11 deletions.
88 changes: 77 additions & 11 deletions web_interface/astpp/application/models/common_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,14 @@ function get_admin_info() {
return $result [0];
}
function generate_receipt($accountid, $amount, $accountinfo, $last_invoice_ID, $invoice_prefix, $due_date) {
$amount = str_replace ( ',', '', $amount );
// ASTPPCOM-857 Ashish start
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$amount = str_replace ( '.', ',', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
// ASTPPCOM-857 end
$invoice_data = array (
"accountid" => $accountid,
"invoice_prefix" => $invoice_prefix,
Expand Down Expand Up @@ -127,14 +134,26 @@ function calculate_currency($amount = 0, $from_currency = '', $to_currency = '',

$to_cur_rate = (self::$global_config ['currency_list'] [$to_currency]) ? self::$global_config ['currency_list'] [$to_currency] : 1;

$amount = str_replace ( ',', '', $amount );
// ASTPPCOM-857 Ashish start
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$amount = str_replace ( '.', ',', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
// ASTPPCOM-857 end
$cal_amount = ($amount * $to_cur_rate) / $from_cur_rate;
if ($format_currency)
$cal_amount = $this->format_currency ( $cal_amount );
if ($append_currency) {
$cal_amount = $cal_amount . " " . $to_currency;
}
$cal_amount = str_replace ( ',', '', $cal_amount );
//ASTPPCOM-857 Ashish start
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$cal_amount = str_replace ( '.', ',', $cal_amount );
}else{
$cal_amount = str_replace ( ',', '', $cal_amount );
}
// ASTPPCOM-857 end
return $cal_amount;
}
function get_dashboard_details(){
Expand Down Expand Up @@ -194,19 +213,39 @@ function calculate_currency_customer($amount = 0, $from_currency = '', $to_curre
$from_cur_rate = (self::$global_config ['currency_list'] [$from_currency] > 0) ? self::$global_config ['currency_list'] [$from_currency] : 1;

$to_cur_rate = (self::$global_config ['currency_list'] [$to_currency]) ? self::$global_config ['currency_list'] [$to_currency] : 1;
$amount = str_replace ( ',', '', $amount );
// ASTPPCOM-857 Ashish start
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$amount = str_replace ( ',', '.', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
// ASTPPCOM-857 end
$cal_amount = ($amount * $to_cur_rate) / $from_cur_rate;

if ($format_currency)
$cal_amount = $this->format_currency ( $cal_amount );
if ($append_currency)
$cal_amount = $cal_amount;
$cal_amount = str_replace ( ',', '', $cal_amount );
// ASTPPCOM-857 Ashish start
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$cal_amount = str_replace ( '.', ',', $cal_amount );
}else{
$cal_amount = str_replace ( ',', '', $cal_amount );
}
// ASTPPCOM-857 end

return $cal_amount;
}
function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) {
$amount = str_replace ( ',', '', $amount );
// ASTPPCOM-857 Ashish start
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$amount = str_replace ( '.', ',', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
// ASTPPCOM-857 end
if ($from_currency == '') {
$from_currency1 = $this->session->userdata ['accountinfo'] ['currency_id'];
$from_currency = $this->common->get_field_name ( 'currency', 'currency', $from_currency1 );
Expand All @@ -223,7 +262,13 @@ function add_calculate_currency($amount = 0, $from_currency = '', $to_currency =
$cal_amount = $this->format_currency ( $cal_amount );
if ($append_currency)
$cal_amount = $cal_amount . " " . $to_currency;
$cal_amount = str_replace ( ',', '', $cal_amount );
// ASTPPCOM-857 Ashish start
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$cal_amount = str_replace ( '.', ',', $cal_amount );
}else{
$cal_amount = str_replace ( ',', '', $cal_amount );
}
// ASTPPCOM-857 end

return $cal_amount;
}
Expand All @@ -236,19 +281,40 @@ function to_calculate_currency($amount = 0, $from_currency = '', $to_currency =

$from_cur_rate = (self::$global_config ['currency_list'] [$from_currency] > 0) ? self::$global_config ['currency_list'] [$from_currency] : 1;
$to_cur_rate = (self::$global_config ['currency_list'] [$to_currency]) ? self::$global_config ['currency_list'] [$to_currency] : 1;
$amount = str_replace ( ',', '', $amount );
// ASTPPCOM-857 Ashish start
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$amount = str_replace ( '.', ',', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
// ASTPPCOM-857 end
$cal_amount = ($amount * $to_cur_rate) / $from_cur_rate;
if ($format_currency)
$cal_amount = $this->format_currency ( $cal_amount );
if ($append_currency)
$cal_amount = $cal_amount . " " . $to_currency;
$cal_amount = str_replace ( ',', '', $cal_amount );
// ASTPPCOM-857 Ashish start
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$cal_amount = str_replace ( '.', ',', $cal_amount );
}else{
$cal_amount = str_replace ( ',', '', $cal_amount );
}
// ASTPPCOM-857 end
return $cal_amount;
}

function format_currency($amount) {
$amount = str_replace ( ',', '', $amount );
return number_format ( $amount, Common_model::$global_config ['system_config'] ['decimalpoints'] );
// ASTPPCOM-857 Ashish start
$amount=number_format ( $amount, Common_model::$global_config ['system_config'] ['decimalpoints'] );
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$amount = str_replace ( '.', ',', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
return $amount;
// ASTPPCOM-857 end
}
function money_format($format, $number) {
$regex = '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?' . '(?:#([0-9]+))?(?:\.([0-9]+))?([in%])/';
Expand Down

0 comments on commit 8e4700b

Please sign in to comment.