2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

fix: set Round Off if not set

This commit is contained in:
18alantom 2022-08-10 12:16:59 +05:30
parent 84ba034337
commit a0aaa8c52b

View File

@ -207,24 +207,26 @@ export async function createDiscountAccount(fyo: Fyo) {
} }
async function setDefaultAccounts(fyo: Fyo) { async function setDefaultAccounts(fyo: Fyo) {
const accountMap: Record<string, string> = { await setDefaultAccount('writeOffAccount', fyo.t`Write Off`, fyo);
writeOffAccount: fyo.t`Write Off`, const isSet = await setDefaultAccount(
roundOffAccount: fyo.t`Rounded Off`, 'roundOffAccount',
}; fyo.t`Rounded Off`,
fyo
for (const key in accountMap) {
const accountName = accountMap[key];
const accountExists = await fyo.db.exists(
ModelNameEnum.Account,
accountName
); );
if (!isSet) {
await setDefaultAccount('roundOffAccount', fyo.t`Round Off`, fyo);
}
}
async function setDefaultAccount(key: string, accountName: string, fyo: Fyo) {
const accountExists = await fyo.db.exists(ModelNameEnum.Account, accountName);
if (!accountExists) { if (!accountExists) {
continue; return false;
} }
await fyo.singles.AccountingSettings!.setAndSync(key, accountName); await fyo.singles.AccountingSettings!.setAndSync(key, accountName);
} return true;
} }
async function completeSetup(companyName: string, fyo: Fyo) { async function completeSetup(companyName: string, fyo: Fyo) {