Skip to content

Commit

Permalink
feat(DATEV): against account for opening entries (#35941)
Browse files Browse the repository at this point in the history
* fix: add missing german translations

* feat(DATEV): against account for opening entries

Allow to specify a separate temporary against account
for opening entries

* feat(DATEV Settings): validate account no. length

* style: format with black

* style: format with black

* test: new settings field, rename filter
  • Loading branch information
barredterra authored Jun 30, 2023
1 parent 18c3a66 commit 0602ddc
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 17 deletions.
14 changes: 12 additions & 2 deletions erpnext/regional/doctype/datev_settings/datev_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"section_break_4",
"account_number_length",
"column_break_6",
"temporary_against_account_number"
"temporary_against_account_number",
"opening_against_account_number"
],
"fields": [
{
Expand Down Expand Up @@ -70,14 +71,23 @@
},
{
"allow_in_quick_entry": 1,
"default": "9999",
"description": "Will be used as against account for all normal ledger entries",
"fieldname": "temporary_against_account_number",
"fieldtype": "Data",
"label": "Temporary Against Account Number",
"reqd": 1
},
{
"default": "9000",
"description": "Will be used as against account for opening ledger entries",
"fieldname": "opening_against_account_number",
"fieldtype": "Data",
"label": "Opening Against Account Number"
}
],
"links": [],
"modified": "2020-11-19 19:00:09.088816",
"modified": "2023-06-30 00:56:59.556731",
"modified_by": "Administrator",
"module": "Regional",
"name": "DATEV Settings",
Expand Down
22 changes: 19 additions & 3 deletions erpnext/regional/doctype/datev_settings/datev_settings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt


# import frappe
from frappe import _, throw
from frappe.model.document import Document


class DATEVSettings(Document):
pass
def validate(self):
if (
self.temporary_against_account_number
and len(self.temporary_against_account_number) != self.account_number_length
):
throw(
_("Temporary Against Account Number must be {0} digits long").format(
self.account_number_length
)
)

if (
self.opening_against_account_number
and len(self.opening_against_account_number) != self.account_number_length
):
throw(
_("Opening Against Account Number must be {0} digits long").format(self.account_number_length)
)
30 changes: 19 additions & 11 deletions erpnext/regional/report/datev/datev.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,12 @@ def execute(filters=None):
"""Entry point for frappe."""
data = []
if filters and validate(filters):
fn = "temporary_against_account_number"
filters[fn] = frappe.get_value("DATEV Settings", filters.get("company"), fn)
temp, opening = frappe.get_value(
"DATEV Settings",
filters.get("company"),
["temporary_against_account_number", "opening_against_account_number"],
)
filters.update({"against_account": temp, "opening_account": opening or temp})
data = get_transactions(filters, as_dict=0)

return COLUMNS, data
Expand Down Expand Up @@ -315,7 +319,7 @@ def run_query(filters, extra_fields, extra_joins, extra_filters, as_dict=1):
acc.account_number as 'Konto',
/* against number or, if empty, party against number */
%(temporary_against_account_number)s as 'Gegenkonto (ohne BU-Schlüssel)',
CASE gl.is_opening when 'Yes' then %(opening_account)s else %(against_account)s end as 'Gegenkonto (ohne BU-Schlüssel)',
'' as 'BU-Schlüssel',
Expand Down Expand Up @@ -530,18 +534,22 @@ def download_datev_csv(filters):
filters = json.loads(filters)

validate(filters)
company = filters.get("company")

company = filters.get("company")
fiscal_year = get_fiscal_year(date=filters.get("from_date"), company=company)
filters["fiscal_year_start"] = fiscal_year[1]

# set chart of accounts used
coa = frappe.get_value("Company", company, "chart_of_accounts")
filters["skr"] = "04" if "SKR04" in coa else ("03" if "SKR03" in coa else "")

datev_settings = frappe.get_doc("DATEV Settings", company)
filters["account_number_length"] = datev_settings.account_number_length
filters["temporary_against_account_number"] = datev_settings.temporary_against_account_number

filters.update(
{
"fiscal_year_start": fiscal_year[1],
"skr": "04" if "SKR04" in coa else ("03" if "SKR03" in coa else ""),
"account_number_length": datev_settings.account_number_length,
"against_account": datev_settings.temporary_against_account_number,
"opening_account": datev_settings.opening_against_account_number
or datev_settings.temporary_against_account_number,
}
)

transactions = get_transactions(filters)
account_names = get_account_names(filters)
Expand Down
5 changes: 4 additions & 1 deletion erpnext/regional/report/datev/test_datev.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ def make_datev_settings(company):
"client": company.name,
"client_number": "12345",
"consultant_number": "67890",
"account_number_length": 4,
"temporary_against_account_number": "9999",
"opening_against_account_number": "9000",
}
).insert()

Expand All @@ -152,7 +154,8 @@ def setUp(self):
"company": self.company.name,
"from_date": today(),
"to_date": today(),
"temporary_against_account_number": "9999",
"against_account": "9999",
"opening_account": "9000",
}

make_datev_settings(self.company)
Expand Down
8 changes: 8 additions & 0 deletions erpnext/translations/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9896,3 +9896,11 @@ Total Equity,Eigenkapital,
Warehouse wise Stock Value,Warenwert nach Lager,
Discount Validity,Frist für den Rabatt,
Discount Validity Based On,Frist für den Rabatt berechnet sich nach,
Account Number Length,Kontonummer Länge,
Temporary Against Account Number,Temporäre Gegenkontonummer,
Change DATEV Settings,DATEV-Einstellungen ändern,
Opening Against Account Number,Gegenkontonummer für Eröffnungsbuchungen,
Will be used as against account for all normal ledger entries,Wird als Gegenkonto für alle normalen Buchungen verwendet,
Will be used as against account for opening ledger entries,Wird als Gegenkonto für alle Eröffnungsbuchungen verwendet,
Temporary Against Account Number must be {0} digits long,Temporäre Gegenkontonummer muss {0} Ziffern lang sein,
Opening Against Account Number must be {0} digits long,Gegenkontonummer für Eröffnungsbuchungen muss {0} Ziffern lang sein,

0 comments on commit 0602ddc

Please sign in to comment.