diff --git a/accounting/importCOA.js b/accounting/importCOA.js index e9c4bd33..d55fac7c 100644 --- a/accounting/importCOA.js +++ b/accounting/importCOA.js @@ -25,8 +25,7 @@ async function importAccounts(children, parentAccount, rootType, rootAccount) { const { accountType, accountNumber } = child; const accountName = getAccountName(rootName, accountNumber); const isGroup = identifyIsGroup(child); - const doc = frappe.getNewDoc({ - doctype: 'Account', + const doc = frappe.doc.getNewDoc('Account', { name: accountName, parentAccount, isGroup, diff --git a/accounting/ledgerPosting.js b/accounting/ledgerPosting.js index 58a17817..aa83689d 100644 --- a/accounting/ledgerPosting.js +++ b/accounting/ledgerPosting.js @@ -27,7 +27,7 @@ export default class LedgerPosting { async setAccountBalanceChange(accountName, type, amount) { const debitAccounts = ['Asset', 'Expense']; - const { rootType } = await frappe.getDoc('Account', accountName); + const { rootType } = await frappe.doc.getDoc('Account', accountName); if (debitAccounts.indexOf(rootType) === -1) { const change = type == 'credit' ? amount : amount.neg(); this.accountEntries.push({ @@ -82,7 +82,10 @@ export default class LedgerPosting { }); for (let entry of data) { - let entryDoc = await frappe.getDoc('AccountingLedgerEntry', entry.name); + let entryDoc = await frappe.doc.getDoc( + 'AccountingLedgerEntry', + entry.name + ); entryDoc.reverted = 1; await entryDoc.update(); } @@ -145,14 +148,12 @@ export default class LedgerPosting { async insertEntries() { for (let entry of this.entries) { - let entryDoc = frappe.getNewDoc({ - doctype: 'AccountingLedgerEntry', - }); + let entryDoc = frappe.doc.getNewDoc('AccountingLedgerEntry'); Object.assign(entryDoc, entry); await entryDoc.insert(); } for (let entry of this.accountEntries) { - let entryDoc = await frappe.getDoc('Account', entry.name); + let entryDoc = await frappe.doc.getDoc('Account', entry.name); entryDoc.balance = entryDoc.balance.add(entry.balanceChange); await entryDoc.update(); } diff --git a/frappe/core/dbHandler.ts b/frappe/core/dbHandler.ts index 70c13d4f..cfd115af 100644 --- a/frappe/core/dbHandler.ts +++ b/frappe/core/dbHandler.ts @@ -72,7 +72,7 @@ export class DatabaseHandler extends DatabaseBase { async getAll( schemaName: string, - options: GetAllOptions + options: GetAllOptions = {} ): Promise { const rawValueMap = (await this.#demux.call( 'getAll', diff --git a/frappe/model/naming.ts b/frappe/model/naming.ts index 45c5d50d..5a7b0ee6 100644 --- a/frappe/model/naming.ts +++ b/frappe/model/naming.ts @@ -1,17 +1,24 @@ import frappe from 'frappe'; +import NumberSeries from 'frappe/models/NumberSeries'; import { getRandomString } from 'frappe/utils'; +import { BaseError } from 'frappe/utils/errors'; +import { Field, Schema } from 'schemas/types'; +import Doc from './doc'; -export async function isNameAutoSet(schemaName: string) { - const doc = frappe.doc.getEmptyDoc(schemaName); - if (doc.meta.naming === 'autoincrement') { +export function getNumberSeries(schema: Schema): Field | undefined { + const numberSeries = schema.fields.find( + (f) => f.fieldname === 'numberSeries' + ); + return numberSeries; +} + +export function isNameAutoSet(schemaName: string): boolean { + const schema = frappe.schemaMap[schemaName]!; + if (schema.naming === 'autoincrement') { return true; } - if (!doc.meta.settings) { - return false; - } - - const { numberSeries } = await doc.getSettings(); + const numberSeries = getNumberSeries(schema); if (numberSeries) { return true; } @@ -19,30 +26,18 @@ export async function isNameAutoSet(schemaName: string) { return false; } -export async function setName(doc) { - if (frappe.isServer) { - // if is server, always name again if autoincrement or other - if (doc.meta.naming === 'autoincrement') { - doc.name = await getNextId(doc.doctype); - return; - } +export async function setName(doc: Doc) { + // if is server, always name again if autoincrement or other + if (doc.schema.naming === 'autoincrement') { + doc.name = await getNextId(doc.schemaName); + return; + } - // Current, per doc number series - if (doc.numberSeries) { - doc.name = await getSeriesNext(doc.numberSeries, doc.doctype); - return; - } - - // Legacy, using doc settings for number series - if (doc.meta.settings) { - const numberSeries = (await doc.getSettings()).numberSeries; - if (!numberSeries) { - return; - } - - doc.name = await getSeriesNext(numberSeries, doc.doctype); - return; - } + // Current, per doc number series + const numberSeries = doc.numberSeries as string | undefined; + if (numberSeries !== undefined) { + doc.name = await getSeriesNext(numberSeries, doc.schemaName); + return; } if (doc.name) { @@ -50,8 +45,8 @@ export async function setName(doc) { } // name === doctype for Single - if (doc.meta.isSingle) { - doc.name = doc.meta.name; + if (doc.schema.isSingle) { + doc.name = doc.schema.name; return; } @@ -62,54 +57,57 @@ export async function setName(doc) { } } -export async function getNextId(doctype) { +export async function getNextId(schemaName: string) { // get the last inserted row - let lastInserted = await getLastInserted(doctype); + const lastInserted = await getLastInserted(schemaName); let name = 1; if (lastInserted) { - let lastNumber = parseInt(lastInserted.name); + let lastNumber = parseInt(lastInserted.name as string); if (isNaN(lastNumber)) lastNumber = 0; name = lastNumber + 1; } return (name + '').padStart(9, '0'); } -export async function getLastInserted(doctype) { - const lastInserted = await frappe.db.getAll({ - doctype: doctype, +export async function getLastInserted(schemaName: string) { + const lastInserted = await frappe.db.getAll(schemaName, { fields: ['name'], limit: 1, - order_by: 'creation', + orderBy: 'creation', order: 'desc', }); return lastInserted && lastInserted.length ? lastInserted[0] : null; } -export async function getSeriesNext(prefix, doctype) { - let series; +export async function getSeriesNext(prefix: string, schemaName: string) { + let series: NumberSeries; try { - series = await frappe.getDoc('NumberSeries', prefix); + series = (await frappe.doc.getDoc('NumberSeries', prefix)) as NumberSeries; } catch (e) { - if (!e.statusCode || e.statusCode !== 404) { + const { statusCode } = e as BaseError; + if (!statusCode || statusCode !== 404) { throw e; } - await createNumberSeries(prefix, doctype); - series = await frappe.getDoc('NumberSeries', prefix); + await createNumberSeries(prefix, schemaName); + series = (await frappe.doc.getDoc('NumberSeries', prefix)) as NumberSeries; } - return await series.next(doctype); + return await series.next(schemaName); } -export async function createNumberSeries(prefix, referenceType, start = 1001) { +export async function createNumberSeries( + prefix: string, + referenceType: string, + start = 1001 +) { const exists = await frappe.db.exists('NumberSeries', prefix); if (exists) { return; } - const series = frappe.getNewDoc({ - doctype: 'NumberSeries', + const series = frappe.doc.getNewDoc('NumberSeries', { name: prefix, start, referenceType, diff --git a/models/doctype/Payment/PaymentServer.js b/models/doctype/Payment/PaymentServer.js index a9713d8f..b5845477 100644 --- a/models/doctype/Payment/PaymentServer.js +++ b/models/doctype/Payment/PaymentServer.js @@ -28,7 +28,7 @@ export default class PaymentServer extends Document { } const doctype = referenceType; - const doc = await frappe.getDoc(doctype, referenceName); + const doc = await frappe.doc.getDoc(doctype, referenceName); let party; let paymentType; @@ -147,7 +147,7 @@ export default class PaymentServer extends Document { if (!['SalesInvoice', 'PurchaseInvoice'].includes(row.referenceType)) { continue; } - let referenceDoc = await frappe.getDoc( + let referenceDoc = await frappe.doc.getDoc( row.referenceType, row.referenceName ); @@ -175,7 +175,7 @@ export default class PaymentServer extends Document { let newOutstanding = outstandingAmount.sub(this.amount); await referenceDoc.set('outstandingAmount', newOutstanding); await referenceDoc.update(); - let party = await frappe.getDoc('Party', this.party); + let party = await frappe.doc.getDoc('Party', this.party); await party.updateOutstandingAmount(); } } @@ -198,7 +198,7 @@ export default class PaymentServer extends Document { async updateReferenceOutstandingAmount() { await this.for.forEach(async ({ amount, referenceType, referenceName }) => { - const refDoc = await frappe.getDoc(referenceType, referenceName); + const refDoc = await frappe.doc.getDoc(referenceType, referenceName); refDoc.setMultiple({ outstandingAmount: refDoc.outstandingAmount.add(amount), }); diff --git a/models/doctype/SalesInvoice/SalesInvoicePrint.vue b/models/doctype/SalesInvoice/SalesInvoicePrint.vue index 75e6ef67..d6d35f6c 100644 --- a/models/doctype/SalesInvoice/SalesInvoicePrint.vue +++ b/models/doctype/SalesInvoice/SalesInvoicePrint.vue @@ -84,15 +84,15 @@ export default { await this.getFont(); }, async getTemplate() { - let invoiceSettings = await frappe.getDoc('SalesInvoiceSettings'); + let invoiceSettings = await frappe.doc.getDoc('SalesInvoiceSettings'); this.template = invoiceTemplates[invoiceSettings.template]; }, async getColor() { - let invoiceSettings = await frappe.getDoc('SalesInvoiceSettings'); + let invoiceSettings = await frappe.doc.getDoc('SalesInvoiceSettings'); this.themeColor = invoiceSettings.themeColor; }, async getFont() { - let invoiceSettings = await frappe.getDoc('SalesInvoiceSettings'); + let invoiceSettings = await frappe.doc.getDoc('SalesInvoiceSettings'); this.font = invoiceSettings.font; }, async toggleCustomizer() { diff --git a/models/doctype/Transaction/TransactionDocument.js b/models/doctype/Transaction/TransactionDocument.js index 49faf74b..6ca2dc4a 100644 --- a/models/doctype/Transaction/TransactionDocument.js +++ b/models/doctype/Transaction/TransactionDocument.js @@ -49,7 +49,8 @@ export default class TransactionDocument extends Document { async getTax(tax) { if (!this._taxes) this._taxes = {}; - if (!this._taxes[tax]) this._taxes[tax] = await frappe.getDoc('Tax', tax); + if (!this._taxes[tax]) + this._taxes[tax] = await frappe.doc.getDoc('Tax', tax); return this._taxes[tax]; } diff --git a/models/doctype/Transaction/TransactionServer.js b/models/doctype/Transaction/TransactionServer.js index c2ddb296..fe995bcc 100644 --- a/models/doctype/Transaction/TransactionServer.js +++ b/models/doctype/Transaction/TransactionServer.js @@ -35,7 +35,10 @@ export default { outstandingAmount: this.baseGrandTotal, }); - let party = await frappe.getDoc('Party', this.customer || this.supplier); + let party = await frappe.doc.getDoc( + 'Party', + this.customer || this.supplier + ); await party.updateOutstandingAmount(); }, @@ -43,7 +46,7 @@ export default { let paymentRefList = await this.getPayments(); for (let paymentFor of paymentRefList) { const paymentReference = paymentFor.parent; - const payment = await frappe.getDoc('Payment', paymentReference); + const payment = await frappe.doc.getDoc('Payment', paymentReference); const paymentEntries = await payment.getPosting(); await paymentEntries.postReverse(); // To set the payment status as unsubmitted. diff --git a/patches/0.0.3/makePaymentRefIdNullable.js b/patches/0.0.3/makePaymentRefIdNullable.js deleted file mode 100644 index 7d9685e6..00000000 --- a/patches/0.0.3/makePaymentRefIdNullable.js +++ /dev/null @@ -1,28 +0,0 @@ -import frappe from 'frappe'; - -export default async function execute() { - // Since sqlite has no ALTER TABLE to change column meta - // the table has to be _Prestiged_. - const tableInfo = await frappe.db.sql('pragma table_info("Payment")'); - const referenceId = tableInfo.find(({ name }) => name === 'referenceId'); - if (!referenceId || !referenceId.notnull) { - return; - } - - await frappe.db.createTable('Payment', '__Payment'); - await frappe.db.sql('insert into __Payment select * from Payment'); - - const mainCount = await frappe.db.knex - .table('Payment') - .count('name as count'); - const replCount = await frappe.db.knex - .table('__Payment') - .count('name as count'); - - if (mainCount[0].count === replCount[0].count) { - await frappe.db.knex.schema.dropTable('Payment'); - await frappe.db.knex.schema.renameTable('__Payment', 'Payment'); - } else { - await frappe.db.knex.schema.dropTable('__Payment'); - } -} diff --git a/patches/0.0.4/convertCurrencyToStrings.js b/patches/0.0.4/convertCurrencyToStrings.js deleted file mode 100644 index dbcdb96c..00000000 --- a/patches/0.0.4/convertCurrencyToStrings.js +++ /dev/null @@ -1,43 +0,0 @@ -import frappe from 'frappe'; - -function getTablesToConvert() { - // Do not change loops to map, doesn't work for some reason. - const toConvert = []; - for (let key in frappe.models) { - const model = frappe.models[key]; - - const fieldsToConvert = []; - for (let i in model.fields) { - const field = model.fields[i]; - - if (field.fieldtype === 'Currency') { - fieldsToConvert.push(field.fieldname); - } - } - - if (fieldsToConvert.length > 0 && !model.isSingle && !model.basedOn) { - toConvert.push({ name: key, fields: fieldsToConvert }); - } - } - - return toConvert; -} - -export default async function execute() { - const toConvert = getTablesToConvert(); - for (let { name, fields } of toConvert) { - const rows = await frappe.db.knex(name); - const convertedRows = rows.map((row) => { - for (let field of fields) { - row[field] = frappe.pesa(row[field] ?? 0).store; - } - - if ('numberFormat' in row) { - delete row.numberFormat; - } - - return row; - }); - await frappe.db.prestigeTheTable(name, convertedRows); - } -} diff --git a/patches/0.3.2/fixJournalEntryIds.js b/patches/0.3.2/fixJournalEntryIds.js deleted file mode 100644 index 30d16e99..00000000 --- a/patches/0.3.2/fixJournalEntryIds.js +++ /dev/null @@ -1,104 +0,0 @@ -import { getPaddedName } from '@/utils'; -import frappe from 'frappe'; -import { journalEntryTypeMap } from '../../models/doctype/JournalEntry/JournalEntry'; - -export async function getCorrectedJournalEntries() { - const jes = await frappe.db.knex('JournalEntry'); - const names = new Set(); - const duplicates = []; - - for (const je of jes) { - if (je.name in journalEntryTypeMap) { - const entryType = je.name; - je.name = je.entryType; - je.entryType = entryType; - } - - if (names.has(je.name)) { - duplicates.push(je); - } else { - names.add(je.name); - } - } - - if (duplicates.length === 0) { - return { jes, currentMap: {}, nsMap: {} }; - } - - const nameMap = getNameMap(names); - const nsMap = await getNumberSeriesMap(nameMap); - const currentMap = {}; - - const editedMap = {}; - - for (const je of duplicates) { - const { prefix } = getNumPrefix(je.name); - if (prefix.length === 0) { - je.name = `${je.name}-${Math.random().toString(36).slice(2, 7)}`; - continue; - } - - const newNum = nameMap[prefix].at(-1) + 1; - nameMap[prefix].push(newNum); - currentMap[prefix] = newNum; - - const newName = getPaddedName(prefix, newNum, nsMap[prefix].padZeros); - editedMap[je.name] = newName; - je.name = newName; - } - - return { jes, currentMap, nsMap }; -} - -async function updateCurrent(currentMap, nsMap) { - for (const name in currentMap) { - nsMap[name].update({ current: currentMap[name] }); - } -} - -async function getNumberSeriesMap(nameMap) { - const nsMap = {}; - for (const name in nameMap) { - nsMap[name] = await frappe.getDoc('NumberSeries', name); - } - return nsMap; -} - -function getNumPrefix(name) { - const mo = name.match(/(\D+)(\d+)$/); - const np = { num: '', prefix: '' }; - if (!mo) { - return np; - } - - np.prefix = mo[1] ?? ''; - np.num = mo[2] ?? ''; - return np; -} - -function getNameMap(names) { - const nameMap = {}; - for (const name of names) { - const { num, prefix } = getNumPrefix(name); - if (prefix.length === 0) { - continue; - } - - nameMap[prefix] ??= []; - nameMap[prefix].push(parseInt(num)); - } - - for (const name in nameMap) { - nameMap[name].sort(); - } - - return nameMap; -} - -export default async function execute() { - const { jes, currentMap, nsMap } = await getCorrectedJournalEntries(); - await frappe.db.prestigeTheTable('JournalEntry', jes); - if (Object.keys(currentMap).length) { - updateCurrent(currentMap, nsMap); - } -} diff --git a/patches/0.3.2/moveNumberSeriesFromSettings.js b/patches/0.3.2/moveNumberSeriesFromSettings.js deleted file mode 100644 index def267df..00000000 --- a/patches/0.3.2/moveNumberSeriesFromSettings.js +++ /dev/null @@ -1,20 +0,0 @@ -import { invertMap } from '@/utils'; -import frappe from 'frappe'; -import { DEFAULT_NUMBER_SERIES } from 'frappe/utils/consts'; - -async function setReferencesOnNumberSeries() { - const map = invertMap(DEFAULT_NUMBER_SERIES); - const rows = await frappe.db.knex('NumberSeries'); - for (const row of rows) { - if (row.referenceType === map[row.name]) { - return; - } - - row.referenceType = map[row.name]; - } - await frappe.db.prestigeTheTable('NumberSeries', rows); -} - -export default async function execute() { - await setReferencesOnNumberSeries(); -} diff --git a/patches/patches.json b/patches/patches.json deleted file mode 100644 index 2382aaba..00000000 --- a/patches/patches.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "version": "0.0.3", - "fileName": "makePaymentRefIdNullable", - "beforeMigrate": true - }, - { - "version": "0.0.4", - "fileName": "convertCurrencyToStrings", - "beforeMigrate": true - }, - { - "version": "0.3.2", - "fileName": "moveNumberSeriesFromSettings", - "beforeMigrate": false - }, - { - "version": "0.3.2", - "fileName": "fixJournalEntryIds", - "beforeMigrate": true - } -] diff --git a/reports/GoodsAndServiceTax/BaseGSTR.js b/reports/GoodsAndServiceTax/BaseGSTR.js index 20cdfb5a..ce039da7 100644 --- a/reports/GoodsAndServiceTax/BaseGSTR.js +++ b/reports/GoodsAndServiceTax/BaseGSTR.js @@ -39,18 +39,21 @@ class BaseGSTR { } async getRow(ledgerEntry) { - ledgerEntry = await frappe.getDoc(ledgerEntry.doctype, ledgerEntry.name); + ledgerEntry = await frappe.doc.getDoc( + ledgerEntry.doctype, + ledgerEntry.name + ); const row = {}; const { gstin } = frappe.AccountingSettings; - let party = await frappe.getDoc( + let party = await frappe.doc.getDoc( 'Party', ledgerEntry.customer || ledgerEntry.supplier ); if (party.address) { - let addressDetails = await frappe.getDoc('Address', party.address); + let addressDetails = await frappe.doc.getDoc('Address', party.address); row.place = addressDetails.pos || ''; } diff --git a/schemas/app/AccountingLedgerEntry.json b/schemas/app/AccountingLedgerEntry.json index ac540180..0dcd5773 100644 --- a/schemas/app/AccountingLedgerEntry.json +++ b/schemas/app/AccountingLedgerEntry.json @@ -3,6 +3,7 @@ "label": "Ledger Entry", "isSingle": false, "isChild": false, + "naming": "autoincrement", "fields": [ { "fieldname": "date", diff --git a/schemas/types.ts b/schemas/types.ts index 072f9dcd..ec90994b 100644 --- a/schemas/types.ts +++ b/schemas/types.ts @@ -108,6 +108,7 @@ export type Field = | NumberField; export type TreeSettings = { parentField: string }; +export type Naming = 'autoincrement' | 'random' | 'numberSeries' export interface Schema { name: string; // Table name @@ -123,6 +124,7 @@ export interface Schema { keywordFields?: string[]; // Used to get fields that are to be used for search. quickEditFields?: string[]; // Used to get fields for the quickEditForm treeSettings?: TreeSettings; // Used to determine root nodes + naming?: Naming; // Used for assigning name, default is 'random' else 'numberSeries' if present } export interface SchemaStub extends Partial { diff --git a/src/components/InvoiceCustomizer.vue b/src/components/InvoiceCustomizer.vue index ab2457f9..68ddba27 100644 --- a/src/components/InvoiceCustomizer.vue +++ b/src/components/InvoiceCustomizer.vue @@ -50,7 +50,7 @@ export default { }; }, async created() { - this.doc = await frappe.getDoc('SalesInvoiceSettings'); + this.doc = await frappe.doc.getDoc('SalesInvoiceSettings'); this.color.hex = this.doc.themeColor; const meta = frappe.getMeta('SalesInvoiceSettings'); this.fields = meta.fields.filter( diff --git a/src/components/ReconciliationValidation.vue b/src/components/ReconciliationValidation.vue index dc1d3f22..a07c31e1 100644 --- a/src/components/ReconciliationValidation.vue +++ b/src/components/ReconciliationValidation.vue @@ -66,7 +66,7 @@ export default { this.selectedEntries.push(this.entries[i]); } for (let entry of this.selectedEntries) { - const payment = await frappe.getDoc('Payment', entry['Payment Entry']); + const payment = await frappe.doc.getDoc('Payment', entry['Payment Entry']); const clearanceDate = luxon.DateTime.fromFormat( entry['Clearance Date'], diff --git a/src/dataImport.ts b/src/dataImport.ts index 9c869e4d..2c6e72dc 100644 --- a/src/dataImport.ts +++ b/src/dataImport.ts @@ -1,6 +1,8 @@ -import { Doc, Field, FieldType, Map } from '@/types/model'; import frappe from 'frappe'; +import { DocValueMap } from 'frappe/core/types'; +import Doc from 'frappe/model/doc'; import { isNameAutoSet } from 'frappe/model/naming'; +import { FieldType, FieldTypeEnum } from 'schemas/types'; import { parseCSV } from './csvParser'; import telemetry from './telemetry/telemetry'; import { Noun, Verb } from './telemetry/types'; @@ -25,9 +27,8 @@ type Exclusion = { [key: string]: string[]; }; -type ObjectMap = { - [key: string]: Map; -}; +type Map = Record; +type ObjectMap = Record; type LabelTemplateFieldMap = { [key: string]: TemplateField; @@ -51,16 +52,16 @@ interface TemplateField { function formatValue(value: string, fieldtype: FieldType): unknown { switch (fieldtype) { - case FieldType.Date: + case FieldTypeEnum.Date: if (value === '') { return ''; } return new Date(value); - case FieldType.Currency: + case FieldTypeEnum.Currency: // @ts-ignore return frappe.pesa(value || 0); - case FieldType.Int: - case FieldType.Float: { + case FieldTypeEnum.Int: + case FieldTypeEnum.Float: { const n = parseFloat(value); if (!Number.isNaN(n)) { return n; @@ -115,7 +116,7 @@ function getFilteredDocFields( return; } - if (fieldtype === FieldType.Table && childtype) { + if (fieldtype === FieldTypeEnum.Table && childtype) { tableTypes.push([childtype, fieldname]); return; } @@ -363,7 +364,7 @@ export class Importer { async importData(setLoadingStatus: LoadingStatusCallback): Promise { const status: Status = { success: false, names: [], message: '' }; - const shouldDeleteName = await isNameAutoSet(this.doctype); + const shouldDeleteName = isNameAutoSet(this.doctype); const docObjs = this.getDocs(); let entriesMade = 0; @@ -382,7 +383,7 @@ export class Importer { delete docObj[key]; } - const doc: Doc = frappe.getEmptyDoc(this.doctype, false); + const doc: Doc = frappe.doc.getEmptyDoc(this.doctype, false); try { await this.makeEntry(doc, docObj); entriesMade += 1; @@ -398,7 +399,7 @@ export class Importer { return this.handleError(doc, err as Error, status); } - status.names.push(doc.name); + status.names.push(doc.name!); } setLoadingStatus(false, entriesMade, docObjs.length); @@ -417,7 +418,7 @@ export class Importer { } async makeEntry(doc: Doc, docObj: Map) { - await doc.set(docObj); + await doc.setMultiple(docObj as DocValueMap); await doc.insert(); if (this.shouldSubmit) { await doc.submit(); diff --git a/src/pages/InvoiceForm.vue b/src/pages/InvoiceForm.vue index feb5f8ee..1dc936a1 100644 --- a/src/pages/InvoiceForm.vue +++ b/src/pages/InvoiceForm.vue @@ -205,11 +205,11 @@ import DropdownWithActions from '@/components/DropdownWithActions'; import PageHeader from '@/components/PageHeader'; import StatusBadge from '@/components/StatusBadge'; import { - getActionsForDocument, - getInvoiceStatus, - openSettings, - routeTo, - showMessageDialog, +getActionsForDocument, +getInvoiceStatus, +openSettings, +routeTo, +showMessageDialog } from '@/utils'; import frappe from 'frappe'; import { handleErrorWithDialog } from '../errorHandling'; @@ -263,7 +263,7 @@ export default { }, async mounted() { try { - this.doc = await frappe.getDoc(this.doctype, this.name); + this.doc = await frappe.doc.getDoc(this.doctype, this.name); window.d = this.doc; } catch (error) { if (error instanceof frappe.errors.NotFoundError) { diff --git a/src/pages/JournalEntryForm.vue b/src/pages/JournalEntryForm.vue index 45411052..13e37dd9 100644 --- a/src/pages/JournalEntryForm.vue +++ b/src/pages/JournalEntryForm.vue @@ -192,7 +192,7 @@ export default { }, async mounted() { try { - this.doc = await frappe.getDoc(this.doctype, this.name); + this.doc = await frappe.doc.getDoc(this.doctype, this.name); window.je = this.doc; } catch (error) { if (error instanceof frappe.errors.NotFoundError) { diff --git a/src/pages/PrintView/PrintView.vue b/src/pages/PrintView/PrintView.vue index c3bf8093..dd137507 100644 --- a/src/pages/PrintView/PrintView.vue +++ b/src/pages/PrintView/PrintView.vue @@ -56,12 +56,12 @@ import Button from '@/components/Button'; import PageHeader from '@/components/PageHeader'; import SearchBar from '@/components/SearchBar'; import TwoColumnForm from '@/components/TwoColumnForm'; -import { IPC_ACTIONS } from 'utils/messages'; import telemetry from '@/telemetry/telemetry'; import { Verb } from '@/telemetry/types'; import { makePDF } from '@/utils'; import { ipcRenderer } from 'electron'; import frappe from 'frappe'; +import { IPC_ACTIONS } from 'utils/messages'; export default { name: 'PrintView', @@ -81,7 +81,7 @@ export default { }; }, async mounted() { - this.doc = await frappe.getDoc(this.doctype, this.name); + this.doc = await frappe.doc.getDoc(this.doctype, this.name); this.printSettings = await frappe.getSingle('PrintSettings'); }, computed: { diff --git a/src/pages/QuickEditForm.vue b/src/pages/QuickEditForm.vue index 44829d52..c3e14a76 100644 --- a/src/pages/QuickEditForm.vue +++ b/src/pages/QuickEditForm.vue @@ -186,7 +186,7 @@ export default { }, async fetchDoc() { try { - this.doc = await frappe.getDoc(this.doctype, this.name); + this.doc = await frappe.doc.getDoc(this.doctype, this.name); this.doc.once('afterRename', () => { openQuickEdit({ diff --git a/src/pages/Settings/TabGeneral.vue b/src/pages/Settings/TabGeneral.vue index cc980d7c..3988ea7d 100644 --- a/src/pages/Settings/TabGeneral.vue +++ b/src/pages/Settings/TabGeneral.vue @@ -12,8 +12,8 @@