From ebf6800d65b39336bd1f9534f8184ce44e5eb697 Mon Sep 17 00:00:00 2001 From: thefalconx33 Date: Mon, 22 Jul 2019 17:11:09 +0530 Subject: [PATCH] FIX: incorrect path to country coa json after building --- models/doctype/account/importCOA.js | 15 ++++++--------- src/main.js | 13 +++++++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/models/doctype/account/importCOA.js b/models/doctype/account/importCOA.js index a4fa446e..2b4284ed 100644 --- a/models/doctype/account/importCOA.js +++ b/models/doctype/account/importCOA.js @@ -58,15 +58,12 @@ async function getCountryCOA() { const doc = await frappe.getDoc('AccountingSettings'); const conCode = countries[doc.country].code; - const countryCOA = path.resolve( - path.join('./fixtures/verified/', conCode + '.json') - ); - - if (fs.existsSync(countryCOA)) { - const jsonText = fs.readFileSync(countryCOA, 'utf-8'); - const json = JSON.parse(jsonText); - return json.tree; - } else { + try { + const countryCoa = require('../../../fixtures/verified/' + + conCode + + '.json'); + return countryCoa.tree; + } catch (e) { return standardCOA; } } diff --git a/src/main.js b/src/main.js index cccb3bcc..da24d8e5 100644 --- a/src/main.js +++ b/src/main.js @@ -45,7 +45,6 @@ frappe.events.on( country, name, email, - abbreviation, bankName, fiscalYearStart, fiscalYearEnd @@ -64,10 +63,16 @@ frappe.events.on( }); await doc.update(); - await frappe.call({ method: 'import-coa' }); - + await frappe.call({ + method: 'import-coa' + }); + const generateRegionalTaxes = require('../models/doctype/Tax/RegionalChanges'); + await generateRegionalTaxes(country); + if (country === 'India') { + frappe.models.Party = require('../models/doctype/Party/RegionalChanges'); + await frappe.db.migrate(); + } frappe.events.trigger('show-desk'); - } ); window.frappe = frappe;