2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30:56 +00:00

feat: use selected chart of accounts

This commit is contained in:
18alantom 2022-02-21 12:07:34 +05:30 committed by Alan
parent 73253212c5
commit c23e670582
4 changed files with 16 additions and 25 deletions

View File

@ -1,6 +1,6 @@
import frappe from 'frappe';
import countries from '../fixtures/countryInfo.json';
import standardCOA from '../fixtures/verified/standardCOA.json';
import { getCOAList } from '../src/utils';
const accountFields = ['accountType', 'accountNumber', 'rootType', 'isGroup'];
function getAccountName(accountName, accountNumber) {
@ -55,9 +55,13 @@ function identifyIsGroup(child) {
return 0;
}
export async function getCountryCOA() {
const doc = await frappe.getDoc('AccountingSettings');
const conCode = countries[doc.country].code;
export async function getCountryCOA(chartOfAccounts) {
const coaList = await getCOAList();
const coa = coaList.find(({ name }) => name === chartOfAccounts);
const conCode = coa.countryCode;
if (!conCode) {
return standardCOA;
}
try {
const countryCoa = (
@ -69,7 +73,7 @@ export async function getCountryCOA() {
}
}
export default async function importCharts() {
const chart = await getCountryCOA();
export default async function importCharts(chartOfAccounts) {
const chart = await getCountryCOA(chartOfAccounts);
await importAccounts(chart, '', '', true);
}

View File

@ -135,11 +135,7 @@ export default {
}
return coa.name;
},
getList: async () =>
(await getCOAList()).map(({ name, countryCode }) => ({
label: name,
value: countryCode,
})),
getList: async () => (await getCOAList()).map(({ name }) => name),
},
],
quickEditFields: [

View File

@ -1,14 +1,5 @@
import frappe from 'frappe';
import importCharts from '../accounting/importCOA';
import registerReportMethods from '../reports';
export default function registerServerMethods() {
registerReportMethods();
frappe.registerMethod({
method: 'import-coa',
async handler() {
await importCharts();
},
});
}

View File

@ -5,6 +5,7 @@ import countryList from '~/fixtures/countryInfo.json';
import generateTaxes from '../../../models/doctype/Tax/RegionalEntries';
import regionalModelUpdates from '../../../models/regionalModelUpdates';
import { callInitializeMoneyMaker } from '../../utils';
import importCharts from '../../../accounting/importCOA';
export default async function setupCompany(setupWizardValues) {
const {
@ -16,6 +17,7 @@ export default async function setupCompany(setupWizardValues) {
bankName,
fiscalYearStart,
fiscalYearEnd,
chartOfAccounts,
} = setupWizardValues;
const accountingSettings = frappe.AccountingSettings;
@ -43,7 +45,7 @@ export default async function setupCompany(setupWizardValues) {
});
await setupGlobalCurrencies(countryList);
await setupChartOfAccounts(bankName, country);
await setupChartOfAccounts(bankName, country, chartOfAccounts);
await setupRegionalChanges(country);
updateInitializationConfig();
@ -87,10 +89,8 @@ async function setupGlobalCurrencies(countries) {
return Promise.all(promises);
}
async function setupChartOfAccounts(bankName, country) {
await frappe.call({
method: 'import-coa',
});
async function setupChartOfAccounts(bankName, country, chartOfAccounts) {
await importCharts(chartOfAccounts);
const parentAccount = await getBankAccountParentName(country);
const docObject = {
doctype: 'Account',