113 lines
3.2 KiB
Python
113 lines
3.2 KiB
Python
from django_ledger import models as led
|
|
from inventory import models as inv_model
|
|
|
|
import os
|
|
from datetime import date, datetime
|
|
from decimal import Decimal
|
|
from random import randint, choices, random
|
|
from zoneinfo import ZoneInfo
|
|
|
|
# import django
|
|
# for easier visualization it is recommended to use pandas to render data...
|
|
# if pandas is not installed, you may install it with this command: pip install -U pandas
|
|
# pandas is not a dependecy of django_ledger...
|
|
# from django.core.exceptions import ObjectDoesNotExist
|
|
|
|
# # Set your django settings module if needed...
|
|
# os.environ['DJANGO_SETTINGS_MODULE'] = 'dev_env.settings'
|
|
|
|
# # if using jupyter notebook need to set DJANGO_ALLOW_ASYNC_UNSAFE as "true"
|
|
# os.environ['DJANGO_ALLOW_ASYNC_UNSAFE'] = 'true'
|
|
|
|
# # change your working directory as needed...
|
|
# os.chdir('../')
|
|
|
|
# django.setup()
|
|
|
|
from django_ledger.models.entity import EntityModel
|
|
from django_ledger.models.items import ItemModel
|
|
from django_ledger.models.invoice import InvoiceModel
|
|
from django_ledger.models.bill import BillModel
|
|
from django_ledger.models.estimate import EstimateModel
|
|
from django.contrib.auth import get_user_model
|
|
from django_ledger.io import roles, DEBIT, CREDIT
|
|
from django_ledger.io.io_library import IOBluePrint, IOLibrary
|
|
from rich import print
|
|
|
|
|
|
def run():
|
|
user = inv_model.Dealer.objects.first().user
|
|
entity_name = f"{user}-{user.pk}-{user.date_joined.date()}"
|
|
|
|
entity = EntityModel.create_entity(
|
|
name=f"4-{entity_name}",
|
|
admin=user,
|
|
use_accrual_method=True,
|
|
fy_start_month=1
|
|
)
|
|
|
|
coa = entity.create_chart_of_accounts(assign_as_default=True,
|
|
commit=True,
|
|
coa_name=f"4-{entity_name}-COA")
|
|
# if coa:
|
|
# entity.populate_default_coa(activate_accounts=True, coa_model=coa)
|
|
|
|
|
|
entity.create_account(
|
|
coa_model=coa,
|
|
code="10100",
|
|
role=roles.ASSET_CA_CASH,
|
|
name='Cash',
|
|
balance_type="debit",
|
|
active=True,
|
|
)
|
|
entity.create_account(
|
|
coa_model=coa,
|
|
code="11000",
|
|
role=roles.ASSET_CA_RECEIVABLES,
|
|
name='Accounts Receivable',
|
|
balance_type="debit",
|
|
active=True
|
|
)
|
|
entity.create_account(
|
|
coa_model=coa,
|
|
code="12000",
|
|
role=roles.ASSET_CA_INVENTORY,
|
|
name='Inventory',
|
|
balance_type="debit",
|
|
active=True)
|
|
|
|
entity.create_account(
|
|
coa_model=coa,
|
|
code="20100",
|
|
role=roles.LIABILITY_CL_ACC_PAYABLE,
|
|
name='Accounts Payable',
|
|
balance_type="credit",
|
|
active=True)
|
|
|
|
entity.create_account(
|
|
coa_model=coa,
|
|
code="40100",
|
|
role=roles.INCOME_OPERATIONAL,
|
|
name='Sales Income',
|
|
balance_type="credit",
|
|
active=True)
|
|
|
|
entity.create_account(
|
|
coa_model=coa,
|
|
code="50100",
|
|
role=roles.COGS,
|
|
name='Cost of Goods Sold',
|
|
balance_type="debit",
|
|
active=True)
|
|
|
|
|
|
uom = entity.create_uom(
|
|
name='Linear Feet',
|
|
unit_abbr='lin-ft'
|
|
)
|
|
|
|
service_model = entity.create_item_service(
|
|
name='Yoga Class',
|
|
uom_model=uom
|
|
) |