diff --git a/container/src/hledger-flow/accounts/btcpayserver/btcpayserver-shared.bash b/container/src/hledger-flow/accounts/btcpayserver/btcpayserver-shared.bash index cb74e17..f188f68 100755 --- a/container/src/hledger-flow/accounts/btcpayserver/btcpayserver-shared.bash +++ b/container/src/hledger-flow/accounts/btcpayserver/btcpayserver-shared.bash @@ -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) diff --git a/container/src/hledger-flow/accounts/btcpayserver/btcpayserver-shared.rules b/container/src/hledger-flow/accounts/btcpayserver/btcpayserver-shared.rules index 18ec31b..1140695 100644 --- a/container/src/hledger-flow/accounts/btcpayserver/btcpayserver-shared.rules +++ b/container/src/hledger-flow/accounts/btcpayserver/btcpayserver-shared.rules @@ -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$