From c7a565d9d6cfcc28141950556a4c09d1fdbd982e Mon Sep 17 00:00:00 2001 From: pankaj koriya <49881668+koriyapankaj@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:13:45 +0530 Subject: [PATCH 1/2] Remove redundant typecasting in balance formatting - Updated balance formatting to remove unnecessary typecasting to integer in the `$result['balance']` variable. This ensures the balance is correctly formatted without altering the original value type. Remove redundant typecasting in balance formatting - Updated balance formatting to remove unnecessary typecasting to integer in the `$result['balance']` variable. This ensures the balance is correctly formatted without altering the original value type. --- upload/admin/controller/marketing/affiliate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload/admin/controller/marketing/affiliate.php b/upload/admin/controller/marketing/affiliate.php index 5ee74530b03..8b104718a37 100644 --- a/upload/admin/controller/marketing/affiliate.php +++ b/upload/admin/controller/marketing/affiliate.php @@ -349,7 +349,7 @@ protected function getList(): string { 'name' => $result['name'], 'tracking' => $result['tracking'], 'commission' => $result['commission'], - 'balance' => $this->currency->format((int)$result['balance'], $this->config->get('config_currency')), + 'balance' => $this->currency->format($result['balance'], $this->config->get('config_currency')), 'status' => $result['status'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), 'customer' => $this->url->link('customer/customer.form', 'user_token=' . $this->session->data['user_token'] . '&customer_id=' . $result['customer_id']), From a7c361d6286deeedef378ac55254ee628e4b927a Mon Sep 17 00:00:00 2001 From: pankaj koriya <49881668+koriyapankaj@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:40:15 +0530 Subject: [PATCH 2/2] Improve balance formatting by handling numeric validation Improve balance formatting by handling numeric validation - Removed unnecessary typecasting to integer in balance formatting. - Added numeric validation to ensure the balance is properly formatted. - Preserved floating-point precision by casting the balance to float. - This change ensures that non-numeric balances default to 0, preventing potential errors while retaining accuracy in currency formatting. --- upload/admin/controller/marketing/affiliate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload/admin/controller/marketing/affiliate.php b/upload/admin/controller/marketing/affiliate.php index 8b104718a37..810d9a38259 100644 --- a/upload/admin/controller/marketing/affiliate.php +++ b/upload/admin/controller/marketing/affiliate.php @@ -349,7 +349,7 @@ protected function getList(): string { 'name' => $result['name'], 'tracking' => $result['tracking'], 'commission' => $result['commission'], - 'balance' => $this->currency->format($result['balance'], $this->config->get('config_currency')), + 'balance' => $this->currency->format(is_numeric($result['balance']) ? (float)$result['balance'] : 0, $this->config->get('config_currency')), 'status' => $result['status'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), 'customer' => $this->url->link('customer/customer.form', 'user_token=' . $this->session->data['user_token'] . '&customer_id=' . $result['customer_id']),