chore: move dialog building function to utils.js
file
This commit is contained in:
parent
58dc0e52e1
commit
5981c7e0ad
@ -194,7 +194,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
|
||||
callback: function(r) {
|
||||
if (r.message) {
|
||||
me.frm.add_custom_button(__("Un-Reconcile"), function() {
|
||||
me.unreconcile_prompt();
|
||||
erpnext.utils.build_unreconcile_dialog(cur_frm);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -202,59 +202,6 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
|
||||
}
|
||||
}
|
||||
|
||||
unreconcile_prompt() {
|
||||
let child_table_fields = [
|
||||
{ label: __("Voucher Type"), fieldname: "voucher_type", fieldtype: "Dynamic Link", options: "DocType", in_list_view: 1, read_only: 1},
|
||||
{ label: __("Voucher No"), fieldname: "voucher_no", fieldtype: "Link", options: "voucher_type", in_list_view: 1, read_only: 1 },
|
||||
{ label: __("Allocated Amount"), fieldname: "allocated_amount", fieldtype: "Float", in_list_view: 1, read_only: 1 },
|
||||
]
|
||||
let unreconcile_dialog_fields = [
|
||||
{
|
||||
label: __('Allocations'),
|
||||
fieldname: 'allocations',
|
||||
fieldtype: 'Table',
|
||||
read_only: 1,
|
||||
fields: child_table_fields,
|
||||
},
|
||||
];
|
||||
|
||||
// get linked payments
|
||||
frappe.call({
|
||||
"method": "erpnext.accounts.doctype.unreconcile_payments.unreconcile_payments.get_linked_payments_for_doc",
|
||||
"args": {
|
||||
"company": this.frm.doc.company,
|
||||
"doctype": this.frm.doc.doctype,
|
||||
"docname": this.frm.doc.name
|
||||
},
|
||||
callback: function(r) {
|
||||
if (r.message) {
|
||||
// populate child table with allocations
|
||||
unreconcile_dialog_fields[0].data = r.message;
|
||||
unreconcile_dialog_fields[0].get_data = function(){ return r.message};
|
||||
|
||||
let d = new frappe.ui.Dialog({
|
||||
title: 'Un-Reconcile Allocations',
|
||||
fields: unreconcile_dialog_fields,
|
||||
size: 'large',
|
||||
cannot_add_rows: 1,
|
||||
primary_action_label: 'Un-Reconcile',
|
||||
primary_action(values) {
|
||||
|
||||
let selected_allocations = values.allocations.filter(x=>x.__checked);
|
||||
if (selected_allocations.length > 0) {
|
||||
// assuming each row is an individual voucher
|
||||
// pass this to server side method that created unreconcile doc for row
|
||||
} else {
|
||||
frappe.msgprint("No Selection");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
d.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
make_maintenance_schedule() {
|
||||
frappe.model.open_mapped_doc({
|
||||
|
@ -769,6 +769,62 @@ erpnext.utils.update_child_items = function(opts) {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
erpnext.utils.build_unreconcile_dialog = function(frm) {
|
||||
if (['Sales Invoice', 'Purchase Invoice', 'Payment Entry', 'Journal Entry'].includes(frm.doc.doctype)) {
|
||||
let child_table_fields = [
|
||||
{ label: __("Voucher Type"), fieldname: "voucher_type", fieldtype: "Dynamic Link", options: "DocType", in_list_view: 1, read_only: 1},
|
||||
{ label: __("Voucher No"), fieldname: "voucher_no", fieldtype: "Link", options: "voucher_type", in_list_view: 1, read_only: 1 },
|
||||
{ label: __("Allocated Amount"), fieldname: "allocated_amount", fieldtype: "Float", in_list_view: 1, read_only: 1 },
|
||||
]
|
||||
let unreconcile_dialog_fields = [
|
||||
{
|
||||
label: __('Allocations'),
|
||||
fieldname: 'allocations',
|
||||
fieldtype: 'Table',
|
||||
read_only: 1,
|
||||
fields: child_table_fields,
|
||||
},
|
||||
];
|
||||
|
||||
// get linked payments
|
||||
frappe.call({
|
||||
"method": "erpnext.accounts.doctype.unreconcile_payments.unreconcile_payments.get_linked_payments_for_doc",
|
||||
"args": {
|
||||
"company": frm.doc.company,
|
||||
"doctype": frm.doc.doctype,
|
||||
"docname": frm.doc.name
|
||||
},
|
||||
callback: function(r) {
|
||||
if (r.message) {
|
||||
// populate child table with allocations
|
||||
unreconcile_dialog_fields[0].data = r.message;
|
||||
unreconcile_dialog_fields[0].get_data = function(){ return r.message};
|
||||
|
||||
let d = new frappe.ui.Dialog({
|
||||
title: 'Un-Reconcile Allocations',
|
||||
fields: unreconcile_dialog_fields,
|
||||
size: 'large',
|
||||
cannot_add_rows: 1,
|
||||
primary_action_label: 'Un-Reconcile',
|
||||
primary_action(values) {
|
||||
|
||||
let selected_allocations = values.allocations.filter(x=>x.__checked);
|
||||
if (selected_allocations.length > 0) {
|
||||
// assuming each row is an individual voucher
|
||||
// pass this to server side method that created unreconcile doc for row
|
||||
} else {
|
||||
frappe.msgprint("No Selection");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
d.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.utils.map_current_doc = function(opts) {
|
||||
function _map() {
|
||||
if($.isArray(cur_frm.doc.items) && cur_frm.doc.items.length > 0) {
|
||||
@ -1097,4 +1153,4 @@ function attach_selector_button(inner_text, append_loction, context, grid_row) {
|
||||
$btn.on("click", function() {
|
||||
context.show_serial_batch_selector(grid_row.frm, grid_row.doc, "", "", true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user