예제 #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
파일: 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)
예제 #3
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()
예제 #4
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)
예제 #5
0
파일: institution.py 프로젝트: m8nky/fixofx
 def load_from_dict(fi_dict):
     return ofx.Institution(name=fi_dict.get('name'),
                            ofx_org=fi_dict.get('ofx_org'),
                            ofx_url=fi_dict.get('ofx_url'),
                            ofx_fid=fi_dict.get('ofx_fid'))
예제 #6
0
if action != "profile":
    # The following allows the username prompt to be written even if output is redirected.
    # On UNIX and Mac, that is. The sys.stdout fallback should work elsewhere, assuming
    # 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: ")

institution = ofx.Institution(ofx_org=options.org,
                              ofx_url=options.url,
                              ofx_fid=options.fid)

account = ofx.Account(acct_type=options.accttype,
                      acct_number=options.acctid,
                      aba_number=options.bankid,
                      institution=institution)

try:
    client = ofx.Client(debug=options.verbose)
    response = None

    if options.verbose:
        # Install an HTTP handler with debug output
        http_handler = urllib2.HTTPHandler(debuglevel=1)
        https_handler = urllib2.HTTPSHandler(debuglevel=1)