mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 15:39:20 +00:00
chore: validations
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
frappe.ui.form.on('E Invoice Settings', {
|
frappe.ui.form.on('E Invoice Settings', {
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
|
if (!frm.doc.enable) return;
|
||||||
|
|
||||||
frm.trigger("show_fetch_token_btn");
|
frm.trigger("show_fetch_token_btn");
|
||||||
frm.add_custom_button(__("Get GSTIN Details"),
|
frm.add_custom_button(__("Get GSTIN Details"),
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
|
"enable",
|
||||||
|
"section_break_2",
|
||||||
"client_id",
|
"client_id",
|
||||||
"client_secret",
|
"client_secret",
|
||||||
"public_key_file",
|
"public_key_file",
|
||||||
@@ -90,12 +92,23 @@
|
|||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"read_only": 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,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-09-25 21:57:58.187647",
|
"modified": "2020-09-29 14:06:36.385386",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "ERPNext Integrations",
|
"module": "ERPNext Integrations",
|
||||||
"name": "E Invoice Settings",
|
"name": "E Invoice Settings",
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import jwt
|
|||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cstr
|
|
||||||
from Crypto.PublicKey import RSA
|
from Crypto.PublicKey import RSA
|
||||||
from Crypto.Cipher import PKCS1_v1_5, AES
|
from Crypto.Cipher import PKCS1_v1_5, AES
|
||||||
from Crypto.Util.Padding import pad, unpad
|
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):
|
class EInvoiceSettings(Document):
|
||||||
def validate(self):
|
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):
|
def before_save(self):
|
||||||
if not self.public_key or self.has_value_changed('public_key_file'):
|
if not self.public_key or self.has_value_changed('public_key_file'):
|
||||||
|
|||||||
Reference in New Issue
Block a user