How to make payment entry form user created doctype

Hi,
I have a doctype name mydoctype i want to create a payment entry as draft when i submit mydoctype and payment type should be pay i have tried below code but when try to submitt mydoctype

i get this error Received Amount is mandatory

but my payment type is “pay”

what i have i tried is

in before save method is

hotel = frappe.db.sql(""" select name,hotel,total_amount,amount_paid,due_amount from`tabHotel Booking` where name='{0}'""".format(name))
ope = frappe.new_doc("Payment Entry")
ope.payment_type = "Pay"
ope.posting_date = today()
ope.party_type = "Supplier"
ope.mode_of_payment = "Cash"
ope.paid_from = "Cash - S"
ope.paid_to = "Creditors - S"
ope.paid_to_account_currency = "BHD"
ope.company = "XXX"
ope.paid_amount = 1000
ope.party = "MY Party"
ope.party_name = "My Party"
ope.docstatus = 0
ope.party_account_field = "paid_to"
ope.party_account = "Creditors - S"
ope.recieved_amount = 1000
ope.save()

Both the amount (paid and received) are required. For reference, please check erpnext/payment_entry.py at develop · frappe/erpnext · GitHub

1 Like

@nabinhait thanks