blob: c460286078d378dcd10d9e23aea323e311ecb255 [file] [log] [blame]
Nabin Hait0357fbc2018-03-09 13:19:52 +05301# Copyright (c) 2018, Frappe Technologies and contributors
2# For license information, please see license.txt
3
Chillar Anand915b3432021-09-02 16:44:59 +05304
Nabin Hait0357fbc2018-03-09 13:19:52 +05305import frappe
6from frappe import _
Chillar Anand915b3432021-09-02 16:44:59 +05307
Nabin Hait0357fbc2018-03-09 13:19:52 +05308from erpnext import get_region
9
Chillar Anand915b3432021-09-02 16:44:59 +053010
Nabin Hait0357fbc2018-03-09 13:19:52 +053011def check_deletion_permission(doc, method):
Himanshu Mishra35b26272018-11-13 11:13:04 +053012 region = get_region(doc.company)
Nabin Haita334ed82019-01-22 10:41:50 +053013 if region in ["Nepal", "France"] and doc.docstatus != 0:
Suraj Shetty48e9bc32020-01-29 15:06:18 +053014 frappe.throw(_("Deletion is not permitted for country {0}").format(region))
Raffael Meyeredba0602019-11-06 14:37:04 +010015
16def create_transaction_log(doc, method):
17 """
18 Appends the transaction to a chain of hashed logs for legal resons.
19 Called on submit of Sales Invoice and Payment Entry.
20 """
21 region = get_region()
22 if region not in ["France", "Germany"]:
23 return
24
25 data = str(doc.as_dict())
26
27 frappe.get_doc({
28 "doctype": "Transaction Log",
29 "reference_doctype": doc.doctype,
30 "document_name": doc.name,
31 "data": data
32 }).insert(ignore_permissions=True)
Ahmad87380d02021-09-06 23:36:55 +050033