Skip to content

Commit

Permalink
wip: add print format to crs, don't override payable account if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
agritheory committed Aug 29, 2022
1 parent 44cb68c commit 6dca9fa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
10 changes: 10 additions & 0 deletions check_run/check_run/doctype/check_run/check_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
})
})
}
17 changes: 13 additions & 4 deletions check_run/check_run/doctype/check_run/check_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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
)
)
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"bank_account",
"column_break_3",
"pay_to_account",
"print_format",
"section_break_4",
"include_purchase_invoices",
"include_journal_entries",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 6dca9fa

Please sign in to comment.