Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grant file download access for multiple downloads to specific roles. #235

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions check_run/check_run/doctype/check_run/check_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,26 @@ function ach_only(frm) {
}
}
if (!r.print_checks_only) {
if (frm.doc.docstatus == 1) {
frm.add_custom_button(__('Download NACHA File'), () => {
download_nacha(frm)
})
if (frm.doc.docstatus == 1 && frm.doc.ach_file_generated == 1) {
frappe
.xcall('check_run.check_run.doctype.check_run.check_run.get_authorized_role_for_ach', { doc: frm.doc })
.then(r => {
if (frappe.user.has_role(r)) {
add_download_nacha_button(frm)
}
})
}
if (frm.doc.docstatus == 1 && frm.doc.ach_file_generated == 0) {
add_download_nacha_button(frm)
}
}
})
}

function add_download_nacha_button(frm) {
frm.add_custom_button(__('Download NACHA File'), () => {
download_nacha(frm)
})
}
function validate_mode_of_payment_mandatory(frm) {
let mode_of_payment_required = []
for (const index in frm.transactions) {
Expand Down Expand Up @@ -399,6 +410,9 @@ function download_nacha(frm) {
window.setTimeout(() => {
frm.reload_doc()
}, 1000)
if (!frm.doc.ach_file_generated) {
frappe.db.set_value('Check Run', frm.doc.name, 'ach_file_generated', 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor this to use a whitelisted function. Generally we want to avoid the use of the frappe.db API in JS because of the permissions issues it presents.

}
}

function settings_button(frm) {
Expand Down
Loading
Loading