refactor: split currency and key/metal formatting into separate units

this simplifies functions and tests, and will make currency optional/variable later
This commit is contained in:
xenticore
2025-04-16 14:04:39 -04:00
parent cb07930c6d
commit dcf45c2740
5 changed files with 51 additions and 19 deletions

View File

@@ -0,0 +1,8 @@
import { conversion_ref_usd } from '../config';
export function convertTF2PriceToUSD(keys: number, metal: number, keyPrice: number): number {
const pureMetal = (keys * keyPrice) + metal;
// Round price up to nearest cent
return Math.ceil(pureMetal * conversion_ref_usd * 100) / 100
}