@@ -35,22 +35,26 @@ from django_ledger.io import roles
3535
3636``` python
3737# change this to your preferred django username...
38- MY_USERNAME = ' elarroba'
38+ MY_USERNAME = ' ceo_user'
39+ MY_PASSWORD = ' NeverUseMe|VeryInsecure!'
3940UserModel = get_user_model()
40- user_model = UserModel.objects.get(username__exact = MY_USERNAME )
41+
42+ try :
43+ user_model = UserModel.objects.get(username__exact = MY_USERNAME )
44+ except :
45+ user_model = UserModel.objects.create(username = MY_USERNAME , password = MY_PASSWORD )
4146```
4247
4348# Create an Entity Model
4449
4550
4651``` python
47- entity_model = EntityModel(
52+ entity_model = EntityModel.create_entity (
4853 name = ' One Big Company, LLC' ,
4954 admin = user_model,
50- accrual_method = True
55+ use_accrual_method = True ,
56+ fy_start_month = 1
5157)
52- entity_model.clean()
53- entity_model = EntityModel.add_root(instance = entity_model)
5458```
5559
5660
@@ -70,9 +74,10 @@ entity_model.has_default_coa()
7074
7175``` python
7276default_coa_model = entity_model.create_chart_of_accounts(
73- assign_as_default = True ,
74- commit = True ,
75- coa_name = ' My QuickStart CoA' )
77+ assign_as_default = True ,
78+ commit = True ,
79+ coa_name = ' My QuickStart CoA'
80+ )
7681```
7782
7883
@@ -113,9 +118,10 @@ default_coa_model = entity_model.get_default_coa()
113118
114119``` python
115120another_coa_model = entity_model.create_chart_of_accounts(
116- assign_as_default = False ,
117- commit = True ,
118- coa_name = ' My Legacy Chart of Accounts' )
121+ assign_as_default = False ,
122+ commit = True ,
123+ coa_name = ' My Legacy Chart of Accounts'
124+ )
119125```
120126
121127# Accounts
@@ -128,9 +134,10 @@ coa_qs, coa_map = entity_model.get_all_coa_accounts()
128134pd.DataFrame(coa_map[default_coa_model].values())
129135```
130136
137+ ### New CoA does not have any accounts yet...
138+
131139
132140``` python
133- # new CoA does not have any accounts yet...
134141pd.DataFrame(coa_map[another_coa_model].values())
135142```
136143
@@ -166,13 +173,6 @@ coa_accounts_by_coa_slug_qs = entity_model.get_coa_accounts(coa_model=default_co
166173pd.DataFrame(coa_accounts_by_coa_slug_qs.values())
167174```
168175
169-
170- ``` python
171- # coa_accounts_by_codes_qs = entity_model.get_accounts_with_codes(code_list=['ABC'],
172- # coa_model=another_coa_model)
173- # pd.DataFrame(coa_accounts_by_codes_qs.values())
174- ```
175-
176176## Get Accounts With Codes and CoA Model
177177
178178
@@ -188,7 +188,7 @@ pd.DataFrame(coa_accounts_by_codes_qs.values())
188188coa_model, account_model = entity_model.create_account(
189189 coa_model = another_coa_model,
190190 account_model_kwargs = {
191- ' code' : f ' 1 { str (randint(10000 ,99999 ))} ABC ' ,
191+ ' code' : f ' 1 { str (randint(10000 , 99999 ))} ABC ' ,
192192 ' role' : roles.ASSET_CA_INVENTORY ,
193193 ' name' : ' A cool account created from the EntityModel API!' ,
194194 ' balance_type' : roles.DEBIT ,
@@ -203,8 +203,8 @@ account_model
203203
204204
205205``` python
206- given_coa_accounts_qs = entity_model.get_coa_accounts(coa_model = another_coa_model)
207- pd.DataFrame(given_coa_accounts_qs .values())
206+ another_coa_accounts_qs = entity_model.get_coa_accounts(coa_model = another_coa_model)
207+ pd.DataFrame(another_coa_accounts_qs .values())
208208```
209209
210210# Customers
@@ -269,7 +269,7 @@ invoice_model = entity_model.create_invoice(
269269
270270
271271``` python
272- # invoice_model.
272+ invoice_model
273273```
274274
275275## Add Items to Invoices
@@ -278,6 +278,7 @@ invoice_model = entity_model.create_invoice(
278278``` python
279279invoices_item_models = invoice_model.get_item_model_qs()
280280
281+ # K= number of items...
281282K = 6
282283
283284invoice_itemtxs = {
@@ -320,6 +321,11 @@ bill_model = entity_model.create_bill(
320321)
321322```
322323
324+
325+ ``` python
326+ bill_model
327+ ```
328+
323329## Add Items to Bills
324330
325331
@@ -410,7 +416,7 @@ pd.DataFrame(estimates_qs.values())
410416
411417``` python
412418estimate_model = entity_model.create_estimate(
413- estimate_title = ' A quote for new potential customer!' ,
419+ estimate_title = ' A quote for new potential customer!' ,
414420 customer_model = ' C-0000000009' ,
415421 contract_terms = EstimateModel.CONTRACT_TERMS_FIXED
416422)
@@ -619,11 +625,13 @@ inventory_model.is_inventory()
619625
620626``` python
621627bs_report = entity_model.get_balance_sheet_statement(
622- to_date = date(2022 ,12 ,31 ),
628+ to_date = date(2022 , 12 , 31 ),
623629 save_pdf = True ,
630+ filepath = ' ./'
624631)
625632# save_pdf=True saves the PDF report in the project's BASE_DIR.
626633# filename and filepath may also be specified...
634+ # will raise not implemented error if PDF support is not enabled...
627635```
628636
629637### Balance Sheet Statement Raw Data
@@ -638,12 +646,14 @@ bs_report.get_report_data()
638646
639647``` python
640648ic_report = entity_model.get_income_statement(
641- from_date = date(2022 ,1 ,1 ),
642- to_date = date(2022 ,12 ,31 ),
643- save_pdf = True
649+ from_date = date(2022 , 1 , 1 ),
650+ to_date = date(2022 , 12 , 31 ),
651+ save_pdf = True ,
652+ filepath = ' ./'
644653)
645654# save_pdf=True saves the PDF report in the project's BASE_DIR.
646655# filename and filepath may also be specified...
656+ # will raise not implemented error if PDF support is not enabled...
647657```
648658
649659### Income Statement Raw Data
@@ -658,9 +668,10 @@ ic_report.get_report_data()
658668
659669``` python
660670cf_report = entity_model.get_cash_flow_statement(
661- from_date = date(2022 ,1 ,1 ),
662- to_date = date(2022 ,12 ,31 ),
663- save_pdf = True
671+ from_date = date(2022 , 1 , 1 ),
672+ to_date = date(2022 , 12 , 31 ),
673+ save_pdf = True ,
674+ filepath = ' ./'
664675)
665676# save_pdf=True saves the PDF report in the project's BASE_DIR.
666677# filename and filepath may also be specified...
@@ -679,9 +690,10 @@ cf_report.get_report_data()
679690``` python
680691reports = entity_model.get_financial_statements(
681692 user_model = user_model,
682- from_date = date(2022 ,1 ,1 ),
683- to_date = date(2022 ,12 ,31 ),
684- save_pdf = True
693+ from_date = date(2022 , 1 , 1 ),
694+ to_date = date(2022 , 12 , 31 ),
695+ save_pdf = True ,
696+ filepath = ' ./'
685697)
686698# save_pdf=True saves the PDF report in the project's BASE_DIR.
687699# filename and filepath may also be specified...
0 commit comments