home *** CD-ROM | disk | FTP | other *** search
- /*
-
- ca2ac - Convert from CheckbookAccountant printed output
- to AmiCheck import format
-
- Synopsis:
-
- ca2ac <input file> <output file>
-
- Parameters:
-
- <input file>
- a "print" file produced by CheckbookAccountant's print function.
-
- <output file>
- where the converted data should go
-
- Description:
-
- This program converts the output produced via
- CheckbookAccountant's "Print" function to an input suitable for
- importation via AmiCheck's ASCII import function. It completely
- converts the data generated when *only* the "Viewable
- Transactions" option is selected in the "Print" requester.
-
- This means that it doesn't handle budgets at all. Note that
- CA allows you to split a transaction into several budget
- categories, which AmiCheck doesn't handle (yet). This makes it
- a bit difficult to do a complete conversion, so don't jettison
- your CBA data files yet!
-
- To generate the input data file:
-
- 1. CA should be running with your account opened
-
- 2. select the Print option under the File Menu
-
- 3. Select the Disk File option in the Print Requester and
- select a file using the resulting File Requester
-
- 4. Select *only* the Viewable Transactions option
-
- 5. Click on the "Ok..." button.
-
- CA will then create the file you specified in step 3. It's
- ASCII, so if you want to see what information will be translated,
- take a gander at it with your favorite text viewer.
-
- Then, run it through ca2ac and import the resultant file into
- AmiCheck via the ASCII import function (see the AmiCheck guide for
- more details).
-
- ca2ac does the following category conversions:
-
- * If the CA entry has the description "Payroll", it makes the
- Category "Salary"
-
-
- Caveats:
-
- There isn't much error checking in this program.
-
- It's pretty simple.
-
- I didn't test the "Taxable" flag conversion, as I don't use it.
- It "should" work.
-
- If the check is voided, CA doesn't put in a date, but AmiCheck
- gets upset if there isn't one. I hardwired the date for voided
- checks to 01/01/1900
-
-
- Distribution:
-
- This is in the public domain. Do with it what you will, but don't
- make it write bad checks.
-
- History:
-
- 1995-07-20 First public release
-
-
- Author:
-
- Diab Jerius djerius@cfa.harvard.edu
-
- */
-
- parse arg file.in file.out .
-
- if file.in = '' | file.out = '' then do
- say 'usage: ca2ac <input file> <output file>'
- exit 10
- end
-
- if ~open( 'input', file.in, 'R' ) then do
- say 'unable to open' file.in
- exit 10
- end
-
- if ~open( 'output', file.out, 'W' ) then do
- say 'unable to open' file.out
- exit 10
- end
-
-
- /* skip first four lines */
- do for 4
- call readln( 'input' )
- end
-
- if eof( 'input' ) then do
- say 'premature EOF on' file.in
- exit 10
- end
-
- /* write out header for AmiCheck import file */
- call writeln( 'output', 'Source' file.out )
-
- count = 0
-
- do while ~eof( 'input' )
-
- line1 = readln( 'input' )
- line2 = readln( 'input' )
-
- if eof( 'input' ) then leave
-
- /* first line is split into 7 sections by column:
- Number, Date, Description, Taxable, Cleared, Sign, Amount
- */
- parse value line1 with 1 number +6 +1 date +10 +2 description +46 +1 taxable
- +1 cleared +1 sign +1 amount .
-
- /* second line is split into two sections by column, memo and running total */
-
- parse value line2 with 20 memo +46 .
-
- call write_entry( number, date, description, taxable, cleared, sign, amount, m
- emo )
-
- count = count + 1
-
- /* get rid of last line */
- call readln( 'input' )
- end
-
- call close( 'input' )
- call close( 'output' )
-
- say 'wrote' count 'entries'
-
- exit 0
-
- write_entry: procedure
- parse arg number, date, description, taxable, cleared, sign, amount, memo
-
- number = strip( number )
- description = strip( description )
- memo = strip( memo )
- amount = compress( amount, ',' )
-
- if number = '' then do
- if sign = '+' then number = 'deposit'
- else number = 'withdrawl'
- end
-
- if cleared = 'C' then state = Y
- else state = N
-
- if taxable = 'T' then state = state || 'Y'
- else state = state || 'N'
-
- if description = '** VOIDED **' then do
- state = state || 'Y'
- date = '01/01/1900'
- end
- else state = state || 'N'
-
- category = ''
- if index( 'Payroll', description ) then category = 'Salary'
-
- call writeln( 'output', '' )
- call writeln( 'output', 'type ' number )
- call writeln( 'output', 'amount ' amount )
- call writeln( 'output', 'date ' date )
- call writeln( 'output', 'name ' description )
- call writeln( 'output', 'addr1 ' )
- call writeln( 'output', 'addr2 ' )
- call writeln( 'output', 'addr3 ' )
- call writeln( 'output', 'memo ' memo )
- call writeln( 'output', 'state ' state )
- call writeln( 'output', 'category' '0.00' category )
-
- return
-
-