chore: move dialog building function to utils.js file
(cherry picked from commit 5981c7e0ad)
This commit is contained in:
@@ -188,7 +188,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
|
|||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
me.frm.add_custom_button(__("Un-Reconcile"), function() {
|
me.frm.add_custom_button(__("Un-Reconcile"), function() {
|
||||||
me.unreconcile_prompt();
|
erpnext.utils.build_unreconcile_dialog(cur_frm);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,59 +196,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() {
|
make_maintenance_schedule() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
|
|||||||
@@ -666,6 +666,62 @@ erpnext.utils.update_child_items = function(opts) {
|
|||||||
}).show();
|
}).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) {
|
erpnext.utils.map_current_doc = function(opts) {
|
||||||
function _map() {
|
function _map() {
|
||||||
if($.isArray(cur_frm.doc.items) && cur_frm.doc.items.length > 0) {
|
if($.isArray(cur_frm.doc.items) && cur_frm.doc.items.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user