You've already forked tf2wikipricing
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:
8
src/content/utils/currency.ts
Normal file
8
src/content/utils/currency.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user