2
0
mirror of https://github.com/frappe/books.git synced 2025-01-22 22:58:28 +00:00

fix: COA issue; TIL webpack bundles jsons -_-

This commit is contained in:
18alantom 2022-02-25 20:37:18 +05:30
parent eade5770b0
commit c49c7429a7
5 changed files with 21 additions and 29 deletions

View File

@ -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) {

View File

@ -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: [

View File

@ -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: '',

View File

@ -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',
};

View File

@ -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;