Hello Community.
I am trying to programatically Register New Payment Entries in ERPNext, and my target is to register them and as well attach the references to Sales Invoices against which they are paid.
Below is my implementation.
payment_entry = frappe.new_doc("Payment Entry")
payment_entry.naming_series = "ACC-PAY-.YYYY.-"
payment_entry.payment_type = "Receive"
payment_entry.mode_of_payment = "Cash"
payment_entry.party_type = "Customer"
payment_entry.party = transaction["customer"]
payment_entry.paid_amount = int(transaction["amount"])
payment_entry.transaction_id = transaction["reference_id"]
payment_entry.source_exchange_rate = 0.07
payment_entry.target_exchange_rate = 0.07
payment_entry.paid_to_account_currency = "UGX"
payment_entry.received_amount = transaction["amount"]
payment_entry.paid_to = "Cash - CA"
payment_entry.append("references", {
"reference_doctype": "Sales Invoice",
"reference_name": transaction["invoice"],
})
payment_entry.save()
I have a variable transaction which has a value of Sales Invoice, Payment Entry is created but it does not include the References. Is there something wrong with my implementation or Is there a correct way to achieve this?
Thank you!