[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") {
frm.add_custom_button(__('Mark Payment Entry'), function(){
frm.add_custom_button(__('Make Payment Entry'), function(){
frappe.call({
method: "erpnext.accounts.doctype.payment_request.payment_request.make_payment_entry",
args: {"docname": frm.doc.name},

View File

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

View File

@ -57,12 +57,14 @@ def work():
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)
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):
outstanding_invoices = list(set([r[3] for r in query_report.run(report,
{"report_date": frappe.flags.current_date })["result"] if r[2]==ref_doctype]))
# make Payment Entry
for inv in outstanding_invoices[:random.randint(1, 2)]:
pe = get_payment_entry(ref_doctype, inv)

View File

@ -41,11 +41,13 @@ def work():
sales_order_name = get_random("Sales Order", filters={"docstatus": 1})
if 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,
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():
b = frappe.get_doc({