blob: ec2db8112403a0b521925e58a4ce3ce8aa6bce3b [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
Ankush Menat494bd9e2022-03-28 18:52:46 +053016
Raffael Meyeredba0602019-11-06 14:37:04 +010017def create_transaction_log(doc, method):
18 """
19 Appends the transaction to a chain of hashed logs for legal resons.
20 Called on submit of Sales Invoice and Payment Entry.
21 """
22 region = get_region()
23 if region not in ["France", "Germany"]:
24 return
25
26 data = str(doc.as_dict())
27
Ankush Menat494bd9e2022-03-28 18:52:46 +053028 frappe.get_doc(
29 {
30 "doctype": "Transaction Log",
31 "reference_doctype": doc.doctype,
32 "document_name": doc.name,
33 "data": data,
34 }
35 ).insert(ignore_permissions=True)