mirror of
https://github.com/frappe/books.git
synced 2024-12-22 02:49:03 +00:00
incr: image in dummy values
- remove getSingle - remove SalesInvoiceSettings cause unused
This commit is contained in:
parent
8ee4dded19
commit
a09fa62f5f
@ -17,6 +17,7 @@ import {
|
||||
purchaseItemPartyMap,
|
||||
} from './helpers';
|
||||
import items from './items.json';
|
||||
import logo from './logo';
|
||||
import parties from './parties.json';
|
||||
|
||||
type Notifier = (stage: string, percent: number) => void;
|
||||
@ -48,6 +49,7 @@ export async function setupDummyInstance(
|
||||
notifier?.(fyo.t`Creating Items and Parties`, -1);
|
||||
await generateStaticEntries(fyo);
|
||||
await generateDynamicEntries(fyo, years, baseCount, notifier);
|
||||
await setOtherSettings(fyo);
|
||||
|
||||
const instanceId = (await fyo.getValue(
|
||||
ModelNameEnum.SystemSettings,
|
||||
@ -56,6 +58,34 @@ export async function setupDummyInstance(
|
||||
return { companyName: options.companyName, instanceId };
|
||||
}
|
||||
|
||||
async function setOtherSettings(fyo: Fyo) {
|
||||
const doc = await fyo.doc.getDoc(ModelNameEnum.PrintSettings);
|
||||
const address = fyo.doc.getNewDoc(ModelNameEnum.Address);
|
||||
await address.setAndSync({
|
||||
addressLine1: '1st Column, Fitzgerald Bridge',
|
||||
city: 'Pune',
|
||||
state: 'Maharashtra',
|
||||
pos: 'Maharashtra',
|
||||
postalCode: '411001',
|
||||
country: 'India',
|
||||
});
|
||||
|
||||
await doc.setAndSync({
|
||||
color: '#F687B3',
|
||||
template: 'Business',
|
||||
displayLogo: true,
|
||||
phone: '+91 8983-000418',
|
||||
logo,
|
||||
address: address.name,
|
||||
});
|
||||
|
||||
const acc = await fyo.doc.getDoc(ModelNameEnum.AccountingSettings);
|
||||
await acc.setAndSync({
|
||||
gstin: '27LIN180000A1Z5',
|
||||
});
|
||||
console.log(acc.gstin, await fyo.db.getSingleValues('gstin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* warning: long functions ahead!
|
||||
*/
|
||||
|
1
dummy/logo.ts
Normal file
1
dummy/logo.ts
Normal file
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
||||
import { Doc } from 'fyo/model/doc';
|
||||
import { DocMap, ModelMap, SinglesMap } from 'fyo/model/types';
|
||||
import { coreModels } from 'fyo/models';
|
||||
import { NotFoundError } from 'fyo/utils/errors';
|
||||
import { NotFoundError, ValueError } from 'fyo/utils/errors';
|
||||
import Observable from 'fyo/utils/observable';
|
||||
import { Schema } from 'schemas/types';
|
||||
import { getRandomString } from 'utils';
|
||||
@ -50,9 +50,17 @@ export class DocHandler {
|
||||
|
||||
async getDoc(
|
||||
schemaName: string,
|
||||
name: string,
|
||||
name?: string,
|
||||
options = { skipDocumentCache: false }
|
||||
) {
|
||||
if (name === undefined) {
|
||||
name = schemaName;
|
||||
}
|
||||
|
||||
if (name === schemaName && !this.fyo.schemaMap[schemaName]?.isSingle) {
|
||||
throw new ValueError(`${schemaName} is not a Single Schema`);
|
||||
}
|
||||
|
||||
let doc: Doc | undefined;
|
||||
if (!options?.skipDocumentCache) {
|
||||
doc = this.#getFromCache(schemaName, name);
|
||||
@ -69,10 +77,6 @@ export class DocHandler {
|
||||
return doc;
|
||||
}
|
||||
|
||||
async getSingle(schemaName: string) {
|
||||
return await this.getDoc(schemaName, schemaName);
|
||||
}
|
||||
|
||||
getNewDoc(
|
||||
schemaName: string,
|
||||
data: DocValueMap = {},
|
||||
|
@ -108,7 +108,7 @@ export class Fyo {
|
||||
await this.#initializeMoneyMaker();
|
||||
|
||||
this.doc.registerModels(models, regionalModels);
|
||||
await this.doc.getSingle('SystemSettings');
|
||||
await this.doc.getDoc('SystemSettings');
|
||||
this._initialized = true;
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,7 @@ export class Account extends Doc {
|
||||
return {
|
||||
parentField: 'parentAccount',
|
||||
async getRootLabel(): Promise<string> {
|
||||
const accountingSettings = await fyo.doc.getSingle(
|
||||
'AccountingSettings'
|
||||
);
|
||||
const accountingSettings = await fyo.doc.getDoc('AccountingSettings');
|
||||
return accountingSettings.companyName as string;
|
||||
},
|
||||
};
|
||||
|
@ -20,7 +20,6 @@ export enum ModelNameEnum {
|
||||
PurchaseInvoiceItem = 'PurchaseInvoiceItem',
|
||||
SalesInvoice = 'SalesInvoice',
|
||||
SalesInvoiceItem = 'SalesInvoiceItem',
|
||||
SalesInvoiceSettings = 'SalesInvoiceSettings',
|
||||
SetupWizard = 'SetupWizard',
|
||||
Tax = 'Tax',
|
||||
TaxDetail = 'TaxDetail',
|
||||
|
@ -1,64 +0,0 @@
|
||||
{
|
||||
"name": "SalesInvoiceSettings",
|
||||
"label": "Sales Invoice Settings",
|
||||
"isSingle": true,
|
||||
"isChild": false,
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "template",
|
||||
"label": "Template",
|
||||
"placeholder": "Template",
|
||||
"fieldtype": "Select",
|
||||
"options": [
|
||||
{
|
||||
"value": "Basic I",
|
||||
"label": "Basic I"
|
||||
},
|
||||
{
|
||||
"value": "Basic II",
|
||||
"label": "Basic II"
|
||||
},
|
||||
{
|
||||
"value": "Modern",
|
||||
"label": "Modern"
|
||||
}
|
||||
],
|
||||
"required": true,
|
||||
"default": "Basic I"
|
||||
},
|
||||
{
|
||||
"fieldname": "font",
|
||||
"label": "Font",
|
||||
"placeholder": "Font",
|
||||
"fieldtype": "Select",
|
||||
"options": [
|
||||
{
|
||||
"value": "Montserrat",
|
||||
"label": "Montserrat"
|
||||
},
|
||||
{
|
||||
"value": "Open Sans",
|
||||
"label": "Open Sans"
|
||||
},
|
||||
{
|
||||
"value": "Oxygen",
|
||||
"label": "Oxygen"
|
||||
},
|
||||
{
|
||||
"value": "Merriweather",
|
||||
"label": "Merriweather"
|
||||
}
|
||||
],
|
||||
"required": true,
|
||||
"default": "Montserrat"
|
||||
},
|
||||
{
|
||||
"fieldname": "themeColor",
|
||||
"label": "Theme Color",
|
||||
"fieldtype": "Data",
|
||||
"required": true,
|
||||
"default": "#000000",
|
||||
"hidden": true
|
||||
}
|
||||
]
|
||||
}
|
@ -18,7 +18,6 @@ import PurchaseInvoice from './app/PurchaseInvoice.json';
|
||||
import PurchaseInvoiceItem from './app/PurchaseInvoiceItem.json';
|
||||
import SalesInvoice from './app/SalesInvoice.json';
|
||||
import SalesInvoiceItem from './app/SalesInvoiceItem.json';
|
||||
import SalesInvoiceSettings from './app/SalesInvoiceSettings.json';
|
||||
import SetupWizard from './app/SetupWizard.json';
|
||||
import Tax from './app/Tax.json';
|
||||
import TaxDetail from './app/TaxDetail.json';
|
||||
@ -75,7 +74,6 @@ export const appSchemas: Schema[] | SchemaStub[] = [
|
||||
|
||||
SalesInvoice as Schema,
|
||||
SalesInvoiceItem as Schema,
|
||||
SalesInvoiceSettings as Schema,
|
||||
|
||||
Tax as Schema,
|
||||
TaxDetail as Schema,
|
||||
|
@ -116,8 +116,8 @@ export default {
|
||||
await this.setDesk(filePath);
|
||||
},
|
||||
async setDeskRoute() {
|
||||
const { onboardingComplete } = await fyo.doc.getSingle('GetStarted');
|
||||
const { hideGetStarted } = await fyo.doc.getSingle('SystemSettings');
|
||||
const { onboardingComplete } = await fyo.doc.getDoc('GetStarted');
|
||||
const { hideGetStarted } = await fyo.doc.getDoc('SystemSettings');
|
||||
|
||||
if (hideGetStarted || onboardingComplete) {
|
||||
routeTo('/');
|
||||
|
@ -128,7 +128,7 @@ export default {
|
||||
Icon,
|
||||
},
|
||||
async mounted() {
|
||||
const { companyName } = await fyo.doc.getSingle('AccountingSettings');
|
||||
const { companyName } = await fyo.doc.getDoc('AccountingSettings');
|
||||
this.companyName = companyName;
|
||||
this.groups = getSidebarConfig();
|
||||
|
||||
|
@ -37,8 +37,8 @@ export async function initializeInstance(
|
||||
}
|
||||
|
||||
async function setSingles(fyo: Fyo) {
|
||||
await fyo.doc.getSingle(ModelNameEnum.AccountingSettings);
|
||||
await fyo.doc.getSingle(ModelNameEnum.GetStarted);
|
||||
await fyo.doc.getDoc(ModelNameEnum.AccountingSettings);
|
||||
await fyo.doc.getDoc(ModelNameEnum.GetStarted);
|
||||
}
|
||||
|
||||
async function setCreds(fyo: Fyo) {
|
||||
@ -58,15 +58,13 @@ async function setVersion(fyo: Fyo) {
|
||||
|
||||
const { appVersion } = fyo.store;
|
||||
if (version !== appVersion) {
|
||||
const systemSettings = await fyo.doc.getSingle(
|
||||
ModelNameEnum.SystemSettings
|
||||
);
|
||||
const systemSettings = await fyo.doc.getDoc(ModelNameEnum.SystemSettings);
|
||||
await systemSettings?.setAndSync('version', appVersion);
|
||||
}
|
||||
}
|
||||
|
||||
async function setInstanceId(fyo: Fyo) {
|
||||
const systemSettings = await fyo.doc.getSingle(ModelNameEnum.SystemSettings);
|
||||
const systemSettings = await fyo.doc.getDoc(ModelNameEnum.SystemSettings);
|
||||
if (!systemSettings.instanceId) {
|
||||
await systemSettings.setAndSync('instanceId', getRandomString());
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ export default {
|
||||
},
|
||||
async fetchAccounts() {
|
||||
this.settings = fyo.models[ModelNameEnum.Account].getTreeSettings(fyo);
|
||||
const { currency } = await fyo.doc.getSingle('AccountingSettings');
|
||||
const { currency } = await fyo.doc.getDoc('AccountingSettings');
|
||||
this.root = {
|
||||
label: await this.settings.getRootLabel(),
|
||||
balance: 0,
|
||||
|
@ -101,7 +101,7 @@ export default {
|
||||
this.sections = getGetStartedConfig();
|
||||
},
|
||||
async activated() {
|
||||
await fyo.doc.getSingle('GetStarted');
|
||||
await fyo.doc.getDoc('GetStarted');
|
||||
this.checkForCompletedTasks();
|
||||
},
|
||||
methods: {
|
||||
@ -145,7 +145,7 @@ export default {
|
||||
return true;
|
||||
}
|
||||
|
||||
const doc = await fyo.doc.getSingle('GetStarted');
|
||||
const doc = await fyo.doc.getDoc('GetStarted');
|
||||
const onboardingComplete = fyo.schemaMap.GetStarted.fields
|
||||
.filter(({ fieldname }) => fieldname !== 'onboardingComplete')
|
||||
.map(({ fieldname }) => doc.get(fieldname))
|
||||
@ -153,7 +153,7 @@ export default {
|
||||
|
||||
if (onboardingComplete) {
|
||||
await this.updateChecks({ onboardingComplete });
|
||||
const systemSettings = await fyo.doc.getSingle('SystemSettings');
|
||||
const systemSettings = await fyo.doc.getDoc('SystemSettings');
|
||||
await systemSettings.set('hideGetStarted', true);
|
||||
await systemSettings.sync();
|
||||
}
|
||||
@ -205,7 +205,7 @@ export default {
|
||||
},
|
||||
async updateChecks(toUpdate) {
|
||||
await fyo.singles.GetStarted.setAndSync(toUpdate);
|
||||
await fyo.doc.getSingle('GetStarted');
|
||||
await fyo.doc.getDoc('GetStarted');
|
||||
},
|
||||
isCompleted(item) {
|
||||
return fyo.singles.GetStarted.get(item.fieldname) || false;
|
||||
|
@ -244,9 +244,9 @@ export default {
|
||||
}
|
||||
await this.handleError(error);
|
||||
}
|
||||
this.printSettings = await fyo.doc.getSingle('PrintSettings');
|
||||
this.printSettings = await fyo.doc.getDoc('PrintSettings');
|
||||
this.companyName = (
|
||||
await fyo.doc.getSingle('AccountingSettings')
|
||||
await fyo.doc.getDoc('AccountingSettings')
|
||||
).companyName;
|
||||
|
||||
let query = this.$route.query;
|
||||
|
@ -77,7 +77,7 @@ export default {
|
||||
},
|
||||
async mounted() {
|
||||
this.doc = await fyo.doc.getDoc(this.schemaName, this.name);
|
||||
this.printSettings = await fyo.doc.getSingle('PrintSettings');
|
||||
this.printSettings = await fyo.doc.getDoc('PrintSettings');
|
||||
|
||||
if (fyo.store.isDevelopment) {
|
||||
window.pv = this;
|
||||
|
@ -60,9 +60,9 @@ export default {
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
this.doc = await fyo.doc.getSingle('PrintSettings');
|
||||
this.doc = await fyo.doc.getDoc('PrintSettings');
|
||||
this.companyName = (
|
||||
await fyo.doc.getSingle('AccountingSettings')
|
||||
await fyo.doc.getDoc('AccountingSettings')
|
||||
).companyName;
|
||||
},
|
||||
computed: {
|
||||
|
@ -55,7 +55,7 @@ async function updateAccountingSettings(
|
||||
}: SetupWizardOptions,
|
||||
fyo: Fyo
|
||||
) {
|
||||
const accountingSettings = (await fyo.doc.getSingle(
|
||||
const accountingSettings = (await fyo.doc.getDoc(
|
||||
'AccountingSettings'
|
||||
)) as AccountingSettings;
|
||||
await accountingSettings.setAndSync({
|
||||
@ -74,7 +74,7 @@ async function updatePrintSettings(
|
||||
{ logo, companyName, email }: SetupWizardOptions,
|
||||
fyo: Fyo
|
||||
) {
|
||||
const printSettings = await fyo.doc.getSingle('PrintSettings');
|
||||
const printSettings = await fyo.doc.getDoc('PrintSettings');
|
||||
await printSettings.setAndSync({
|
||||
logo,
|
||||
companyName,
|
||||
@ -93,7 +93,7 @@ async function updateSystemSettings(
|
||||
companyCurrency ?? countryOptions.currency ?? DEFAULT_CURRENCY;
|
||||
const locale = countryOptions.locale ?? DEFAULT_LOCALE;
|
||||
const countryCode = getCountryCodeFromCountry(country);
|
||||
const systemSettings = await fyo.doc.getSingle('SystemSettings');
|
||||
const systemSettings = await fyo.doc.getDoc('SystemSettings');
|
||||
const instanceId = getRandomString();
|
||||
|
||||
systemSettings.setAndSync({
|
||||
|
Loading…
Reference in New Issue
Block a user