Skip to content

Commit

Permalink
Merge pull request #402 from ZIMkaRU/bugfix/fix-tax-report-ccy-conver…
Browse files Browse the repository at this point in the history
…sion

Improve tax report ccy conversion
  • Loading branch information
ezewer authored Aug 5, 2024
2 parents 833b178 + 6ce158c commit bc605bb
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions workers/loc.api/sync/transaction.tax.report/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const { setTimeout } = require('node:timers/promises')

const INTERRUPTER_NAMES = require(
'bfx-report/workers/loc.api/interrupter/interrupter.names'
)
Expand Down Expand Up @@ -460,28 +462,31 @@ class TransactionTaxReport {
const getDataFn = this.rService[this.SYNC_API_METHODS.PUBLIC_TRADES]
.bind(this.rService)

const { res } = await this.getDataFromApi({
getData: (s, args) => getDataFn(args),
args,
callerName: 'TRANSACTION_TAX_REPORT',
eNetErrorAttemptsTimeframeMin: 10,
eNetErrorAttemptsTimeoutMs: 10000,
interrupter
})
for (let i = 0; i < 6; i += 1) {
const { res } = await this.getDataFromApi({
getData: (s, args) => getDataFn(args),
args,
callerName: 'TRANSACTION_TAX_REPORT',
eNetErrorAttemptsTimeframeMin: 10,
eNetErrorAttemptsTimeoutMs: 10000,
interrupter
})

const pubTrades = Array.isArray(res)
? res
: []
if (isTestEnv) {
/*
* Need to reverse pub-trades array for test env
* as mocked test server return data in desc order
*/
return res.reverse()
}
if (Array.isArray(res)) {
return res
}

if (isTestEnv) {
/*
* Need to reverse pub-trades array for test env
* as mocked test server return data in desc order
*/
return pubTrades.reverse()
await setTimeout(10000)
}

return pubTrades
return []
}

async #updateExactUsdValueInColls (trxs) {
Expand Down

0 comments on commit bc605bb

Please sign in to comment.