git ssb

0+

cel / ledger-scripts



Tree: f1521af2d73e96acaa4e96dfc60dbfc50373845a

Files: f1521af2d73e96acaa4e96dfc60dbfc50373845a / electrum2ledger

1056 bytesRaw
1#!/usr/bin/awk -f
2
3BEGIN {
4 FPAT = "([^,]*)|(\"[^\"]+\")";
5 assets_account="Assets:Bitcoin:Electrum";
6 fee_account="Expenses:Broker:Miner Fees";
7 expenses_account="Expenses";
8 income_account="Income";
9}
10
11# Skip header
12/^transaction_hash.*/ {
13 next;
14}
15
16# Read transaction
17{
18 transaction_hash=$1
19 label=$2
20 confirmations=$3
21 value=+$4
22 fee=+$5
23 balance=$6
24 timestamp=$7
25
26 # Format date
27 i = index(timestamp, " ")-1;
28 date = substr(timestamp, 0, i);
29 gsub("-", "/", date);
30
31 # Remove quotes
32 sub(/^"(.*)"$/, "$1", label);
33
34 # Print fee only if we paid it
35 if (value > 0) {
36 fee = 0;
37 }
38
39 printf "; %s\n", transaction_hash;
40 printf "%s %s\n", date, label;
41 printf " %-32s %12.8f BTC\n", assets_account, value;
42 if (value < 0) {
43 if (fee) {
44 printf " %-32s %12.8f BTC\n", fee_account, -fee;
45 }
46 printf " %-32s %12.8f BTC\n", expenses_account, fee-value;
47 } else {
48 printf " %s\n", income_account;
49 }
50 print "";
51}
52

Built with git-ssb-web