mirror of
https://github.com/frappe/books.git
synced 2026-08-24 02:24:17 -05:00
Merge pull request #1383 from Gadha2311/party-ledger
feat : Party ledger
This commit is contained in:
+15
-3
@@ -125,10 +125,22 @@ export default defineComponent({
|
||||
docsPathMap[this.reportClassName] ?? docsPathMap.Reports!;
|
||||
await this.setReportData();
|
||||
|
||||
const filters = JSON.parse(this.defaultFilters) as Record<string, DocValue>;
|
||||
const filterKeys = Object.keys(filters);
|
||||
const filters = this.$route.query as Record<string, DocValue>;
|
||||
const validFilters: Record<string, DocValue> = {};
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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`,
|
||||
|
||||
Reference in New Issue
Block a user