blob: d7dcbf4fe184ecf555b72c36d55d2ee716c18552 [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
Aditya Hasef3c22f32019-01-22 18:22:20 +05304from __future__ import unicode_literals
Chillar Anand915b3432021-09-02 16:44:59 +05305
Nabin Hait0357fbc2018-03-09 13:19:52 +05306import frappe
7from frappe import _
Chillar Anand915b3432021-09-02 16:44:59 +05308
Nabin Hait0357fbc2018-03-09 13:19:52 +05309from erpnext import get_region
10
Chillar Anand915b3432021-09-02 16:44:59 +053011
Nabin Hait0357fbc2018-03-09 13:19:52 +053012def check_deletion_permission(doc, method):
Himanshu Mishra35b26272018-11-13 11:13:04 +053013 region = get_region(doc.company)
Nabin Haita334ed82019-01-22 10:41:50 +053014 if region in ["Nepal", "France"] and doc.docstatus != 0:
Suraj Shetty48e9bc32020-01-29 15:06:18 +053015 frappe.throw(_("Deletion is not permitted for country {0}").format(region))
Raffael Meyeredba0602019-11-06 14:37:04 +010016
17def 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
28 frappe.get_doc({
29 "doctype": "Transaction Log",
30 "reference_doctype": doc.doctype,
31 "document_name": doc.name,
32 "data": data
33 }).insert(ignore_permissions=True)
Ahmad87380d02021-09-06 23:36:55 +050034