feat: remove german sales invoice validation (#24441)
This can be better achieved via Customize Form (mandatory and mandatory_depends_on)
This commit is contained in:
parent
16bcd01f6d
commit
f6f4376463
@ -416,9 +416,6 @@ regional_overrides = {
|
||||
'Italy': {
|
||||
'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.italy.utils.update_itemised_tax_data',
|
||||
'erpnext.controllers.accounts_controller.validate_regional': 'erpnext.regional.italy.utils.sales_invoice_validate',
|
||||
},
|
||||
'Germany': {
|
||||
'erpnext.controllers.accounts_controller.validate_regional': 'erpnext.regional.germany.accounts_controller.validate_regional',
|
||||
}
|
||||
}
|
||||
user_privacy_documents = [
|
||||
|
@ -1,53 +0,0 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe import msgprint
|
||||
|
||||
|
||||
REQUIRED_FIELDS = {
|
||||
"Sales Invoice": [
|
||||
{
|
||||
"field_name": "company_address",
|
||||
"regulation": "§ 14 Abs. 4 Nr. 1 UStG"
|
||||
},
|
||||
{
|
||||
"field_name": "company_tax_id",
|
||||
"regulation": "§ 14 Abs. 4 Nr. 2 UStG"
|
||||
},
|
||||
{
|
||||
"field_name": "taxes",
|
||||
"regulation": "§ 14 Abs. 4 Nr. 8 UStG"
|
||||
},
|
||||
{
|
||||
"field_name": "customer_address",
|
||||
"regulation": "§ 14 Abs. 4 Nr. 1 UStG",
|
||||
"condition": "base_grand_total > 250"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def validate_regional(doc):
|
||||
"""Check if required fields for this document are present."""
|
||||
required_fields = REQUIRED_FIELDS.get(doc.doctype)
|
||||
if not required_fields:
|
||||
return
|
||||
|
||||
meta = frappe.get_meta(doc.doctype)
|
||||
field_map = {field.fieldname: field.label for field in meta.fields}
|
||||
|
||||
for field in required_fields:
|
||||
condition = field.get("condition")
|
||||
if condition and not frappe.safe_eval(condition, doc.as_dict()):
|
||||
continue
|
||||
|
||||
field_name = field.get("field_name")
|
||||
regulation = field.get("regulation")
|
||||
if field_name and not doc.get(field_name):
|
||||
missing(field_map.get(field_name), regulation)
|
||||
|
||||
|
||||
def missing(field_label, regulation):
|
||||
"""Notify the user that a required field is missing."""
|
||||
translated_msg = _('Remember to set {field_label}. It is required by {regulation}.', context='Specific for Germany. Example: Remember to set Company Tax ID. It is required by § 14 Abs. 4 Nr. 2 UStG.') # noqa: E501
|
||||
formatted_msg = translated_msg.format(field_label=frappe.bold(_(field_label)), regulation=regulation)
|
||||
msgprint(formatted_msg)
|
@ -1,12 +0,0 @@
|
||||
import frappe
|
||||
import unittest
|
||||
from erpnext.regional.germany.accounts_controller import validate_regional
|
||||
|
||||
|
||||
class TestAccountsController(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.sales_invoice = frappe.get_last_doc('Sales Invoice')
|
||||
|
||||
def test_validate_regional(self):
|
||||
validate_regional(self.sales_invoice)
|
Loading…
Reference in New Issue
Block a user