diff --git a/client/src/config/financialReportsMenu.js b/client/src/config/financialReportsMenu.js index b2be8e6d3..59a2c3e43 100644 --- a/client/src/config/financialReportsMenu.js +++ b/client/src/config/financialReportsMenu.js @@ -7,39 +7,64 @@ export default [ reports: [ { title: 'Balance Sheet Report', - desc: 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', + desc: + 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', link: '/financial-reports/balance-sheet', }, { title: 'Trial Balance Sheet', - desc: 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', + desc: + 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', link: '/financial-reports/trial-balance-sheet', }, { title: 'Journal Report', - desc: 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', + desc: + 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', link: '/financial-reports/journal-sheet', }, { title: 'Profit/Loss Report', - desc: 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', + desc: + 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', link: '/financial-reports/profit-loss-sheet', }, { title: 'General Ledger Report', - desc: 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', + desc: + 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', link: '/financial-reports/general-ledger', }, { title: 'Receivable Aging Summary', - desc: 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', + desc: + 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', link: '/financial-reports/receivable-aging-summary', }, { title: 'Payable Aging Summary', - desc: 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', + desc: + 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', link: '/financial-reports/payable-aging-summary', }, - ] + { + title: 'Purchases By Items', + desc: + 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', + link: '/financial-reports/purchases-by-items', + }, + { + title: 'Sales by Items', + desc: + 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', + link: '/financial-reports/sales-by-items', + }, + { + title: 'Inventory valuation', + desc: + 'Shows the average age of unresolved issues for a project or filter. This helps you see whether your backlog is being kept up to date.', + link: '/financial-reports/inventory-valuation', + }, + ], }, ]; diff --git a/client/src/containers/FinancialStatements/APAgingSummary/APAgingSummaryActionsBar.js b/client/src/containers/FinancialStatements/APAgingSummary/APAgingSummaryActionsBar.js index fa000b9bd..0e475cfa8 100644 --- a/client/src/containers/FinancialStatements/APAgingSummary/APAgingSummaryActionsBar.js +++ b/client/src/containers/FinancialStatements/APAgingSummary/APAgingSummaryActionsBar.js @@ -27,7 +27,7 @@ import { saveInvoke, compose } from 'utils'; */ function APAgingSummaryActionsBar({ // #withPayableAgingSummary - payableAgingFilter, + isFilterDrawerOpen, // #withARAgingSummaryActions toggleAPAgingSummaryFilterDrawer: toggleFilterDrawerDisplay, @@ -66,14 +66,14 @@ function APAgingSummaryActionsBar({ className={classNames(Classes.MINIMAL, 'button--table-views')} icon={} text={ - payableAgingFilter ? ( + isFilterDrawerOpen ? ( ) : ( ) } onClick={handleFilterToggleClick} - active={payableAgingFilter} + active={isFilterDrawerOpen} /> { }, ]; }; + +export const inventoryValuationReducer = (sheet) => { + const results = []; + + if (sheet.items) { + sheet.items.forEach((item) => { + results.push(item); + }); + } + if (sheet.total) { + results.push({ + rowType: 'total', + ...sheet.total, + }); + } + return results; +}; + +export const purchasesByItemsReducer = (sheet) => { + const results = []; + + if (sheet.items) { + sheet.items.forEach((item) => { + results.push(item); + }); + } + if (sheet.total) { + results.push({ + rowType: 'total', + ...sheet.total, + }); + } + return results; +}; +export const salesByItemsReducer = (sheet) => { + const results = []; + + if (sheet.items) { + sheet.items.forEach((item) => { + results.push(item); + }); + } + if (sheet.total) { + results.push({ + rowType: 'total', + ...sheet.total, + }); + } + return results; +}; \ No newline at end of file diff --git a/client/src/hooks/query/financialReports.js b/client/src/hooks/query/financialReports.js index 2cfce8db2..1ec454c3b 100644 --- a/client/src/hooks/query/financialReports.js +++ b/client/src/hooks/query/financialReports.js @@ -7,6 +7,9 @@ import { journalTableRowsReducer, ARAgingSummaryTableRowsMapper, APAgingSummaryTableRowsMapper, + inventoryValuationReducer, + purchasesByItemsReducer, + salesByItemsReducer, } from 'containers/FinancialStatements/reducers'; import t from './types'; @@ -94,13 +97,12 @@ export function useProfitLossSheet(query, props) { * Retrieve general ledger (GL) sheet. */ export function useGeneralLedgerSheet(query, props) { - return useRequestQuery( [t.FINANCIAL_REPORT, t.GENERAL_LEDGER, query], { - method: 'get', - url: '/financial_statements/general_ledger', - params: query, + method: 'get', + url: '/financial_statements/general_ledger', + params: query, }, { select: (res) => ({ @@ -208,3 +210,80 @@ export function useAPAgingSummaryReport(query, props) { }, ); } + +/** + * Retrieve inventory valuation. + */ +export function useInventoryValuation(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.INVENTORY_VALUATION, query], + { + method: 'get', + url: '/financial_statements/inventory-valuation', + params: query, + }, + { + select: (res) => ({ + tableRows: inventoryValuationReducer(res.data.data), + ...res.data, + }), + defaultData: { + tableRows: [], + data: [], + query: {}, + }, + ...props, + }, + ); +} +/** + * Retrieve purchases by items. + */ +export function usePurchasesByItems(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.PURCHASES_BY_ITEMS, query], + { + method: 'get', + url: '/financial_statements/purchases-by-items', + params: query, + }, + { + select: (res) => ({ + tableRows: purchasesByItemsReducer(res.data.data), + ...res.data, + }), + defaultData: { + tableRows: [], + data: [], + query: {}, + }, + ...props, + }, + ); +} + +/** + * Retrieve sales by items. + */ +export function useSalesByItems(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.SALES_BY_ITEMS, query], + { + method: 'get', + url: '/financial_statements/sales-by-items', + params: query, + }, + { + select: (res) => ({ + tableRows: salesByItemsReducer(res.data.data), + ...res.data, + }), + defaultData: { + tableRows: [], + data: [], + query: {}, + }, + ...props, + }, + ); +} diff --git a/client/src/lang/en/index.js b/client/src/lang/en/index.js index f6ba635b3..e1e04f1a5 100644 --- a/client/src/lang/en/index.js +++ b/client/src/lang/en/index.js @@ -1037,4 +1037,16 @@ export default { currency_sign: 'Currency sign', cannot_change_item_inventory_account: 'Cannot change item inventory account while the item has transactions.', + + purchases_by_items: 'Purchases by items', + quantity_purchased: 'Quantity purchased', + purchase_amount: 'Purchase amount', + average_price: 'Average price', + sales_by_items: 'Sales by items', + sold_quantity: 'Sold quantity', + sold_amount: 'Sold amount', + average_price: 'Average price', + asset_value: 'Asset value', + average: 'Average', + inventory_valuation: 'Inventory valuation', }; diff --git a/client/src/routes/dashboard.js b/client/src/routes/dashboard.js index 1689fc8be..902ba5dd4 100644 --- a/client/src/routes/dashboard.js +++ b/client/src/routes/dashboard.js @@ -182,6 +182,43 @@ export default [ sidebarShrink: true, backLink: true, }, + { + path: `/financial-reports/purchases-by-items`, + component: lazy(() => + import( + 'containers/FinancialStatements/PurchasesByItems/PurchasesByItems' + ), + ), + breadcrumb: 'Purchases by Items', + // hotkey: '', + pageTitle: formatMessage({ id: 'purchases_by_items' }), + backLink: true, + sidebarShrink: true, + }, + { + path: `/financial-reports/sales-by-items`, + component: lazy(() => + import('containers/FinancialStatements/SalesByItems/SalesByItems'), + ), + breadcrumb: 'Sales by Items', + // hotkey: '', + pageTitle: formatMessage({ id: 'sales_by_items' }), + backLink: true, + sidebarShrink: true, + }, + { + path: `/financial-reports/inventory-valuation`, + component: lazy(() => + import( + 'containers/FinancialStatements/InventoryValuation/InventoryValuation' + ), + ), + breadcrumb: 'Inventory Valuation ', + // hotkey: '', + pageTitle: formatMessage({ id: 'inventory_valuation' }), + backLink: true, + sidebarShrink: true, + }, { path: '/financial-reports', component: lazy(() => diff --git a/client/src/store/financialStatement/financialStatements.actions.js b/client/src/store/financialStatement/financialStatements.actions.js index f961a7eda..eaca5f0f4 100644 --- a/client/src/store/financialStatement/financialStatements.actions.js +++ b/client/src/store/financialStatement/financialStatements.actions.js @@ -2,20 +2,20 @@ import t from 'store/types'; /** * Toggles display of the balance sheet filter drawer. - * @param {boolean} toggle + * @param {boolean} toggle */ export function toggleBalanceSheetFilterDrawer(toggle) { return { type: `${t.BALANCE_SHEET}/${t.DISPLAY_FILTER_DRAWER_TOGGLE}`, payload: { - toggle + toggle, }, }; } /** * Toggles display of the trial balance sheet filter drawer. - * @param {boolean} toggle + * @param {boolean} toggle */ export function toggleTrialBalanceSheetFilterDrawer(toggle) { return { @@ -28,39 +28,39 @@ export function toggleTrialBalanceSheetFilterDrawer(toggle) { /** * Toggles display of the journal sheet filter drawer. - * @param {boolean} toggle + * @param {boolean} toggle */ export function toggleJournalSheeetFilterDrawer(toggle) { return { type: `${t.JOURNAL}/${t.DISPLAY_FILTER_DRAWER_TOGGLE}`, payload: { - toggle + toggle, }, }; } /** * Toggles display of the profit/loss filter drawer. - * @param {boolean} toggle + * @param {boolean} toggle */ export function toggleProfitLossFilterDrawer(toggle) { return { type: `${t.PROFIT_LOSS}/${t.DISPLAY_FILTER_DRAWER_TOGGLE}`, payload: { - toggle + toggle, }, }; } /** * Toggles display of the general ledger filter drawer. - * @param {boolean} toggle + * @param {boolean} toggle */ export function toggleGeneralLedgerFilterDrawer(toggle) { return { type: `${t.GENERAL_LEDGER}/${t.DISPLAY_FILTER_DRAWER_TOGGLE}`, payload: { - toggle + toggle, }, }; } @@ -74,7 +74,7 @@ export function toggleARAgingSummaryFilterDrawer(toggle) { type: `${t.AR_AGING_SUMMARY}/${t.DISPLAY_FILTER_DRAWER_TOGGLE}`, payload: { toggle, - } + }, }; } @@ -87,6 +87,44 @@ export function toggleAPAgingSummaryFilterDrawer(toggle) { type: `${t.AP_AGING_SUMMARY}/${t.DISPLAY_FILTER_DRAWER_TOGGLE}`, payload: { toggle, - } + }, }; -} \ No newline at end of file +} + +/** + * Toggles display of the purchases by items filter drawer. + * @param {boolean} toggle + */ +export function togglePurchasesByItemsFilterDrawer(toggle) { + return { + type: `${t.PURCHASES_BY_ITEMS}/${t.DISPLAY_FILTER_DRAWER_TOGGLE}`, + payload: { + toggle, + }, + }; +} + +/** + * Toggles display of the sells by items filter drawer. + * @param {boolean} toggle + */ +export function toggleSalesByItemsFilterDrawer(toggle) { + return { + type: `${t.SALES_BY_ITEMS}/${t.DISPLAY_FILTER_DRAWER_TOGGLE}`, + payload: { + toggle, + }, + }; +} +/** + * Toggles display of the inventory valuation filter drawer. + * @param {boolean} toggle + */ +export function toggleInventoryValuationFilterDrawer(toggle) { + return { + type: `${t.INVENTORY_VALUATION}/${t.DISPLAY_FILTER_DRAWER_TOGGLE}`, + payload: { + toggle, + }, + }; +} diff --git a/client/src/store/financialStatement/financialStatements.reducer.js b/client/src/store/financialStatement/financialStatements.reducer.js index 21268e89f..d21666577 100644 --- a/client/src/store/financialStatement/financialStatements.reducer.js +++ b/client/src/store/financialStatement/financialStatements.reducer.js @@ -24,6 +24,15 @@ const initialState = { APAgingSummary: { displayFilterDrawer: false, }, + purchasesByItems: { + displayFilterDrawer: false, + }, + salesByItems: { + displayFilterDrawer: false, + }, + inventoryValuation: { + displayFilterDrawer: false, + }, }; /** @@ -48,4 +57,10 @@ export default createReducer(initialState, { ...financialStatementFilterToggle(t.PROFIT_LOSS, 'profitLoss'), ...financialStatementFilterToggle(t.AR_AGING_SUMMARY, 'ARAgingSummary'), ...financialStatementFilterToggle(t.AP_AGING_SUMMARY, 'APAgingSummary'), + ...financialStatementFilterToggle(t.PURCHASES_BY_ITEMS, 'purchasesByItems'), + ...financialStatementFilterToggle(t.SALES_BY_ITEMS, 'salesByItems'), + ...financialStatementFilterToggle( + t.INVENTORY_VALUATION, + 'inventoryValuation', + ), }); diff --git a/client/src/store/financialStatement/financialStatements.selectors.js b/client/src/store/financialStatement/financialStatements.selectors.js index 5954c8209..92a9f7410 100644 --- a/client/src/store/financialStatement/financialStatements.selectors.js +++ b/client/src/store/financialStatement/financialStatements.selectors.js @@ -36,8 +36,18 @@ export const ARAgingSummaryFilterDrawerSelector = (state) => { export const APAgingSummaryFilterDrawerSelector = (state) => { return filterDrawerByTypeSelector('APAgingSummary')(state); -} +}; +export const purchasesByItemsFilterDrawerSelector = (state) => { + return filterDrawerByTypeSelector('purchasesByItems')(state); +}; + +export const salesByItemsFilterDrawerSelector = (state) => { + return filterDrawerByTypeSelector('salesByItems')(state); +}; +export const inventoryValuationFilterDrawerSelector = (state) => { + return filterDrawerByTypeSelector('inventoryValuation')(state); +}; /** * Retrieve balance sheet filter drawer. @@ -99,7 +109,6 @@ export const getARAgingSummaryFilterDrawer = createSelector( }, ); - /** * Retrieve whether display AR aging summary drawer filter. */ @@ -117,3 +126,33 @@ export const getFinancialSheetQueryFactory = (sheetType) => createSelector(sheetByTypeSelector(sheetType), (sheet) => { return sheet && sheet.query ? sheet.query : {}; }); + +/** + * Retrieve whether purchases by items display filter drawer. + */ +export const getPurchasesByItemsFilterDrawer = createSelector( + purchasesByItemsFilterDrawerSelector, + (isOpen) => { + return isOpen; + }, +); + +/** + * Retrieve whether sales by items display filter drawer. + */ +export const getSalesByItemsFilterDrawer = createSelector( + salesByItemsFilterDrawerSelector, + (isOpen) => { + return isOpen; + }, +); + +/** + * Retrieve whether sells by items display filter drawer. + */ +export const getInventoryValuationFilterDrawer = createSelector( + inventoryValuationFilterDrawerSelector, + (isOpen) => { + return isOpen; + }, +); diff --git a/client/src/store/financialStatement/financialStatements.types.js b/client/src/store/financialStatement/financialStatements.types.js index cb3d0094b..f5fabee35 100644 --- a/client/src/store/financialStatement/financialStatements.types.js +++ b/client/src/store/financialStatement/financialStatements.types.js @@ -6,5 +6,8 @@ export default { PROFIT_LOSS: 'PROFIT_LOSS', AR_AGING_SUMMARY: 'AR_AGING_SUMMARY', AP_AGING_SUMMARY: 'AP_AGING_SUMMARY', - DISPLAY_FILTER_DRAWER_TOGGLE: 'DISPLAY_FILTER_DRAWER_TOGGLE' + DISPLAY_FILTER_DRAWER_TOGGLE: 'DISPLAY_FILTER_DRAWER_TOGGLE', + PURCHASES_BY_ITEMS: 'PURCHASES_BY_ITEMS', + SALES_BY_ITEMS: 'SALES_BY_ITEMS', + INVENTORY_VALUATION: 'INVENTORY_VALUATION', };