diff --git a/accounting/importCOA.js b/accounting/importCOA.js index 14cfccba..d1629840 100644 --- a/accounting/importCOA.js +++ b/accounting/importCOA.js @@ -56,7 +56,7 @@ function identifyIsGroup(child) { } export async function getCountryCOA(chartOfAccounts) { - const coaList = await getCOAList(); + const coaList = getCOAList(); const coa = coaList.find(({ name }) => name === chartOfAccounts); const conCode = coa.countryCode; if (!conCode) { diff --git a/models/doctype/SetupWizard/SetupWizard.js b/models/doctype/SetupWizard/SetupWizard.js index 35ea046c..7860727f 100644 --- a/models/doctype/SetupWizard/SetupWizard.js +++ b/models/doctype/SetupWizard/SetupWizard.js @@ -127,7 +127,7 @@ export default { if (!doc.country) return; const { code } = countryList[doc.country]; - const coaList = await getCOAList(); + const coaList = getCOAList(); const coa = coaList.find(({ countryCode }) => countryCode === code); if (coa === undefined) { @@ -135,7 +135,7 @@ export default { } return coa.name; }, - getList: async () => (await getCOAList()).map(({ name }) => name), + getList: () => getCOAList().map(({ name }) => name), }, ], quickEditFields: [ diff --git a/src/background.js b/src/background.js index 069e27a1..64e09a34 100644 --- a/src/background.js +++ b/src/background.js @@ -233,28 +233,6 @@ ipcMain.handle(IPC_ACTIONS.GET_LANGUAGE_MAP, async (event, code) => { return obj; }); -ipcMain.handle(IPC_ACTIONS.GET_COA_LIST, async () => { - const p = path.resolve('./fixtures/verified'); - const files = await fs.readdir(p); - const coas = []; - - for (let file of files) { - if (!file.endsWith('.json')) { - continue; - } - const fh = await fs.open(path.join(p, file)); - const json = await fh.readFile({ encoding: 'utf-8' }); - const { name, countryCode } = JSON.parse(json); - if (name === undefined) { - continue; - } - - coas.push({ name, countryCode }); - } - - return coas; -}); - ipcMain.handle(IPC_ACTIONS.GET_FILE, async (event, options) => { const response = { name: '', diff --git a/src/messages.js b/src/messages.js index 3ec6db53..ad507fea 100644 --- a/src/messages.js +++ b/src/messages.js @@ -25,7 +25,6 @@ export const IPC_ACTIONS = { SEND_ERROR: 'send-error', GET_LANGUAGE_MAP: 'get-language-map', CHECK_FOR_UPDATES: 'check-for-updates', - GET_COA_LIST: 'get-coa-list', GET_FILE: 'get-file', }; diff --git a/src/utils.js b/src/utils.js index 7e9142d0..40693498 100644 --- a/src/utils.js +++ b/src/utils.js @@ -513,10 +513,25 @@ function getLanguageCode(initLanguage, oldLanguage) { return [languageCodeMap[language], language, usingDefault]; } -export async function getCOAList() { +export function getCOAList() { if (!frappe.temp.coaList) { - const coaList = await ipcRenderer.invoke(IPC_ACTIONS.GET_COA_LIST); - coaList.unshift({ name: t`Standard Chart of Accounts`, countryCode: '' }); + const coaList = [ + { name: t`Standard Chart of Accounts`, countryCode: '' }, + + { countryCode: 'ae', name: 'U.A.E - Chart of Accounts' }, + { + countryCode: 'ca', + name: 'Canada - Plan comptable pour les provinces francophones', + }, + { countryCode: 'gt', name: 'Guatemala - Cuentas' }, + { countryCode: 'hu', name: 'Hungary - Chart of Accounts' }, + { countryCode: 'id', name: 'Indonesia - Chart of Accounts' }, + { countryCode: 'in', name: 'India - Chart of Accounts' }, + { countryCode: 'mx', name: 'Mexico - Plan de Cuentas' }, + { countryCode: 'ni', name: 'Nicaragua - Catalogo de Cuentas' }, + { countryCode: 'nl', name: 'Netherlands - Grootboekschema' }, + { countryCode: 'sg', name: 'Singapore - Chart of Accounts' }, + ]; frappe.temp.coaList = coaList; } return frappe.temp.coaList;