Merge pull request #183 into master

99c7075 hledger-flow: btcpayserver: add local timezone support (Aaron Fiore)
338053e hledger-flow: btcpayserver: add taxed_as INCOME tag (Aaron Fiore)
This commit is contained in:
2025-03-05 16:44:16 -08:00
2 changed files with 32 additions and 10 deletions

View File

@@ -77,13 +77,29 @@ function btcpayserver::legacy()
if (NR<2 || $1 !~ global_year)
next
printf $1 OFS # ReceivedDate
# ReceivedDate (w/ local timezone added)
sub(/ /, "T", $1) # HACK: makes arg-friendly by removing space
cmd = "date \"+%F %T %z\" --date="$1 | getline date
printf date OFS
printf $2 OFS # StoreId
printf $3 OFS # OrderId
printf $4 OFS # InvoiceId
printf $5 OFS # InvoiceCreatedDate
printf $6 OFS # InvoiceExpirationDate
printf $7 OFS # InvoiceMonitoringDate
# InvoiceCreatedDate (w/ local timezone added)
sub(/ /, "T", $5)
cmd = "date \"+%F %T %z\" --date="$5 | getline date
printf date OFS
# InvoiceExpirationDate (w/ local timezone added)
sub(/ /, "T", $6)
cmd = "date \"+%F %T %z\" --date="$6 | getline date
printf date OFS
# InvoiceMonitoringDate (w/ local timezone added)
sub(/ /, "T", $7)
cmd = "date \"+%F %T %z\" --date="$7 | getline date
printf date OFS
# PaymentId
# NOTE: BTCPay Server will append the block index as "-N" to the txid
@@ -160,7 +176,11 @@ function btcpayserver::wallets()
if ($6 !~ /^-/)
next
printf $1 OFS # Date (ReceivedDate)
# Date (ReceivedDate w/ local timezone added)
sub(/ /, "T", $1) # HACK: makes arg-friendly by removing space
cmd = "date \"+%F %T %z\" --date="$1 | getline date
printf date OFS
printf OFS # (StoreId)
printf OFS # (OrderId)
printf $4 OFS # InvoiceId (InvoiceId)

View File

@@ -19,7 +19,7 @@
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-format %Y-%m-%d %H:%M:%S %z
date %ReceivedDate
description %ReceivedDate
@@ -38,21 +38,23 @@ if %Accounted ^[^a-z]*$
# Comment
#
# NOTE: all IN assumed to be INCOME
# 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 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, taxed_as:INCOME
# 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 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, taxed_as:INCOME
# 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 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, taxed_as:INCOME
# 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 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, taxed_as:INCOME
# Comment for "Wallets" export
if %direction ^OUT$