Annotation of pta/pta_import.1, Revision 1.11
1.11 ! freda 1: .\" $Id: pta_import.1,v 1.10 2020/11/30 16:19:19 freda Exp $
1.1 schwarze 2: .\"
3: .\" Copyright (c) 2020 Freda Bundchen
4: .\"
5: .\" Permission to use, copy, modify, and distribute this software for any
6: .\" purpose with or without fee is hereby granted, provided that the above
7: .\" copyright notice and this permission notice appear in all copies.
8: .\"
9: .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16: .\"
1.11 ! freda 17: .Dd $Mdocdate: November 30 2020 $
1.1 schwarze 18: .Dt PTA_IMPORT 1
19: .Os
20: .Sh NAME
21: .Nm pta_import
22: .Nd print pta journal entries from bank CSV file input
23: .Sh SYNOPSIS
24: .Nm pta_import
1.5 schwarze 25: .Fl I Ar accountname
1.2 schwarze 26: .Op Ar file
1.1 schwarze 27: .Sh DESCRIPTION
28: The
29: .Nm
1.2 schwarze 30: utility converts lines from a CSV
31: .Ar file
32: generated by a financial
1.1 schwarze 33: institution into journal entries used by
34: .Xr pta 1 .
1.2 schwarze 35: .Pp
36: If the
37: .Ar file
38: argument is omitted, standard input is read instead.
1.3 schwarze 39: .Pp
1.5 schwarze 40: .Ar accountname
1.3 schwarze 41: is exactly one of
1.4 schwarze 42: .Pp
43: .Bl -bullet -offset indent -compact
44: .It
1.6 freda 45: .Cm bbva_usa
46: .It
1.9 freda 47: .Cm capital_one_360
48: .It
1.4 schwarze 49: .Cm capital_one_credit
50: .It
51: .Cm chase_credit
52: .It
1.9 freda 53: .Cm etrade_ira
54: .It
1.4 schwarze 55: .Cm optum_hsa
1.6 freda 56: .It
57: .Cm sparkasse_camt
58: .It
59: .Cm wellsfargo
1.3 schwarze 60: .El
61: .Pp
62: and corresponds to an existing
1.8 freda 63: .Pa ./import/ Ns Ar accountname Ns Pa .txt
64: configuration file.
1.5 schwarze 65: .Ss Configuration file format
1.8 freda 66: Each configuration file contains rules
1.7 freda 67: used to import transactions from a financial institution.
1.5 schwarze 68: Like all
69: .Xr pta 1
70: input files, it is an
71: .Xr ascii 7
72: text file using strings of one or more space characters
73: as the field delimiter and using the hash character
74: .Pq Sq #
75: in the first column to mark lines as ignored.
76: .Pp
1.7 freda 77: The rules are as follows:
78: .Bl -tag -width Ds
79: .It Ic ACCOUNT Ar csv_account_number
80: The number in
81: .Xr pta-accounts 5
82: of the bank or credit card account this CSV file contains entries for.
83: This rule is required in every configuration file.
1.11 ! freda 84: .It Ic AMOUNT Oo Ar debit_column Oc Ar credit_column
! 85: The column numbers in the CSV file containing amounts to be
! 86: booked on the debit or credits side of the contra account
! 87: .Ar account_number ,
! 88: respectively.
! 89: If
! 90: .Ar debit_column
! 91: is omitted, amounts preceded by a minus sign or enclosed
! 92: in parentheses are booked to the debit side.
1.10 freda 93: .It Ic COSTCENTER Ar costcenter_column
94: The column number in the CSV file containing the cost center.
95: Numbering starts from 1.
96: If this rule is not specified, no cost centers are assigned.
97: .It Ic DATE Ar date_column date_format
98: The column number in the CSV file containing the date.
99: Numbering starts from 1.
100: The
101: .Ar date_format
102: is one of
103: .Ic MM/DD/YY ,
104: .Ic MM/DD/YYYY ,
105: .Ic YYYY-MM-DD ,
106: or
107: .Ic DD.MM.YY .
108: This rule is required in every configuration file.
1.11 ! freda 109: .It Ic DESCRIPTION Ar descr_column ...
! 110: The column numbers in the CSV file to be concatenated to form the
! 111: text string for the journal entry.
! 112: Numbering starts from 1.
1.7 freda 113: .It Ic DELIM Ar delimiter
114: The character used to separate fields.
115: This rule is required in every configuration file.
116: Most financial institutions use commas but some use semicolons.
117: .It Ic HEADER Ar header
118: Skip the first line of the CSV file if it matches the
119: .Ar header
120: line verbatim, or cause parsing to fail if it does not.
121: .It Ic IGNORE Ar regular_expression
122: Skip all lines in the CSV file matching the
123: .Ar regular_expression .
1.10 freda 124: .It Ic QUANTITY Ar quantity_column
125: The column number in the CSV file containing the number of stock shares.
126: Numbering starts from 1.
127: If this rule is not specified, no information about the number of traded
128: securities is appended to the text string.
1.7 freda 129: .It Ic QUOTE Ar quote
130: Expects that every field starts and ends with the
131: .Ar quote
132: character.
133: .It Ar selector account_number booking_identifier
134: Lines in the CSV file that match the
1.5 schwarze 135: .Ar selector
1.7 freda 136: are associated with the contra account
1.5 schwarze 137: .Ar account_number
1.7 freda 138: and are assigned the
139: .Ar booking_identifier .
140: The selector is a string consisting of regular expressions separated
141: by delimiters defined in the
142: .Ic DELIM
143: rule.
144: .El
1.1 schwarze 145: .Sh FILES
1.4 schwarze 146: .Bl -tag -width Ds -compact
1.8 freda 147: .It Pa ./import/bbva_usa.txt
1.9 freda 148: .It Pa ./import/capital_one_360.txt
1.8 freda 149: .It Pa ./import/capital_one_credit.txt
150: .It Pa ./import/chase_credit.txt
1.9 freda 151: .It Pa ./import/etrade_ira.txt
152: .It Pa ./import/optum_hsa.txt
1.8 freda 153: .It Pa ./import/sparkasse_camt.txt
154: .It Pa ./import/wellsfargo.txt
1.1 schwarze 155: .El
1.3 schwarze 156: .Pp
157: These files contain the header that the financial institution uses, the
158: account number from
159: .Pa ./accounts.txt
160: used by this account, as well as patterns used to map transactions to
161: the correct account and booking identifier.
1.1 schwarze 162: .Sh EXIT STATUS
163: .Ex -std
164: .Sh EXAMPLES
165: Add journal entries to a journal file using a CSV file generated by
166: a financial institution:
167: .Pp
1.3 schwarze 168: .Dl "$ pta_import -I chase_credit chasedownload.csv >> journal.txt"
1.5 schwarze 169: .Ss Account numbers in the configuration file
170: The line
1.1 schwarze 171: .Pp
1.5 schwarze 172: .Dl ACCOUNT 3235
1.3 schwarze 173: .Pp
1.5 schwarze 174: in the configuration file corresponds to a line such as
1.3 schwarze 175: .Pp
1.5 schwarze 176: .Dl 3235 L Capital One credit card
1.3 schwarze 177: .Pp
178: in
1.5 schwarze 179: .Pa ./accounts.txt .
1.1 schwarze 180: .Pp
1.3 schwarze 181: The description
182: .Qq Capital One credit card
183: may vary, but in this example, the account numbers
1.5 schwarze 184: .Qq 3235
1.3 schwarze 185: match, and the account type is
186: .Qq L
187: to indicate that it is a liability account.
1.5 schwarze 188: .Ss Patterns in the configuration file
1.3 schwarze 189: Suppose
1.4 schwarze 190: .Pp
1.3 schwarze 191: .Dl ,,,Automotive,,, 1111 AUTO
192: .Pp
193: is a sample entry in the
1.8 freda 194: .Pa ./import/chase_credit.txt
1.3 schwarze 195: file which uses headers of the form
196: .Pp
197: .Dl Transaction Date,Post Date,Description,Category,Type,Amount
198: .Pp
199: Then this
200: .Ar selector
201: ignores the transaction date, post date, description, type, and amount.
202: It matches the
203: .Qq Automotive
204: category and maps transactions to account
205: .Qq 1111
206: defined in
207: .Pa ./accounts.txt
208: with the
209: .Qq Auto
210: booking identifier.
1.5 schwarze 211: .Ss A sample credit card purchase
212: If
213: .Pa chasedownload.csv
214: file contains
215: .Pp
216: .Dl "10/26/2020,10/26/2020,example.com*asldfkj,Shopping,Sale,-17.07"
217: .Pp
218: and
1.8 freda 219: .Pa ./import/chase_credit.txt
1.5 schwarze 220: contains
221: .Bd -literal -offset Ds
222: ACCOUNT 3234
223: ,,,Shopping,,, 9996 SHOP
224: .Ed
225: .Pp
226: and
227: .Pa ./accounts.txt
228: contains
229: .Bd -literal -offset Ds
230: 3234 L Chase credit card
231: 9996 X shopping
232: .Ed
233: .Pp
234: then the
235: .Qq Shopping
236: category defined by Chase is mapped to the user's
237: .Qq SHOP
238: booking identifier, the user's account for shopping
239: expenses is defined as
240: .Qq 9996
241: in their
242: .Pa ./accounts.txt ,
243: the user's account for the credit card is 3234 in their
244: .Pa ./accounts.txt ,
245: and
246: .Nm
247: prints
248: .Pp
249: .Dl "20201026 SHOP 9996 3234 17.07 example.com*asldfkj"
1.3 schwarze 250: .Ss A complete example
251: Suppose
252: .Pa ./accounts.txt
253: is given by
254: .Bd -literal
255: 1700 A My Bank
256: 3234 L My Chase Credit Card
257: 5102 X Physician expenses
258: 5103 X Dental expenses
259: 5203 X Shopping
260: .Ed
1.1 schwarze 261: .Pp
1.3 schwarze 262: and
263: .Pa chasedownload.csv
264: is given by
265: .Bd -literal
266: Transaction Date,Post Date,Description,Category,Type,Amount,Memo
267: 11/06/2020,11/09/2020,Dr. Joseph Schmoe,Health & Wellness,Sale,-100.00,
268: 11/06/2020,11/09/2020,Dr. Sally Sue,Health & Wellness,Sale,-183.00,
269: 11/08/2020,11/08/2020,example.com,Shopping,Sale,-53.83,
270: 11/04/2020,11/04/2020,Payment Thank You - Web,,Payment,75.43,
271: .Ed
1.1 schwarze 272: .Pp
1.3 schwarze 273: and
1.8 freda 274: .Pa ./import/chase_credit.txt
1.3 schwarze 275: is given by
276: .Bd -literal
277: # Chase credit card header is
278: # Transaction Date,Post Date,Description,Category,Type,Amount
279: # The format of this file is
280: # selector account_number booking_identifier
281: # selector is a comma-separated list of regular expressions which
282: # matches corresponding fields in the CSV file
283: ACCOUNT 3234
284: ,,,Automotive,,, 1111 AUTO
285: ,,,Bills & Utilities,,, 2222 BILLS
286: ,,,Fees & Adjustments,,, 3333 FEES
287: ,,,Food & Drink,,, 4444 FOOD
288: ,,,Gas,,, 5555 GAS
289: ,,,Gifts & Donations,,, 6666 GIFTS
290: ,,,Groceries,,, 7777 GROCERIES
291: ,,Dr. Sally Sue,,,, 5103 DENTAL
292: ,,,Health & Wellness,,, 5102 PHYSICIAN
293: ,,,Home,,, 9999 HOME
294: ,,,Personal,,, 9998 PERSONAL
295: ,,,Professional Services,,, 9997 PRO
296: ,,,Shopping,,, 5203 SHOP
297: ,,,,Payment,, 1700 PAY
298: .Ed
1.1 schwarze 299: .Pp
300: Then
1.4 schwarze 301: .Pp
1.3 schwarze 302: .Dl pta_import -I chase_credit chasedownload.csv
1.4 schwarze 303: .Pp
1.3 schwarze 304: outputs
305: .Bd -literal
306: 20201109 PHYSICIAN 5102 3234 100.00 Dr. Joseph Schmoe
307: 20201109 DENTAL 5103 3234 183.00 Dr. Sally Sue
308: 20201108 SHOP 5203 3234 53.83 example.com
309: 20201104 PAY 3234 1700 75.43 Payment Thank You - Web
310: .Ed
1.5 schwarze 311: .Pp
312: Note that the selector for Dr\&. Sally Sue
313: in the example configuration file comes before the
314: Health & Wellness selector.
315: Since the first match wins, transactions for Dr\&. Sally Sue
316: can be classified with the DENTAL booking identifier,
317: even though the bank's CSV file classifies
318: these transactions as Health & Wellness.
1.1 schwarze 319: .Sh SEE ALSO
320: .Xr pta-accounts 5 ,
321: .Xr pta-journal 5 ,
322: .Xr pta-glossary 7
323: .Sh BUGS
324: Currently,
325: .Nm
326: has the following limitations:
327: .Bl -dash
328: .It
1.3 schwarze 329: Pattern recognition in the
1.8 freda 330: .Pa import/accountname.txt
1.3 schwarze 331: files is under continued development.
332: .It
1.9 freda 333: User-defined configuration files are not currently
334: supported.
1.1 schwarze 335: .El
CVSweb