diff --git a/models/baseModels/Invoice/Invoice.ts b/models/baseModels/Invoice/Invoice.ts index 879bd641..d89d83a0 100644 --- a/models/baseModels/Invoice/Invoice.ts +++ b/models/baseModels/Invoice/Invoice.ts @@ -71,7 +71,9 @@ export abstract class Invoice extends Transactional { returnAgainst?: string; get isSales() { - return this.schemaName === 'SalesInvoice' || this.schemaName == 'SalesQuote'; + return ( + this.schemaName === 'SalesInvoice' || this.schemaName == 'SalesQuote' + ); } get isQuote() { diff --git a/models/baseModels/InvoiceItem/InvoiceItem.ts b/models/baseModels/InvoiceItem/InvoiceItem.ts index 95560849..6c9371a1 100644 --- a/models/baseModels/InvoiceItem/InvoiceItem.ts +++ b/models/baseModels/InvoiceItem/InvoiceItem.ts @@ -47,7 +47,10 @@ export abstract class InvoiceItem extends Doc { itemTaxedTotal?: Money; get isSales() { - return this.schemaName === 'SalesInvoiceItem' || this.schemaName === 'SalesQuoteItem'; + return ( + this.schemaName === 'SalesInvoiceItem' || + this.schemaName === 'SalesQuoteItem' + ); } get date() { diff --git a/models/baseModels/SalesQuote/SalesQuote.ts b/models/baseModels/SalesQuote/SalesQuote.ts index 8ac10b3f..2c23731d 100644 --- a/models/baseModels/SalesQuote/SalesQuote.ts +++ b/models/baseModels/SalesQuote/SalesQuote.ts @@ -1,14 +1,18 @@ import { Fyo } from 'fyo'; +import { DocValueMap } from 'fyo/core/types'; import { Action, ListViewSettings } from 'fyo/model/types'; -import { LedgerPosting } from 'models/Transactional/LedgerPosting'; import { ModelNameEnum } from 'models/types'; import { getQuoteActions, getTransactionStatusColumn } from '../../helpers'; import { Invoice } from '../Invoice/Invoice'; import { SalesQuoteItem } from '../SalesQuoteItem/SalesQuoteItem'; +import { Defaults } from '../Defaults/Defaults'; export class SalesQuote extends Invoice { items?: SalesQuoteItem[]; + // This is an inherited method and it must keep the async from the parent + // class + // eslint-disable-next-line @typescript-eslint/require-await async getPosting() { return null; } @@ -23,20 +27,18 @@ export class SalesQuote extends Invoice { const terms = defaults.salesInvoiceTerms ?? ''; const numberSeries = defaults.salesInvoiceNumberSeries ?? undefined; - const data = { - ...this, + const data: DocValueMap = { + ...this.getValidDict(false, true), date: new Date().toISOString(), terms, numberSeries, quote: this.name, - items: [] + items: [], }; const invoice = this.fyo.doc.getNewDoc(schemaName, data) as Invoice; for (const row of this.items ?? []) { - await invoice.append('items', { - ...row - }); + await invoice.append('items', row.getValidDict(false, true)); } if (!invoice.items?.length) { diff --git a/models/helpers.ts b/models/helpers.ts index 4e0ec45c..c5a25f49 100644 --- a/models/helpers.ts +++ b/models/helpers.ts @@ -11,6 +11,7 @@ import { } from './baseModels/Account/types'; import { numberSeriesDefaultsMap } from './baseModels/Defaults/Defaults'; import { Invoice } from './baseModels/Invoice/Invoice'; +import { SalesQuote } from './baseModels/SalesQuote/SalesQuote'; import { StockMovement } from './inventory/StockMovement'; import { StockTransfer } from './inventory/StockTransfer'; import { InvoiceStatus, ModelNameEnum } from './types'; @@ -19,9 +20,7 @@ export function getQuoteActions( fyo: Fyo, schemaName: ModelNameEnum.SalesQuote ): Action[] { - return [ - getMakeInvoiceAction(fyo, schemaName), - ]; + return [getMakeInvoiceAction(fyo, schemaName)]; } export function getInvoiceActions( @@ -76,7 +75,10 @@ export function getMakeStockTransferAction( export function getMakeInvoiceAction( fyo: Fyo, - schemaName: ModelNameEnum.Shipment | ModelNameEnum.PurchaseReceipt | ModelNameEnum.SalesQuote + schemaName: + | ModelNameEnum.Shipment + | ModelNameEnum.PurchaseReceipt + | ModelNameEnum.SalesQuote ): Action { let label = fyo.t`Sales Invoice`; if (schemaName === ModelNameEnum.PurchaseReceipt) { @@ -88,13 +90,13 @@ export function getMakeInvoiceAction( group: fyo.t`Create`, condition: (doc: Doc) => { if (schemaName === ModelNameEnum.SalesQuote) { - return doc.isSubmitted + return doc.isSubmitted; } else { - return doc.isSubmitted && !doc.backReference + return doc.isSubmitted && !doc.backReference; } }, action: async (doc: Doc) => { - let invoice = await (doc as SalesQuote | StockTransfer).getInvoice(); + const invoice = await (doc as SalesQuote | StockTransfer).getInvoice(); if (!invoice || !invoice.name) { return; } diff --git a/schemas/app/SalesQuote.json b/schemas/app/SalesQuote.json index 2d3f7540..9f524845 100644 --- a/schemas/app/SalesQuote.json +++ b/schemas/app/SalesQuote.json @@ -15,26 +15,6 @@ "default": "SQUOT-", "section": "Default" }, - { - "fieldname": "account", - "drop": true - }, - { - "fieldname": "stockNotTransferred", - "drop": true - }, - { - "fieldname": "backReference", - "drop": true - }, - { - "fieldname": "makeAutoStockTransfer", - "drop": true - }, - { - "fieldname": "returnAgainst", - "drop": true - }, { "fieldname": "party", "label": "Customer", @@ -54,5 +34,13 @@ "section": "Items" } ], - "keywordFields": ["name", "party"] + "keywordFields": ["name", "party"], + "removeFields": [ + "account", + "stockNotTransferred", + "backReference", + "makeAutoStockTransfer", + "returnAgainst", + "isReturned" + ] } diff --git a/schemas/index.ts b/schemas/index.ts index f5e15b02..c7c2f0b8 100644 --- a/schemas/index.ts +++ b/schemas/index.ts @@ -197,11 +197,7 @@ function getCombined( const combined = Object.assign(abstractSchema, extendingSchema); for (const fieldname in extendingFields) { - if (extendingFields[fieldname].drop) { - delete abstractFields[fieldname] - } else { - abstractFields[fieldname] = extendingFields[fieldname]; - } + abstractFields[fieldname] = extendingFields[fieldname]; } combined.fields = getListFromMap(abstractFields); diff --git a/src/pages/TemplateBuilder/SetType.vue b/src/pages/TemplateBuilder/SetType.vue index dd70df3d..8b5f142f 100644 --- a/src/pages/TemplateBuilder/SetType.vue +++ b/src/pages/TemplateBuilder/SetType.vue @@ -4,9 +4,7 @@
- {{ - t`Select the template type.` - }} + {{ t`Select the template type.` }}