Skip to content

Commit

Permalink
feat(book_ops): TurboTax staking rewards report
Browse files Browse the repository at this point in the history
Staking rewards ended up in other income, though.
  • Loading branch information
dckc committed Feb 25, 2024
1 parent 755d28c commit 17347d7
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions packages/brcal/src/book_ops.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- uncat:
select date_format(uncat.post_date, '%Y-%m-%d') tx_date, uncat.description
select date(uncat.post_date) tx_date, uncat.description
, uncat.amount, uncat.memo,
trim(acct.memo) memo_acct, uncat.tx_guid
, acct.path acct_path
Expand Down Expand Up @@ -116,7 +116,7 @@ order by hidden, age, account_type, name
;

-- incomeStatement:
with period as (select '2022-01-01' as lo, '2022-06-30' as hi)
with period as (select '2023-01-01' as lo, '2023-12-31' as hi)
, acct as (select account_type, code, guid from accounts where account_type in ('INCOME', 'EXPENSE'))
, tx as (select post_date, guid from transactions join period where date(post_date) >= lo and date(post_date) <= hi)
, split as (
Expand Down Expand Up @@ -255,7 +255,7 @@ order by yr, o, path
-- 2020-01-01 13:00:00 -0800,BUY,Coinbase,BTC,1,500,USD,5.50

-- bitCoinTaxTradeExport:
with period as (select '2022-01-01' lo, '2022-12-31' as hi)
with period as (select '2023-01-01' lo, '2023-12-31' as hi)
, tx as (select * from transactions tx join period where tx.post_date between lo and hi)
, asset as (
select a.account_type, code, name, mnemonic, a.guid
Expand Down Expand Up @@ -285,11 +285,12 @@ from trade
order by post_date, num
;

-- Date,Action,Account,Symbol,Volume
-- 2020-01-01 13:00:00 -0800,INCOME,"Blockchain Wallet",BTC,1
-- Date Type Sent Asset Sent Amount Received Asset Received Amount Fee Asset Fee Amount Market Value Currency Market Value Description Transaction Hash Transaction ID
-- 12/23/2022 23:15 Stake 0.05 ETH received .05 ETH from staking rewards 0x12345abcde
-- https://digitalasset.intuit.com/DOCUMENT/A6oMzp4uC/Custom_CSV_Template.csv

-- bitCoinTaxIncomeExport:
with period as (select '2022-01-01' lo, '2022-12-31' as hi)
-- tuboTaxImport:
with period as (select '2023-01-01' lo, '2023-12-31' as hi)
, tx as (select * from transactions tx join period where tx.post_date between lo and hi)
, asset as (
select a.account_type, code, name, mnemonic, a.guid
Expand All @@ -301,19 +302,21 @@ with period as (select '2022-01-01' lo, '2022-12-31' as hi)
select tx.post_date, tx.num, tx.description, a.name, a.mnemonic, s.action
, 1.0 * value_num / value_denom value
, 1.0 * quantity_num / quantity_denom quantity
, s.memo
from tx
join splits s on s.tx_guid = tx.guid
join asset a on s.account_guid = a.guid
where s.action in ('Grant', 'Claim')
)
select date(post_date) || ' ' || num 'Date'
, case when action is 'Grant' then 'INCOME' else 'MINING' end Action
, name Account
, description Memo
, mnemonic Symbol
, abs(quantity) Volume
, value Total
, 'USD' Currency
select date(post_date) || ' ' || replace(num, 'Z', '') 'Date'
, case when action is 'Grant' then 'Income' else 'Stake' end Type
, abs(quantity) 'Received Amount'
, mnemonic 'Received Asset'
, 'USD' 'Market Value Currency'
, value 'Market Value'
, name || ': ' || description Description
, null 'Sent Amount'
, null 'Sent Asset'
from trade
order by post_date, num
;

0 comments on commit 17347d7

Please sign in to comment.