chore: validations

This commit is contained in:
Saqib Ansari
2020-09-29 14:17:50 +05:30
committed by Saurabh
parent d9e4ebc00c
commit d72d2367ab
3 changed files with 20 additions and 3 deletions

View File

@@ -3,6 +3,8 @@
frappe.ui.form.on('E Invoice Settings', {
refresh: function(frm) {
if (!frm.doc.enable) return;
frm.trigger("show_fetch_token_btn");
frm.add_custom_button(__("Get GSTIN Details"),
() => {

View File

@@ -5,6 +5,8 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"enable",
"section_break_2",
"client_id",
"client_secret",
"public_key_file",
@@ -90,12 +92,23 @@
"fieldtype": "Data",
"hidden": 1,
"read_only": 1
},
{
"default": "0",
"fieldname": "enable",
"fieldtype": "Check",
"label": "Enable"
},
{
"depends_on": "enable",
"fieldname": "section_break_2",
"fieldtype": "Section Break"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2020-09-25 21:57:58.187647",
"modified": "2020-09-29 14:06:36.385386",
"modified_by": "Administrator",
"module": "ERPNext Integrations",
"name": "E Invoice Settings",

View File

@@ -9,7 +9,6 @@ import jwt
import json
import base64
import frappe
from frappe.utils import cstr
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5, AES
from Crypto.Util.Padding import pad, unpad
@@ -21,7 +20,10 @@ from frappe.integrations.utils import make_post_request, make_get_request
class EInvoiceSettings(Document):
def validate(self):
pass
mandatory_fields = ['client_id', 'client_secret', 'gstin', 'username', 'password', 'public_key']
for d in mandatory_fields:
if not self.get(d):
frappe.throw(_("{} is required").format(frappe.unscrub(d)), title=_("Missing Values"))
def before_save(self):
if not self.public_key or self.has_value_changed('public_key_file'):