Skip to content

Commit

Permalink
Improve balance formatting by handling numeric validation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
koriyapankaj authored Aug 8, 2024
1 parent c7a565d commit a7c361d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion upload/admin/controller/marketing/affiliate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down

0 comments on commit a7c361d

Please sign in to comment.