diff --git a/check_run/check_run/doctype/check_run/check_run.js b/check_run/check_run/doctype/check_run/check_run.js index 463f5dcb..ab7e66b0 100644 --- a/check_run/check_run/doctype/check_run/check_run.js +++ b/check_run/check_run/doctype/check_run/check_run.js @@ -19,6 +19,7 @@ frappe.ui.form.on("Check Run", { }, refresh: frm => { frm.layout.show_message('') + settings_button(frm) permit_first_user(frm) get_defaults(frm) set_queries(frm) @@ -308,3 +309,12 @@ function download_nacha(frm) { frm.reload_doc() }, 1000) } + +function settings_button(frm){ + frm.add_custom_button("Modify Settings", () => { + frappe.xcall("check_run.check_run.doctype.check_run.check_run.get_check_run_settings", { doc: frm.doc } + ).then(r => { + frappe.set_route("Form", "Check Run Settings", r.name) + }) + }) +} \ No newline at end of file diff --git a/check_run/check_run/doctype/check_run/check_run.py b/check_run/check_run/doctype/check_run/check_run.py index 1b4e8858..80c18d24 100644 --- a/check_run/check_run/doctype/check_run/check_run.py +++ b/check_run/check_run/doctype/check_run/check_run.py @@ -25,6 +25,8 @@ class CheckRun(Document): def onload(self): + if self.is_new(): + return settings = get_check_run_settings(self) if not settings: self.set_onload('settings_missing', True) @@ -77,7 +79,8 @@ def get_last_check_number(self): self.initial_check_number = int(check_number or 0) + 1 def get_default_payable_account(self): - self.pay_to_account = frappe.get_value('Company', self.company, "default_payable_account") + if not self.pay_to_account: + self.pay_to_account = frappe.get_value('Company', self.company, "default_payable_account") def set_default_dates(self): if not self.posting_date: @@ -220,6 +223,7 @@ def increment_print_count(self, reprint_check_number=None): def render_check_pdf(self, reprint_check_number=None): if not frappe.db.exists('File', 'Home/Check Run'): frappe.new_doc("File").update({"file_name":"Check Run", "is_folder": True, "folder":"Home"}).save() + settings = get_check_run_settings(self) initial_check_number = int(self.initial_check_number) if reprint_check_number and reprint_check_number != 'undefined': self.initial_check_number = int(reprint_check_number) @@ -234,7 +238,7 @@ def render_check_pdf(self, reprint_check_number=None): output = frappe.get_print( 'Payment Entry', pe, - frappe.get_meta('Payment Entry').default_print_format, + settings.print_format or frappe.get_meta('Payment Entry').default_print_format, as_pdf=True, output=output, no_letterhead=0, @@ -245,6 +249,10 @@ def render_check_pdf(self, reprint_check_number=None): ref['check_number'] = self.initial_check_number + check_increment _transactions.append(ref) check_increment += 1 + elif docstatus == 1: + for ref in group: + _transactions.append(ref) + if _transactions and reprint_check_number: frappe.db.set_value('Check Run', self.name, 'transactions', json.dumps(_transactions)) frappe.db.set_value('Check Run', self.name, 'initial_check_number', self.initial_check_number) @@ -367,6 +375,7 @@ def get_entries(doc): FROM `tabPayment Entry`, `tabPayment Entry Reference` WHERE `tabPayment Entry Reference`.parent = `tabPayment Entry`.name AND `tabPayment Entry Reference`.reference_doctype = 'Journal Entry' + AND `tabPayment Entry`.party = `tabJournal Entry Account`.party AND `tabPayment Entry`.docstatus = 1 ) ) @@ -467,8 +476,8 @@ def build_nacha_file_from_payment_entries(doc, payment_entries, settings): exceptions.append(f'{pe.party_type} Bank missing for {pe.party_name}') if party_bank: party_bank_routing_number = frappe.db.get_value('Bank', party_bank, 'aba_number') - if not party_bank_routing_number: - exceptions.append(f'{pe.party_type} Bank Routing Number missing for {pe.party_name}/{employee_bank}') + if not party_bank_routing_number: + exceptions.append(f'{pe.party_type} Bank Routing Number missing for {pe.party_name}/{employee_bank}') ach_entry = ACHEntry( transaction_code=22, # checking account receiving_dfi_identification=party_bank_routing_number, diff --git a/check_run/check_run/doctype/check_run_settings/check_run_settings.json b/check_run/check_run/doctype/check_run_settings/check_run_settings.json index 67f167ef..a700a9e5 100644 --- a/check_run/check_run/doctype/check_run_settings/check_run_settings.json +++ b/check_run/check_run/doctype/check_run_settings/check_run_settings.json @@ -10,6 +10,7 @@ "bank_account", "column_break_3", "pay_to_account", + "print_format", "section_break_4", "include_purchase_invoices", "include_journal_entries", @@ -125,10 +126,16 @@ "fieldname": "ach_description", "fieldtype": "Data", "label": "ACH Description" + }, + { + "fieldname": "print_format", + "fieldtype": "Link", + "label": "Print Format", + "options": "Print Format" } ], "links": [], - "modified": "2022-08-22 19:30:11.238397", + "modified": "2022-08-26 16:54:08.327344", "modified_by": "Administrator", "module": "Check Run", "name": "Check Run Settings",