2
0
mirror of https://github.com/frappe/books.git synced 2025-02-08 23:18:31 +00:00

incr: use CommonForm for a few docs

- show errors
- shit setName to after validation
This commit is contained in:
18alantom 2023-02-21 11:04:35 +05:30
parent 0c077f09d2
commit e0141b70d8
14 changed files with 262 additions and 150 deletions

View File

@ -117,7 +117,10 @@ export class DocHandler {
const idx = this.#temporaryNameCounters[schema.name]; const idx = this.#temporaryNameCounters[schema.name];
this.#temporaryNameCounters[schema.name] = idx + 1; this.#temporaryNameCounters[schema.name] = idx + 1;
return this.fyo.t`New ${schema.label ?? schema.name} - Temp No. ${idx}`; return this.fyo.t`New ${schema.label ?? schema.name} ${String(idx).padStart(
2,
'0'
)}`;
} }
/** /**

View File

@ -868,9 +868,9 @@ export class Doc extends Observable<DocValue | Doc[]> {
} }
async _insert() { async _insert() {
await setName(this, this.fyo);
this._setBaseMetaValues(); this._setBaseMetaValues();
await this._preSync(); await this._preSync();
await setName(this, this.fyo);
const validDict = this.getValidDict(false, true); const validDict = this.getValidDict(false, true);
let data: DocValueMap; let data: DocValueMap;

View File

@ -111,6 +111,7 @@ export class Item extends Doc {
static getListViewSettings(): ListViewSettings { static getListViewSettings(): ListViewSettings {
return { return {
formRoute: ({ name }) => `/edit/Item/${name}`,
columns: ['name', 'unit', 'tax', 'rate'], columns: ['name', 'unit', 'tax', 'rate'],
}; };
} }

View File

@ -617,6 +617,7 @@ export class Payment extends Transactional {
static getListViewSettings(fyo: Fyo): ListViewSettings { static getListViewSettings(fyo: Fyo): ListViewSettings {
return { return {
formRoute: ({ name }) => `/edit/Payment/${name}`,
columns: ['name', getDocStatusListColumn(), 'party', 'date', 'amount'], columns: ['name', getDocStatusListColumn(), 'party', 'date', 'amount'],
}; };
} }

View File

@ -75,6 +75,7 @@ export class StockMovement extends Transfer {
static getListViewSettings(fyo: Fyo): ListViewSettings { static getListViewSettings(fyo: Fyo): ListViewSettings {
return { return {
formRoute: ({ name }) => `/edit/StockMovement/${name}`,
columns: [ columns: [
'name', 'name',
getDocStatusListColumn(), getDocStatusListColumn(),

View File

@ -4,50 +4,20 @@
"isSingle": false, "isSingle": false,
"naming": "manual", "naming": "manual",
"fields": [ "fields": [
{
"fieldname": "image",
"label": "Image",
"section": "Default",
"fieldtype": "AttachImage"
},
{ {
"fieldname": "name", "fieldname": "name",
"label": "Item Name", "label": "Item Name",
"fieldtype": "Data", "fieldtype": "Data",
"placeholder": "Item Name", "placeholder": "Item Name",
"section": "Default",
"required": true "required": true
}, },
{
"fieldname": "image",
"label": "Image",
"fieldtype": "AttachImage"
},
{
"fieldname": "description",
"label": "Description",
"placeholder": "Item Description",
"fieldtype": "Text"
},
{
"fieldname": "unit",
"label": "Unit Type",
"fieldtype": "Link",
"target": "UOM",
"create": true,
"default": "Unit",
"placeholder": "Unit Type"
},
{
"fieldname": "itemType",
"label": "Type",
"placeholder": "Type",
"fieldtype": "Select",
"default": "Product",
"options": [
{
"value": "Product",
"label": "Product"
},
{
"value": "Service",
"label": "Service"
}
]
},
{ {
"fieldname": "for", "fieldname": "for",
"label": "For", "label": "For",
@ -67,14 +37,57 @@
} }
], ],
"required": true, "required": true,
"section": "Default",
"default": "Both" "default": "Both"
}, },
{
"fieldname": "itemType",
"label": "Type",
"placeholder": "Type",
"fieldtype": "Select",
"default": "Product",
"section": "Default",
"options": [
{
"value": "Product",
"label": "Product"
},
{
"value": "Service",
"label": "Service"
}
]
},
{
"fieldname": "unit",
"label": "Unit Type",
"fieldtype": "Link",
"target": "UOM",
"create": true,
"default": "Unit",
"section": "Details",
"placeholder": "Unit Type"
},
{
"fieldname": "rate",
"label": "Rate",
"section": "Details",
"fieldtype": "Currency"
},
{
"fieldname": "description",
"label": "Description",
"placeholder": "Item Description",
"section": "Details",
"fieldtype": "Text"
},
{ {
"fieldname": "incomeAccount", "fieldname": "incomeAccount",
"label": "Sales Acc.", "label": "Sales Acc.",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Account", "target": "Account",
"placeholder": "Income", "placeholder": "Income",
"section": "Accounts",
"create": true, "create": true,
"required": true "required": true
}, },
@ -84,6 +97,7 @@
"fieldtype": "Link", "fieldtype": "Link",
"target": "Account", "target": "Account",
"placeholder": "Expense", "placeholder": "Expense",
"section": "Accounts",
"create": true, "create": true,
"required": true "required": true
}, },
@ -92,31 +106,30 @@
"label": "Tax", "label": "Tax",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Tax", "target": "Tax",
"section": "Accounts",
"create": true, "create": true,
"placeholder": "Tax" "placeholder": "Tax"
}, },
{
"fieldname": "rate",
"label": "Rate",
"fieldtype": "Currency"
},
{ {
"fieldname": "hsnCode", "fieldname": "hsnCode",
"label": "HSN/SAC", "label": "HSN/SAC",
"fieldtype": "Int", "fieldtype": "Int",
"placeholder": "HSN/SAC Code" "placeholder": "HSN/SAC Code",
"section": "Inventory"
}, },
{ {
"fieldname": "barcode", "fieldname": "barcode",
"label": "Barcode", "label": "Barcode",
"fieldtype": "Data", "fieldtype": "Data",
"placeholder": "Barcode" "placeholder": "Barcode",
"section": "Inventory"
}, },
{ {
"fieldname": "trackItem", "fieldname": "trackItem",
"label": "Track Item", "label": "Track Item",
"fieldtype": "Check", "fieldtype": "Check",
"default": false "default": false,
"section": "Inventory"
} }
], ],
"quickEditFields": [ "quickEditFields": [

View File

@ -100,6 +100,27 @@
"required": true, "required": true,
"section": "Details" "section": "Details"
}, },
{
"fieldname": "clearanceDate",
"label": "Clearance Date",
"placeholder": "Clearance Date",
"fieldtype": "Date",
"section": "Details"
},
{
"fieldname": "referenceId",
"label": "Ref. / Cheque No.",
"placeholder": "Ref. / Cheque No.",
"fieldtype": "Data",
"section": "Details"
},
{
"fieldname": "referenceDate",
"label": "Reference Date",
"placeholder": "Ref. Date",
"fieldtype": "Date",
"section": "Details"
},
{ {
"fieldname": "amount", "fieldname": "amount",
"label": "Amount", "label": "Amount",
@ -120,27 +141,6 @@
"computed": true, "computed": true,
"section": "Amounts" "section": "Amounts"
}, },
{
"fieldname": "referenceId",
"label": "Ref. / Cheque No.",
"placeholder": "Ref. / Cheque No.",
"fieldtype": "Data",
"section": "References"
},
{
"fieldname": "referenceDate",
"label": "Reference Date",
"placeholder": "Ref. Date",
"fieldtype": "Date",
"section": "References"
},
{
"fieldname": "clearanceDate",
"label": "Clearance Date",
"placeholder": "Clearance Date",
"fieldtype": "Date",
"section": "References"
},
{ {
"fieldname": "for", "fieldname": "for",
"label": "Payment Reference", "label": "Payment Reference",

View File

@ -11,13 +11,18 @@
"fieldname": "name", "fieldname": "name",
"fieldtype": "Data", "fieldtype": "Data",
"required": true, "required": true,
"readOnly": true "readOnly": true,
"section": "Default"
}, },
{ {
"fieldname": "date", "fieldname": "numberSeries",
"label": "Date", "label": "Number Series",
"fieldtype": "Datetime", "fieldtype": "Link",
"required": true "target": "NumberSeries",
"create": true,
"required": true,
"default": "SMOV-",
"section": "Default"
}, },
{ {
"fieldname": "movementType", "fieldname": "movementType",
@ -41,29 +46,30 @@
"label": "Manufacture" "label": "Manufacture"
} }
], ],
"required": true
},
{
"fieldname": "numberSeries",
"label": "Number Series",
"fieldtype": "Link",
"target": "NumberSeries",
"create": true,
"required": true, "required": true,
"default": "SMOV-" "section": "Default"
}, },
{ {
"fieldname": "amount", "fieldname": "date",
"label": "Total Amount", "label": "Date",
"fieldtype": "Currency", "fieldtype": "Datetime",
"readOnly": true "required": true,
"section": "Default"
}, },
{ {
"fieldname": "items", "fieldname": "items",
"label": "Items", "label": "Items",
"fieldtype": "Table", "fieldtype": "Table",
"target": "StockMovementItem", "target": "StockMovementItem",
"required": true "required": true,
"section": "Items"
},
{
"fieldname": "amount",
"label": "Total Amount",
"fieldtype": "Currency",
"readOnly": true,
"section": "Items"
} }
], ],
"quickEditFields": [ "quickEditFields": [

View File

@ -116,7 +116,7 @@ export default {
}, },
async openNewDoc() { async openNewDoc() {
const schemaName = this.df.target; const schemaName = this.df.target;
const doc = await fyo.doc.getNewDoc(schemaName); const doc = fyo.doc.getNewDoc(schemaName);
const filters = await this.getCreateFilters(); const filters = await this.getCreateFilters();

View File

@ -13,15 +13,12 @@
</p> </p>
<feather-icon v-else name="more-horizontal" class="w-4 h-4" /> <feather-icon v-else name="more-horizontal" class="w-4 h-4" />
</DropdownWithActions> </DropdownWithActions>
<Button v-if="doc?.canSave" type="primary" @click="() => doc.sync()"> <Button v-if="doc?.canSave" type="primary" @click="sync">
{{ t`Save` }} {{ t`Save` }}
</Button> </Button>
<Button <Button v-else-if="doc?.canSubmit" type="primary" @click="submit">{{
v-else-if="doc?.canSubmit" t`Submit`
type="primary" }}</Button>
@click="() => doc.submit()"
>{{ t`Submit` }}</Button
>
</template> </template>
<template #body> <template #body>
<FormHeader <FormHeader
@ -44,6 +41,8 @@
:title="name" :title="name"
:fields="fields" :fields="fields"
:doc="doc" :doc="doc"
:errors="errors"
@value-change="onValueChange"
/> />
</div> </div>
@ -61,7 +60,7 @@
bottom-0 bottom-0
bg-white bg-white
" "
v-if="groupedFields.size > 1" v-if="groupedFields && groupedFields.size > 1"
> >
<div <div
v-for="key of groupedFields.keys()" v-for="key of groupedFields.keys()"
@ -100,6 +99,7 @@
</FormContainer> </FormContainer>
</template> </template>
<script lang="ts"> <script lang="ts">
import { DocValue } from 'fyo/core/types';
import { Doc } from 'fyo/model/doc'; import { Doc } from 'fyo/model/doc';
import { ValidationError } from 'fyo/utils/errors'; import { ValidationError } from 'fyo/utils/errors';
import { getDocStatus } from 'models/helpers'; import { getDocStatus } from 'models/helpers';
@ -110,6 +110,8 @@ import DropdownWithActions from 'src/components/DropdownWithActions.vue';
import FormContainer from 'src/components/FormContainer.vue'; import FormContainer from 'src/components/FormContainer.vue';
import FormHeader from 'src/components/FormHeader.vue'; import FormHeader from 'src/components/FormHeader.vue';
import StatusBadge from 'src/components/StatusBadge.vue'; import StatusBadge from 'src/components/StatusBadge.vue';
import { handleErrorWithDialog } from 'src/errorHandling';
import { getErrorMessage } from 'src/utils';
import { ActionGroup, UIGroupedFields } from 'src/utils/types'; import { ActionGroup, UIGroupedFields } from 'src/utils/types';
import { import {
getFieldsGroupedByTabAndSection, getFieldsGroupedByTabAndSection,
@ -122,7 +124,7 @@ import CommonFormSection from './CommonFormSection.vue';
export default defineComponent({ export default defineComponent({
props: { props: {
name: { type: String, default: '' }, name: { type: String, default: '' },
schemaName: { type: String, default: ModelNameEnum.StockMovement }, schemaName: { type: String, default: ModelNameEnum.SalesInvoice },
}, },
provide() { provide() {
return { return {
@ -133,12 +135,16 @@ export default defineComponent({
}, },
data() { data() {
return { return {
errors: {},
docOrNull: null, docOrNull: null,
activeTab: 'Default', activeTab: 'Default',
groupedFields: null,
quickEditDoc: null, quickEditDoc: null,
} as { } as {
errors: Record<string, string>;
docOrNull: null | Doc; docOrNull: null | Doc;
activeTab: string; activeTab: string;
groupedFields: null | UIGroupedFields;
quickEditDoc: null | Doc; quickEditDoc: null | Doc;
}; };
}, },
@ -149,6 +155,7 @@ export default defineComponent({
} }
await this.setDoc(); await this.setDoc();
this.groupedFields = this.getGroupedFields();
}, },
computed: { computed: {
hasDoc(): boolean { hasDoc(): boolean {
@ -187,7 +194,7 @@ export default defineComponent({
return this.t`New Entry`; return this.t`New Entry`;
} }
return this.docOrNull?.name!?? this.t`New Entry`; return this.docOrNull?.name! ?? this.t`New Entry`;
}, },
schema(): Schema { schema(): Schema {
const schema = this.fyo.schemaMap[this.schemaName]; const schema = this.fyo.schemaMap[this.schemaName];
@ -198,6 +205,10 @@ export default defineComponent({
return schema; return schema;
}, },
activeGroup(): Map<string, Field[]> { activeGroup(): Map<string, Field[]> {
if (!this.groupedFields) {
return new Map();
}
const group = this.groupedFields.get(this.activeTab); const group = this.groupedFields.get(this.activeTab);
if (!group) { if (!group) {
throw new ValidationError( throw new ValidationError(
@ -207,9 +218,6 @@ export default defineComponent({
return group; return group;
}, },
groupedFields(): UIGroupedFields {
return getFieldsGroupedByTabAndSection(this.schema);
},
groupedActions(): ActionGroup[] { groupedActions(): ActionGroup[] {
if (!this.hasDoc) { if (!this.hasDoc) {
return []; return [];
@ -219,17 +227,53 @@ export default defineComponent({
}, },
}, },
methods: { methods: {
getGroupedFields(): UIGroupedFields {
if (!this.hasDoc) {
return new Map();
}
return getFieldsGroupedByTabAndSection(this.schema, this.doc);
},
async sync() {
try {
await this.doc.sync();
} catch (err) {
if (!(err instanceof Error)) {
return;
}
await handleErrorWithDialog(err, this.doc);
}
},
async submit() {
try {
await this.doc.submit();
} catch (err) {
if (!(err instanceof Error)) {
return;
}
await handleErrorWithDialog(err, this.doc);
}
},
async setDoc() { async setDoc() {
if (this.hasDoc) { if (this.hasDoc) {
return; return;
} }
if (this.name) { if (this.name) {
this.docOrNull = await this.fyo.doc.getDoc(this.schemaName, this.name); await this.setDocFromName(this.name);
} else { } else {
this.docOrNull = this.fyo.doc.getNewDoc(this.schemaName); this.docOrNull = this.fyo.doc.getNewDoc(this.schemaName);
} }
}, },
async setDocFromName(name: string) {
try {
this.docOrNull = await this.fyo.doc.getDoc(this.schemaName, name);
} catch (err) {
this.docOrNull = this.fyo.doc.getNewDoc(this.schemaName);
}
},
async toggleQuickEditDoc(doc: Doc | null) { async toggleQuickEditDoc(doc: Doc | null) {
if (this.quickEditDoc && doc) { if (this.quickEditDoc && doc) {
this.quickEditDoc = null; this.quickEditDoc = null;
@ -238,6 +282,23 @@ export default defineComponent({
this.quickEditDoc = doc; this.quickEditDoc = doc;
}, },
async onValueChange(field: Field, value: DocValue) {
const { fieldname } = field;
console.log(fieldname, value);
delete this.errors[fieldname];
try {
await this.doc.set(fieldname, value);
} catch (err) {
if (!(err instanceof Error)) {
return;
}
this.errors[fieldname] = getErrorMessage(err, this.doc);
}
this.groupedFields = this.getGroupedFields();
},
}, },
components: { components: {
FormContainer, FormContainer,

View File

@ -1,5 +1,5 @@
<template> <template>
<div v-if="filteredFields.length > 0"> <div v-if="(fields ?? []).length > 0">
<div <div
v-if="showTitle && title" v-if="showTitle && title"
class="flex justify-between items-center cursor-pointer select-none" class="flex justify-between items-center cursor-pointer select-none"
@ -15,55 +15,47 @@
/> />
</div> </div>
<div class="grid gap-4 gap-x-8 grid-cols-2" v-if="!collapsed"> <div class="grid gap-4 gap-x-8 grid-cols-2" v-if="!collapsed">
<FormControl <div
v-for="field of filteredFields" v-for="field of fields"
class="mt-auto"
:class="field.fieldtype === 'Table' ? 'col-span-2 text-base' : ''"
:show-label="true"
:border="true"
:key="field.fieldname" :key="field.fieldname"
:df="field" class="mb-auto"
:value="doc[field.fieldname]" :class="field.fieldtype === 'Table' ? 'col-span-2 text-base' : ''"
@editrow="(doc:Doc) => $emit('editrow', doc)" >
@change="async (value) => await doc.set(field.fieldname, value)" <FormControl
/> :show-label="true"
:border="true"
:df="field"
:value="doc[field.fieldname]"
@editrow="(doc: Doc) => $emit('editrow', doc)"
@change="(value: DocValue) => $emit('value-change', field, value)"
/>
<div v-if="errors?.[field.fieldname]" class="text-sm text-red-600">
{{ errors[field.fieldname] }}
</div>
</div>
</div> </div>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { DocValue } from 'fyo/core/types';
import { Doc } from 'fyo/model/doc'; import { Doc } from 'fyo/model/doc';
import { Field } from 'schemas/types'; import { Field } from 'schemas/types';
import FormControl from 'src/components/Controls/FormControl.vue'; import FormControl from 'src/components/Controls/FormControl.vue';
import { evaluateHidden } from 'src/utils/doc';
import { defineComponent, PropType } from 'vue'; import { defineComponent, PropType } from 'vue';
export default defineComponent({ export default defineComponent({
emits: ['editrow'], emits: ['editrow', 'value-change'],
props: { props: {
title: String, title: String,
errors: Object as PropType<Record<string, string>>,
showTitle: Boolean, showTitle: Boolean,
doc: { type: Object as PropType<Doc>, required: true }, doc: { type: Object as PropType<Doc>, required: true },
fields: Array as PropType<Field[]>, fields: Array as PropType<Field[]>,
}, },
data() { data() {
return { collapsed: false }; return { collapsed: false } as {
}, collapsed: boolean;
computed: { };
filteredFields(): Field[] {
const fields: Field[] = [];
for (const field of this.fields ?? []) {
if (evaluateHidden(field, this.doc)) {
continue;
}
if (field.meta) {
continue;
}
fields.push(field);
}
return fields;
},
}, },
components: { FormControl }, components: { FormControl },
}); });

View File

@ -9,6 +9,7 @@ import JournalEntryForm from 'src/pages/JournalEntryForm.vue';
import ListView from 'src/pages/ListView/ListView.vue'; import ListView from 'src/pages/ListView/ListView.vue';
import PrintView from 'src/pages/PrintView/PrintView.vue'; import PrintView from 'src/pages/PrintView/PrintView.vue';
import QuickEditForm from 'src/pages/QuickEditForm.vue'; import QuickEditForm from 'src/pages/QuickEditForm.vue';
import CommonForm from 'src/pages/CommonForm/CommonForm.vue';
import Report from 'src/pages/Report.vue'; import Report from 'src/pages/Report.vue';
import Settings from 'src/pages/Settings/Settings.vue'; import Settings from 'src/pages/Settings/Settings.vue';
import { import {
@ -43,6 +44,33 @@ function getGeneralFormItems(): RouteRecordRaw[] {
); );
} }
function getCommonFormItems(): RouteRecordRaw[] {
return [
ModelNameEnum.Payment,
ModelNameEnum.StockMovement,
ModelNameEnum.Item,
].map((schemaName) => {
return {
path: `/edit/${schemaName}/:name`,
name: `${schemaName}Form`,
components: {
default: CommonForm,
edit: QuickEditForm,
},
props: {
default: (route) => {
route.params.schemaName = schemaName;
return {
schemaName,
name: route.params.name,
};
},
edit: (route) => route.query,
},
};
});
}
const routes: RouteRecordRaw[] = [ const routes: RouteRecordRaw[] = [
{ {
path: '/', path: '/',
@ -53,6 +81,7 @@ const routes: RouteRecordRaw[] = [
component: GetStarted, component: GetStarted,
}, },
...getGeneralFormItems(), ...getGeneralFormItems(),
...getCommonFormItems(),
{ {
path: '/edit/JournalEntry/:name', path: '/edit/JournalEntry/:name',
name: 'JournalEntryForm', name: 'JournalEntryForm',
@ -167,6 +196,9 @@ export function getCreateRoute(
ModelNameEnum.JournalEntry, ModelNameEnum.JournalEntry,
ModelNameEnum.Shipment, ModelNameEnum.Shipment,
ModelNameEnum.PurchaseReceipt, ModelNameEnum.PurchaseReceipt,
ModelNameEnum.StockMovement,
ModelNameEnum.Payment,
ModelNameEnum.Item,
].includes(schemaName as ModelNameEnum) ].includes(schemaName as ModelNameEnum)
) { ) {
return `/edit/${schemaName}/${name}`; return `/edit/${schemaName}/${name}`;

View File

@ -93,25 +93,16 @@ async function openFormEditDoc(schemaName: string, fyo: Fyo) {
function getCreateList(fyo: Fyo): SearchItem[] { function getCreateList(fyo: Fyo): SearchItem[] {
const hasInventory = fyo.doc.singles.AccountingSettings?.enableInventory; const hasInventory = fyo.doc.singles.AccountingSettings?.enableInventory;
const quickEditCreateList = [
...(hasInventory ? [ModelNameEnum.StockMovement] : []),
].map(
(schemaName) =>
({
label: fyo.schemaMap[schemaName]?.label,
group: 'Create',
action() {
openQuickEditDoc(schemaName, fyo);
},
} as SearchItem)
);
const formEditCreateList = [ const formEditCreateList = [
ModelNameEnum.SalesInvoice, ModelNameEnum.SalesInvoice,
ModelNameEnum.PurchaseInvoice, ModelNameEnum.PurchaseInvoice,
ModelNameEnum.JournalEntry, ModelNameEnum.JournalEntry,
...(hasInventory ...(hasInventory
? [ModelNameEnum.Shipment, ModelNameEnum.PurchaseReceipt] ? [
ModelNameEnum.Shipment,
ModelNameEnum.PurchaseReceipt,
ModelNameEnum.StockMovement,
]
: []), : []),
].map( ].map(
(schemaName) => (schemaName) =>
@ -197,7 +188,7 @@ function getCreateList(fyo: Fyo): SearchItem[] {
} as SearchItem; } as SearchItem;
}); });
return [quickEditCreateList, formEditCreateList, filteredCreateList].flat(); return [formEditCreateList, filteredCreateList].flat();
} }
function getReportList(fyo: Fyo): SearchItem[] { function getReportList(fyo: Fyo): SearchItem[] {

View File

@ -17,6 +17,7 @@ import { IPC_ACTIONS } from 'utils/messages';
import { App, createApp, h, ref } from 'vue'; import { App, createApp, h, ref } from 'vue';
import { RouteLocationRaw } from 'vue-router'; import { RouteLocationRaw } from 'vue-router';
import { stringifyCircular } from './'; import { stringifyCircular } from './';
import { evaluateHidden } from './doc';
import { import {
ActionGroup, ActionGroup,
MessageDialogOptions, MessageDialogOptions,
@ -73,6 +74,7 @@ export async function openQuickEdit({
if (forWhat[0] === 'not in' && forWhat[1] === 'Sales') { if (forWhat[0] === 'not in' && forWhat[1] === 'Sales') {
defaults = Object.assign({ for: 'Purchases' }); defaults = Object.assign({ for: 'Purchases' });
} }
console.log(method, schemaName, name);
router[method]({ router[method]({
query: { query: {
@ -390,7 +392,8 @@ function getDuplicateAction(doc: Doc): Action {
} }
export function getFieldsGroupedByTabAndSection( export function getFieldsGroupedByTabAndSection(
schema: Schema schema: Schema,
doc: Doc
): UIGroupedFields { ): UIGroupedFields {
const grouped: UIGroupedFields = new Map(); const grouped: UIGroupedFields = new Map();
for (const field of schema?.fields ?? []) { for (const field of schema?.fields ?? []) {
@ -405,6 +408,14 @@ export function getFieldsGroupedByTabAndSection(
tabbed.set(section, []); tabbed.set(section, []);
} }
if (field.meta) {
continue;
}
if (evaluateHidden(field, doc)) {
continue;
}
tabbed.get(section)!.push(field); tabbed.get(section)!.push(field);
} }