Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]Language and Balance account #597

Merged
merged 1 commit into from
Aug 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 56 additions & 10 deletions web_interface/astpp/application/models/common_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ function get_admin_info() {
return $result [0];
}
function generate_receipt($accountid, $amount, $accountinfo, $last_invoice_ID, $invoice_prefix, $due_date) {
$amount = str_replace ( ',', '', $amount );
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'pt_BR')){
$amount = str_replace ( '.', ',', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
$invoice_data = array (
"accountid" => $accountid,
"invoice_prefix" => $invoice_prefix,
Expand Down Expand Up @@ -122,14 +127,23 @@ 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 );
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'pt_BR')){
$amount = str_replace ( ',', '.', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
$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 );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'pt_BR')){
$cal_amount = str_replace ( '.', ',', $cal_amount );
}else{
$cal_amount = str_replace ( ',', '', $cal_amount );
}
return $cal_amount;
}
function calculate_currency_customer($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) {
Expand All @@ -142,19 +156,33 @@ 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 );
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'pt_BR')){
$amount = str_replace ( ',', '.', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
$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 );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'pt_BR')){
$cal_amount = str_replace ( '.', ',', $cal_amount );
}else{
$cal_amount = str_replace ( ',', '', $cal_amount );
}

return $cal_amount;
}
function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) {
$amount = str_replace ( ',', '', $amount );
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'pt_BR')){
$amount = str_replace ( '.', ',', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
if ($from_currency == '') {
$from_currency1 = $this->session->userdata ['accountinfo'] ['currency_id'];
$from_currency = $this->common->get_field_name ( 'currency', 'currency', $from_currency1 );
Expand All @@ -171,7 +199,11 @@ 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 );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'pt_BR')){
$cal_amount = str_replace ( '.', ',', $cal_amount );
}else{
$cal_amount = str_replace ( ',', '', $cal_amount );
}

return $cal_amount;
}
Expand All @@ -184,18 +216,32 @@ 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 );
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'pt_BR')){
$amount = str_replace ( '.', ',', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
$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 );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'pt_BR')){
$cal_amount = str_replace ( '.', ',', $cal_amount );
}else{
$cal_amount = str_replace ( ',', '', $cal_amount );
}
return $cal_amount;
}

function format_currency($amount) {
$amount = str_replace ( ',', '', $amount );
$current_language=$this->session->userdata ( 'user_language' );
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'pt_BR')){
$amount = str_replace ( '.', ',', $amount );
}else{
$amount = str_replace ( ',', '', $amount );
}
return number_format ( $amount, Common_model::$global_config ['system_config'] ['decimalpoints'] );
}
function money_format($format, $number) {
Expand Down