Fix toFixed error by converting string prices to numbers
This commit is contained in:
@@ -67,9 +67,18 @@ export class PaymentController {
|
||||
ORDER BY quantity ASC
|
||||
`);
|
||||
|
||||
// Convert decimal fields to numbers
|
||||
const packages = Array.isArray(rows) ? rows.map((pkg: any) => ({
|
||||
...pkg,
|
||||
total_price: Number(pkg.total_price),
|
||||
price_per_token: Number(pkg.price_per_token),
|
||||
discount_percentage: Number(pkg.discount_percentage),
|
||||
quantity: Number(pkg.quantity)
|
||||
})) : [];
|
||||
|
||||
return {
|
||||
success: true,
|
||||
packages: Array.isArray(rows) ? rows : []
|
||||
packages
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error getting token packages:', error);
|
||||
|
||||
Reference in New Issue
Block a user