fix: improve UX of DATEV report (#23892)
* feat(DATEV Settings): button to show report * feat(desk): add DATEV to Reports under Accounting * fix(report DATEV): last calendar month as default * fix: let user create DATEV Settings (Instead of showing an error message.)
This commit is contained in:
parent
39102e68df
commit
896e4b1722
@ -23,7 +23,7 @@
|
|||||||
{
|
{
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"label": "Reports",
|
"label": "Reports",
|
||||||
"links": "[\n {\n \"dependencies\": [\n \"GL Entry\"\n ],\n \"doctype\": \"GL Entry\",\n \"is_query_report\": true,\n \"label\": \"Trial Balance for Party\",\n \"name\": \"Trial Balance for Party\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Journal Entry\"\n ],\n \"doctype\": \"Journal Entry\",\n \"is_query_report\": true,\n \"label\": \"Payment Period Based On Invoice Date\",\n \"name\": \"Payment Period Based On Invoice Date\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Sales Invoice\"\n ],\n \"doctype\": \"Sales Invoice\",\n \"is_query_report\": true,\n \"label\": \"Sales Partners Commission\",\n \"name\": \"Sales Partners Commission\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Customer\"\n ],\n \"doctype\": \"Customer\",\n \"is_query_report\": true,\n \"label\": \"Customer Credit Balance\",\n \"name\": \"Customer Credit Balance\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Sales Invoice\"\n ],\n \"doctype\": \"Sales Invoice\",\n \"is_query_report\": true,\n \"label\": \"Sales Payment Summary\",\n \"name\": \"Sales Payment Summary\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Address\"\n ],\n \"doctype\": \"Address\",\n \"is_query_report\": true,\n \"label\": \"Address And Contacts\",\n \"name\": \"Address And Contacts\",\n \"type\": \"report\"\n }\n]"
|
"links": "[\n {\n \"dependencies\": [\n \"GL Entry\"\n ],\n \"doctype\": \"GL Entry\",\n \"is_query_report\": true,\n \"label\": \"Trial Balance for Party\",\n \"name\": \"Trial Balance for Party\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Journal Entry\"\n ],\n \"doctype\": \"Journal Entry\",\n \"is_query_report\": true,\n \"label\": \"Payment Period Based On Invoice Date\",\n \"name\": \"Payment Period Based On Invoice Date\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Sales Invoice\"\n ],\n \"doctype\": \"Sales Invoice\",\n \"is_query_report\": true,\n \"label\": \"Sales Partners Commission\",\n \"name\": \"Sales Partners Commission\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Customer\"\n ],\n \"doctype\": \"Customer\",\n \"is_query_report\": true,\n \"label\": \"Customer Credit Balance\",\n \"name\": \"Customer Credit Balance\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Sales Invoice\"\n ],\n \"doctype\": \"Sales Invoice\",\n \"is_query_report\": true,\n \"label\": \"Sales Payment Summary\",\n \"name\": \"Sales Payment Summary\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Address\"\n ],\n \"doctype\": \"Address\",\n \"is_query_report\": true,\n \"label\": \"Address And Contacts\",\n \"name\": \"Address And Contacts\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"GL Entry\"\n ],\n \"doctype\": \"GL Entry\",\n \"is_query_report\": true,\n \"label\": \"DATEV Export\",\n \"name\": \"DATEV\",\n \"type\": \"report\"\n }\n]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -99,7 +99,7 @@
|
|||||||
"idx": 0,
|
"idx": 0,
|
||||||
"is_standard": 1,
|
"is_standard": 1,
|
||||||
"label": "Accounting",
|
"label": "Accounting",
|
||||||
"modified": "2020-11-06 13:05:58.650150",
|
"modified": "2020-11-11 18:35:11.542909",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Accounting",
|
"name": "Accounting",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('DATEV Settings', {
|
frappe.ui.form.on('DATEV Settings', {
|
||||||
// refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
|
frm.add_custom_button('Show Report', () => frappe.set_route('query-report', 'DATEV'), "fa fa-table");
|
||||||
// }
|
}
|
||||||
});
|
});
|
||||||
|
@ -11,14 +11,14 @@ frappe.query_reports["DATEV"] = {
|
|||||||
{
|
{
|
||||||
"fieldname": "from_date",
|
"fieldname": "from_date",
|
||||||
"label": __("From Date"),
|
"label": __("From Date"),
|
||||||
"default": frappe.datetime.month_start(),
|
"default": moment().subtract(1, 'month').startOf('month').format(),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "to_date",
|
"fieldname": "to_date",
|
||||||
"label": __("To Date"),
|
"label": __("To Date"),
|
||||||
"default": frappe.datetime.now_date(),
|
"default": moment().subtract(1, 'month').endOf('month').format(),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
@ -30,9 +30,23 @@ frappe.query_reports["DATEV"] = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
onload: function(query_report) {
|
onload: function(query_report) {
|
||||||
|
let company = frappe.query_report.get_filter_value('company');
|
||||||
|
frappe.db.exists('DATEV Settings', company).then((settings_exist) => {
|
||||||
|
if (!settings_exist) {
|
||||||
|
frappe.confirm(__('DATEV Settings for your Company are missing. Would you like to create them now?'),
|
||||||
|
() => frappe.new_doc('DATEV Settings', {'company': company})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
query_report.page.add_menu_item(__("Download DATEV File"), () => {
|
query_report.page.add_menu_item(__("Download DATEV File"), () => {
|
||||||
const filters = JSON.stringify(query_report.get_values());
|
const filters = JSON.stringify(query_report.get_values());
|
||||||
window.open(`/api/method/erpnext.regional.report.datev.datev.download_datev_csv?filters=${filters}`);
|
window.open(`/api/method/erpnext.regional.report.datev.datev.download_datev_csv?filters=${filters}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
query_report.page.add_menu_item(__("Change DATEV Settings"), () => {
|
||||||
|
let company = frappe.query_report.get_filter_value('company'); // read company from filters again – it might have changed by now.
|
||||||
|
frappe.set_route('Form', 'DATEV Settings', company);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -94,8 +94,11 @@ COLUMNS = [
|
|||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
"""Entry point for frappe."""
|
"""Entry point for frappe."""
|
||||||
validate(filters)
|
data = []
|
||||||
return COLUMNS, get_transactions(filters, as_dict=0)
|
if filters and validate(filters):
|
||||||
|
data = get_transactions(filters, as_dict=0)
|
||||||
|
|
||||||
|
return COLUMNS, data
|
||||||
|
|
||||||
|
|
||||||
def validate(filters):
|
def validate(filters):
|
||||||
@ -114,10 +117,14 @@ def validate(filters):
|
|||||||
|
|
||||||
validate_fiscal_year(from_date, to_date, company)
|
validate_fiscal_year(from_date, to_date, company)
|
||||||
|
|
||||||
try:
|
if not frappe.db.exists('DATEV Settings', filters.get('company')):
|
||||||
frappe.get_doc('DATEV Settings', filters.get('company'))
|
frappe.log_error(_('Please create {} for Company {}.').format(
|
||||||
except frappe.DoesNotExistError:
|
'<a href="desk#List/DATEV%20Settings/List">{}</a>'.format(_('DATEV Settings')),
|
||||||
frappe.throw(_('Please create <b>DATEV Settings</b> for Company <b>{}</b>.').format(filters.get('company')))
|
frappe.bold(filters.get('company'))
|
||||||
|
))
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def validate_fiscal_year(from_date, to_date, company):
|
def validate_fiscal_year(from_date, to_date, company):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user