# Path: pynYNAB/schema/budget.py
# class Transaction(Base, BudgetEntity):
#     accepted = Column(Boolean, default=True)
#     amount = Column(AmountType)
#     cash_amount = Column(AmountType)
#     check_number = Column(String)
#     cleared = Column(String, default='Uncleared')
#     credit_amount = Column(AmountType)
#     credit_amount_adjusted = Column(AmountType)
#     date = Column(Date)
#     date_entered_from_schedule = Column(Date)
#     entities_account_id = Column(ForeignKey('account.id'))
#     entities_account = relationship('Account', foreign_keys=entities_account_id)
#     entities_payee_id = Column(ForeignKey('payee.id'))
#     entities_payee = relationship('Payee')
#     entities_scheduled_transaction_id = Column(ForeignKey('scheduledtransaction.id'))
#     entities_subcategory_id = Column(ForeignKey('subcategory.id'))
#     entities_subcategory = relationship('SubCategory')
#     flag = Column(Enum(ColorFlagType), default=None)
#     imported_date = Column(Date)
#     imported_payee = Column(String)
#     matched_transaction_id = Column(ForeignKey('transaction.id'))
#     matched_transaction = relationship('Transaction', foreign_keys=matched_transaction_id)
#     memo = Column(String)
#     source = Column(String)
#     subcategory_credit_amount_preceding = Column(AmountType, default=0)
#     transfer_account_id = Column(ForeignKey('account.id'))
#     transfer_account = relationship('Account', foreign_keys=transfer_account_id)
#     transfer_subtransaction_id = Column(ForeignKey('subtransaction.id'))
#     transfer_transaction_id = Column(ForeignKey('transaction.id'))
#     transfer_transaction = relationship('Transaction', foreign_keys=transfer_transaction_id)
#     ynab_id = Column(String)
# 
# Path: pynYNAB/utils.py
# def get_or_create_payee(client, name):
#     payees = {p.name: p for p in client.budget.be_payees if
#               p.name == name}
#     if name in payees:
#         return payees[name]
#     payee = Payee(
#         name=name
#     )
# 
#     client.budget.be_payees.append(payee)
#     client.push(1)
#     return payee


from datetime import datetime
from dotenv import load_dotenv,find_dotenv
from pynYNAB.ClientFactory import clientfromargs
from pynYNAB.schema.budget import Transaction
from pynYNAB.scripts.__main__ import parser
from pynYNAB.utils import get_or_create_payee
transactions = []

account_id = account0.id
transfer_id = account1.id

# Payees:  "Transfer : account_name"
account_payee_id = payees['Transfer : ' + account1.account_name].id
transfer_payee_id = payees['Transfer : ' + account0.account_name].id

imported_date = datetime.now().date()

payee_name = 'Payee'
payee = get_or_create_payee(client, payee_name)
payee_id = payee.id

amount = 10
date = datetime(2016,10,5).date()


transaction_1 = Transaction(
    entities_account_id=account_id,
    entities_payee_id=account_payee_id,
    amount=amount,
    date=date,
    imported_date=imported_date,
    imported_payee=payee_name,
    source='Matched',
    cash_amount=amount
)


# Path: pynYNAB/schema/budget.py
# class Transaction(Base, BudgetEntity):
#     accepted = Column(Boolean, default=True)
#     amount = Column(AmountType)
#     cash_amount = Column(AmountType)
#     check_number = Column(String)
#     cleared = Column(String, default='Uncleared')
#     credit_amount = Column(AmountType)
#     credit_amount_adjusted = Column(AmountType)
#     date = Column(Date)
#     date_entered_from_schedule = Column(Date)
#     entities_account_id = Column(ForeignKey('account.id'))
#     entities_account = relationship('Account', foreign_keys=entities_account_id)
#     entities_payee_id = Column(ForeignKey('payee.id'))
#     entities_payee = relationship('Payee')
#     entities_scheduled_transaction_id = Column(ForeignKey('scheduledtransaction.id'))
#     entities_subcategory_id = Column(ForeignKey('subcategory.id'))
#     entities_subcategory = relationship('SubCategory')
#     flag = Column(Enum(ColorFlagType), default=None)
#     imported_date = Column(Date)
#     imported_payee = Column(String)
#     matched_transaction_id = Column(ForeignKey('transaction.id'))
#     matched_transaction = relationship('Transaction', foreign_keys=matched_transaction_id)
#     memo = Column(String)
#     source = Column(String)
#     subcategory_credit_amount_preceding = Column(AmountType, default=0)
#     transfer_account_id = Column(ForeignKey('account.id'))
#     transfer_account = relationship('Account', foreign_keys=transfer_account_id)
#     transfer_subtransaction_id = Column(ForeignKey('subtransaction.id'))
#     transfer_transaction_id = Column(ForeignKey('transaction.id'))
#     transfer_transaction = relationship('Transaction', foreign_keys=transfer_transaction_id)
#     ynab_id = Column(String)
# 
# Path: pynYNAB/utils.py
# def get_or_create_payee(client, name):
#     payees = {p.name: p for p in client.budget.be_payees if
#               p.name == name}
#     if name in payees:
#         return payees[name]
#     payee = Payee(
#         name=name
#     )
# 
#     client.budget.be_payees.append(payee)
#     client.push(1)
#     return payee


# Path: testscripts/test_matched.py
from datetime import datetime
from dotenv import load_dotenv,find_dotenv
from pynYNAB.ClientFactory import clientfromargs
from pynYNAB.schema.budget import Transaction
from pynYNAB.scripts.__main__ import parser
from pynYNAB.utils import get_or_create_payee

transactions = []

account_id = account0.id
transfer_id = account1.id

# Payees:  "Transfer : account_name"
account_payee_id = payees['Transfer : ' + account1.account_name].id
transfer_payee_id = payees['Transfer : ' + account0.account_name].id

imported_date = datetime.now().date()

payee_name = 'Payee'
payee = get_or_create_payee(client, payee_name)
payee_id = payee.id

amount = 10
date = datetime(2016,10,5).date()


transaction_1 = Transaction(
    entities_account_id=account_id,
    entities_payee_id=account_payee_id,
    amount=amount,
    date=date,
    imported_date=imported_date,
    imported_payee=payee_name,
    source='Matched',
    cash_amount=amount
)


transaction_orig = Transaction(