Skip to content

Commit

Permalink
Consider ledger entries with platform payments as a deposit for taxes
Browse files Browse the repository at this point in the history
  • Loading branch information
ZIMkaRU committed Jul 3, 2024
1 parent ff56334 commit a73c0d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
31 changes: 20 additions & 11 deletions workers/loc.api/sync/movements/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class Movements {
isExcludePrivate = true,
isWithdrawals = false,
isDeposits = false,
isMovementsWithoutSATransferLedgers = false
isMovementsWithoutSATransferLedgers = false,
areExtraPaymentsIncluded = false
} = params ?? {}

const user = await this.authenticator
Expand Down Expand Up @@ -96,7 +97,8 @@ class Movements {
sort: ledgersOrder,
isWithdrawals,
isDeposits,
isExcludePrivate
isExcludePrivate,
areExtraPaymentsIncluded
})

if (isMovementsWithoutSATransferLedgers) {
Expand Down Expand Up @@ -229,7 +231,8 @@ class Movements {
exclude = ['user_id'],
isExcludePrivate = true,
isWithdrawals = false,
isDeposits = false
isDeposits = false,
areExtraPaymentsIncluded = false
} = params ?? {}

const withdrawalsFilter = isWithdrawals
Expand All @@ -244,19 +247,25 @@ class Movements {
depositsFilter,
_filter
)
const extraPaymentsFilter = areExtraPaymentsIncluded
? {
$or: {
$eq: {
_isInvoicePayOrder: 1,
_isAirdropOnWallet: 1,
_isMarginFundingPayment: 1,
_isAffiliateRebate: 1,
_isStakingPayments: 1
}
}
}
: { $or: { $eq: { _isInvoicePayOrder: 1 } } }

return this.dao.getElemsInCollBy(
this.ALLOWED_COLLS.LEDGERS,
{
subQuery: {
filter: {
$or: {
$eq: {
_isInvoicePayOrder: 1,
_isAirdropOnWallet: 1
}
}
}
filter: extraPaymentsFilter
},
filter: {
$lte: { mts: end },
Expand Down
6 changes: 4 additions & 2 deletions workers/loc.api/sync/transaction.tax.report/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,16 @@ class TransactionTaxReport {
start,
end,
isWithdrawals: true,
isExcludePrivate: false
isExcludePrivate: false,
areExtraPaymentsIncluded: true
})
const depositsPromise = this.movements.getMovements({
auth: user,
start,
end,
isDeposits: true,
isExcludePrivate: false
isExcludePrivate: false,
areExtraPaymentsIncluded: true
})

const [
Expand Down

0 comments on commit a73c0d3

Please sign in to comment.