Files
docker-finance/container/src/hledger-flow/accounts/btcpayserver/btcpayserver-shared.rules
Aaron Fiore 5352e34196 hledger-flow: btcpayserver: add prelim support for v2 reports
- Removes previous format (fully deprecated)
- Adds support for "Legacy Invoice" and "Wallets" reports

See code notes regarding caveats and TODOs.
2025-02-07 21:22:54 -08:00

82 lines
3.5 KiB
Plaintext

# docker-finance | modern accounting for the power-user
#
# Copyright (C) 2021-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/>.
# TODO: currently, only supports "Legacy Invoice" and "Wallets" format (w/ additional custom columns)
fields ReceivedDate,StoreId,OrderId,InvoiceId,InvoiceCreatedDate,InvoiceExpirationDate,InvoiceMonitoringDate,txid,index,Destination,PaymentType,CryptoCode,Paid,NetworkFee,ConversionRate,PaidCurrency,InvoiceCurrency,InvoiceDue,InvoicePrice,InvoiceItemCode,InvoiceItemDesc,InvoiceFullStatus,InvoiceStatus,InvoiceExceptionStatus,BuyerEmail,Accounted,direction,subaccount
# NOTE: BTCPayServer exports to localtime
date-format %Y-%m-%d %H:%M:%S
date %ReceivedDate
description %ReceivedDate
if %InvoiceItemDesc [a-z0-9]
description %ReceivedDate | %InvoiceItemDesc
account1 assets:btcpayserver:%subaccount:%CryptoCode
amount %Paid %CryptoCode
# If invoice is expired or otherwise not accounted for, skip
if %Accounted ^[^a-z]*$
skip
#
# Comment
#
# Default comment
comment created:%InvoiceCreatedDate, expired:%InvoiceExpirationDate, store_id:%StoreId, order_id:%OrderId, invoice_id:%InvoiceId, type:%PaymentType, to_address:%Destination, txid:%txid, index:%index, status:%InvoiceStatus, direction:%direction
# Comment w/ item code
if %InvoiceItemCode [a-z0-9]
comment created:%InvoiceCreatedDate, expired:%InvoiceExpirationDate, store_id:%StoreId, order_id:%OrderId, invoice_id:%InvoiceId, item_code:%InvoiceItemCode, type:%PaymentType, to_address:%Destination, txid:%txid, index:%index, status:%InvoiceStatus, direction:%direction
# Comment w/ buyer email
if %BuyerEmail [a-z0-9]
comment created:%InvoiceCreatedDate, expired:%InvoiceExpirationDate, store_id:%StoreId, order_id:%OrderId, invoice_id:%InvoiceId, email:%BuyerEmail, type:%PaymentType, to_address:%Destination, txid:%txid, index:%index, status:%InvoiceStatus, direction:%direction
# Comment w/ both item code + buyer email
if %InvoiceItemCode [a-z0-9]
& %BuyerEmail [a-z0-9]
comment created:%InvoiceCreatedDate, expired:%InvoiceExpirationDate, store_id:%StoreId, order_id:%OrderId, invoice_id:%InvoiceId, item_code:%InvoiceItemCode, email:%BuyerEmail, type:%PaymentType, to_address:%Destination, txid:%txid, index:%index, status:%InvoiceStatus, direction:%direction
# Comment for "Wallets" export
if %direction ^OUT$
comment txid:%txid, confirmed:%Accounted, direction:%direction
#
# Direction
#
# Default income
if %direction ^IN$
account2 income:btcpayserver:%subaccount:%CryptoCode
comment2 %ReceivedDate,INCOME,btcpayserver:%subaccount,%CryptoCode,%Paid,%InvoiceCurrency,%PaidCurrency,%InvoiceId
# Default equity transfer
if %direction ^OUT$
account2 equity:btcpayserver:%subaccount:deposit:%CryptoCode
# TODO:
#
# WARNING:
#
# - All outgoing txs do *not* account for fees (they are lumped in with the total).
# * Until upstream changes this, any fees must be separated manually w/ custom rules.
# vim: sw=2 sts=2 si ai et