Hi,
Am attempting to create a function to add a journal entry. And getting this error. frappe.exceptions.ValidationError: Party Type must be set first
Below is the code
@frappe.whitelist(allow_guest=True)
def insert_journalx(dr,cr,ref,amount):
jv = frappe.new_doc(‘Journal Entry’)
jv.voucher_type = ‘Journal Entry’
jv.naming_series = ‘ACC-JV-.YYYY.-’
jv.posting_date = ‘2023-08-01’
jv.company = ‘KIMANA FARM’
jv.remark = ‘test’
jv.append('accounts', {
'account': dr ,
'party_type' : 'Student',
'party' : ref,
'credit' : float(amount),
'debit' : float(0),
'debit_in_account_currency' : float(0),
'credit_in_account_currency' : float(amount)
})
jv.append('accounts', {
'account': cr ,
'party_type' : 'Student',
'party' : ref,
'debit' : float(amount),
'credit' : float(0),
'credit_in_account_currency' : float(0),
'debit_in_account_currency' : float(amount)
})
jv.save()
jv.submit()