diff --git a/src/pages/Report.vue b/src/pages/Report.vue index 02d94de1..5a458344 100644 --- a/src/pages/Report.vue +++ b/src/pages/Report.vue @@ -125,10 +125,22 @@ export default defineComponent({ docsPathMap[this.reportClassName] ?? docsPathMap.Reports!; await this.setReportData(); - const filters = JSON.parse(this.defaultFilters) as Record; - const filterKeys = Object.keys(filters); + const filters = this.$route.query as Record; + const validFilters: Record = {}; + + if (filters.defaultFilters && typeof filters.defaultFilters === 'string') { + const parsed = JSON.parse(filters.defaultFilters); + Object.assign(validFilters, parsed); + } + + for (const [key, value] of Object.entries(filters)) { + if (key !== 'defaultFilters' && typeof value === 'string') { + validFilters[key] = value; + } + } + const filterKeys = Object.keys(validFilters); for (const key of filterKeys) { - await this.report?.set(key, filters[key]); + await this.report?.set(key, validFilters[key]); } if (filterKeys.length) { diff --git a/src/utils/ui.ts b/src/utils/ui.ts index daabff6c..3c735bd9 100644 --- a/src/utils/ui.ts +++ b/src/utils/ui.ts @@ -197,6 +197,11 @@ export function getActionsForDoc(doc?: Doc): Action[] { getCancelAction(doc), ]; + if (doc?.schemaName === 'Party') { + const viewActions = getViewActions(doc); + actions.push(...viewActions); + } + return actions .filter((d) => d.condition?.(doc) ?? true) .map((d) => { @@ -235,6 +240,27 @@ export function getGroupedActionsForDoc(doc?: Doc): ActionGroup[] { return [grouped, actionsMap['']].flat().filter(Boolean); } +function getViewActions(doc: Doc): Action[] { + const actions: Action[] = [ + { + label: t`General Ledger`, + group: t`View`, + condition: (doc: Doc) => doc.schemaName === 'Party', + action: async () => { + await router.push({ + path: '/report/GeneralLedger', + query: { + defaultFilters: JSON.stringify({ + party: doc.name, + }), + }, + }); + }, + }, + ]; + return actions; +} + function getCancelAction(doc: Doc): Action { return { label: t`Cancel`,