feat: assign pe status on creation of payment order

This commit is contained in:
Mangesh-Khairnar 2019-05-08 16:04:18 +05:30
parent 8aa9589aaf
commit a4d55c9858
3 changed files with 25 additions and 20 deletions

View File

@ -11,7 +11,7 @@
"party", "party",
"column_break_2", "column_break_2",
"posting_date", "posting_date",
"bank", "company_bank",
"company_bank_account", "company_bank_account",
"section_break_5", "section_break_5",
"references", "references",
@ -23,6 +23,7 @@
"fieldname": "naming_series", "fieldname": "naming_series",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Series", "label": "Series",
"no_copy": 1,
"options": "PMO-", "options": "PMO-",
"reqd": 1 "reqd": 1
}, },
@ -34,6 +35,7 @@
"reqd": 1 "reqd": 1
}, },
{ {
"depends_on": "eval: doc.payment_order_type=='Payment Request';",
"fieldname": "party", "fieldname": "party",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1, "in_list_view": 1,
@ -51,14 +53,6 @@
"in_list_view": 1, "in_list_view": 1,
"label": "Posting Date" "label": "Posting Date"
}, },
{
"fetch_from": "Company.default_bank",
"fieldname": "bank",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Bank",
"options": "Bank"
},
{ {
"fieldname": "section_break_5", "fieldname": "section_break_5",
"fieldtype": "Section Break" "fieldtype": "Section Break"
@ -84,17 +78,27 @@
"fieldname": "payment_order_type", "fieldname": "payment_order_type",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Payment Order Type", "label": "Payment Order Type",
"options": "\nPayment Request\nPayment Entry" "options": "\nPayment Request\nPayment Entry",
"reqd": 1
}, },
{ {
"fieldname": "company_bank_account", "fieldname": "company_bank_account",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Company Bank Account", "label": "Company Bank Account",
"options": "Bank Account" "options": "Bank Account",
"reqd": 1
},
{
"fetch_from": "company_bank_account.bank",
"fieldname": "company_bank",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Bank",
"options": "Bank"
} }
], ],
"is_submittable": 1, "is_submittable": 1,
"modified": "2019-05-06 19:57:03.661653", "modified": "2019-05-08 16:00:09.027739",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Payment Order", "name": "Payment Order",

View File

@ -11,18 +11,18 @@ from frappe.model.document import Document
class PaymentOrder(Document): class PaymentOrder(Document):
def on_submit(self): def on_submit(self):
self.update_payment_request_status() self.update_payment_status()
def on_cancel(self): def on_cancel(self):
self.update_payment_request_status(cancel=True) self.update_payment_status(cancel=True)
def update_payment_request_status(self, cancel=False): def update_payment_status(self, cancel=False):
status = 'Payment Ordered' status = 'Payment Ordered'
if cancel: if cancel:
status = 'Initiated' status = 'Initiated'
for d in self.references: for d in self.references:
frappe.db.set_value('Payment Request', d.payment_request, 'status', status) frappe.db.set_value(self.payment_order_type, d.get(frappe.scrub(self.payment_order_type)), 'status', status)
def get_mop_query(doctype, txt, searchfield, start, page_len, filters): def get_mop_query(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(""" select mode_of_payment from `tabPayment Order Reference` return frappe.db.sql(""" select mode_of_payment from `tabPayment Order Reference`
@ -60,7 +60,7 @@ def make_journal_entry(doc, supplier, mode_of_payment=None):
je.voucher_type = 'Bank Entry' je.voucher_type = 'Bank Entry'
if mode_of_payment and mode_of_payment_type.get(mode_of_payment) == 'Cash': if mode_of_payment and mode_of_payment_type.get(mode_of_payment) == 'Cash':
je.voucher_type = "Cash Entry" je.voucher_type = "Cash Entry"
paid_amt = 0 paid_amt = 0
party_account = get_party_account('Supplier', supplier, doc.company) party_account = get_party_account('Supplier', supplier, doc.company)
for d in doc.references: for d in doc.references:
@ -84,4 +84,4 @@ def make_journal_entry(doc, supplier, mode_of_payment=None):
je.flags.ignore_mandatory = True je.flags.ignore_mandatory = True
je.save() je.save()
frappe.msgprint(_("{0} {1} created").format(je.doctype, je.name)) frappe.msgprint(_("{0} {1} created").format(je.doctype, je.name))

View File

@ -82,7 +82,8 @@
"fieldtype": "Link", "fieldtype": "Link",
"label": "Bank Account", "label": "Bank Account",
"options": "Bank Account", "options": "Bank Account",
"read_only": 1 "read_only": 1,
"reqd": 1
}, },
{ {
"fieldname": "column_break_10", "fieldname": "column_break_10",
@ -112,7 +113,7 @@
} }
], ],
"istable": 1, "istable": 1,
"modified": "2019-05-05 22:23:32.723766", "modified": "2019-05-08 13:56:25.724557",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Payment Order Reference", "name": "Payment Order Reference",