diff --git a/models/baseModels/Payment/Payment.ts b/models/baseModels/Payment/Payment.ts index ad48feca..6e7992fb 100644 --- a/models/baseModels/Payment/Payment.ts +++ b/models/baseModels/Payment/Payment.ts @@ -26,7 +26,8 @@ import { AccountTypeEnum } from '../Account/types'; import { Invoice } from '../Invoice/Invoice'; import { Party } from '../Party/Party'; import { PaymentFor } from '../PaymentFor/PaymentFor'; -import { PaymentType } from './types'; +import { PaymentType, PaymentTypeEnum } from './types'; +import { PartyRoleEnum } from '../Party/types'; import { TaxSummary } from '../TaxSummary/TaxSummary'; import { PaymentMethod } from '../PaymentMethod/PaymentMethod'; @@ -662,17 +663,23 @@ export class Payment extends Transactional { const partyDoc = (await this.loadAndGetLink('party')) as Party; const outstanding = partyDoc.outstandingAmount as Money; - if (partyDoc.role === 'Supplier') { + if (partyDoc.role === PartyRoleEnum.Supplier) { if (refDoc?.isReturn) { - return 'Receive'; + return PaymentTypeEnum.Receive; } else { - return 'Pay'; + return PaymentTypeEnum.Pay; } - } else if (partyDoc.role === 'Customer') { + } else if (partyDoc.role === PartyRoleEnum.Customer) { if (refDoc?.isSales && refDoc.isReturn) { - return 'Pay'; + return PaymentTypeEnum.Pay; } else { - return 'Receive'; + return PaymentTypeEnum.Receive; + } + } else if (partyDoc.role === PartyRoleEnum.Both) { + if (refDoc?.isSales && refDoc.isReturn) { + return PaymentTypeEnum.Pay; + } else { + return PaymentTypeEnum.Receive; } } @@ -681,9 +688,9 @@ export class Payment extends Transactional { } if (outstanding?.isPositive()) { - return 'Receive'; + return PaymentTypeEnum.Receive; } - return 'Pay'; + return PaymentTypeEnum.Pay; }, }, amount: { diff --git a/schemas/core/SystemSettings.json b/schemas/core/SystemSettings.json index f55ca4f4..d58da4fd 100644 --- a/schemas/core/SystemSettings.json +++ b/schemas/core/SystemSettings.json @@ -72,6 +72,14 @@ "description": "When linking documents, if no match is found and filtering is in effect, allow to disable filters.", "section": "Default" }, + { + "fieldname": "removeFilter", + "label": "Remove Filter", + "fieldtype": "Check", + "default": false, + "description": "When enabled, removes all default filters applied across the system, showing all available options instead of filtered ones.", + "section": "Default" + }, { "fieldname": "locale", "label": "Locale", diff --git a/src/components/Controls/Link.vue b/src/components/Controls/Link.vue index bf5a7014..56a5d0d9 100644 --- a/src/components/Controls/Link.vue +++ b/src/components/Controls/Link.vue @@ -155,7 +155,7 @@ export default { this.filtersDisabled = true; this.results = []; setTimeout(() => { - this.toggleDropdown(true); + this.isDropdownOpen = true; this.updateSuggestions(keyword); }, 1); }, @@ -192,6 +192,11 @@ export default { if (this.df.filters) { return this.df.filters; } + + if (fyo.singles.SystemSettings?.removeFilter) { + return null; + } + const { schemaName, fieldname } = this.df; const getFilters = fyo.models[schemaName]?.filters?.[fieldname]; diff --git a/src/utils/search.ts b/src/utils/search.ts index c9a89784..a891e919 100644 --- a/src/utils/search.ts +++ b/src/utils/search.ts @@ -22,6 +22,7 @@ interface StoredRecentItem { route?: string; schemaName?: string; reportName?: string; + initData?: RawValueMap; timestamp: number; } @@ -102,6 +103,7 @@ function getCreateList(fyo: Fyo): SearchItem[] { label: fyo.schemaMap[schemaName]?.label, group: 'Create', action: getCreateAction(fyo, schemaName), + schemaName, } as SearchItem) ); @@ -151,6 +153,8 @@ function getCreateList(fyo: Fyo): SearchItem[] { label, group: 'Create', action: getCreateAction(fyo, schemaName, create), + schemaName, + initData: create, } as SearchItem; }); @@ -430,6 +434,9 @@ export class Search { recentItem.route = item.route; } else if (item.group === 'Docs') { recentItem.schemaName = item.schemaLabel; + } else if (item.group === 'Create') { + recentItem.schemaName = item.schemaName; + recentItem.initData = item.initData; } const updatedRecents = [ @@ -470,6 +477,9 @@ export class Search { private _executeRecentAction(item: StoredRecentItem) { if (item.route) { void routeTo(item.route); + } else if (item.schemaName && item.group === 'Create') { + const action = getCreateAction(this.fyo, item.schemaName, item.initData); + void action(); } else if (item.schemaName) { this._openDocList(item.schemaName); } else if (item.reportName) { diff --git a/utils/types.ts b/utils/types.ts index 34fbde0b..10679859 100644 --- a/utils/types.ts +++ b/utils/types.ts @@ -1,4 +1,4 @@ -import type { ConfigFile } from 'fyo/core/types'; +import type { ConfigFile, RawValueMap } from 'fyo/core/types'; export type UnknownMap = Record; export type Translation = { translation: string; context?: string }; @@ -96,4 +96,6 @@ export interface SearchItem { group: Exclude; route?: string; action?: () => void | Promise; + schemaName?: string; + initData?: RawValueMap; }