QIFImport.pm

When performing any step read in X lines and remember what line in the file we are on.

Database version 1.4 should add used bool to qif_<list>_tb

Legend:

Black

Blue

Green

Red

No change

Changes

New

Deprecated/Removed



Commands:

display => "Upload File"

review_log => "Review Log"

parse_class_list - take code from parse file/data to import list data from file into temp tables

parse_category_list - take code from parse file to import list data from file into temp tables

parse_account_list - take code from parse file to import list data from file into temp tables

parse_security_list - take code from parse file to import list data from file into temp tables

build_lists_from_account_transactions - parses file and gets all lines with S and L at the beginning of line in account transaction section (lists: category, class, account) to build list:
  1. grab item 2. search for item in qif_<list>_tb 3. if not found, insert item into table 4. mark item in table as used.

build_lists_from_investment_transactions - parses file and gets all lines with S and L at the beginning of line in account and investment transaction section (lists: security, category, class, account)
  1. grab item 2. search for item in qif_<list>_tb 3. if not found, insert item into table 4. mark item in table as used.

build_lists_from_prices - parses file and gets all unique Securities used in the prices data in the file

ask_entities => "Ask Entities"

guess_securities => "Guess Securities"

map_securities => "Map Securities"

guess_classes => "Guess Classes"

map_classes => "Map Classes"

guess_categories => "Guess Categories" --search based on used flag. For entries w/o income_expense_flag give all first_digit of 4,5

map_categories => "Map Categories"

guess_accounts => "Guess Accounts"

map_accounts => "Map Accounts"

//parse => "Parse File" - skip lists, skip account_transactions. Just parse investment transactions and prices

//insert_parsed_data => "Insert Parsed Data"

import_account_transactions - process X records and keep line #

select_import_accounts => "Select Import Accounts"

import_buy_investment_transactions => "Import Buy Investment Transactions" - parse from file instead of database

import_investment_transactions => "Import Investment Transactions" parse from file instead of database

import_processed_investment_transaction => "Import Processed Investment Transaction"

sharesselect => "Shares Selection"

import_prices => "Import Stock Prices" - parse from file instead of database

import_complete => "Import Complete" - clean up the import: 1) delete uploaded QIF data file


Notes on commands:


import_account_transactions

  When importing the amounts, the revenues are positive and the expenses are negative. This also means that a negative revenue or positive expense should do the opposite of what is normal. If we ignore contra accounts for a moment then based on first_digit debit_increases flag

  if mapped account first_digit is 1, 5 debit increases true

  if mapped account first_digit is 2,3,4 debit increases false

  if 5, negate debit increases flag because expenses are on negative basis

  Now if number is negative switch debit/credit for that row

Steps 1,2,3 can be combined and the following algorithm used:

  if mapped account first_digit is 1, debit increases true

  if mapped account first_digit is 2,3,4, 5 debit increases false

  Now if number is negative switch debit/credit for that row


Test case

In Quicken, transfer 2 dollars in a split from asset account to liability account

!Type:Bank

!Account:asset

D

P

U -2

S liability      -5

S liability      3

The algorithm first comes across the first S with negative five. Sees the liability account as first_digit 2.

  debit_increases is false so it would be normal to credit. Since number is negative we debit the liability account 5

next S liability 3, normal to credit so credit 3

lastly we get to overall account decrease by 2, credit to asset 2


In reality the transaction could be broken down into this simple equation.



Debit

Credit

liability


2



asset


2

But because of the way quicken exports it will actually map to



Debit

Credit

liability


5



liability


3


asset


2