/
libofx.rb
138 lines (128 loc) 路 4.66 KB
/
libofx.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
class Libofx < Formula
desc "Library to support OFX command responses"
homepage "https://github.com/libofx/libofx"
url "https://github.com/libofx/libofx/releases/download/0.10.9/libofx-0.10.9.tar.gz"
sha256 "1ca89ff7d681c9edad312172ac464231a8de686e653213612f9417492cef0d37"
license "GPL-2.0-or-later"
bottle do
sha256 arm64_sonoma: "ed293b1aa272081ac72e90ed0fde58477750798dccfc1daaa7c46813d950f268"
sha256 arm64_ventura: "4c2f9ec0e41e667c21b2a6c1fbe81d11e356e1d5d5afdf80b1f3e771a6da3183"
sha256 arm64_monterey: "c6e732fd8e3dac426fea0f2845c634af8542661058265f43886ef2f65828f95f"
sha256 arm64_big_sur: "0cbb926e59cd1032c9db87a9c4b33747a45dc6f48b2e4a1c26fefd066401c8f5"
sha256 sonoma: "5b79bf585dd46d33881ce4627fc9b05ec5263090299e85b43121e46d74779ca6"
sha256 ventura: "64a1c8fe606555249a4a3610912062525f0253c98f479f1246d7cd57355d185d"
sha256 monterey: "aa32a1500793c8add1ae49017887b2288f5c0d921d4db3681c1150f854da1038"
sha256 big_sur: "8e0d20d6e6f664a559e2e4cd665562b514b17ec491fe9a433bc8b85fb4ba221e"
sha256 catalina: "08593e309b9133e1b534200b44ed4a87446fa305f63dfdc79e1de93a9ac22835"
sha256 x86_64_linux: "88107478b5837f83a6f9f6f99279b3fa10c9465b7fca30fb52ff51a6b07f1271"
end
head do
url "https://github.com/libofx/libofx.git", branch: "master"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "gengetopt" => :build
depends_on "libtool" => :build
end
depends_on "open-sp"
def install
ENV.cxx11
system "./autogen.sh" if build.head?
opensp = Formula["open-sp"]
system "./configure", "--disable-dependency-tracking",
"--with-opensp-includes=#{opensp.opt_include}/OpenSP",
"--with-opensp-libs=#{opensp.opt_lib}",
"--prefix=#{prefix}"
system "make", "install"
end
test do
(testpath/"test.ofx").write <<~EOS
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX>
<SIGNONMSGSRSV1>
<SONRS>
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<DTSERVER>20130525225731.258
<LANGUAGE>ENG
<DTPROFUP>20050531060000.000
<FI>
<ORG>FAKE
<FID>1101
</FI>
<INTU.BID>51123
<INTU.USERID>9774652
</SONRS>
</SIGNONMSGSRSV1>
<BANKMSGSRSV1>
<STMTTRNRS>
<TRNUID>0
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<STMTRS>
<CURDEF>USD
<BANKACCTFROM>
<BANKID>5472369148
<ACCTID>145268707
<ACCTTYPE>CHECKING
</BANKACCTFROM>
<BANKTRANLIST>
<DTSTART>20000101070000.000
<DTEND>20130525060000.000
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20110331120000.000
<TRNAMT>0.01
<FITID>0000486
<NAME>DIVIDEND EARNED FOR PERIOD OF 03
<MEMO>DIVIDEND ANNUAL PERCENTAGE YIELD EARNED IS 0.05%
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20110405120000.000
<TRNAMT>-34.51
<FITID>0000487
<NAME>AUTOMATIC WITHDRAWAL, ELECTRIC BILL
<MEMO>AUTOMATIC WITHDRAWAL, ELECTRIC BILL WEB(S )
</STMTTRN>
<STMTTRN>
<TRNTYPE>CHECK
<DTPOSTED>20110407120000.000
<TRNAMT>-25.00
<FITID>0000488
<CHECKNUM>319
<NAME>RETURNED CHECK FEE, CHECK # 319
<MEMO>RETURNED CHECK FEE, CHECK # 319 FOR $45.33 ON 04/07/11
</STMTTRN>
</BANKTRANLIST>
<LEDGERBAL>
<BALAMT>100.99
<DTASOF>20130525225731.258
</LEDGERBAL>
<AVAILBAL>
<BALAMT>75.99
<DTASOF>20130525225731.258
</AVAILBAL>
</STMTRS>
</STMTTRNRS>
</BANKMSGSRSV1>
</OFX>
EOS
output = shell_output("#{bin}/ofxdump #{testpath}/test.ofx")
assert_equal output.scan(/Account ID\s?: 5472369148 145268707/).length, 5
%w[0000486 0000487 0000488].each do |fid|
assert_match "Financial institution's ID for this transaction: #{fid}", output
end
end
end