forked from EvergreenCrypto/docker-finance
docker-finance | modern accounting for the power-user
Dedicated to Michael Morgan: a beautiful, beautiful soul.
---
Internal signing keys:
Aaron Fiore (sole author)
- 518A22F85BEFD32BCC99C48603F90C4F35E0213E
- 31ECA5C347A0CC0815EDE730A3EACCFCDA7E685E
- C8187C585CB07A4DA81CC0F37318B50EBE9C0DA8
Internal repositories (rebased from):
Staging:
$ git log -n1 --pretty=format:"%H"
c8e0cd66f6c89fa7b3c62f72fb524a4cc454b7b6
$ git rev-list --max-parents=0 HEAD
ac3863b8c234755855f1aea3a07a853122decdf2
Private:
$ git log -n1 --pretty=format:"%H"
69bb3591eaa2990a9637832bb484690e00c4f926
$ git rev-list --max-parents=0 HEAD
a5c1cc9fb593c4cf09bc0adfef6cb6d2964511ae
This commit is contained in:
@@ -0,0 +1,322 @@
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
fields account_id,coinbase_id,type,status_,amount_amount,amount_currency,native_amount_amount,native_amount_currency,description,created_at,updated_at,resource,resource_path,instant_exchange,details_title,details_subtitle,details_header,network_transaction_fee_amount,network_transaction_fee_currency,network_transaction_amount_amount,network_transaction_amount_currency,to_currency,to_address_info_address,native_amount_price,native_network_transaction_fee_amount,native_conversion_fee_amount,advanced_trade_fill_fill_price,advanced_trade_fill_product_id,advanced_trade_fill_order_id,advanced_trade_fill_commission,advanced_trade_fill_order_side,small_satoshi_multiplier,txid,network_status,direction,subaccount
|
||||
|
||||
date %created_at
|
||||
# TODO: for trades, use updated_at?
|
||||
|
||||
date-format %Y-%m-%d %H:%M:%S
|
||||
|
||||
# TODO: any reference to USD should instead be the native currency field
|
||||
|
||||
account1 assets:coinbase:%subaccount:%amount_currency
|
||||
amount %amount_amount %amount_currency
|
||||
|
||||
description %created_at +0000
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id
|
||||
|
||||
if %txid [0-1a-z]
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, network_status:%network_status, txid:%txid
|
||||
|
||||
# See preprocess note
|
||||
if %coinbase_id ^SKIP$
|
||||
skip
|
||||
|
||||
################################################################################
|
||||
# #
|
||||
# TRANSFER #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
# Not needed since canceled won't be accounted for anyway
|
||||
if %type ^delayed_canceled$
|
||||
skip
|
||||
|
||||
# Banking
|
||||
if %type (^fiat_withdrawal$|^exchange_deposit$)
|
||||
amount -%amount_amount %amount_currency
|
||||
account2 equity:coinbase:%subaccount:deposit:%amount_currency
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Wallet #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# Normal wallet sends (default assume equity / send to self. Use custom rules if expense.)
|
||||
if %type ^send$
|
||||
& %details_title Sent
|
||||
amount -%amount_amount %amount_currency
|
||||
account2 equity:coinbase:%subaccount:deposit:%amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, network_status:%network_status
|
||||
|
||||
if %type ^send$
|
||||
& %details_title Sent
|
||||
& %to_currency [a-z]
|
||||
& %to_address_info_address [0-9a-z]
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, to_currency:%to_currency, to_address:%to_address_info_address, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, network_status:%network_status
|
||||
|
||||
if %type ^send$
|
||||
& %details_title Sent
|
||||
& %native_network_transaction_fee_amount [1-9]
|
||||
amount -%network_transaction_amount_amount %amount_currency
|
||||
account3 assets:coinbase:%subaccount:%network_transaction_fee_currency
|
||||
amount3 -%network_transaction_fee_amount %network_transaction_fee_currency @@ %native_network_transaction_fee_amount %native_amount_currency
|
||||
account4 expenses:coinbase:%subaccount:fees:%native_amount_currency
|
||||
amount4 %native_network_transaction_fee_amount %native_amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, to_currency:%to_currency, to_address:%to_address_info_address, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, network_status:%network_status, txid:%txid, taxed_as:SPEND
|
||||
comment3 %created_at +0000,SPEND,coinbase,%network_transaction_fee_currency,%network_transaction_fee_amount,%native_amount_currency,%native_network_transaction_fee_amount,FEE
|
||||
# Marked as comment3 in case user-defined rules use comment2 to SPEND the non-fee amount
|
||||
|
||||
# Normal wallet receives
|
||||
if %type ^send$
|
||||
& %details_title Received
|
||||
& %details_subtitle address
|
||||
account2 equity:coinbase:%subaccount:withdrawal:%amount_currency
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Coinbase Pro #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# Deposit from Coinbase *to* Pro
|
||||
if %type ^pro_deposit$
|
||||
amount -%amount_amount %amount_currency
|
||||
account2 equity:coinbase-pro:deposit:%amount_currency
|
||||
|
||||
# Withdrawal from Pro *to* Coinbase
|
||||
if %type ^pro_withdrawal$
|
||||
account2 equity:coinbase-pro:withdrawal:%amount_currency
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Coinbase Vault #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# To vault
|
||||
if %type ^transfer$
|
||||
amount -%amount_amount %amount_currency
|
||||
account2 assets:coinbase:%subaccount:vault:%amount_currency
|
||||
|
||||
# From vault
|
||||
if %type ^vault_withdrawal$
|
||||
account1 assets:coinbase:%subaccount:vault:%amount_currency
|
||||
amount -%amount_amount %amount_currency
|
||||
account2 assets:coinbase:%subaccount:%amount_currency
|
||||
|
||||
# TODO: fix(?) pagination and see if this is still needed
|
||||
# From vault (eliminate double-spend / extra tx "To XXX Wallet")
|
||||
if %type ^vault_withdrawal$
|
||||
& %details_subtitle To
|
||||
skip
|
||||
|
||||
# TODO: fix(?) pagination and see if this is still needed
|
||||
# To vault (eliminate double-spend / extra tx "From XXX Wallet")
|
||||
if %type ^transfer$
|
||||
& %details_subtitle From
|
||||
skip
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Coinbase Borrow #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# NOTE: TODO: currently, CSVs do not provide cash borrowing tx!!!! All that exists is loan payback
|
||||
|
||||
if %details_subtitle ^To coinbase-credit-consumer-wallet@coinbase.com$
|
||||
account2 expenses:coinbase:%subaccount:receivable:loans:USD
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Spend (Coinbase Card) #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# Rebates ("rewards")
|
||||
if %type ^send$
|
||||
& %details_subtitle (From Card Rewards|From Coinbase Card)
|
||||
amount %amount_amount %amount_currency @@ %native_amount_amount %native_amount_currency
|
||||
account2 income:coinbase:%subaccount:card:%native_amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, taxed_as:REBATE
|
||||
comment2 %created_at +0000,BUY,coinbase,%amount_currency,%amount_amount,%native_amount_currency,%native_amount_amount,,
|
||||
|
||||
# Crypto Spend
|
||||
if %type ^cardspend$
|
||||
amount -%amount_amount %amount_currency @@ %native_amount_amount %native_amount_currency
|
||||
account2 expenses:coinbase:%subaccount:card:%amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, taxed_as:SPEND
|
||||
comment2 %created_at +0000,SPEND,coinbase,%amount_currency,%amount_amount,USD,,
|
||||
|
||||
# Crypto Spend (USDC)
|
||||
if %type ^cardspend$
|
||||
& %amount_currency ^USDC$
|
||||
amount -%amount_amount %amount_currency @@ %amount_amount %native_amount_currency
|
||||
account2 expenses:coinbase:%subaccount:card:%native_amount_currency
|
||||
comment2 %created_at +0000,SPEND,coinbase,%amount_currency,%amount_amount,USD,%amount_amount,
|
||||
|
||||
# Cash (USD Wallet) Spend
|
||||
# NOTE: not a taxable event but SPEND is kept for potential need
|
||||
if %type ^cardspend$
|
||||
& %details_subtitle ^Using Coinbase Card$
|
||||
& %amount_currency ^USD$
|
||||
amount -%amount_amount %amount_currency
|
||||
account2 expenses:coinbase:%subaccount:card:%amount_currency
|
||||
comment details_subtitle:%details_subtitle, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, taxed_as:SPEND
|
||||
comment2 %created_at +0000,SPEND,coinbase,%amount_currency,%amount_amount,USD,%amount_amount,
|
||||
|
||||
################################################################################
|
||||
# #
|
||||
# INCOME #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
# Quiz rewards
|
||||
if %type ^send$
|
||||
& %details_subtitle From Coinbase Earn
|
||||
account2 income:coinbase:%subaccount:%amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, taxed_as:INCOME
|
||||
comment2 %created_at +0000,INCOME,coinbase,%amount_currency,%amount_amount,%native_amount_currency,,REWARD
|
||||
|
||||
# Interest
|
||||
if %type ^interest$
|
||||
account2 income:coinbase:%subaccount:interest:%amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, taxed_as:INCOME
|
||||
comment2 %created_at +0000,INCOME,coinbase,%amount_currency,%amount_amount,%native_amount_currency,,INTEREST
|
||||
|
||||
# Staking
|
||||
if %type (^inflation_reward$|^staking_reward$)
|
||||
account2 income:coinbase:%subaccount:staking:%amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, taxed_as:INCOME
|
||||
comment2 %created_at +0000,INCOME,coinbase,%amount_currency,%amount_amount,%native_amount_currency,,STAKING
|
||||
|
||||
################################################################################
|
||||
# #
|
||||
# TRADE #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
# Gets rid of erroneous double-tx when dealing with USD Coin and $ on Coinbase Advanced Trading
|
||||
if %type (^buy$|^sell$|^advanced_trade_fill$)
|
||||
& %amount_currency ^USD$
|
||||
skip
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Convert / Conversion #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# "Convert/Conversion"
|
||||
# NOTE: this appears to be *only* for Coinbase and NOT Coinbase Pro
|
||||
# NOTE: for whatever reason, for conversions back in 2019 or so, Coinbase never
|
||||
# dumped to the official USD wallet/account. I don't know where the dump went,
|
||||
# so a "conversion" account is created which should account for that. An
|
||||
# accurate fiat balance should now be provided, as a result.
|
||||
if %type ^trade$
|
||||
amount %amount_amount %amount_currency @@ %native_amount_amount %native_amount_currency
|
||||
account2 equity:coinbase:%subaccount:conversion:%native_amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, native_conversion_fee_amount:%native_conversion_fee_amount, account_id:%account_id, coinbase_id:%coinbase_id, taxed_as:BUY
|
||||
comment2 %created_at +0000,BUY,coinbase,%amount_currency,%amount_amount,%native_amount_currency,%native_amount_amount,%native_amount_currency,%native_conversion_fee_amount
|
||||
|
||||
if %type ^trade$
|
||||
& %details_title Converted from
|
||||
amount -%amount_amount %amount_currency @@ %native_amount_amount %native_amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, native_conversion_fee_amount:%native_conversion_fee_amount, account_id:%account_id, coinbase_id:%coinbase_id, taxed_as:SELL
|
||||
comment2 %created_at +0000,SELL,coinbase,%amount_currency,%amount_amount,%native_amount_currency,%native_amount_amount,%native_amount_currency,%native_conversion_fee_amount
|
||||
|
||||
if %type ^trade$
|
||||
& %details_title Converted from
|
||||
& %details_subtitle Using USDC Wallet
|
||||
amount -%amount_amount %amount_currency @@ %native_amount_amount %native_amount_currency
|
||||
account2 equity:coinbase:%subaccount:conversion:%native_amount_currency
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Coinbase Trade #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# Trade (buy/sell) but not "convert/conversion"
|
||||
|
||||
if %type ^buy$
|
||||
amount %amount_amount %amount_currency @@ %native_amount_amount %native_amount_currency
|
||||
account2 assets:coinbase:%subaccount:%native_amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, native_conversion_fee_amount:%native_conversion_fee_amount, account_id:%account_id, coinbase_id:%coinbase_id, taxed_as:BUY
|
||||
comment2 %created_at +0000,BUY,coinbase,%amount_currency,%amount_amount,%native_amount_currency,%native_amount_amount,,
|
||||
#comment2 %created_at +0000,BUY,coinbase,%amount_currency,%amount_amount,%native_amount_amount,%native_amount_currency,%native_conversion_fee_amount,%native_amount_currency
|
||||
|
||||
if %type ^sell$
|
||||
amount -%amount_amount %amount_currency @@ %native_amount_amount %native_amount_currency
|
||||
account2 assets:coinbase:%subaccount:%native_amount_currency
|
||||
comment details_title:%details_title, details_subtitle:%details_subtitle, details_header:%details_header, type:%type, status:%status_, native_conversion_fee_amount:%native_conversion_fee_amount, account_id:%account_id, coinbase_id:%coinbase_id, taxed_as:SELL
|
||||
comment2 %created_at +0000,SELL,coinbase,%amount_currency,%amount_amount,%native_amount_currency,%native_amount_amount,,
|
||||
#comment2 %created_at +0000,SELL,coinbase,%amount_currency,%amount_amount,%native_amount_amount,%native_amount_currency,%native_conversion_fee_amount,%native_amount_currency
|
||||
|
||||
# TODO: not very templatable, unique to each user's bank name
|
||||
if %type (^buy$|^fiat_deposit$)
|
||||
& %details_subtitle (Bank|Checking|Credit|Debit|Saving)
|
||||
account2 equity:coinbase:%subaccount:withdrawal:%native_amount_currency
|
||||
|
||||
if %type (^sell$|^fiat_withdrawal$)
|
||||
& %details_subtitle (Bank|Checking|Credit|Debit|Saving)
|
||||
account2 equity:coinbase:%subaccount:deposit:%native_amount_currency
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Coinbase Advanced Trading #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# BUY
|
||||
|
||||
if %type ^advanced_trade_fill$
|
||||
& %advanced_trade_fill_order_side ^buy$
|
||||
account2 assets:coinbase:%subaccount:%native_amount_currency
|
||||
account3 assets:coinbase:%subaccount:%native_amount_currency
|
||||
amount3 -%advanced_trade_fill_commission %native_amount_currency
|
||||
account4 expenses:coinbase:%subaccount:fees:trading:%native_amount_currency
|
||||
amount4 %advanced_trade_fill_commission %native_amount_currency
|
||||
comment details_title:%details_title, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, advanced_trade_fill_fill_price:%advanced_trade_fill_fill_price, advanced_trade_fill_product_id:%advanced_trade_fill_product_id, advanced_trade_fill_order_id:%advanced_trade_fill_order_id, advanced_trade_fill_commission:%advanced_trade_fill_commission, advanced_trade_fill_order_side:%advanced_trade_fill_order_side, taxed_as:BUY
|
||||
|
||||
# Satoshis large enough to produce > 0 native amount
|
||||
if %type ^advanced_trade_fill$
|
||||
& %advanced_trade_fill_order_side ^buy$
|
||||
& %native_amount_amount [1-9]
|
||||
amount %amount_amount %amount_currency @@ %native_amount_amount %native_amount_currency
|
||||
comment2 %created_at +0000,BUY,coinbase,%amount_currency,%amount_amount,%native_amount_currency,%native_amount_amount,%native_amount_currency,%advanced_trade_fill_commission
|
||||
|
||||
# Satoshis small enough to produce $0.00 native amount (thanks, Coinbase!)
|
||||
if %type ^advanced_trade_fill$
|
||||
& %advanced_trade_fill_order_side ^buy$
|
||||
& %small_satoshi_multiplier [1-9]
|
||||
amount %amount_amount %amount_currency @@ %small_satoshi_multiplier %native_amount_currency
|
||||
comment2 %created_at +0000,BUY,coinbase,%amount_currency,%amount_amount,%native_amount_currency,%small_satoshi_multiplier,%native_amount_currency,%advanced_trade_fill_commission
|
||||
|
||||
# SELL
|
||||
|
||||
if %type ^advanced_trade_fill$
|
||||
& %advanced_trade_fill_order_side ^sell$
|
||||
account2 assets:coinbase:%subaccount:%native_amount_currency
|
||||
account3 assets:coinbase:%subaccount:%native_amount_currency
|
||||
amount3 -%advanced_trade_fill_commission %native_amount_currency
|
||||
account4 expenses:coinbase:%subaccount:fees:trading:%native_amount_currency
|
||||
amount4 %advanced_trade_fill_commission %native_amount_currency
|
||||
comment details_title:%details_title, type:%type, status:%status_, account_id:%account_id, coinbase_id:%coinbase_id, advanced_trade_fill_fill_price:%advanced_trade_fill_fill_price, advanced_trade_fill_product_id:%advanced_trade_fill_product_id, advanced_trade_fill_order_id:%advanced_trade_fill_order_id, advanced_trade_fill_commission:%advanced_trade_fill_commission, advanced_trade_fill_order_side:%advanced_trade_fill_order_side, taxed_as:SELL
|
||||
|
||||
# Satoshis large enough to produce > 0 native amount
|
||||
if %type ^advanced_trade_fill$
|
||||
& %advanced_trade_fill_order_side ^sell$
|
||||
& %native_amount_amount [1-9]
|
||||
amount -%amount_amount %amount_currency @@ %native_amount_amount %native_amount_currency
|
||||
comment2 %created_at +0000,SELL,coinbase,%amount_currency,%amount_amount,%native_amount_currency,%native_amount_amount,%native_amount_currency,%advanced_trade_fill_commission
|
||||
|
||||
# Satoshis small enough to produce $0.00 native amount
|
||||
if %type ^advanced_trade_fill$
|
||||
& %advanced_trade_fill_order_side ^sell$
|
||||
& %small_satoshi_multiplier [1-9]
|
||||
amount -%amount_amount %amount_currency @@ %small_satoshi_multiplier %native_amount_currency
|
||||
comment2 %created_at +0000,SELL,coinbase,%amount_currency,%amount_amount,%native_amount_currency,%small_satoshi_multiplier,%native_amount_currency,%advanced_trade_fill_commission
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
Reference in New Issue
Block a user