From b9be83dc2b6855f4c7c376cd0f8c6742a43a6013 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Sun, 27 Aug 2023 00:44:37 +0200 Subject: [PATCH] fix(webapp): add validation to aging summary customize form --- .../APAgingSummary/common.tsx | 12 +++-- .../APAgingSummary/components.tsx | 54 +------------------ .../ARAgingSummary/common.tsx | 8 ++- 3 files changed, 16 insertions(+), 58 deletions(-) diff --git a/packages/webapp/src/containers/FinancialStatements/APAgingSummary/common.tsx b/packages/webapp/src/containers/FinancialStatements/APAgingSummary/common.tsx index 87ed03627..a5619532b 100644 --- a/packages/webapp/src/containers/FinancialStatements/APAgingSummary/common.tsx +++ b/packages/webapp/src/containers/FinancialStatements/APAgingSummary/common.tsx @@ -36,19 +36,23 @@ export const getAPAgingSummaryQuerySchema = () => { .required() .integer() .positive() - .label('agingBeforeDays'), + .label('Aging days before') + .min(1) + .max(500), agingPeriods: Yup.number() .required() .integer() .positive() - .label('agingPeriods'), + .max(12) + .min(1) + .label('Aging periods'), }); }; /** * Parses the AP aging summary query state. - * @param locationQuery - * @returns + * @param locationQuery + * @returns */ const parseAPAgingSummaryQuery = (locationQuery) => { const defaultQuery = getDefaultAPAgingSummaryQuery(); diff --git a/packages/webapp/src/containers/FinancialStatements/APAgingSummary/components.tsx b/packages/webapp/src/containers/FinancialStatements/APAgingSummary/components.tsx index 17429cd1d..f6af9931a 100644 --- a/packages/webapp/src/containers/FinancialStatements/APAgingSummary/components.tsx +++ b/packages/webapp/src/containers/FinancialStatements/APAgingSummary/components.tsx @@ -1,11 +1,9 @@ // @ts-nocheck import React, { useMemo } from 'react'; -import intl from 'react-intl-universal'; -import * as R from 'ramda'; -import { If, FormattedMessage as T } from '@/components'; -import { useAPAgingSummaryContext } from './APAgingSummaryProvider'; +import { If } from '@/components'; import FinancialLoadingBar from '../FinancialLoadingBar'; +import { useAPAgingSummaryContext } from './APAgingSummaryProvider'; import { agingSummaryDynamicColumns } from '../AgingSummary/dynamicColumns'; /** @@ -19,54 +17,6 @@ export const useAPAgingSummaryColumns = () => { return agingSummaryDynamicColumns(table.columns, table.rows); }; -/** - * Retrieve AP aging summary columns. - */ -// export const useAPAgingSummaryColumns = () => { -// const { -// APAgingSummary: { tableRows, columns }, -// } = useAPAgingSummaryContext(); - -// const agingColumns = React.useMemo(() => { -// return columns.map( -// (agingColumn) => -// `${agingColumn.before_days} - ${ -// agingColumn.to_days || intl.get('and_over') -// }`, -// ); -// }, [columns]); - -// return useMemo( -// () => [ -// { -// Header: , -// accessor: 'name', -// className: 'vendor_name', -// width: 240, -// sticky: 'left', -// textOverview: true, -// }, -// { -// Header: , -// accessor: 'current', -// className: 'current', -// width: getColumnWidth(tableRows, `current`, { minWidth: 120 }), -// }, -// ...agingColumns.map((agingColumn, index) => ({ -// Header: agingColumn, -// accessor: `aging-${index}`, -// width: getColumnWidth(tableRows, `aging-${index}`, { minWidth: 120 }), -// })), -// { -// Header: , -// accessor: 'total', -// width: getColumnWidth(tableRows, 'total', { minWidth: 120 }), -// }, -// ], -// [tableRows, agingColumns], -// ); -// }; - /** * A/P aging summary sheet loading bar. */ diff --git a/packages/webapp/src/containers/FinancialStatements/ARAgingSummary/common.tsx b/packages/webapp/src/containers/FinancialStatements/ARAgingSummary/common.tsx index e70c6efb3..6152b25c2 100644 --- a/packages/webapp/src/containers/FinancialStatements/ARAgingSummary/common.tsx +++ b/packages/webapp/src/containers/FinancialStatements/ARAgingSummary/common.tsx @@ -35,12 +35,16 @@ export const getARAgingSummaryQuerySchema = () => { .required() .integer() .positive() - .label('agingDaysBefore'), + .label('Aging days before') + .min(1) + .max(500), agingPeriods: Yup.number() .required() .integer() .positive() - .label('agingPeriods'), + .max(12) + .min(1) + .label('Aging periods'), }); };