Skip to content

Commit

Permalink
wip: ach workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
agritheory committed Aug 7, 2022
1 parent 4911093 commit 00081ee
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 24 deletions.
32 changes: 32 additions & 0 deletions check_run/check_run/custom/mode_of_payment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"custom_fields": [],
"custom_perms": [],
"doctype": "Mode of Payment",
"property_setters": [
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2022-08-05 13:10:55.278054",
"default_value": null,
"doc_type": "Mode of Payment",
"docstatus": 0,
"doctype_or_field": "DocField",
"field_name": "type",
"idx": 0,
"modified": "2022-08-05 13:10:55.278054",
"modified_by": "Administrator",
"name": "Mode of Payment-type-options",
"owner": "Administrator",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "options",
"property_type": "Text",
"row_name": null,
"value": "Cash\nBank\nGeneral\nPhone\nElectronic"
}
],
"sync_on_migrate": 1
}
120 changes: 120 additions & 0 deletions check_run/check_run/custom/supplier.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,126 @@
"translatable": 0,
"unique": 0,
"width": null
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"creation": "2022-06-30 11:20:02.666689",
"default": null,
"depends_on": null,
"description": null,
"docstatus": 0,
"dt": "Supplier",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "bank",
"fieldtype": "Link",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 33,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "payment_terms",
"label": "Bank",
"length": 0,
"mandatory_depends_on": null,
"modified": "2022-06-30 11:20:02.666689",
"modified_by": "Administrator",
"name": "Supplier-bank",
"no_copy": 0,
"non_negative": 0,
"options": "Bank",
"owner": "Administrator",
"parent": null,
"parentfield": null,
"parenttype": null,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"translatable": 0,
"unique": 0,
"width": null
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"creation": "2022-06-30 11:20:02.666689",
"default": null,
"depends_on": "",
"description": "<a id=\"bank-account\">Show Bank Account Number</a>",
"docstatus": 0,
"dt": "Supplier",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "bank_account",
"fieldtype": "Password",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 36,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "default_mode_of_payment",
"label": "Bank Account",
"length": 0,
"mandatory_depends_on": null,
"modified": "2022-06-30 11:20:02.666689",
"modified_by": "Administrator",
"name": "Supplier-bank_account",
"no_copy": 0,
"non_negative": 0,
"options": null,
"owner": "Administrator",
"parent": null,
"parentfield": null,
"parenttype": null,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"translatable": 0,
"unique": 0,
"width": null
}
],
"custom_perms": [],
Expand Down
78 changes: 65 additions & 13 deletions check_run/check_run/doctype/check_run/check_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,29 @@ frappe.ui.form.on("Check Run", {
permit_first_user(frm)
get_defaults(frm)
set_queries(frm)
if(frm.is_new()){
get_balance(frm)
}
frappe.call({
method: "ach_only",
doc: frm.doc,
}).done(r => {
if(!r.message.ach_only){
if(frm.doc.docstatus == 1) {
if(frm.doc.print_count > 0){
if (!r.message.ach_only) {
if (frm.doc.docstatus == 1) {
if (frm.doc.print_count > 0 && frm.doc.status != 'Ready to Print') {
frm.add_custom_button("Re-Print Checks", () => { reprint_checks(frm) })
} else {
frm.add_custom_button("Print Checks", () => { print_checks(frm) })
} else if (frm.doc.print_count == 0 && frm.doc.status == 'Submitted') {
render_checks(frm)
}
}
if (frm.doc.status == 'Ready to Print') {
frm.add_custom_button("Download Checks", () => { download_checks(frm) })
}
}
if (!r.message.print_checks_only) {
if (frm.doc.docstatus == 1) {
frm.add_custom_button("Download NACHA File", () => { download_nacha(frm) })
}
}
})
get_entries(frm)
Expand All @@ -42,14 +53,11 @@ frappe.ui.form.on("Check Run", {
frm.set_df_property('initial_check_number', 'read_only', 1)
frm.set_df_property('final_check_number', 'read_only', 1)
}

},
onload_post_render: frm => {
frm.page.wrapper.find('.layout-side-section').hide()
permit_first_user(frm)
frappe.xcall('check_run.check_run.doctype.check_run.check_run.get_balance', { doc: frm.doc })
.then(r => {
frm.set_value('beg_balance', r)
})
},
end_date: frm => {
get_entries(frm)
Expand All @@ -74,9 +82,20 @@ frappe.ui.form.on("Check Run", {
},
pay_to_account: frm => {
get_entries(frm)
},
bank_account: frm => {
get_balance(frm)
}
})

function get_balance(frm){
frappe.xcall('check_run.check_run.doctype.check_run.check_run.get_balance', { doc: frm.doc })
.then(r => {
frm.set_value('beg_balance', r)
})
}


function set_queries(frm){
frm.set_query("bank_account", function() {
return {
Expand Down Expand Up @@ -181,13 +200,13 @@ function confirm_print(frm){
d.wrapper.find('#reprint').on('click', () => {
d.fields_dict.reprint_check_number.df.reqd = 1
let values = cur_dialog.get_values()
print_checks(frm, values.reprint_check_number || undefined)
reprint_checks(frm, values.reprint_check_number || undefined)
d.hide()
})
d.show()
}

function reprint_checks(frm){
function reprint_checks(frm) {
let d = new frappe.ui.Dialog({
title: __("Re-Print"),
fields: [
Expand All @@ -198,7 +217,7 @@ function reprint_checks(frm){
{
fieldname: 'reprint_check_number',
fieldtype: 'Data',
label: "New Initial Check Number",
label: "New Intial Check Number",
}
],
minimizable: false,
Expand All @@ -207,8 +226,11 @@ function reprint_checks(frm){
d.wrapper.find('#reprint').on('click', () => {
d.fields_dict.reprint_check_number.df.reqd = 1
let values = cur_dialog.get_values()
print_checks(frm, values.reprint_check_number || undefined)
render_checks(frm, values.reprint_check_number || undefined)
d.hide()
window.setTimeout(() => {
frm.reload_doc()
}, 1000)
})
d.show()
}
Expand All @@ -234,4 +256,34 @@ function validate_mode_of_payment_mandatory(frm){
title: __('Mode of Payment Required'),
raise_exception: true,
})
}

function render_checks(frm, reprint_check_number = undefined) {
frappe.call({
method: "increment_print_count",
doc: frm.doc,
args: { reprint_check_number: reprint_check_number }
}).done(() => {
frm.reload_doc()
frm.add_custom_button("Re-Print Checks", () => { reprint_checks(frm) })
}).fail((r) => {
frm.reload_doc()
})
}

function download_checks(frm) {
frappe.xcall("check_run.check_run.doctype.check_run.check_run.download_checks", { docname: frm.doc.name })
.then(r => {
if (r) {
frm.reload_doc()
window.open(r)
}
})
}

function download_nacha(frm) {
window.open(`/api/method/check_run.check_run.doctype.check_run.check_run.download_nacha?docname=${frm.doc.name}`)
window.setTimeout(() => {
frm.reload_doc()
}, 1000)
}
4 changes: 2 additions & 2 deletions check_run/check_run/doctype/check_run/check_run.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"fieldname": "status",
"fieldtype": "Select",
"hidden": 1,
"options": "Draft\nSubmitted\nConfirm Print\nPrinted"
"options": "Draft\nSubmitted\nReady to Print\nConfirm Print\nPrinted"
},
{
"fieldname": "check_run_table",
Expand All @@ -157,7 +157,7 @@
],
"is_submittable": 1,
"links": [],
"modified": "2022-08-03 16:34:50.373207",
"modified": "2022-08-05 11:04:34.261714",
"modified_by": "Administrator",
"module": "Check Run",
"name": "Check Run",
Expand Down
Loading

0 comments on commit 00081ee

Please sign in to comment.