mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-10 07:55:21 +02:00
rollback more stuff
This commit is contained in:
parent
18562477bf
commit
187b84e1c5
4 changed files with 271 additions and 262 deletions
|
@ -99,21 +99,7 @@ export async function createTestInvestmentAccount(
|
|||
(s) => s.date === it.date && s.ticker === it.ticker
|
||||
)?.price
|
||||
|
||||
function getTransactionCategory(type: string) {
|
||||
switch (type) {
|
||||
case 'BUY':
|
||||
return 'buy'
|
||||
case 'SELL':
|
||||
return 'sell'
|
||||
case 'DIVIDEND':
|
||||
return 'dividend'
|
||||
case 'DEPOSIT':
|
||||
case 'WITHDRAW':
|
||||
return 'transfer'
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
const isCashFlow = it.type === 'DEPOSIT' || it.type === 'WITHDRAW'
|
||||
|
||||
return {
|
||||
securityId: securities.find((s) => it.ticker === s.symbol)?.id,
|
||||
|
@ -122,7 +108,26 @@ export async function createTestInvestmentAccount(
|
|||
amount: price ? new Prisma.Decimal(price).times(it.qty) : it.qty,
|
||||
quantity: price ? it.qty : 0,
|
||||
price: price ?? 0,
|
||||
category: getTransactionCategory(it.type),
|
||||
plaidType:
|
||||
isCashFlow || it.type === 'DIVIDEND'
|
||||
? 'cash'
|
||||
: it.type === 'BUY'
|
||||
? 'buy'
|
||||
: it.type === 'SELL'
|
||||
? 'sell'
|
||||
: undefined,
|
||||
plaidSubtype:
|
||||
it.type === 'DEPOSIT'
|
||||
? 'deposit'
|
||||
: it.type === 'WITHDRAW'
|
||||
? 'withdrawal'
|
||||
: it.type === 'DIVIDEND'
|
||||
? 'dividend'
|
||||
: it.type === 'BUY'
|
||||
? 'buy'
|
||||
: it.type === 'SELL'
|
||||
? 'sell'
|
||||
: undefined,
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
|
|
@ -70,7 +70,8 @@ export class InvestmentTransactionBalanceSyncStrategy extends BalanceSyncStrateg
|
|||
it.account_id = ${pAccountId}
|
||||
AND it.date BETWEEN ${pStart} AND now()
|
||||
AND ( -- filter for transactions that modify a position
|
||||
it.category IN ('buy', 'sell', 'transfer')
|
||||
it.plaid_type IN ('buy', 'sell', 'transfer')
|
||||
OR it.finicity_transaction_id IS NOT NULL
|
||||
)
|
||||
GROUP BY
|
||||
1, 2
|
||||
|
|
|
@ -243,7 +243,10 @@ export class AccountQueryService implements IAccountQueryService {
|
|||
AND it.date BETWEEN sd.start_date AND ${pEnd}
|
||||
-- filter for investment_transactions that represent external flows
|
||||
AND (
|
||||
it.category = 'transfer'
|
||||
(it.plaid_type = 'cash' AND it.plaid_subtype IN ('contribution', 'deposit', 'withdrawal'))
|
||||
OR (it.plaid_type = 'transfer' AND it.plaid_subtype IN ('transfer'))
|
||||
OR (it.plaid_type = 'buy' AND it.plaid_subtype IN ('contribution'))
|
||||
OR (it.finicity_transaction_id IS NOT NULL AND it.finicity_investment_transaction_type IN ('contribution', 'deposit', 'transfer'))
|
||||
)
|
||||
GROUP BY
|
||||
1, 2
|
||||
|
|
|
@ -315,9 +315,6 @@ export class InsightService implements IInsightService {
|
|||
{
|
||||
finicityInvestmentTransactionType: 'dividend',
|
||||
},
|
||||
{
|
||||
category: 'dividend',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
|
@ -750,7 +747,10 @@ export class InsightService implements IInsightService {
|
|||
WHERE
|
||||
it.account_id = ${accountId}
|
||||
AND (
|
||||
it.category = 'transfer'
|
||||
(it.plaid_type = 'cash' AND it.plaid_subtype IN ('contribution', 'deposit', 'withdrawal'))
|
||||
OR (it.plaid_type = 'transfer' AND it.plaid_subtype IN ('transfer', 'send', 'request'))
|
||||
OR (it.plaid_type = 'buy' AND it.plaid_subtype IN ('contribution'))
|
||||
OR (it.finicity_transaction_id IS NOT NULL AND it.finicity_investment_transaction_type IN ('contribution', 'deposit', 'transfer'))
|
||||
)
|
||||
-- Exclude any contributions made prior to the start date since balances will be 0
|
||||
AND (a.start_date is NULL OR it.date >= a.start_date)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue