frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.04k stars 7.21k forks source link

Using a german company without tax-id results in a hard error #24321

Closed Simiil closed 2 years ago

Simiil commented 3 years ago

Using a german company without tax-id results in a hard error on a User Account with german translations

After analyzing the error and the code, it seems to be a issue when translating the error message:

this translation on line 9550 seems to change the case of a paramater to an upper case R (Regulation instead of regulation)

Context information

version: erpnext 13.x.x-develop frappe 13.x.x-develop

stacktrace:

Steps to reproduce the issue

  1. Fresh erp next install
  2. create a german company
  3. do not set a tax id
  4. set user language to german

Observed result

everytime the company is in use, the error occus

Stacktrace / full error message

request.js:356 Traceback (most recent call last):
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/app.py", line 64, in application
    response = frappe.api.handle()
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/api.py", line 58, in handle
    return frappe.handler.handle()
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/handler.py", line 30, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/handler.py", line 70, in execute_cmd
    return frappe.call(method, frappe.form_dict)
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/init.py", line 1132, in call
    return fn(*args, newargs)
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/model/document.py", line 285, in save
    return self.save(args, kwargs)
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/model/document.py", line 307, in _save
    self.insert()
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/model/document.py", line 238, in insert
    self.run_before_save_methods()
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/model/document.py", line 947, in run_before_save_methods
    self.run_method("validate")
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/model/document.py", line 848, in run_method
    out = Document.hook(fn)(self, *args, kwargs)
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/model/document.py", line 1133, in composer
    return composed(self, method, args, *kwargs)
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/model/document.py", line 1116, in runner
    add_to_return_value(self, fn(self, args, *kwargs))
  File "/home/frappe/erpnext-demo/apps/frappe/frappe/model/document.py", line 842, in <lambda>
    fn = lambda self, args, *kwargs: getattr(self, method)(args, kwargs)
  File "/home/frappe/erpnext-demo/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 71, in validate
    super(SalesInvoice, self).validate()
  File "/home/frappe/erpnext-demo/apps/erpnext/erpnext/controllers/selling_controller.py", line 41, in validate
    super(SellingController, self).validate()
  File "/home/frappe/erpnext-demo/apps/erpnext/erpnext/controllers/stock_controller.py", line 21, in validate
    super(StockController, self).validate()
  File "/home/frappe/erpnext-demo/apps/erpnext/erpnext/controllers/accounts_controller.py", line 112, in validate
    validate_regional(self)
  File "/home/frappe/erpnext-demo/apps/erpnext/erpnext/init.py", line 129, in caller
    return frappe.get_attr(regional_overrides[region][fn_name])(*args, kwargs)
  File "/home/frappe/erpnext-demo/apps/erpnext/erpnext/regional/germany/accounts_controller.py", line 46, in validate_regional
    missing(field_map.get(field_name), regulation)
  File "/home/frappe/erpnext-demo/apps/erpnext/erpnext/regional/germany/accounts_controller.py", line 52, in missing
    formatted_msg = translated_msg.format(field_label=frappe.bold((field_label)), regulation=regulation)
KeyError: 'Regulation'
zahlenhexe commented 3 years ago

Because of this error, it is not possible to make a POS Closing Entry. Even if a tax_id is entered.

grafik

I did not set company_address:

frappe-bench/apps/erpnext/erpnext/regional/germany/accounts_controller.py:

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"
        }
    ]
}
lghtcrss commented 3 years ago

I have the same issue when creating a sales invoice in a german environment.

stale[bot] commented 2 years ago

This issue has been automatically marked as inactive because it has not had recent activity and it wasn't validated by maintainer team. It will be closed within a week if no further activity occurs.