Codacy corrections
This commit is contained in:
@@ -28,9 +28,9 @@ frappe.ui.form.on('Bank Account', {
|
||||
if (frm.doc.integration_id) {
|
||||
frm.add_custom_button(__("Unlink external integrations"), function() {
|
||||
frappe.confirm(__("This action will unlink this account from any external service integrating ERPNext with your bank accounts. It cannot be undone. Are you certain ?"), function() {
|
||||
frm.set_value("integration_id", "")
|
||||
frm.set_value("integration_id", "");
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.provide("erpnext.integrations")
|
||||
frappe.provide("erpnext.integrations");
|
||||
|
||||
frappe.ui.form.on('Plaid Settings', {
|
||||
link_new_account: function(frm) {
|
||||
new erpnext.integrations.plaidLink(frm)
|
||||
new erpnext.integrations.plaidLink(frm);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,16 +20,16 @@ erpnext.integrations.plaidLink = class plaidLink {
|
||||
init_config() {
|
||||
const me = this;
|
||||
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.plaid_configuration')
|
||||
.then(result => {
|
||||
if (result !== "disabled") {
|
||||
me.plaid_env = result.plaid_env;
|
||||
me.plaid_public_key = result.plaid_public_key;
|
||||
me.client_name = result.client_name;
|
||||
me.init_plaid()
|
||||
} else {
|
||||
frappe.throw(__("Please save your document before adding a new account"))
|
||||
}
|
||||
})
|
||||
.then(result => {
|
||||
if (result !== "disabled") {
|
||||
me.plaid_env = result.plaid_env;
|
||||
me.plaid_public_key = result.plaid_public_key;
|
||||
me.client_name = result.client_name;
|
||||
me.init_plaid();
|
||||
} else {
|
||||
frappe.throw(__("Please save your document before adding a new account"));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
init_plaid() {
|
||||
@@ -44,24 +44,24 @@ erpnext.integrations.plaidLink = class plaidLink {
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
me.onScriptError(error)
|
||||
me.onScriptError(error);
|
||||
})
|
||||
}
|
||||
|
||||
loadScript(src) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (document.querySelector('script[src="' + src + '"]')) {
|
||||
resolve()
|
||||
return
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
const el = document.createElement('script')
|
||||
el.type = 'text/javascript'
|
||||
el.async = true
|
||||
el.src = src
|
||||
el.addEventListener('load', resolve)
|
||||
el.addEventListener('error', reject)
|
||||
el.addEventListener('abort', reject)
|
||||
document.head.appendChild(el)
|
||||
const el = document.createElement('script');
|
||||
el.type = 'text/javascript';
|
||||
el.async = true;
|
||||
el.src = src;
|
||||
el.addEventListener('load', resolve);
|
||||
el.addEventListener('error', reject);
|
||||
el.addEventListener('abort', reject);
|
||||
document.head.appendChild(el);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -76,15 +76,15 @@ erpnext.integrations.plaidLink = class plaidLink {
|
||||
}
|
||||
|
||||
onScriptError(error) {
|
||||
console.error('There was an issue loading the link-initialize.js script');
|
||||
console.log(error);
|
||||
frappe.msgprint('There was an issue loading the link-initialize.js script');
|
||||
frappe.msgprint(error);
|
||||
}
|
||||
|
||||
plaid_success(token, response) {
|
||||
const me = this;
|
||||
|
||||
frappe.prompt({
|
||||
fieldtype:"Link",
|
||||
fieldtype:"Link",
|
||||
options: "Company",
|
||||
label:__("Company"),
|
||||
fieldname:"company",
|
||||
@@ -92,13 +92,13 @@ erpnext.integrations.plaidLink = class plaidLink {
|
||||
}, (data) => {
|
||||
me.company = data.company;
|
||||
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.add_institution', {token: token, response: response})
|
||||
.then((result) => {
|
||||
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.add_bank_accounts', {response: response,
|
||||
bank: result, company: me.company})
|
||||
})
|
||||
.then((result) => {
|
||||
frappe.show_alert({message:__("Bank accounts added"), indicator:'green'});
|
||||
})
|
||||
.then((result) => {
|
||||
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.add_bank_accounts', {response: response,
|
||||
bank: result, company: me.company});
|
||||
})
|
||||
.then(() => {
|
||||
frappe.show_alert({message:__("Bank accounts added"), indicator:'green'});
|
||||
});
|
||||
}, __("Select a company"), __("Continue"));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
|
||||
import unittest
|
||||
import frappe
|
||||
from erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings import plaid_configuration, add_account_type, add_account_subtype, new_bank_transaction, get_transactions, add_bank_accounts
|
||||
from erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings import plaid_configuration, add_account_type, add_account_subtype, new_bank_transaction, add_bank_accounts
|
||||
import json
|
||||
from frappe.utils.response import json_handler
|
||||
from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account
|
||||
@@ -152,11 +152,4 @@ class TestPlaidSettings(unittest.TestCase):
|
||||
|
||||
new_bank_transaction(transactions)
|
||||
|
||||
self.assertTrue(len(frappe.get_all("Bank Transaction")) == 1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
self.assertTrue(len(frappe.get_all("Bank Transaction")) == 1)
|
||||
Reference in New Issue
Block a user