예제 #1
0
 def setUp(self):
     self.port = 9486
     self.server = MockOfxServer(port=self.port)
     self.mockurl = "http://localhost:" + str(self.port) + "/"
     self.institution = ofx.Institution(ofx_org="Test Bank",
                                        ofx_fid="99999",
                                        ofx_url=self.mockurl)
     self.checking_account = ofx.Account(acct_number="1122334455",
                                         aba_number="12345678",
                                         acct_type="Checking",
                                         institution=self.institution)
     self.savings_account = ofx.Account(acct_number="1122334455",
                                        aba_number="12345678",
                                        acct_type="Savings",
                                        institution=self.institution)
     self.creditcard_account = ofx.Account(acct_number="1122334455",
                                           aba_number="12345678",
                                           acct_type="Credit Card",
                                           institution=self.institution)
     self.username = "******"
     self.password = "******"
     self.client = ofx.Client()
     self.checking_stmt = ofx_test_utils.get_checking_stmt()
     self.savings_stmt = ofx_test_utils.get_savings_stmt()
     self.creditcard_stmt = ofx_test_utils.get_creditcard_stmt()
예제 #2
0
 def setUp(self):
     self.institution = ofx.Institution(name="Test Bank",
                                        ofx_org="Test Bank",
                                        ofx_url="https://ofx.example.com",
                                        ofx_fid="9999999")
     self.good_acct = ofx.Account(acct_type="CHECKING",
                                  acct_number="1122334455",
                                  aba_number="123456789",
                                  institution=self.institution)
     self.bad_acct = ofx.Account(acct_type="Fnargle",
                                 acct_number="",
                                 aba_number="",
                                 institution=None)
예제 #3
0
파일: main.py 프로젝트: lcecliff/txnotify
def main():
    # Set up our OFX client
    institution = ofx.Institution(ofx_org=settings.OFX_SETTINGS['org'],
                                  ofx_url=settings.OFX_SETTINGS['url'],
                                  ofx_fid=settings.OFX_SETTINGS['fid'])
    account = ofx.Account(acct_type=settings.ACCOUNT_TYPE,
                          acct_number=settings.ACCOUNT_NUMBER,
                          aba_number=settings.OFX_SETTINGS['code'],
                          institution=institution)
    client = ofx.Client(debug=settings.DEBUG)

    # Get our current statement
    response = client.get_statement(account, settings.ACCOUNT_USERNAME,
                                    settings.ACCOUNT_PASSWORD)

    # This ugly bit of navigation gets us the list of the transactions that
    # have occured in this statement.
    statement_dict = response.get_statements()[0].as_dict()

    try:
        line_items = statement_dict['STMTRS']['BANKTRANLIST']
    except KeyError:
        line_items = statement_dict['CCSTMTRS']['BANKTRANLIST']

    line_items = sorted(line_items,
                        key=lambda v: v.asDict().get('DTPOSTED'),
                        reverse=True)

    email_body = generate_email_body(line_items)

    now = datetime.now().strftime('%Y-%m-%d %I:%M%p')
    subject = "[%s] New %s Transactions" % (now, settings.ACCOUNT_NAME)

    send_email(subject, email_body)
예제 #4
0
 def setUp(self):
     self.request = ofx.Request()
     self.institution = ofx.Institution(ofx_org="fi_name", ofx_fid="1000")
     self.account = ofx.Account(acct_number="00112233",
                                aba_number="12345678",
                                acct_type="Checking",
                                institution=self.institution)
     self.username = "******"
     self.password = "******"
     self.parser  = ofx.Parser()
예제 #5
0
    def _extract_account(self, acct_block):
        acct_dict = acct_block.asDict()

        if acct_dict.has_key("DESC"):
            desc = acct_dict["DESC"]
        else:
            desc = None

        if acct_dict.has_key("BANKACCTINFO"):
            acctinfo = acct_dict["BANKACCTINFO"]
            return ofx.Account(ofx_block=acctinfo["BANKACCTFROM"], desc=desc)

        elif acct_dict.has_key("CCACCTINFO"):
            acctinfo = acct_dict["CCACCTINFO"]
            account = ofx.Account(ofx_block=acctinfo["CCACCTFROM"], desc=desc)
            account.acct_type = "CREDITCARD"
            return account

        else:
            return None
예제 #6
0
    def __init__(self, statement):
        self.parse_result = statement
        self.parse_dict = self.parse_result.asDict()

        if self.parse_dict.has_key("STMTRS"):
            stmt = self.parse_dict["STMTRS"]
            self.account = ofx.Account(ofx_block=stmt["BANKACCTFROM"])
        elif self.parse_dict.has_key("CCSTMTRS"):
            stmt = self.parse_dict["CCSTMTRS"]
            self.account = ofx.Account(ofx_block=stmt["CCACCTFROM"])
            self.account.acct_type = "CREDITCARD"
        else:
            error = ValueError("Unknown statement type: %s." % statement)
            raise error

        self.currency = self._get(stmt, "CURDEF")
        self.begin_date = self._get(stmt["BANKTRANLIST"], "DTSTART")
        self.end_date = self._get(stmt["BANKTRANLIST"], "DTEND")
        self.balance = self._get(stmt["LEDGERBAL"], "BALAMT")
        self.bal_date = self._get(stmt["LEDGERBAL"], "DTASOF")
예제 #7
0
파일: account.py 프로젝트: m8nky/fixofx
 def load_from_dict(acct_dict):
     return ofx.Account(acct_type=acct_dict.get('acct_type'),
                        acct_number=acct_dict.get('acct_number'),
                        aba_number=acct_dict.get('aba_number'),
                        balance=acct_dict.get('balance'),
                        desc=acct_dict.get('desc'))
예제 #8
0
    # people on those other platforms aren't redirecting output like the UNIX-heads are.
    terminal = None
    if os.access("/dev/tty", os.W_OK):
        terminal = open("/dev/tty", 'w')
    else:
        terminal = sys.stdout
    terminal.write("Enter account username: "******"Enter account password: "******"HTTP Debug Output:"
        print "=================="