Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PART-4] Add transaction tax report #383

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion workers/loc.api/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,18 @@ class AuthTokenTTLSettingError extends ArgsParamsError {
}
}

class CurrencyConversionError extends BaseError {
constructor (data, message = 'ERR_CURRENCY_HAS_NOT_BEEN_CONVERTED_TO_USD') {
super({ data, message })
}
}

class CurrencyPairSeparationError extends BaseError {
constructor (data, message = 'ERR_CURRENCY_PAIR_HAS_NOT_BEEN_SEPARATED_CORRECTLY') {
super({ data, message })
}
}

module.exports = {
BaseError,
CollSyncPermissionError,
Expand Down Expand Up @@ -284,5 +296,7 @@ module.exports = {
LastSyncedInfoGettingError,
SyncInfoUpdatingError,
AuthTokenGenerationError,
AuthTokenTTLSettingError
AuthTokenTTLSettingError,
CurrencyConversionError,
CurrencyPairSeparationError
}
6 changes: 4 additions & 2 deletions workers/loc.api/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const {
pickLowerObjectsNumbers,
sumAllObjectsNumbers,
pickAllLowerObjectsNumbers,
sumArrayVolumes
sumArrayVolumes,
pushLargeArr
} = require('./utils')
const {
isSubAccountApiKeys,
Expand All @@ -33,5 +34,6 @@ module.exports = {
pickLowerObjectsNumbers,
sumAllObjectsNumbers,
pickAllLowerObjectsNumbers,
sumArrayVolumes
sumArrayVolumes,
pushLargeArr
}
9 changes: 8 additions & 1 deletion workers/loc.api/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ const sumArrayVolumes = (propName, objects = []) => {
}, [])
}

const pushLargeArr = (dest, src) => {
for (const item of src) {
dest.push(item)
}
}

module.exports = {
checkParamsAuth,
tryParseJSON,
Expand All @@ -276,5 +282,6 @@ module.exports = {
pickLowerObjectsNumbers,
sumAllObjectsNumbers,
pickAllLowerObjectsNumbers,
sumArrayVolumes
sumArrayVolumes,
pushLargeArr
}
15 changes: 9 additions & 6 deletions workers/loc.api/sync/helpers/get-back-iterable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ module.exports = (array) => {
[Symbol.iterator] (areEntriesReturned) {
return {
index: array.length,
res: {
done: false,
value: undefined
},
next () {
this.index -= 1
this.res.done = this.index < 0
this.res.value = areEntriesReturned
? [this.index, array[this.index]]
: array[this.index]

return {
done: this.index < 0,
value: areEntriesReturned
? [this.index, array[this.index]]
: array[this.index]
}
return this.res
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion workers/loc.api/sync/transaction.tax.report/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
const TRX_TAX_STRATEGIES = require('./trx.tax.strategies')
const remapTrades = require('./remap-trades')
const remapMovements = require('./remap-movements')
const lookUpTrades = require('./look-up-trades')

module.exports = {
TRX_TAX_STRATEGIES,
remapTrades,
remapMovements
remapMovements,
lookUpTrades
}
Loading