Exemplo n.º 1
0
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)
Exemplo n.º 2
0

    # 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)
        )

        ynab_transaction.payee_name = payee_name

        if 'transactionFlagColor' in vars(api_settings) and api_settings.transactionFlagColor != None:
            ynab_transaction.flag_color = api_settings.transactionFlagColor
Exemplo n.º 3
0
                        '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

        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))

        ynab_transaction.payee_name = payee_name

        if 'transactionFlagColor' in vars(
                api_settings) and api_settings.transactionFlagColor != None:
            ynab_transaction.flag_color = api_settings.transactionFlagColor

        if 'reservedFlagColor' in vars(
                api_settings) and api_settings.reservedFlagColor != None and (
                    transaction_item.get('isReservation') == True or
                    (transaction_item.get('otherAccountNumberSpecified')
                     == False
                     and transaction_item.get('source') != 'Archive')):
            ynab_transaction.flag_color = api_settings.reservedFlagColor