195 lines
5.6 KiB
Python
195 lines
5.6 KiB
Python
from datetime import date
|
|
from decimal import Decimal
|
|
|
|
from account.resource import AccountResource
|
|
from account.schemas import AccountCreate, CategoryCreate
|
|
|
|
def inject_fixtures(session):
|
|
for f in fixtures_account:
|
|
f = prepare_dict(session, f)
|
|
schema = AccountCreate(**f)
|
|
AccountResource.create(schema, session)
|
|
|
|
for f in fixtures_category:
|
|
f = prepare_dict(session, f)
|
|
schema = CategoryCreate(**f)
|
|
AccountResource.create(schema, session)
|
|
|
|
def prepare_dict(session, entry):
|
|
if entry['parent_path']:
|
|
parent = AccountResource.get_by_path(session, entry['parent_path'])
|
|
entry['parent_account_id'] = parent.id
|
|
else:
|
|
entry['parent_account_id'] = None
|
|
del entry['parent_path']
|
|
return entry
|
|
|
|
fixtures_account = [
|
|
{
|
|
"name": "Current Assets",
|
|
"parent_path": None,
|
|
"type": "Asset",
|
|
"opening_date": date(1970, 1, 2),
|
|
"opening_balance": Decimal("0.00"),
|
|
},
|
|
{
|
|
"name": "Cash in Wallet",
|
|
"parent_path": "/Accounts/Asset/Current Assets/",
|
|
"type": "Asset",
|
|
"opening_date": date(1970, 1, 3),
|
|
"opening_balance": Decimal("0.00"),
|
|
},
|
|
{
|
|
"name": "Checking Account",
|
|
"parent_path": "/Accounts/Asset/Current Assets/",
|
|
"type": "Asset",
|
|
"opening_date": date(1970, 1, 4),
|
|
"opening_balance": Decimal("0.00"),
|
|
},
|
|
{
|
|
"name": "Savings Account",
|
|
"parent_path": "/Accounts/Asset/Current Assets/",
|
|
"type": "Asset",
|
|
"opening_date": date(1970, 1, 5),
|
|
"opening_balance": Decimal("0.00"),
|
|
},
|
|
{
|
|
"name": "Debt Accounts",
|
|
"parent_path": None,
|
|
"type": "Liability",
|
|
"opening_date": date(1970, 1, 6),
|
|
"opening_balance": Decimal("0.00"),
|
|
},
|
|
{
|
|
"name": "Credit Card",
|
|
"parent_path": "/Accounts/Liability/Debt Accounts/",
|
|
"type": "Liability",
|
|
"opening_date": date(1970, 1, 7),
|
|
"opening_balance": Decimal("0.00"),
|
|
},
|
|
]
|
|
|
|
fixtures_category = [
|
|
{
|
|
"name": "Salary",
|
|
"parent_path": None,
|
|
"type": "Income",
|
|
},
|
|
{
|
|
"name": "Other Income",
|
|
"parent_path": None,
|
|
"type": "Income",
|
|
},
|
|
{
|
|
"name": "Auto",
|
|
"parent_path": None,
|
|
"type": "Expense",
|
|
},
|
|
{
|
|
"name": "Home",
|
|
"parent_path": None,
|
|
"type": "Expense",
|
|
},
|
|
{
|
|
"name": "Rent",
|
|
"parent_path": "/Categories/Expense/Home/",
|
|
"type": "Expense",
|
|
},
|
|
{
|
|
"name": "Electricity",
|
|
"parent_path": "/Categories/Expense/Home/",
|
|
"type": "Expense",
|
|
},
|
|
{
|
|
"name": "Entertainment",
|
|
"parent_path": None,
|
|
"type": "Expense",
|
|
},
|
|
{
|
|
"name": "Groceries",
|
|
"parent_path": None,
|
|
"type": "Expense",
|
|
}
|
|
]
|
|
|
|
"""
|
|
<accounts>
|
|
<account type="9" name="">
|
|
<account type="9" name="Current Assets">
|
|
<account type="3" name="Cash in Wallet"/>
|
|
<account type="1" name="Checking Account"/>
|
|
<account type="1" name="Savings Account"/>
|
|
</account>
|
|
</account>
|
|
<account type="16" name="">
|
|
<account type="16" name="Opening Balances">
|
|
<flag name="OpeningBalanceAccount" value="Yes"/>
|
|
</account>
|
|
</account>
|
|
<account type="13" name="">
|
|
<account type="13" name="Adjustment"/>
|
|
<account type="13" name="Auto">
|
|
<account type="13" name="Fees"/>
|
|
<account type="13" name="Fuel"/>
|
|
<account type="13" name="Parking"/>
|
|
<account type="13" name="Repair and Maintenance"/>
|
|
</account>
|
|
<account type="13" name="Bank Service Charge"/>
|
|
<account type="13" name="Books"/>
|
|
<account type="13" name="Cable"/>
|
|
<account type="13" name="Charity"/>
|
|
<account type="13" name="Clothes"/>
|
|
<account type="13" name="Computer"/>
|
|
<account type="13" name="Dining"/>
|
|
<account type="13" name="Education"/>
|
|
<account type="13" name="Entertainment">
|
|
<account type="13" name="Music/Movies"/>
|
|
<account type="13" name="Recreation"/>
|
|
<account type="13" name="Travel"/>
|
|
</account>
|
|
<account type="13" name="Gifts"/>
|
|
<account type="13" name="Groceries"/>
|
|
<account type="13" name="Hobbies"/>
|
|
<account type="13" name="Insurance">
|
|
<account type="13" name="Auto Insurance"/>
|
|
<account type="13" name="Health Insurance"/>
|
|
<account type="13" name="Life Insurance"/>
|
|
</account>
|
|
<account type="13" name="Laundry/Dry Cleaning"/>
|
|
<account type="13" name="Medical Expenses"/>
|
|
<account type="13" name="Miscellaneous"/>
|
|
<account type="13" name="Online Services"/>
|
|
<account type="13" name="Phone"/>
|
|
<account type="13" name="Public Transportation"/>
|
|
<account type="13" name="Subscriptions"/>
|
|
<account type="13" name="Supplies"/>
|
|
<account type="13" name="Taxes">
|
|
<account type="13" name="Federal"/>
|
|
<account type="13" name="Medicare"/>
|
|
<account type="13" name="Other Tax"/>
|
|
<account type="13" name="Social Security"/>
|
|
<account type="13" name="State/Province"/>
|
|
</account>
|
|
<account type="13" name="Utilities">
|
|
<account type="13" name="Electric"/>
|
|
<account type="13" name="Garbage collection"/>
|
|
<account type="13" name="Gas"/>
|
|
<account type="13" name="Water"/>
|
|
</account>
|
|
</account>
|
|
<account type="12" name="">
|
|
<account type="12" name="Bonus"/>
|
|
<account type="12" name="Gifts Received"/>
|
|
<account type="12" name="Interest Income">
|
|
<account type="12" name="Checking Interest"/>
|
|
<account type="12" name="Other Interest"/>
|
|
<account type="12" name="Savings Interest"/>
|
|
</account>
|
|
<account type="12" name="Other Income"/>
|
|
<account type="12" name="Salary"/>
|
|
</account>
|
|
<account type="10" name="">
|
|
<account type="4" name="Credit Card"/>
|
|
</account>
|
|
</accounts>
|
|
""" |