Skip to content

Commit

Permalink
fix: updated currency usage
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed Sep 24, 2021
1 parent 5e632ba commit 4773977
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/src/transactions/logic/calculatePrices.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Currency } from 'src/steam/currency';
import { AccountOptions } from '../../accounts/options';
import { getAllItemsPrice } from '../../steam/market';
import { NextFunction } from '../../util/middleware';
Expand All @@ -7,9 +8,11 @@ import { ItemPrice, OfferContext } from '../types';
export default async function middleware(context: OfferContext, next: NextFunction) {
const { processor, itemsToReceive, itemsToGive } = context;
const { options } = processor.account;
const currency = Currency[options.status.currency || 'USD']

context.receiveItemsPrices = await getAllItemsPrice(
itemsToReceive,
processor.account.options.status.currency
currency
);

if (context.receiveItemsPrices.some((item) => isTrash(item, options))) {
Expand All @@ -18,7 +21,7 @@ export default async function middleware(context: OfferContext, next: NextFuncti

context.receivePrice = reducePrices(context.receiveItemsPrices);

context.giveItemsPrices = await getAllItemsPrice(itemsToGive, options.status.currency);
context.giveItemsPrices = await getAllItemsPrice(itemsToGive, currency);
context.givePrice = reducePrices(context.giveItemsPrices);

context.profit = context.receivePrice - context.givePrice;
Expand Down

0 comments on commit 4773977

Please sign in to comment.