Finance::IIF |
Finance::IIF - Parse and create IIF files for QuickBooks
use Finance::IIF; my $iif = Finance::IIF->new( file => "test.iif" ); while ( my $record = $iif->next ) { print( "Header: ", $record->{header}, "\n" ); foreach my $key ( keys %{$record} ) { print( " ", $key, ": ", $record->{$key}, "\n" ); } }
Finance::IIF is a module for working with IIF files for QuickBooks in Perl. This module reads IIF data records from a file passing each successive record to the caller for processing.
A hash reference is returned for each record read from a file. The hash will have a ``header'' value which contains the header type that was read along with all supported values found for that record. If a value is not specified in the data file, the value will not exist in this hash.
No processing or validation is done on values found in files or data structures to try and convert them into appropriate types and formats. It is expected that users of this module or extensions to this module will do any additional processing or validation as required.
TRNS (QuickBooks can't export but does import this format) TRNS SPLT CODE IIF QIF CODE IIF QIF TRNSID SPLID TRNSTYPE TRNSTYPE TRANSTYPE TRANSTYPE date DATE D DATE ACCNT category ACCNT S payee NAME P NAME amount ACCOUNT T CLASS number DOCNUM N amount AMOUNT $ memo MEMO M DOCNUM status CLEAR C memo MEMO E TOPRINT CLEAR NAMEISTAXABLE QNTY NAMEIS TAXABLE PRICE address ADDR1 A REIMBEXP address ADDR2 A INVITEM address ADDR3 A SERVICEDATE address ADDR4 A TAXABLE address ADDR5 A PAYMETH DUEDATE OTHER2 TERMS VALADJ SHIPVIA YEARTODATE PAID OTHER3 SHIPDATE OTHER1 YEARTODATE REP FOB PONUM INVTITLE INVMEMO SADDR1 SADDR2 category L
QuickBooks doesn't support investment accounts Quicken does.
HDR (Generated in every export) PROD VER REL IIFVER DATE TIME
In QuickBooks accounts and categories are the same thing accounts. In Quicken they are separate accounts and categories.
ACCNT (Chart of Accounts) CODE IIF QIF Account QIF Category name NAME N N REFNUM TIMESTAMP type ACCNTTYPE T balance OBAMOUNT B description DESC D D ACCNUM SCD EXTRA limit L tax X T note A expense E income I schedule R
Customer, Vendor, Employee, Other Name are all possible payee's in QuickBooks in Quicken you don't really have a notion of payee.
CUST (Customer List) NAME REFNUM TIMESTAMP BADDR1 BADDR2 BADDR3 BADDR4 BADDR5 SADDR1 SADDR2 SADDR3 SADDR4 SADDR5 PHONE1 PHONE2 FAXNUM CONT1 CONT2 CTYPE TERMS TAXABLE LIMIT RESALENUM REP TAXITEM NOTEPAD SALUTATION COMPANYNAME FIRSTNAME MIDINIT LASTNAME CUSTFLD1 CUSTFLD2 CUSTFLD3 CUSTFLD4 CUSTFLD5 CUSTFLD6 CUSTFLD7 CUSTFLD8 CUSTFLD9 CUSTFLD10 CUSTFLD11 CUSTFLD12 CUSTFLD13 CUSTFLD14 CUSTFLD15 VEND (Vendor List) NAME REFNUM TIMESTAMP PRINTAS ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 VTYPE CONT1 CONT2 PHONE1 PHONE2 FAXNUM NOTE TAXID LIMIT TERMS NOTEPAD SALUTATION COMPANYNAME FIRSTNAME MIDINIT LASTNAME CUSTFLD1 CUSTFLD2 CUSTFLD3 CUSTFLD4 CUSTFLD5 CUSTFLD6 CUSTFLD7 CUSTFLD8 CUSTFLD9 CUSTFLD10 CUSTFLD11 CUSTFLD12 CUSTFLD13 CUSTFLD14 CUSTFLD15 1099 EMP (Employee List) EMP QBP CUSTOMPI HOURLYPI LOCALPI NAME EMPLOYEE PAYITEM PAYITEM PAYITEM REFNUM NAME AMOUNT AMOUNT AMOUNT TIMESTAMP REFNUM LIMIT LIMIT LIMIT INIT TIMESTAMP LOCALITY ADDR1 SALARY W2LOCNAME ADDR2 PAYPERIOD ADDR3 CLAS ADDR4 NUMCUSTOM ADDR5 NUMHOURLY SSNO SICKACCRL PHONE1 SICKRATE PHONE2 SICKACCRD NOTEPAD SICKUSED FIRSTNAME VACACCRL MIDINIT VACRATE LASTNAME VACACCRD SALUTATION VACUSED CUSTFLD1 HIREDATE CUSTFLD2 RELEASEDATE CUSTFLD3 FEDSTATUS CUSTFLD4 FEDALLOW CUSTFLD5 FEDEXTRA CUSTFLD6 STATESWH CUSTFLD7 STATESDI CUSTFLD8 STATESUI CUSTFLD9 PAYITEMSWH CUSTFLD10 PAYITEMSDI CUSTFLD11 PAYITEMSUI CUSTFLD12 STATESTATUS CUSTFLD13 STATEALLOW CUSTFLD14 STATEEXTRA CUSTFLD15 STATEMISC FEDTAX SSEC MCARE FUTA TIMECARD CARRYSICK CARRYVAC SICKPERPAY VACPERPAY OTHERNAME (Other Name List) NAME REFNUM TIMESTAMP BADDR1 BADDR2 BADDR3 BADDR4 BADDR5 PHONE1 PHONE2 FAXNUM CONT1 NOTEPAD SALUTATION COMPANYNAME FIRSTNAME MIDINIT LASTNAME
CTYPE (Customer Type List) NAME REFNUM TIMESTAMP
VTYPE (Vendor Type List) NAME REFNUM TIMESTAMP
CLASS (Class List) CODE IIF QIF name NAME N REFNUM TIMESTAMP description D
INVITEM (Item List) INVITEM INVITEM NAME NAME REFNUM REFNUM TIMESTAMP TIMESTAMP INVITEMTYPE INVITEMTYPE DESC DESC PURCHASE TOPRINT DESC EXTRA ACCNT QNTY ASSETACCNT CUSTFLD1 COGSACCNT CUSTFLD2 PRICE CUSTFLD3 COST CUSTFLD4 TAXABLE CUSTFLD5 PAYMETH TAXVEND TAXDIST PREFVEND REORDERPOINT EXTRA CUSTFLD1 CUSTFLD2 CUSTFLD3 CUSTFLD4 CUSTFLD5 DEP_TYPE ISPASSEDTHRU
TODO (To Do Notes) REFNUM ISDONE DATE DESC
TERMS (Payment Terms List) NAME REFNUM TIMESTAMP DUEDAYS MINDAYS DISCPER DISCDAYS TERMSTYPE
PAYMETH (Payment Method List) NAME REFNUM TIMESTAMP
SHIPMETH (Shipping Method List) NAME REFNUM TIMESTAMP
INVMEMO (Customer Message List) NAME REFNUM TIMESTAMP
BUD (Budgets) Code IIF QIF name ACCNT N PERIOD budget AMOUNT B budget AMOUNT B budget AMOUNT B budget AMOUNT B budget AMOUNT B budget AMOUNT B budget AMOUNT B budget AMOUNT B budget AMOUNT B budget AMOUNT B budget AMOUNT B budget AMOUNT B STARTDATE CLASS CUSTOMER description D expense E income I tax T schedule R
new()
Creates a new instance of Finance::IIF. Supports the following initializing values.
my $iif = Finance::IIF->new( file => "myfile", debug => 1 );
If the file is specified it will be opened on new.
Specifies file to use for processing. See file() for details.
my $in = Finance::IIF->new( file => "myfile" ); OR my $in = Finance::IIF->new( file => [ "myfile", "<:crlf" ] );
Can be used to redefine the IIF record separator. Default is $/.
my $in = Finance::IIF->new( record_separator => "\n" );
Note: For MacOS X it may be necessary to change this to ``\r''. See autodetect for another option.
Enable auto detection of the record separator based on the file contents. Default is ``0''.
my $in = Finance::IIF->new( autodetect => 1 );
Perl uses $/ to define line separators for text files. Perl sets this value according to the OS perl is running on:
Windows="\r\n" Mac="\r" Unix="\n"
In many cases you may find yourself with text files that do not match the OS. In these cases Finance::IIF by default will not process that IIF file correctly. This feature is an attempt to help with the most common cases of having the wrong text file for the OS Finance::IIF is running on.
This feature depends on being able to seek to the end of the file and reading the last 2 characters to determine the proper separator. If a seek can not be performed or the last 2 characters are not a proper separator the record_separator will default to $/ or the value passed in. If a valid record_separator is found then it will be set according to what was in the file.
Can be used to output debug information. Default is ``0''.
my $iif = Finance::IIF->new( debug => 1 );
file()
Specify file name and optionally additional parameters that will be used to obtain a filehandle. The argument can be a filename (SCALAR) an ARRAY reference or an ARRAY whose values must be valid arguments for passing to IO::File->new.
$iif->file("myfile"); OR $iif->file( [ "myfile", "<:crlf" ] ); OR $iif->file( "myfile", "<:crlf" );
record_separator()
Returns the currently used record_separator. This is used primarly in situations where you open a IIF file with autodetect and then want to write out a IIF file in the same format.
my $iif = Finance::IIF->new( file => "input.iif", autodetect => 1 ); my $rs = $iif->record_separator;
open()
Open already specified file.
$iif->open();
Open also supports the same arguments as file().
$iif->open("myfile");
next()
For input files return the next record in the IIF file.
my $record = $in->next();
Returns undef if no more records are available.
reset()
Resets the filehandle so the records can be read again from the beginning of the file.
$iif->reset();
close()
Closes the open file.
$iif->close();
Examples
Add support for writing IIF files
Test cases for IIF parsing
Matthew McGillis <matthew@mcgillis.org> http://www.mcgillis.org/
Phil Lobbes <phil at perkpartners dot com>
Project maintaned at http://sourceforge.net/projects/finance-iif
Copyright (C) 2006 by Matthew McGillis and Phil Lobbes. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Finance::IIF |