fix: Add journal entry in demo
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index e5d9318..a9eef94 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -78,7 +78,7 @@
"customer",
"supplier",
]
-demo_transaction_doctypes = ["purchase_invoice", "sales_invoice", "payment_entry"]
+demo_transaction_doctypes = ["purchase_invoice", "sales_invoice", "payment_entry", "journal_entry"]
jinja = {
"methods": [
diff --git a/erpnext/setup/demo.py b/erpnext/setup/demo.py
index a6d90ed..50bc43d 100644
--- a/erpnext/setup/demo.py
+++ b/erpnext/setup/demo.py
@@ -83,7 +83,9 @@
posting_date = (
start_date if doctype.get("doctype") == "Purchase Invoice" else get_random_date(start_date)
)
- bank_account = frappe.db.get_value("Company", company, "default_bank_account")
+ bank_account, default_receivable_account = frappe.db.get_value(
+ "Company", company, ["default_bank_account", "default_receivable_account"]
+ )
bank_field = "paid_to" if doctype.get("party_type") == "Customer" else "paid_from"
doctype.update(
@@ -101,20 +103,27 @@
"Company", company, ["default_income_account", "default_expense_account"]
)
- for item in doctype.get("items") or []:
- item.update(
- {
- "cost_center": erpnext.get_default_cost_center(company),
- "income_account": income_account,
- "expense_account": expense_account,
- }
- )
+ if doctype in ("Purchase Invoice", "Sales Invoice"):
+ for item in doctype.get("items") or []:
+ item.update(
+ {
+ "cost_center": erpnext.get_default_cost_center(company),
+ "income_account": income_account,
+ "expense_account": expense_account,
+ }
+ )
+ elif doctype == "Journal Entry":
+ pass
+ # update_accounts(doctype, bank_account, default_receivable_account)
doc = frappe.get_doc(doctype)
doc.save(ignore_permissions=True)
doc.submit()
+# def update_accounts(doctype, company, bank_account):
+
+
def get_random_date(start_date):
return add_days(start_date, randint(1, 365))
diff --git a/erpnext/setup/demo_data/journal_entry.json b/erpnext/setup/demo_data/journal_entry.json
new file mode 100644
index 0000000..b751c7c
--- /dev/null
+++ b/erpnext/setup/demo_data/journal_entry.json
@@ -0,0 +1,25 @@
+[
+ {
+ "cheque_date": "2023-03-14",
+ "cheque_no": "33",
+ "doctype": "Journal Entry",
+ "accounts": [
+ {
+ "party_type": "Customer",
+ "party": "ABC Enterprises",
+ "credit_in_account_currency": 40000.0,
+ "debit_in_account_currency": 0.0,
+ "doctype": "Journal Entry Account",
+ "parentfield": "accounts",
+ },
+ {
+ "credit_in_account_currency": 0.0,
+ "debit_in_account_currency": 40000.0,
+ "doctype": "Journal Entry Account",
+ "parentfield": "accounts",
+ }
+ ],
+ "user_remark": "test",
+ "voucher_type": "Bank Entry"
+ }
+]
\ No newline at end of file