feat: make account number length configurable (#23845)
diff --git a/erpnext/regional/doctype/datev_settings/datev_settings.json b/erpnext/regional/doctype/datev_settings/datev_settings.json
index 39486df..713e8e3 100644
--- a/erpnext/regional/doctype/datev_settings/datev_settings.json
+++ b/erpnext/regional/doctype/datev_settings/datev_settings.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"autoname": "field:client",
"creation": "2019-08-13 23:56:34.259906",
"doctype": "DocType",
@@ -6,6 +7,7 @@
"engine": "InnoDB",
"field_order": [
"client",
+ "account_number_length",
"column_break_2",
"client_number",
"section_break_4",
@@ -28,8 +30,8 @@
"fieldtype": "Data",
"in_list_view": 1,
"label": "Client ID",
- "reqd": 1,
- "length": 5
+ "length": 5,
+ "reqd": 1
},
{
"fieldname": "consultant",
@@ -43,8 +45,8 @@
"fieldtype": "Data",
"in_list_view": 1,
"label": "Consultant ID",
- "reqd": 1,
- "length": 7
+ "length": 7,
+ "reqd": 1
},
{
"fieldname": "column_break_2",
@@ -57,9 +59,17 @@
{
"fieldname": "column_break_6",
"fieldtype": "Column Break"
+ },
+ {
+ "default": "4",
+ "fieldname": "account_number_length",
+ "fieldtype": "Int",
+ "label": "Account Number Length",
+ "reqd": 1
}
],
- "modified": "2019-08-14 00:03:26.616460",
+ "links": [],
+ "modified": "2020-11-05 17:52:11.674329",
"modified_by": "Administrator",
"module": "Regional",
"name": "DATEV Settings",
@@ -104,4 +114,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
-}
+}
\ No newline at end of file
diff --git a/erpnext/regional/germany/utils/datev/datev_csv.py b/erpnext/regional/germany/utils/datev/datev_csv.py
index cf07a1c..f138a80 100644
--- a/erpnext/regional/germany/utils/datev/datev_csv.py
+++ b/erpnext/regional/germany/utils/datev/datev_csv.py
@@ -106,7 +106,7 @@
# M = Start of the fiscal year (Wirtschaftsjahresbeginn)
frappe.utils.formatdate(filters.get('fiscal_year_start'), 'yyyyMMdd'),
# N = Length of account numbers (Sachkontenlänge)
- datev_settings.get('account_number_length', '4'),
+ str(filters.get('account_number_length', 4)),
# O = Transaction batch start date (YYYYMMDD)
frappe.utils.formatdate(filters.get('from_date'), 'yyyyMMdd') if csv_class.DATA_CATEGORY == DataCategory.TRANSACTIONS else '',
# P = Transaction batch end date (YYYYMMDD)
diff --git a/erpnext/regional/report/datev/datev.py b/erpnext/regional/report/datev/datev.py
index dbae230..3f4cb98 100644
--- a/erpnext/regional/report/datev/datev.py
+++ b/erpnext/regional/report/datev/datev.py
@@ -340,6 +340,8 @@
coa = frappe.get_value('Company', company, 'chart_of_accounts')
filters['skr'] = '04' if 'SKR04' in coa else ('03' if 'SKR03' in coa else '')
+ filters['account_number_length'] = frappe.get_value('DATEV Settings', company, 'account_number_length')
+
transactions = get_transactions(filters)
account_names = get_account_names(filters)
customers = get_customers(filters)