2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

chore: validate and lint typescript

This commit is contained in:
Mildred Ki'Lya 2023-12-22 09:50:35 +01:00
parent 47d90d8756
commit 4dfeb98e4a
8 changed files with 49 additions and 58 deletions

View File

@ -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() {

View File

@ -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() {

View File

@ -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) {

View File

@ -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;
}

View File

@ -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"
]
}

View File

@ -197,12 +197,8 @@ 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];
}
}
combined.fields = getListFromMap(abstractFields);
return combined;

View File

@ -4,9 +4,7 @@
<hr />
<div class="p-4 w-full flex flex-col gap-4">
<p class="text-base text-gray-900">
{{
t`Select the template type.`
}}
{{ t`Select the template type.` }}
</p>
<Select
:df="df"
@ -27,12 +25,10 @@
import { PrintTemplate } from 'models/baseModels/PrintTemplate';
import { OptionField } from 'schemas/types';
import Button from 'src/components/Button.vue';
import Float from 'src/components/Controls/Float.vue';
import Select from 'src/components/Controls/Select.vue';
import FormHeader from 'src/components/FormHeader.vue';
import { defineComponent } from 'vue';
type SizeName = typeof printSizes[number];
export default defineComponent({
components: { FormHeader, Select, Button },
props: { doc: { type: PrintTemplate, required: true } },
@ -42,14 +38,14 @@ export default defineComponent({
},
computed: {
df(): OptionField {
const options = PrintTemplate.lists.type(this.doc)
const options = PrintTemplate.lists.type(this.doc);
return {
...fyo.getField('PrintTemplate', 'type'),
options,
fieldtype: 'Select',
default: options[0].value
}
}
default: options[0].value,
} as OptionField;
},
},
mounted() {
this.type = this.doc.type ?? 'SalesInvoice';

View File

@ -204,7 +204,7 @@ async function getPrintTemplateDocValues(doc: Doc, fieldnames?: string[]) {
values[fieldname] = table;
}
values.submitted = doc.submitted
values.submitted = doc.submitted;
values.entryType = doc.schema.name;
values.entryLabel = doc.schema.label;
@ -364,12 +364,14 @@ function getNameAndTypeFromTemplateFile(
return [{ name: `${name} - ${label}`, type: schemaName }];
}
return [ModelNameEnum.SalesInvoice, ModelNameEnum.SalesQuote, ModelNameEnum.PurchaseInvoice].map(
(schemaName) => {
return [
ModelNameEnum.SalesInvoice,
ModelNameEnum.SalesQuote,
ModelNameEnum.PurchaseInvoice,
].map((schemaName) => {
const label = fyo.schemaMap[schemaName]?.label ?? schemaName;
return { name: `${name} - ${label}`, type: schemaName };
}
);
});
}
export const baseTemplate = `<main class="h-full w-full bg-white">