fix: convert whitespace to tabs
This commit is contained in:
parent
7554f11260
commit
614b9270e7
@ -2,8 +2,8 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('Ledger Merge', {
|
frappe.ui.form.on('Ledger Merge', {
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
frappe.realtime.on('ledger_merge_refresh', ({ ledger_merge }) => {
|
frappe.realtime.on('ledger_merge_refresh', ({ ledger_merge }) => {
|
||||||
if (ledger_merge !== frm.doc.name) return;
|
if (ledger_merge !== frm.doc.name) return;
|
||||||
frm.refresh();
|
frm.refresh();
|
||||||
});
|
});
|
||||||
@ -11,57 +11,54 @@ frappe.ui.form.on('Ledger Merge', {
|
|||||||
frappe.realtime.on('ledger_merge_progress', data => {
|
frappe.realtime.on('ledger_merge_progress', data => {
|
||||||
if (data.ledger_merge !== frm.doc.name) return;
|
if (data.ledger_merge !== frm.doc.name) return;
|
||||||
let message = __('Merging {0} of {1}', [data.current, data.total]);
|
let message = __('Merging {0} of {1}', [data.current, data.total]);
|
||||||
let percent = Math.floor((data.current * 100) / data.total);
|
let percent = Math.floor((data.current * 100) / data.total);
|
||||||
frm.dashboard.show_progress(__('Merge Progress'), percent, message);
|
frm.dashboard.show_progress(__('Merge Progress'), percent, message);
|
||||||
frm.page.set_indicator(__('In Progress'), 'orange');
|
frm.page.set_indicator(__('In Progress'), 'orange');
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.set_query("account", function(doc) {
|
frm.set_query("account", function(doc) {
|
||||||
if (!doc.company) frappe.throw(__('Please set Company'));
|
if (!doc.company) frappe.throw(__('Please set Company'));
|
||||||
if (!doc.root_type) frappe.throw(__('Please set Root Type'));
|
if (!doc.root_type) frappe.throw(__('Please set Root Type'));
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
is_group: 0,
|
|
||||||
root_type: doc.root_type,
|
|
||||||
company: doc.company
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
frm.set_query('account', 'merge_accounts', function(doc, cdt, cdn) {
|
|
||||||
if (!doc.company) frappe.throw(__('Please set Company'));
|
|
||||||
if (!doc.root_type) frappe.throw(__('Please set Root Type'));
|
|
||||||
if (!doc.account) frappe.throw(__('Please set Account'));
|
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
is_group: 0,
|
is_group: 0,
|
||||||
root_type: doc.root_type,
|
root_type: doc.root_type,
|
||||||
name: ["!=", doc.account],
|
company: doc.company
|
||||||
company: doc.company
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
|
||||||
|
|
||||||
refresh: function(frm) {
|
frm.set_query('account', 'merge_accounts', function(doc, cdt, cdn) {
|
||||||
frm.page.hide_icon_group();
|
if (!doc.company) frappe.throw(__('Please set Company'));
|
||||||
frm.trigger('set_merge_status');
|
if (!doc.root_type) frappe.throw(__('Please set Root Type'));
|
||||||
|
if (!doc.account) frappe.throw(__('Please set Account'));
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
is_group: 0,
|
||||||
|
root_type: doc.root_type,
|
||||||
|
name: ["!=", doc.account],
|
||||||
|
company: doc.company
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onload_post_render: function(frm) {
|
refresh: function(frm) {
|
||||||
|
frm.page.hide_icon_group();
|
||||||
|
frm.trigger('set_merge_status');
|
||||||
|
},
|
||||||
|
|
||||||
|
onload_post_render: function(frm) {
|
||||||
frm.trigger('update_primary_action');
|
frm.trigger('update_primary_action');
|
||||||
},
|
},
|
||||||
|
|
||||||
after_save: function(frm) {
|
after_save: function(frm) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
frm.trigger('update_primary_action');
|
frm.trigger('update_primary_action');
|
||||||
}, 750);
|
}, 500);
|
||||||
},
|
},
|
||||||
|
|
||||||
update_primary_action: function(frm) {
|
update_primary_action: function(frm) {
|
||||||
console.log(!frm.is_new());
|
|
||||||
console.log(frm.is_dirty());
|
|
||||||
console.log("-");
|
|
||||||
if (frm.is_dirty()) {
|
if (frm.is_dirty()) {
|
||||||
frm.enable_save();
|
frm.enable_save();
|
||||||
return;
|
return;
|
||||||
@ -69,8 +66,7 @@ frappe.ui.form.on('Ledger Merge', {
|
|||||||
frm.disable_save();
|
frm.disable_save();
|
||||||
if (frm.doc.status !== 'Success') {
|
if (frm.doc.status !== 'Success') {
|
||||||
if (!frm.is_new()) {
|
if (!frm.is_new()) {
|
||||||
let label =
|
let label = frm.doc.status === 'Pending' ? __('Start Merge') : __('Retry');
|
||||||
frm.doc.status === 'Pending' ? __('Start Merge') : __('Retry');
|
|
||||||
frm.page.set_primary_action(label, () => frm.events.start_merge(frm));
|
frm.page.set_primary_action(label, () => frm.events.start_merge(frm));
|
||||||
} else {
|
} else {
|
||||||
frm.page.set_primary_action(__('Save'), () => frm.save());
|
frm.page.set_primary_action(__('Save'), () => frm.save());
|
||||||
@ -78,8 +74,8 @@ frappe.ui.form.on('Ledger Merge', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
start_merge: function(frm) {
|
start_merge: function(frm) {
|
||||||
frm.call({
|
frm.call({
|
||||||
method: 'form_start_merge',
|
method: 'form_start_merge',
|
||||||
args: { docname: frm.doc.name },
|
args: { docname: frm.doc.name },
|
||||||
btn: frm.page.btn_primary
|
btn: frm.page.btn_primary
|
||||||
@ -88,37 +84,39 @@ frappe.ui.form.on('Ledger Merge', {
|
|||||||
frm.disable_save();
|
frm.disable_save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
set_merge_status: function(frm) {
|
set_merge_status: function(frm) {
|
||||||
if (frm.doc.status == "Pending") return;
|
if (frm.doc.status == "Pending") return;
|
||||||
let successful_records = 0;
|
let successful_records = 0;
|
||||||
frm.doc.merge_accounts.forEach((row) => {
|
frm.doc.merge_accounts.forEach((row) => {
|
||||||
if(row.merged) successful_records += 1;
|
if(row.merged) successful_records += 1;
|
||||||
});
|
});
|
||||||
let message_args = [successful_records, frm.doc.merge_accounts.length];
|
let message_args = [successful_records, frm.doc.merge_accounts.length];
|
||||||
frm.dashboard.set_headline(__('Successfully merged {0} out of {1}.', message_args));
|
frm.dashboard.set_headline(__('Successfully merged {0} out of {1}.', message_args));
|
||||||
},
|
},
|
||||||
|
|
||||||
root_type: function(frm) {
|
root_type: function(frm) {
|
||||||
frm.set_value('account', '');
|
frm.set_value('account', '');
|
||||||
frm.set_value('merge_accounts', []);
|
frm.set_value('merge_accounts', []);
|
||||||
},
|
},
|
||||||
|
|
||||||
company: function(frm) {
|
company: function(frm) {
|
||||||
frm.set_value('account', '');
|
frm.set_value('account', '');
|
||||||
frm.set_value('merge_accounts', []);
|
frm.set_value('merge_accounts', []);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on('Ledger Merge Accounts', {
|
frappe.ui.form.on('Ledger Merge Accounts', {
|
||||||
merge_accounts_add: function(frm, cdt, cdn) {
|
merge_accounts_add: function(frm, cdt, cdn) {
|
||||||
frm.trigger('update_primary_action');
|
frm.trigger('update_primary_action');
|
||||||
},
|
},
|
||||||
merge_accounts_remove: function(frm, cdt, cdn) {
|
|
||||||
frm.trigger('update_primary_action');
|
merge_accounts_remove: function(frm, cdt, cdn) {
|
||||||
},
|
frm.trigger('update_primary_action');
|
||||||
account: function(frm, cdt, cdn) {
|
},
|
||||||
frm.trigger('update_primary_action');
|
|
||||||
}
|
account: function(frm, cdt, cdn) {
|
||||||
})
|
frm.trigger('update_primary_action');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
@ -4,5 +4,6 @@
|
|||||||
# import frappe
|
# import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
class LedgerMergeAccounts(Document):
|
class LedgerMergeAccounts(Document):
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user