Exemple #1
0
    def test_Nettgiro_short(self):
        # arrange
        transaction = nettgiro_actual_transaction_short_text

        # act 
        result = getPayee(transaction)

        #assert
        self.assertEqual(result, 'Nettgiro')
Exemple #2
0
    def test_Renter(self):
        # arrange
        transaction = {'transactionTypeCode': 752, 'text':'testing testing'}

        # act 
        result = getPayee(transaction)

        #assert
        self.assertEqual(result, 'Sbanken')
Exemple #3
0
    def test_Nettgiro(self):
        # arrange
        # transaction = nettgiro_actual_transaction_short_text
        transaction = nettgiro_actual_transaction

        # act 
        result = getPayee(transaction)

        #assert
        self.assertEqual(result, 'Berntsen anders')
def main():
    # enable_debug_logging()
    import api_settings
    import pprint

    http_session = create_authenticated_http_session(api_settings.CLIENTID,
                                                     api_settings.SECRET)

    # customer_info = get_customer_information(http_session, api_settings.CUSTOMERID)
    # pprint.pprint(customer_info)

    # pprint.pprint(accounts)

    accountNo = input('What is the account number:')
    account = getAccount(http_session, api_settings.CUSTOMERID, accountNo)

    if account == None:
        print('Account not found!')
        exit(1)

    year = input('What year?')
    if year == '':
        year = 2020

    year = int(year)
    if year < 2000:
        year = 2020

    transactions = get_transactions_year(http_session, api_settings.CUSTOMERID,
                                         account['accountId'], year)
    # pprint.pprint(transactions)

    with open(account['name'] + '_' + account['accountNumber'] + '.csv',
              'w',
              encoding='utf-8') as csvfile:
        ktowriter = csv.writer(csvfile,
                               delimiter=',',
                               quotechar='"',
                               quoting=csv.QUOTE_MINIMAL)
        ktowriter.writerow(['Date', 'Payee', 'Memo', 'Outflow', 'Inflow'])

        for item in transactions:
            date = getTransactionDate(item)
            payee = getPayee(item)
            memo = getMemo(item)
            outflow = getOut(item)
            inflow = getIn(item)
            ktowriter.writerow([date, payee, memo, outflow, inflow])
            if payee.find('ircuit') > 0:
                pprint.pprint(item)
                print(date, payee, memo, outflow, inflow)
            logging.error("Exception when calling TransactionsApi->get_transactions_by_account: %s\n" % e)

        existing_transactions = api_response.data.transactions

        logging.info("Got %i existing YNAB transactions from %s", len(existing_transactions), account_map['Name'])


    # Loop through all transactions        
    for transaction_item in transactions:
        payee_id = None
        if api_settings.includeReservedTransactions != True:
            if transaction_item.get('isReservation') == True: # or transaction_item.get('otherAccountNumberSpecified') == False:
                continue

        try:
            payee_name = getPayee(transaction_item)
         # We raise ValueError in case there is Visa transaction that has no card details, skipping it so far
        except ValueError:
            pass
        
        logging.info("Transaction: %s,  amount: %s, typecode: %s, text: %s", getYnabTransactionDate(transaction_item), transaction_item['amount'], transaction_item['transactionTypeCode'], getMemo(transaction_item))

        ynab_transaction = ynab.TransactionDetail(
            date=getYnabTransactionDate(transaction_item), 
            amount=getIntAmountMilli(transaction_item), 
            cleared='uncleared', 
            approved=False, 
            account_id=account_map['account'],
            memo=getMemo(transaction_item),
            import_id=getYnabSyncId(transaction_item)
        )
Exemple #6
0
 def test_transactions(self):
     
     for i in range(len(test_transaction_list)):
         result = getPayee(test_transaction_list[i])
         self.assertEqual(result, test_trans_result_list[i])