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:
parent
84ba034337
commit
a0aaa8c52b
@ -207,24 +207,26 @@ export async function createDiscountAccount(fyo: Fyo) {
|
||||
}
|
||||
|
||||
async function setDefaultAccounts(fyo: Fyo) {
|
||||
const accountMap: Record<string, string> = {
|
||||
writeOffAccount: fyo.t`Write Off`,
|
||||
roundOffAccount: fyo.t`Rounded Off`,
|
||||
};
|
||||
|
||||
for (const key in accountMap) {
|
||||
const accountName = accountMap[key];
|
||||
const accountExists = await fyo.db.exists(
|
||||
ModelNameEnum.Account,
|
||||
accountName
|
||||
await setDefaultAccount('writeOffAccount', fyo.t`Write Off`, fyo);
|
||||
const isSet = await setDefaultAccount(
|
||||
'roundOffAccount',
|
||||
fyo.t`Rounded Off`,
|
||||
fyo
|
||||
);
|
||||
|
||||
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) {
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
|
||||
await fyo.singles.AccountingSettings!.setAndSync(key, accountName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async function completeSetup(companyName: string, fyo: Fyo) {
|
||||
|
Loading…
Reference in New Issue
Block a user