I am testing adding Journal Entry programmatically. This is my sample code.
def on_submit(self):
from erpnext.accounts.general_ledger import make_gl_entries
gl_map = []
credit_account = frappe.get_doc("Account", "Debtors - CI")
debit_account = frappe.get_doc("Account", "Cash - CI")
customer = frappe.get_doc("Customer", "Juan de la cruz")
gl_map.append(
frappe._dict({
"account": credit_account,
"party_type": "Customer",
"party": customer,
"against": debit_account,
"debit": flt(10000),
"credit": flt(10000),
"remarks": "Test Journal",
})
)
if gl_map:
make_gl_entries(gl_map, cancel=0, adv_adj=0)
but when I submit I got this error
Incorrect number of General Ledger Entries found. You might have selected a wrong Account in the transaction.
What did I miss? Or I did it totally wrong?