mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-02 13:08:27 +00:00
Codacy corrections
This commit is contained in:
@@ -28,9 +28,9 @@ frappe.ui.form.on('Bank Account', {
|
|||||||
if (frm.doc.integration_id) {
|
if (frm.doc.integration_id) {
|
||||||
frm.add_custom_button(__("Unlink external integrations"), function() {
|
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() {
|
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
|
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.provide("erpnext.integrations")
|
frappe.provide("erpnext.integrations");
|
||||||
|
|
||||||
frappe.ui.form.on('Plaid Settings', {
|
frappe.ui.form.on('Plaid Settings', {
|
||||||
link_new_account: function(frm) {
|
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() {
|
init_config() {
|
||||||
const me = this;
|
const me = this;
|
||||||
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.plaid_configuration')
|
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.plaid_configuration')
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result !== "disabled") {
|
if (result !== "disabled") {
|
||||||
me.plaid_env = result.plaid_env;
|
me.plaid_env = result.plaid_env;
|
||||||
me.plaid_public_key = result.plaid_public_key;
|
me.plaid_public_key = result.plaid_public_key;
|
||||||
me.client_name = result.client_name;
|
me.client_name = result.client_name;
|
||||||
me.init_plaid()
|
me.init_plaid();
|
||||||
} else {
|
} else {
|
||||||
frappe.throw(__("Please save your document before adding a new account"))
|
frappe.throw(__("Please save your document before adding a new account"));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init_plaid() {
|
init_plaid() {
|
||||||
@@ -44,24 +44,24 @@ erpnext.integrations.plaidLink = class plaidLink {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
me.onScriptError(error)
|
me.onScriptError(error);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
loadScript(src) {
|
loadScript(src) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
if (document.querySelector('script[src="' + src + '"]')) {
|
if (document.querySelector('script[src="' + src + '"]')) {
|
||||||
resolve()
|
resolve();
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const el = document.createElement('script')
|
const el = document.createElement('script');
|
||||||
el.type = 'text/javascript'
|
el.type = 'text/javascript';
|
||||||
el.async = true
|
el.async = true;
|
||||||
el.src = src
|
el.src = src;
|
||||||
el.addEventListener('load', resolve)
|
el.addEventListener('load', resolve);
|
||||||
el.addEventListener('error', reject)
|
el.addEventListener('error', reject);
|
||||||
el.addEventListener('abort', reject)
|
el.addEventListener('abort', reject);
|
||||||
document.head.appendChild(el)
|
document.head.appendChild(el);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,15 +76,15 @@ erpnext.integrations.plaidLink = class plaidLink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onScriptError(error) {
|
onScriptError(error) {
|
||||||
console.error('There was an issue loading the link-initialize.js script');
|
frappe.msgprint('There was an issue loading the link-initialize.js script');
|
||||||
console.log(error);
|
frappe.msgprint(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
plaid_success(token, response) {
|
plaid_success(token, response) {
|
||||||
const me = this;
|
const me = this;
|
||||||
|
|
||||||
frappe.prompt({
|
frappe.prompt({
|
||||||
fieldtype:"Link",
|
fieldtype:"Link",
|
||||||
options: "Company",
|
options: "Company",
|
||||||
label:__("Company"),
|
label:__("Company"),
|
||||||
fieldname:"company",
|
fieldname:"company",
|
||||||
@@ -92,13 +92,13 @@ erpnext.integrations.plaidLink = class plaidLink {
|
|||||||
}, (data) => {
|
}, (data) => {
|
||||||
me.company = data.company;
|
me.company = data.company;
|
||||||
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.add_institution', {token: token, response: response})
|
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.add_institution', {token: token, response: response})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.add_bank_accounts', {response: response,
|
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.add_bank_accounts', {response: response,
|
||||||
bank: result, company: me.company})
|
bank: result, company: me.company});
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then(() => {
|
||||||
frappe.show_alert({message:__("Bank accounts added"), indicator:'green'});
|
frappe.show_alert({message:__("Bank accounts added"), indicator:'green'});
|
||||||
})
|
});
|
||||||
}, __("Select a company"), __("Continue"));
|
}, __("Select a company"), __("Continue"));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import frappe
|
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
|
import json
|
||||||
from frappe.utils.response import json_handler
|
from frappe.utils.response import json_handler
|
||||||
from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account
|
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)
|
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