# docker-finance | modern accounting for the power-user
#
# Copyright (C) 2024-2025 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 timestamp,txid,type,from_address,from_amount,from_currency,to_amount,to_currency,fee_amount,fee_currency,direction,subaccount

date-format %Y-%m-%d %H:%M:%S %z
date %timestamp

description %timestamp

comment type:%type, txid:%txid, direction:%direction

# Default equity transfer
if %direction ^IN$
  account1 assets:adalite:%subaccount:%from_currency
  amount %from_amount %from_currency
  account2 equity:adalite:%subaccount:withdrawal:%from_currency

# Default expense
if %direction ^OUT$
  account1 assets:adalite:%subaccount:%to_currency
  amount -%to_amount %to_currency
  account2 expenses:adalite:%subaccount:%to_currency

if %direction ^OUT$
& %fee_amount [1-9]
  account3 assets:adalite:%subaccount:%fee_currency
  amount3 -%fee_amount %fee_currency
  account4 expenses:adalite:%subaccount:fees:%fee_currency
  amount4 %fee_amount %fee_currency
  comment type:%type, txid:%txid, direction:%direction, taxed_as:SPEND
  comment3 %timestamp,SPEND,adalite:%subaccount,%fee_currency,%fee_amount,USD,,FEE
# Using comment3 so a comment2 SPEND isn't overwritten (when applicable)

# vim: sw=2 sts=2 si ai et
