예제 #1
0
 def test_no_institution(self):
     ofxpath = os.path.join('fixtures', 'no-institution.ofx')
     sync = OfxSynchronizer(self.lgr)
     ofx = OfxSynchronizer.parse_file(ofxpath)
     txns = sync.filter(ofx.account.statement.transactions,
                        ofx.account.account_id)
     self.assertEquals(len(txns), 3)
예제 #2
0
 def test_one_settleDate(self):
     ofxpath = os.path.join('fixtures', 'fidelity-one-dtsettle.ofx')
     ofx = OfxSynchronizer.parse_file(ofxpath)
     sync = OfxSynchronizer(self.lgr)
     txns = sync.filter(ofx.account.statement.transactions,
                        ofx.account.account_id)
     self.assertEquals(len(txns), 17)
예제 #3
0
 def test_apostrophe(self):
     ofxpath = os.path.join('fixtures', 'apostrophe.ofx')
     ofx = OfxSynchronizer.parse_file(ofxpath)
     sync = OfxSynchronizer(self.lgr)
     txns = sync.filter(ofx.account.statement.transactions,
                        ofx.account.account_id)
     self.assertEquals(len(txns), 1)
예제 #4
0
파일: cli.py 프로젝트: egh/ledger-autosync
def import_ofx(ledger, args):
    sync = OfxSynchronizer(ledger, hardcodeaccount=args.hardcodeaccount,
                           shortenaccount=args.shortenaccount)
    ofx = OfxSynchronizer.parse_file(args.PATH)
    txns = sync.filter(
        ofx.account.statement.transactions,
        ofx.account.account_id)
    accountname = args.account
    if accountname is None:
        if ofx.account.institution is not None:
            accountname = "%s:%s" % (ofx.account.institution.organization,
                                     ofx.account.account_id)
        else:
            accountname = UNKNOWN_BANK_ACCOUNT

    # build SecurityList (including indexing by CUSIP and ticker symbol)
    security_list = SecurityList(ofx)

    converter = make_ofx_converter(account=ofx.account,
                                   name=accountname,
                                   ledger=ledger,
                                   indent=args.indent,
                                   fid=args.fid,
                                   unknownaccount=args.unknownaccount,
                                   payee_format=args.payee_format,
                                   hardcodeaccount=args.hardcodeaccount,
                                   shortenaccount=args.shortenaccount,
                                   security_list=security_list)
    print_results(converter, ofx, ledger, txns, args)
예제 #5
0
def import_ofx(ledger, args):
    sync = OfxSynchronizer(ledger,
                           hardcodeaccount=args.hardcodeaccount,
                           shortenaccount=args.shortenaccount)
    ofx = OfxSynchronizer.parse_file(args.PATH)
    txns = sync.filter(ofx.account.statement.transactions,
                       ofx.account.account_id)
    accountname = args.account
    if accountname is None:
        if ofx.account.institution is not None:
            accountname = "%s:%s" % (ofx.account.institution.organization,
                                     ofx.account.account_id)
        else:
            accountname = UNKNOWN_BANK_ACCOUNT

    # build SecurityList (including indexing by CUSIP and ticker symbol)
    security_list = SecurityList(ofx)

    converter = make_ofx_converter(account=ofx.account,
                                   name=accountname,
                                   ledger=ledger,
                                   indent=args.indent,
                                   fid=args.fid,
                                   unknownaccount=args.unknownaccount,
                                   payee_format=args.payee_format,
                                   hardcodeaccount=args.hardcodeaccount,
                                   shortenaccount=args.shortenaccount,
                                   security_list=security_list,
                                   date_format=args.date_format,
                                   infer_account=args.infer_account)
    print_results(converter, ofx, ledger, txns, args)
예제 #6
0
 def test_partial_sync(self):
     ledger = Ledger(os.path.join('fixtures', 'checking-partial.lgr'))
     sync = OfxSynchronizer(ledger)
     ofx = OfxSynchronizer.parse_file(
         os.path.join('fixtures', 'checking.ofx'))
     txns = sync.filter(ofx.account.statement.transactions,
                        ofx.account.account_id)
     self.assertEqual(len(txns), 1)
예제 #7
0
 def test_one_settleDate(self):
     ofxpath = os.path.join('fixtures', 'fidelity-one-dtsettle.ofx')
     ofx = OfxSynchronizer.parse_file(ofxpath)
     sync = OfxSynchronizer(self.lgr)
     txns = sync.filter(
         ofx.account.statement.transactions,
         ofx.account.account_id)
     self.assertEqual(len(txns), 17)
예제 #8
0
 def test_comment_txns(self):
     ledger = Ledger(os.path.join('fixtures', 'empty.lgr'))
     sync = OfxSynchronizer(ledger)
     ofx = OfxSynchronizer.parse_file(
         os.path.join('fixtures', 'comments.ofx'))
     txns = sync.filter(ofx.account.statement.transactions,
                        ofx.account.account_id)
     self.assertEqual(len(txns), 1)
예제 #9
0
 def test_apostrophe(self):
     ofxpath = os.path.join('fixtures', 'apostrophe.ofx')
     ofx = OfxSynchronizer.parse_file(ofxpath)
     sync = OfxSynchronizer(self.lgr)
     txns = sync.filter(
         ofx.account.statement.transactions,
         ofx.account.account_id)
     self.assertEqual(len(txns), 1)
예제 #10
0
 def test_no_institution(self):
     ofxpath = os.path.join('fixtures', 'no-institution.ofx')
     sync = OfxSynchronizer(self.lgr)
     ofx = OfxSynchronizer.parse_file(ofxpath)
     txns = sync.filter(
         ofx.account.statement.transactions,
         ofx.account.account_id)
     self.assertEqual(len(txns), 3)
예제 #11
0
 def test_partial_sync(self):
     ledger = Ledger(os.path.join('fixtures', 'checking-partial.lgr'))
     sync = OfxSynchronizer(ledger)
     ofx = OfxSynchronizer.parse_file(
         os.path.join('fixtures', 'checking.ofx'))
     txns = sync.filter(
         ofx.account.statement.transactions,
         ofx.account.account_id)
     self.assertEqual(len(txns), 1)
예제 #12
0
 def test_comment_txns(self):
     ledger = Ledger(os.path.join('fixtures', 'empty.lgr'))
     sync = OfxSynchronizer(ledger)
     ofx = OfxSynchronizer.parse_file(
         os.path.join('fixtures', 'comments.ofx'))
     txns = sync.filter(
         ofx.account.statement.transactions,
         ofx.account.account_id)
     self.assertEqual(len(txns), 1)
예제 #13
0
 def test_accented_characters_latin1(self):
     ofxpath = os.path.join('fixtures', 'accented_characters_latin1.ofx')
     ofx = OfxSynchronizer.parse_file(ofxpath)
     sync = OfxSynchronizer(self.lgr)
     txns = sync.filter(ofx.account.statement.transactions,
                        ofx.account.account_id)
     converter = OfxConverter(account=ofx.account, name="Foo")
     self.assertEqual(converter.format_payee(txns[0]),
                      "Virement Interac à: Jean")
     self.assertEqual(len(txns), 1)
예제 #14
0
def import_ofx(ledger, args):
    sync = OfxSynchronizer(ledger,
                           hardcodeaccount=args.hardcodeaccount,
                           shortenaccount=args.shortenaccount)
    ofx = OfxSynchronizer.parse_file(args.PATH)

    if args.account != None and len(args.account) != len(ofx.accounts):
        sys.stderr.write(
            "number of account name (--account) does not match the number of accounts in the OFX file\n"
        )
        exit(1)

    account_idx = 0
    for account in ofx.accounts:
        txns = sync.filter(account.statement.transactions, account.account_id)
        try:
            accountname = args.account[account_idx]
        except (IndexError, TypeError):
            accountname = None
        if accountname is None:
            if account.institution is not None:
                accountname = "%s:%s" % (account.institution.organization,
                                         account.account_id)
            elif args.account_format is not None:
                accountname = args.account_format.format(
                    account_id=account.account_id,
                    account_type=account.account_type,
                    routing_number=account.routing_number,
                    branch_id=account.branch_id)
            else:
                accountname = "%s:%s" % (UNKNOWN_BANK_ACCOUNT, account_idx)

        # build SecurityList (including indexing by CUSIP and ticker symbol)
        security_list = SecurityList(ofx)

        converter = make_ofx_converter(
            account=account,
            name=accountname,
            ledger=ledger,
            indent=args.indent,
            fid=args.fid,
            unknownaccount=args.unknownaccount,
            payee_format=args.payee_format,
            hardcodeaccount=args.hardcodeaccount,  #TODO
            shortenaccount=args.shortenaccount,  #TODO
            security_list=security_list)
        print_results(converter, ofx, ledger, txns, args, account_idx)
        account_idx += 1
예제 #15
0
def import_ofx(ledger, args):
    sync = OfxSynchronizer(ledger)
    (ofx, txns) = sync.parse_file(args.PATH)
    accountname = args.account
    if accountname is None:
        if ofx.account.institution is not None:
            accountname = "%s:%s" % (ofx.account.institution.organization,
                                     ofx.account.account_id)
        else:
            raise EmptyInstitutionException("Institution provided by OFX is \
empty and no accountname supplied!")
    converter = OfxConverter(account=ofx.account,
                             name=accountname,
                             ledger=ledger,
                             indent=args.indent,
                             fid=args.fid,
                             unknownaccount=args.unknownaccount)
    print_results(converter, ofx, ledger, txns, args)
예제 #16
0
def import_ofx(ledger, args):
    sync = OfxSynchronizer(ledger,
                           hardcodeaccount=args.hardcodeaccount,
                           shortenaccount=args.shortenaccount)
    (ofx, txns) = sync.parse_file(args.PATH)
    accountname = args.account
    if accountname is None:
        if ofx.account.institution is not None:
            accountname = "%s:%s" % (ofx.account.institution.organization,
                                     ofx.account.account_id)
        else:
            accountname = UNKNOWN_BANK_ACCOUNT

    converter = OfxConverter(ofx=ofx,
                             name=accountname,
                             ledger=ledger,
                             indent=args.indent,
                             fid=args.fid,
                             unknownaccount=args.unknownaccount,
                             payee_format=args.payee_format,
                             hardcodeaccount=args.hardcodeaccount,
                             shortenaccount=args.shortenaccount)

    print_results(converter, ofx, ledger, txns, args)
예제 #17
0
 def test_no_institution_no_accountname(self):
     ofxpath = os.path.join('fixtures', 'no-institution.ofx')
     ofx = OfxSynchronizer.parse_file(ofxpath)
     OfxConverter(account=ofx.account, name=None)
예제 #18
0
 def test_partial_sync(self):
     ledger = Ledger(os.path.join('fixtures', 'checking-partial.lgr'))
     sync = OfxSynchronizer(ledger)
     (ofx, txns) = sync.parse_file(os.path.join('fixtures', 'checking.ofx'))
     self.assertEqual(len(txns), 1)
예제 #19
0
 def test_fully_synced(self):
     ledger = Ledger(os.path.join('fixtures', 'checking.lgr'))
     sync = OfxSynchronizer(ledger)
     (ofx, txns) = sync.parse_file(os.path.join('fixtures', 'checking.ofx'))
     self.assertEqual(txns, [])
예제 #20
0
 def test_comment_txns(self):
     ledger = Ledger(os.path.join('fixtures', 'empty.lgr'))
     sync = OfxSynchronizer(ledger)
     (ofx, txns) = sync.parse_file(os.path.join('fixtures', 'comments.ofx'))
     self.assertEqual(len(txns), 1)