This commit is contained in:
a.bouhuolia
2021-02-22 17:00:57 +02:00
21 changed files with 432 additions and 267 deletions

View File

@@ -76,4 +76,17 @@ export function toggleARAgingSummaryFilterDrawer(toggle) {
toggle,
}
};
}
/**
* Toggles display of the AP aging summary filter drawer.
* @param {boolean} toggle -
*/
export function toggleAPAgingSummaryFilterDrawer(toggle) {
return {
type: `${t.AP_AGING_SUMMARY}/${t.DISPLAY_FILTER_DRAWER_TOGGLE}`,
payload: {
toggle,
}
};
}

View File

@@ -137,6 +137,41 @@ export const ARAgingSummaryTableRowsMapper = (sheet, total) => {
];
};
export const APAgingSummaryTableRowsMapper = (sheet, total) => {
const rows = [];
const mapAging = (agingPeriods) => {
return agingPeriods.reduce((acc, aging, index) => {
acc[`aging-${index}`] = aging.total.formatted_amount;
return acc;
}, {});
};
sheet.vendors.forEach((vendor) => {
const agingRow = mapAging(vendor.aging);
rows.push({
rowType: 'vendor',
name: vendor.vendor_name,
...agingRow,
current: vendor.current.formatted_amount,
total: vendor.total.formatted_amount,
});
});
if (rows.length <= 0) {
return [];
}
return [
...rows,
{
name: '',
rowType: 'total',
current: sheet.total.current.formatted_amount,
...mapAging(sheet.total.aging),
total: sheet.total.total.formatted_amount,
},
];
};
export const mapTrialBalanceSheetToRows = (sheet) => {
const results = [];

View File

@@ -34,6 +34,11 @@ export const ARAgingSummaryFilterDrawerSelector = (state) => {
return filterDrawerByTypeSelector('ARAgingSummary')(state);
};
export const APAgingSummaryFilterDrawerSelector = (state) => {
return filterDrawerByTypeSelector('APAgingSummary')(state);
}
/**
* Retrieve balance sheet filter drawer.
*/
@@ -94,6 +99,17 @@ export const getARAgingSummaryFilterDrawer = createSelector(
},
);
/**
* Retrieve whether display AR aging summary drawer filter.
*/
export const getAPAgingSummaryFilterDrawer = createSelector(
APAgingSummaryFilterDrawerSelector,
(isOpen) => {
return isOpen;
},
);
/**
* Retrieve financial statement query by the given sheet index.
*/