Skip to content

Commit

Permalink
Merge pull request iNextrix#678 from iNextrix/ASTPPCOM-1319_FUND_TRAN…
Browse files Browse the repository at this point in the history
…SFER_BALANCE

[FIX] Balance Transferring
  • Loading branch information
devangn authored Jan 31, 2023
2 parents 3ae9828 + 16a805c commit 19fb3e5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
24 changes: 12 additions & 12 deletions web_interface/astpp/application/models/common_model.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,11 @@ function calculate_currency_customer($amount = 0, $from_currency = '', $to_curre

return $cal_amount;
}
function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) {
// ASTPPCOM-857 Ashish start
// Kinjal ASTPPCOM-1319 Start
$current_language= $current_language == '' ? $this->session->userdata ( 'user_language' ):$current_language;
// Kinjal ASTPPCOM-1319 END
$current_language=$this->session->userdata ( 'user_language' );
// ASTPPCOM-1319 Start
function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true,$current_language = '') {
// ASTPPCOM-1319 END
// ASTPPCOM-857 Ashish start
$current_language= $current_language == '' ? $this->session->userdata ( 'user_language' ):$current_language;
if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){
$amount = str_replace ( '.', ',', $amount );
}else{
Expand All @@ -295,12 +294,14 @@ function add_calculate_currency($amount = 0, $from_currency = '', $to_currency =
}
$to_currency = ($to_currency == '') ? self::$global_config ['system_config'] ['base_currency'] : $to_currency;
if (self::$global_config ['currency_list'] [$from_currency] > 0) {

$cal_amount = ($amount * self::$global_config ['currency_list'] [$to_currency]) / self::$global_config ['currency_list'] [$from_currency];

} else {
// Kinjal ASTPPCOM-1319 Start
$cal_amount = str_replace(',','.',$cal_amount);
// Kinjal ASTPPCOM-1319 End
} else {
$cal_amount = $amount;
}

if ($format_currency)
$cal_amount = $this->format_currency ( $cal_amount );
if ($append_currency)
Expand All @@ -311,8 +312,7 @@ function add_calculate_currency($amount = 0, $from_currency = '', $to_currency =
}else{
$cal_amount = str_replace ( ',', '', $cal_amount );
}
// ASTPPCOM-857 end

// ASTPPCOM-857 end
return $cal_amount;
}
function to_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) {
Expand Down Expand Up @@ -562,4 +562,4 @@ function check_unique_data($action,$Select,$value,$tbl) {
return $query;
}

}
}
30 changes: 17 additions & 13 deletions web_interface/astpp/application/modules/user/controllers/user.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ function user_invoices_list_json()
$due_date = $this->common->convert_GMT_to_new('','',$value['due_date']);
$from_currency = Common_model::$global_config['system_config']['base_currency'];
$to_currency = $this->common->get_field_name('currency', 'currency', $accountinfo['currency_id']);
$charge_type = $this->common->get_field_name("charge_type","invoice_details",array("invoiceid"=>$value['id']));
$charge_type = $this->common->get_field_name("charge_type","invoice_details",array("invoiceid"=>$value['id']));

if ($from_currency != $to_currency) {
$outstanding = ($value['is_paid'] == 1) ? $value['debit'] - $value['credit'] : 0.00;
Expand Down Expand Up @@ -1412,7 +1412,7 @@ function user_didlist_search()
unset($action['dids.number']['number']);
unset($action['dids.number']['number-string']);

}
}



Expand Down Expand Up @@ -1978,6 +1978,7 @@ function user_fund_transfer_save()
if ($accountinfo['posttoexternal'] != '1') {
$data['page_title'] = gettext('Send Credit');
$post_array = $this->input->post();

$accountinfo = $this->session->userdata('accountinfo');
$account = (array) $this->db->get_where('accounts', array(
"id" => $accountinfo['id']
Expand Down Expand Up @@ -2044,19 +2045,20 @@ function user_fund_transfer_save()
if (($toaccountinfo['type'] != 3) && ($toaccountinfo['type'] != 0)) {

$this->session->set_flashdata('astpp_notification', gettext('Access Denied! unable transfer fund to this account'));
}

$post_array['credit'] = number_format($this->common_model->add_calculate_currency($post_array['credit'], '', '', false, false), 4);

}
// Kinjal ASTPPCOM-1319 Start
$post_array['credit'] = number_format($this->common_model->add_calculate_currency($post_array['credit'], '', '', false, false,'en_En'), 4);
// Kinjal ASTPPCOM-1319 END

$minimum_fund = (array) $this->db->get_where('system', array(
"name" => "minimum_fund_transfer"
), 1)->first_row();
$minimum_fund['value'] = number_format($this->common_model->add_calculate_currency($minimum_fund['value'], '', '', false, false), 4);

// Kinjal ASTPPCOM-1319 Start
$minimum_fund['value'] = number_format($this->common_model->add_calculate_currency($minimum_fund['value'], '', '', false, false,'en_En'), 4);
$from_currency = common_model::$global_config['system_config'] ['base_currency'];
$minimum_fund_value = number_format($this->common_model->add_calculate_currency($minimum_fund['value'],$from_currency, $currency['currency'], false, false,'en_En'), 4);
// Kinjal ASTPPCOM-1319 END
if ($post_array['toaccountid'] == $account_info['number']) {
$this->session->set_flashdata('astpp_notification', gettext('You can not transfer fund in same account.'));
} elseif ($reseller_id != $account_info['reseller_id']) {
Expand All @@ -2072,7 +2074,9 @@ function user_fund_transfer_save()
} elseif ($post_array['credit'] < 0) {
$this->session->set_flashdata('astpp_notification', gettext('Please enter amount greater then 0.'));
} elseif ($minimum_fund['value'] > $post_array['credit']) {
$this->session->set_flashdata('astpp_notification', gettext(sprintf('You need to enter minimum %s for fund transfer. ', $minimum_fund['value'])));
// Kinjal ASTPPCOM-1319 Start
$this->session->set_flashdata('astpp_notification', gettext('You need to enter minimum').' '.$minimum_fund_value.' '.gettext('for fund transfer.'));
// Kinjal ASTPPCOM-1319 END
} elseif (! isset($toid) || ! isset($post_array['toaccountid'])) {
$this->session->set_flashdata('astpp_notification', gettext('Please enter valid account number!'));
} elseif ($post_array['credit'] < 0 || $post_array['credit'] > $balance) {
Expand All @@ -2083,6 +2087,7 @@ function user_fund_transfer_save()
$from['id'] = $post_array['id'];
$from['account_currency'] = $post_array['account_currency'];
$from['accountid'] = $post_array['fromaccountid'];

if ($account['posttoexternal'] == 1) {
$from['credit'] = abs($post_array['credit']);
$from['payment_type'] = '0';
Expand All @@ -2092,7 +2097,7 @@ function user_fund_transfer_save()
}
// Kinjal ASTPPCOM-1319 Start
$from['credit'] = str_replace(',', '.', $from['credit']);
// Kinjal ASTPPCOM-1319 Start
// Kinjal ASTPPCOM-1319 END
$from['posttoexternal'] = $account['posttoexternal'];

$from['notes'] = $post_array['notes'];
Expand Down Expand Up @@ -2165,13 +2170,12 @@ function user_fund_transfer_save()
"is_update_balance" => "true"
);
$insert_payment_arr_to['is_apply_tax'] = "false";

$this->payment->add_payments_transcation($insert_payment_arr_to, $to_account_info, $to_currency_info);
$from_account_info['amount'] = $from['credit'];
$to_account_info['to_currency'] = $this->common->get_field_name ( 'currency', 'currency', $to_account_info['currency_id']);
$to_account_info['number'] = $from_account_info['number'];
$to_account_info['amount'] = $from['credit'];
// $from_account_info['refillbalance'] = $from['credit'];
// $from_account_info['number'] = $to_account_info['number'];
$this->common->mail_to_users('customer_refill_balance', $to_account_info);
$from_account_info['number'] = $to_account_info['number'];
$this->common->mail_to_users('balance_transfer', $from_account_info);
Expand Down Expand Up @@ -2249,10 +2253,10 @@ private function check_calls_running(){
foreach ($calls as $key => $value) {
$calls[$i]['presence_data'] = @$calls_final[$value['call_uuid']]['presence_data'];
$livecall_data = explode("|||", $calls[$i]['presence_data']);
$account_explode=explode('(',$livecall_data[1]);
$account_explode=explode('(',$livecall_data[1]);
if (isset($value['state']) && ($value['state'] == 'CS_EXCHANGE_MEDIA' || $value['state'] == 'CS_CONSUME_MEDIA') ) {
if($accountinfo['number'] == rtrim($account_explode[1],')') || array_key_exists($value['initial_dest'],$sip_device_final_array)){
$response_return=false;
$response_return=false;
}
}
}
Expand Down

0 comments on commit 19fb3e5

Please sign in to comment.