mirror of
https://github.com/frappe/books.git
synced 2024-11-08 14:50:56 +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,
|
purchaseItemPartyMap,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
import items from './items.json';
|
import items from './items.json';
|
||||||
|
import logo from './logo';
|
||||||
import parties from './parties.json';
|
import parties from './parties.json';
|
||||||
|
|
||||||
type Notifier = (stage: string, percent: number) => void;
|
type Notifier = (stage: string, percent: number) => void;
|
||||||
@ -48,6 +49,7 @@ export async function setupDummyInstance(
|
|||||||
notifier?.(fyo.t`Creating Items and Parties`, -1);
|
notifier?.(fyo.t`Creating Items and Parties`, -1);
|
||||||
await generateStaticEntries(fyo);
|
await generateStaticEntries(fyo);
|
||||||
await generateDynamicEntries(fyo, years, baseCount, notifier);
|
await generateDynamicEntries(fyo, years, baseCount, notifier);
|
||||||
|
await setOtherSettings(fyo);
|
||||||
|
|
||||||
const instanceId = (await fyo.getValue(
|
const instanceId = (await fyo.getValue(
|
||||||
ModelNameEnum.SystemSettings,
|
ModelNameEnum.SystemSettings,
|
||||||
@ -56,6 +58,34 @@ export async function setupDummyInstance(
|
|||||||
return { companyName: options.companyName, instanceId };
|
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!
|
* 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 { Doc } from 'fyo/model/doc';
|
||||||
import { DocMap, ModelMap, SinglesMap } from 'fyo/model/types';
|
import { DocMap, ModelMap, SinglesMap } from 'fyo/model/types';
|
||||||
import { coreModels } from 'fyo/models';
|
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 Observable from 'fyo/utils/observable';
|
||||||
import { Schema } from 'schemas/types';
|
import { Schema } from 'schemas/types';
|
||||||
import { getRandomString } from 'utils';
|
import { getRandomString } from 'utils';
|
||||||
@ -50,9 +50,17 @@ export class DocHandler {
|
|||||||
|
|
||||||
async getDoc(
|
async getDoc(
|
||||||
schemaName: string,
|
schemaName: string,
|
||||||
name: string,
|
name?: string,
|
||||||
options = { skipDocumentCache: false }
|
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;
|
let doc: Doc | undefined;
|
||||||
if (!options?.skipDocumentCache) {
|
if (!options?.skipDocumentCache) {
|
||||||
doc = this.#getFromCache(schemaName, name);
|
doc = this.#getFromCache(schemaName, name);
|
||||||
@ -69,10 +77,6 @@ export class DocHandler {
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSingle(schemaName: string) {
|
|
||||||
return await this.getDoc(schemaName, schemaName);
|
|
||||||
}
|
|
||||||
|
|
||||||
getNewDoc(
|
getNewDoc(
|
||||||
schemaName: string,
|
schemaName: string,
|
||||||
data: DocValueMap = {},
|
data: DocValueMap = {},
|
||||||
|
@ -108,7 +108,7 @@ export class Fyo {
|
|||||||
await this.#initializeMoneyMaker();
|
await this.#initializeMoneyMaker();
|
||||||
|
|
||||||
this.doc.registerModels(models, regionalModels);
|
this.doc.registerModels(models, regionalModels);
|
||||||
await this.doc.getSingle('SystemSettings');
|
await this.doc.getDoc('SystemSettings');
|
||||||
this._initialized = true;
|
this._initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +58,7 @@ export class Account extends Doc {
|
|||||||
return {
|
return {
|
||||||
parentField: 'parentAccount',
|
parentField: 'parentAccount',
|
||||||
async getRootLabel(): Promise<string> {
|
async getRootLabel(): Promise<string> {
|
||||||
const accountingSettings = await fyo.doc.getSingle(
|
const accountingSettings = await fyo.doc.getDoc('AccountingSettings');
|
||||||
'AccountingSettings'
|
|
||||||
);
|
|
||||||
return accountingSettings.companyName as string;
|
return accountingSettings.companyName as string;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,6 @@ export enum ModelNameEnum {
|
|||||||
PurchaseInvoiceItem = 'PurchaseInvoiceItem',
|
PurchaseInvoiceItem = 'PurchaseInvoiceItem',
|
||||||
SalesInvoice = 'SalesInvoice',
|
SalesInvoice = 'SalesInvoice',
|
||||||
SalesInvoiceItem = 'SalesInvoiceItem',
|
SalesInvoiceItem = 'SalesInvoiceItem',
|
||||||
SalesInvoiceSettings = 'SalesInvoiceSettings',
|
|
||||||
SetupWizard = 'SetupWizard',
|
SetupWizard = 'SetupWizard',
|
||||||
Tax = 'Tax',
|
Tax = 'Tax',
|
||||||
TaxDetail = 'TaxDetail',
|
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 PurchaseInvoiceItem from './app/PurchaseInvoiceItem.json';
|
||||||
import SalesInvoice from './app/SalesInvoice.json';
|
import SalesInvoice from './app/SalesInvoice.json';
|
||||||
import SalesInvoiceItem from './app/SalesInvoiceItem.json';
|
import SalesInvoiceItem from './app/SalesInvoiceItem.json';
|
||||||
import SalesInvoiceSettings from './app/SalesInvoiceSettings.json';
|
|
||||||
import SetupWizard from './app/SetupWizard.json';
|
import SetupWizard from './app/SetupWizard.json';
|
||||||
import Tax from './app/Tax.json';
|
import Tax from './app/Tax.json';
|
||||||
import TaxDetail from './app/TaxDetail.json';
|
import TaxDetail from './app/TaxDetail.json';
|
||||||
@ -75,7 +74,6 @@ export const appSchemas: Schema[] | SchemaStub[] = [
|
|||||||
|
|
||||||
SalesInvoice as Schema,
|
SalesInvoice as Schema,
|
||||||
SalesInvoiceItem as Schema,
|
SalesInvoiceItem as Schema,
|
||||||
SalesInvoiceSettings as Schema,
|
|
||||||
|
|
||||||
Tax as Schema,
|
Tax as Schema,
|
||||||
TaxDetail as Schema,
|
TaxDetail as Schema,
|
||||||
|
@ -116,8 +116,8 @@ export default {
|
|||||||
await this.setDesk(filePath);
|
await this.setDesk(filePath);
|
||||||
},
|
},
|
||||||
async setDeskRoute() {
|
async setDeskRoute() {
|
||||||
const { onboardingComplete } = await fyo.doc.getSingle('GetStarted');
|
const { onboardingComplete } = await fyo.doc.getDoc('GetStarted');
|
||||||
const { hideGetStarted } = await fyo.doc.getSingle('SystemSettings');
|
const { hideGetStarted } = await fyo.doc.getDoc('SystemSettings');
|
||||||
|
|
||||||
if (hideGetStarted || onboardingComplete) {
|
if (hideGetStarted || onboardingComplete) {
|
||||||
routeTo('/');
|
routeTo('/');
|
||||||
|
@ -128,7 +128,7 @@ export default {
|
|||||||
Icon,
|
Icon,
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
const { companyName } = await fyo.doc.getSingle('AccountingSettings');
|
const { companyName } = await fyo.doc.getDoc('AccountingSettings');
|
||||||
this.companyName = companyName;
|
this.companyName = companyName;
|
||||||
this.groups = getSidebarConfig();
|
this.groups = getSidebarConfig();
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ export async function initializeInstance(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function setSingles(fyo: Fyo) {
|
async function setSingles(fyo: Fyo) {
|
||||||
await fyo.doc.getSingle(ModelNameEnum.AccountingSettings);
|
await fyo.doc.getDoc(ModelNameEnum.AccountingSettings);
|
||||||
await fyo.doc.getSingle(ModelNameEnum.GetStarted);
|
await fyo.doc.getDoc(ModelNameEnum.GetStarted);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setCreds(fyo: Fyo) {
|
async function setCreds(fyo: Fyo) {
|
||||||
@ -58,15 +58,13 @@ async function setVersion(fyo: Fyo) {
|
|||||||
|
|
||||||
const { appVersion } = fyo.store;
|
const { appVersion } = fyo.store;
|
||||||
if (version !== appVersion) {
|
if (version !== appVersion) {
|
||||||
const systemSettings = await fyo.doc.getSingle(
|
const systemSettings = await fyo.doc.getDoc(ModelNameEnum.SystemSettings);
|
||||||
ModelNameEnum.SystemSettings
|
|
||||||
);
|
|
||||||
await systemSettings?.setAndSync('version', appVersion);
|
await systemSettings?.setAndSync('version', appVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setInstanceId(fyo: Fyo) {
|
async function setInstanceId(fyo: Fyo) {
|
||||||
const systemSettings = await fyo.doc.getSingle(ModelNameEnum.SystemSettings);
|
const systemSettings = await fyo.doc.getDoc(ModelNameEnum.SystemSettings);
|
||||||
if (!systemSettings.instanceId) {
|
if (!systemSettings.instanceId) {
|
||||||
await systemSettings.setAndSync('instanceId', getRandomString());
|
await systemSettings.setAndSync('instanceId', getRandomString());
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async fetchAccounts() {
|
async fetchAccounts() {
|
||||||
this.settings = fyo.models[ModelNameEnum.Account].getTreeSettings(fyo);
|
this.settings = fyo.models[ModelNameEnum.Account].getTreeSettings(fyo);
|
||||||
const { currency } = await fyo.doc.getSingle('AccountingSettings');
|
const { currency } = await fyo.doc.getDoc('AccountingSettings');
|
||||||
this.root = {
|
this.root = {
|
||||||
label: await this.settings.getRootLabel(),
|
label: await this.settings.getRootLabel(),
|
||||||
balance: 0,
|
balance: 0,
|
||||||
|
@ -101,7 +101,7 @@ export default {
|
|||||||
this.sections = getGetStartedConfig();
|
this.sections = getGetStartedConfig();
|
||||||
},
|
},
|
||||||
async activated() {
|
async activated() {
|
||||||
await fyo.doc.getSingle('GetStarted');
|
await fyo.doc.getDoc('GetStarted');
|
||||||
this.checkForCompletedTasks();
|
this.checkForCompletedTasks();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -145,7 +145,7 @@ export default {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const doc = await fyo.doc.getSingle('GetStarted');
|
const doc = await fyo.doc.getDoc('GetStarted');
|
||||||
const onboardingComplete = fyo.schemaMap.GetStarted.fields
|
const onboardingComplete = fyo.schemaMap.GetStarted.fields
|
||||||
.filter(({ fieldname }) => fieldname !== 'onboardingComplete')
|
.filter(({ fieldname }) => fieldname !== 'onboardingComplete')
|
||||||
.map(({ fieldname }) => doc.get(fieldname))
|
.map(({ fieldname }) => doc.get(fieldname))
|
||||||
@ -153,7 +153,7 @@ export default {
|
|||||||
|
|
||||||
if (onboardingComplete) {
|
if (onboardingComplete) {
|
||||||
await this.updateChecks({ 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.set('hideGetStarted', true);
|
||||||
await systemSettings.sync();
|
await systemSettings.sync();
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async updateChecks(toUpdate) {
|
async updateChecks(toUpdate) {
|
||||||
await fyo.singles.GetStarted.setAndSync(toUpdate);
|
await fyo.singles.GetStarted.setAndSync(toUpdate);
|
||||||
await fyo.doc.getSingle('GetStarted');
|
await fyo.doc.getDoc('GetStarted');
|
||||||
},
|
},
|
||||||
isCompleted(item) {
|
isCompleted(item) {
|
||||||
return fyo.singles.GetStarted.get(item.fieldname) || false;
|
return fyo.singles.GetStarted.get(item.fieldname) || false;
|
||||||
|
@ -244,9 +244,9 @@ export default {
|
|||||||
}
|
}
|
||||||
await this.handleError(error);
|
await this.handleError(error);
|
||||||
}
|
}
|
||||||
this.printSettings = await fyo.doc.getSingle('PrintSettings');
|
this.printSettings = await fyo.doc.getDoc('PrintSettings');
|
||||||
this.companyName = (
|
this.companyName = (
|
||||||
await fyo.doc.getSingle('AccountingSettings')
|
await fyo.doc.getDoc('AccountingSettings')
|
||||||
).companyName;
|
).companyName;
|
||||||
|
|
||||||
let query = this.$route.query;
|
let query = this.$route.query;
|
||||||
|
@ -77,7 +77,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.doc = await fyo.doc.getDoc(this.schemaName, this.name);
|
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) {
|
if (fyo.store.isDevelopment) {
|
||||||
window.pv = this;
|
window.pv = this;
|
||||||
|
@ -60,9 +60,9 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.doc = await fyo.doc.getSingle('PrintSettings');
|
this.doc = await fyo.doc.getDoc('PrintSettings');
|
||||||
this.companyName = (
|
this.companyName = (
|
||||||
await fyo.doc.getSingle('AccountingSettings')
|
await fyo.doc.getDoc('AccountingSettings')
|
||||||
).companyName;
|
).companyName;
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -55,7 +55,7 @@ async function updateAccountingSettings(
|
|||||||
}: SetupWizardOptions,
|
}: SetupWizardOptions,
|
||||||
fyo: Fyo
|
fyo: Fyo
|
||||||
) {
|
) {
|
||||||
const accountingSettings = (await fyo.doc.getSingle(
|
const accountingSettings = (await fyo.doc.getDoc(
|
||||||
'AccountingSettings'
|
'AccountingSettings'
|
||||||
)) as AccountingSettings;
|
)) as AccountingSettings;
|
||||||
await accountingSettings.setAndSync({
|
await accountingSettings.setAndSync({
|
||||||
@ -74,7 +74,7 @@ async function updatePrintSettings(
|
|||||||
{ logo, companyName, email }: SetupWizardOptions,
|
{ logo, companyName, email }: SetupWizardOptions,
|
||||||
fyo: Fyo
|
fyo: Fyo
|
||||||
) {
|
) {
|
||||||
const printSettings = await fyo.doc.getSingle('PrintSettings');
|
const printSettings = await fyo.doc.getDoc('PrintSettings');
|
||||||
await printSettings.setAndSync({
|
await printSettings.setAndSync({
|
||||||
logo,
|
logo,
|
||||||
companyName,
|
companyName,
|
||||||
@ -93,7 +93,7 @@ async function updateSystemSettings(
|
|||||||
companyCurrency ?? countryOptions.currency ?? DEFAULT_CURRENCY;
|
companyCurrency ?? countryOptions.currency ?? DEFAULT_CURRENCY;
|
||||||
const locale = countryOptions.locale ?? DEFAULT_LOCALE;
|
const locale = countryOptions.locale ?? DEFAULT_LOCALE;
|
||||||
const countryCode = getCountryCodeFromCountry(country);
|
const countryCode = getCountryCodeFromCountry(country);
|
||||||
const systemSettings = await fyo.doc.getSingle('SystemSettings');
|
const systemSettings = await fyo.doc.getDoc('SystemSettings');
|
||||||
const instanceId = getRandomString();
|
const instanceId = getRandomString();
|
||||||
|
|
||||||
systemSettings.setAndSync({
|
systemSettings.setAndSync({
|
||||||
|
Loading…
Reference in New Issue
Block a user