mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
chore: rename schema to template & js cleanup
This commit is contained in:
@@ -4,58 +4,18 @@
|
|||||||
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;
|
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.call({
|
|
||||||
doc: frm.doc,
|
|
||||||
method: 'get_gstin_details',
|
|
||||||
args: {
|
|
||||||
'gstin': '36AAECF1151A1ZC'
|
|
||||||
},
|
|
||||||
freeze: true,
|
|
||||||
callback: (res) => console.log(res)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
frm.add_custom_button(__("Generate IRN"),
|
|
||||||
() => {
|
|
||||||
frm.call({
|
|
||||||
doc: frm.doc,
|
|
||||||
method: 'generate_irn',
|
|
||||||
args: {
|
|
||||||
'invoice': 'SINV-20-21-0051'
|
|
||||||
},
|
|
||||||
freeze: true,
|
|
||||||
callback: (res) => console.log(res)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
frm.add_custom_button(__("Fetch IRN Details"),
|
|
||||||
() => {
|
|
||||||
frm.call({
|
|
||||||
doc: frm.doc,
|
|
||||||
method: 'get_irn_details',
|
|
||||||
args: {
|
|
||||||
'irn': 'c63d9e180dfdaa9242e29e2e1e0a8d76f20e116ed3de179a2e9120f384e1b432'
|
|
||||||
},
|
|
||||||
freeze: true,
|
|
||||||
callback: (res) => console.log(res)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
show_fetch_token_btn(frm) {
|
show_fetch_token_btn(frm) {
|
||||||
const { token_expiry } = frm.doc;
|
const { token_expiry } = frm.doc;
|
||||||
const now = frappe.datetime.now_datetime();
|
const now = frappe.datetime.now_datetime();
|
||||||
const expiry_in_mins = moment(token_expiry).diff(now, "minute");
|
const expiry_in_mins = moment(token_expiry).diff(now, "minute");
|
||||||
if (expiry_in_mins <= 1) {
|
if (expiry_in_mins <= 1 || !token_expiry) {
|
||||||
frm.add_custom_button(__("Fetch Token"),
|
frm.add_custom_button(__("Fetch Token"),
|
||||||
() => {
|
() => {
|
||||||
frm.call({
|
frm.call({
|
||||||
doc: frm.doc,
|
method: 'erpnext.regional.india.e_invoice_utils.fetch_token',
|
||||||
method: 'make_authentication_request',
|
|
||||||
freeze: true,
|
freeze: true,
|
||||||
callback: () => frm.refresh()
|
callback: () => frm.refresh()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ def get_header(creds):
|
|||||||
headers.update(dict(Gstin=creds.gstin, AuthToken=creds.auth_token))
|
headers.update(dict(Gstin=creds.gstin, AuthToken=creds.auth_token))
|
||||||
return headers
|
return headers
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
def fetch_token(self):
|
def fetch_token(self):
|
||||||
einv_creds = get_einv_credentials()
|
einv_creds = get_einv_credentials()
|
||||||
|
|
||||||
@@ -250,7 +251,7 @@ def get_item_list(invoice):
|
|||||||
gst_accounts_list = [d for accounts in gst_accounts.values() for d in accounts if d]
|
gst_accounts_list = [d for accounts in gst_accounts.values() for d in accounts if d]
|
||||||
|
|
||||||
for d in invoice.items:
|
for d in invoice.items:
|
||||||
item_schema = read_json("einv_item_schema")
|
item_schema = read_json("einv_item_template")
|
||||||
item = frappe._dict(dict())
|
item = frappe._dict(dict())
|
||||||
item.update(d.as_dict())
|
item.update(d.as_dict())
|
||||||
item.sr_no = d.idx
|
item.sr_no = d.idx
|
||||||
@@ -331,7 +332,7 @@ def get_return_doc_reference(invoice):
|
|||||||
))
|
))
|
||||||
|
|
||||||
def make_e_invoice(invoice):
|
def make_e_invoice(invoice):
|
||||||
schema = read_json("einv_schema")
|
schema = read_json("einv_template")
|
||||||
validations = read_json("einv_validation")
|
validations = read_json("einv_validation")
|
||||||
validations = json.loads(validations)
|
validations = json.loads(validations)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user