[minor][fix] flag fix for payment entry creation via payment request

This commit is contained in:
Saurabh 2016-07-22 15:17:17 +05:30
parent 90c0b7fbea
commit 6e0a00b537
4 changed files with 13 additions and 10 deletions

View File

@ -33,7 +33,7 @@ frappe.ui.form.on("Payment Request", "refresh", function(frm) {
} }
if(!frm.doc.payment_gateway_account && frm.doc.status == "Initiated") { if(!frm.doc.payment_gateway_account && frm.doc.status == "Initiated") {
frm.add_custom_button(__('Mark Payment Entry'), function(){ frm.add_custom_button(__('Make Payment Entry'), function(){
frappe.call({ frappe.call({
method: "erpnext.accounts.doctype.payment_request.payment_request.make_payment_entry", method: "erpnext.accounts.doctype.payment_request.payment_request.make_payment_entry",
args: {"docname": frm.doc.name}, args: {"docname": frm.doc.name},

View File

@ -73,7 +73,7 @@ class PaymentRequest(Document):
return payment_entry return payment_entry
def create_payment_entry(self): def create_payment_entry(self, submit=True):
"""create entry""" """create entry"""
frappe.flags.ignore_account_permission = True frappe.flags.ignore_account_permission = True
@ -113,7 +113,7 @@ class PaymentRequest(Document):
"amount": payment_entry.difference_amount "amount": payment_entry.difference_amount
}) })
if not self.flags.make_draft_payment_entry: if submit:
payment_entry.insert(ignore_permissions=True) payment_entry.insert(ignore_permissions=True)
payment_entry.submit() payment_entry.submit()
@ -264,10 +264,9 @@ def resend_payment_email(docname):
return frappe.get_doc("Payment Request", docname).send_email() return frappe.get_doc("Payment Request", docname).send_email()
@frappe.whitelist() @frappe.whitelist()
def make_payment_entry(docname, make_draft_payment_entry=True): def make_payment_entry(docname):
doc = frappe.get_doc("Payment Request", docname) doc = frappe.get_doc("Payment Request", docname)
doc.flags.make_draft_payment_entry = make_draft_payment_entry return doc.create_payment_entry(submit=False).as_dict()
return doc.set_as_paid().as_dict()
def make_status_as_paid(doc, method): def make_status_as_paid(doc, method):
for ref in doc.references: for ref in doc.references:

View File

@ -57,7 +57,9 @@ def work():
payment_request = make_payment_request(dt="Sales Invoice", dn=si.name, recipient_id=si.contact_email, payment_request = make_payment_request(dt="Sales Invoice", dn=si.name, recipient_id=si.contact_email,
submit_doc=True, mute_email=True, use_dummy_message=True) submit_doc=True, mute_email=True, use_dummy_message=True)
make_payment_entry(payment_request.name, make_draft_payment_entry=False) payment_entry = frappe.get_doc(make_payment_entry(payment_request.name))
payment_entry.posting_date = frappe.flags.current_date
payment_entry.submit()
def make_payment_entries(ref_doctype, report): def make_payment_entries(ref_doctype, report):
outstanding_invoices = list(set([r[3] for r in query_report.run(report, outstanding_invoices = list(set([r[3] for r in query_report.run(report,

View File

@ -41,11 +41,13 @@ def work():
sales_order_name = get_random("Sales Order", filters={"docstatus": 1}) sales_order_name = get_random("Sales Order", filters={"docstatus": 1})
if sales_order_name: if sales_order_name:
so = frappe.get_doc("Sales Order", sales_order_name) so = frappe.get_doc("Sales Order", sales_order_name)
if (flt(so.grand_total) - flt(so.advance_paid)) > 0: if flt(so.per_billed) != 100:
payment_request = make_payment_request(dt="Sales Order", dn=so.name, recipient_id=so.contact_email, payment_request = make_payment_request(dt="Sales Order", dn=so.name, recipient_id=so.contact_email,
submit_doc=True, mute_email=True, use_dummy_message=True) submit_doc=True, mute_email=True, use_dummy_message=True)
make_payment_entry(payment_request.name, make_draft_payment_entry=False) payment_entry = frappe.get_doc(make_payment_entry(payment_request.name))
payment_entry.posting_date = frappe.flags.current_date
payment_entry.submit()
def make_opportunity(): def make_opportunity():
b = frappe.get_doc({ b = frappe.get_doc({