diff --git a/src/components/payroll/PayrollHeadPanel.js b/src/components/payroll/PayrollHeadPanel.js index 061bafe..2a5cda9 100644 --- a/src/components/payroll/PayrollHeadPanel.js +++ b/src/components/payroll/PayrollHeadPanel.js @@ -71,7 +71,7 @@ class PayrollHeadPanel extends FormPanel { render() { const { - edited, classes, intl, readOnly, isPayrollFromFailedInvoices, + edited, classes, intl, readOnly, isPayrollFromFailedInvoices, benefitPlanId, } = this.props; const payroll = { ...edited }; const { appliedCustomFilters, appliedFiltersRowStructure } = this.state; @@ -114,6 +114,7 @@ class PayrollHeadPanel extends FormPanel { onChange={(paymentPlan) => this.updateAttribute('paymentPlan', paymentPlan)} value={payroll?.paymentPlan} readOnly={readOnly} + benefitPlanId={benefitPlanId} /> diff --git a/src/index.js b/src/index.js index 36a1a50..c01fed7 100644 --- a/src/index.js +++ b/src/index.js @@ -7,7 +7,7 @@ import { PinDrop } from '@material-ui/icons'; import MonetizationOnIcon from '@material-ui/icons/MonetizationOn'; import { FormattedMessage } from '@openimis/fe-core'; -import { RIGHT_PAYMENT_POINT_SEARCH, RIGHT_PAYROLL_SEARCH } from './constants'; +import { RIGHT_PAYMENT_POINT_SEARCH, RIGHT_PAYROLL_CREATE, RIGHT_PAYROLL_SEARCH } from './constants'; import reducer from './reducer'; import messages_en from './translations/en.json'; import PaymentPointPage from './pages/payment-point/PaymentPointPage'; @@ -61,6 +61,7 @@ const DEFAULT_CONFIG = { { key: 'payroll.PaymentPointPicker', ref: PaymentPointPicker }, { key: 'payroll.PaymentPointPicker.projection', ref: ['id', 'name', 'location'] }, { key: 'payroll.benefitConsumptionPayrollSearcher', ref: BenefitConsumptionPayrollSearcher }, + { key: 'payroll.payrollCreateRight', ref: RIGHT_PAYROLL_CREATE }, ], 'core.Router': [ { path: ROUTE_PAYMENT_POINTS, component: PaymentPointsPage }, @@ -68,7 +69,10 @@ const DEFAULT_CONFIG = { { path: ROUTE_PAYROLLS, component: PayrollsPage }, { path: ROUTE_PAYROLLS_APPROVED, component: ApprovedPayrollsPage }, { path: ROUTE_PAYROLLS_RECONCILED, component: ReconciledPayrollsPage }, - { path: `${ROUTE_PAYROLL}/:payroll_uuid?/:createPayrollFromFailedInvoices?`, component: PayrollPage }, + { + path: `${ROUTE_PAYROLL}/:payroll_uuid?/:createPayrollFromFailedInvoices?/:benefitPlanId?`, + component: PayrollPage, + }, ], 'invoice.MainMenu': [ { diff --git a/src/pages/payroll/PayrollPage.js b/src/pages/payroll/PayrollPage.js index 4babd2b..08e6beb 100644 --- a/src/pages/payroll/PayrollPage.js +++ b/src/pages/payroll/PayrollPage.js @@ -45,6 +45,7 @@ function PayrollPage({ clearConfirm, createPayrollFromFailedInvoices, journalize, + benefitPlanId, }) { const modulesManager = useModulesManager(); const classes = useStyles(); @@ -138,6 +139,9 @@ function PayrollPage({ editedPayroll, formatMessageWithValues('payroll.mutation.create', mutationLabel(payroll)), ); + if (benefitPlanId) { + back(); + } }; const actions = []; @@ -169,6 +173,7 @@ function PayrollPage({ payroll={payroll} readOnly={readOnly} isPayrollFromFailedInvoices={isPayrollFromFailedInvoices} + benefitPlanId={benefitPlanId} /> ) @@ -185,8 +190,9 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({ }, dispatch); const mapStateToProps = (state, props) => ({ - statePayrollUuid: props?.match?.params.payroll_uuid, + statePayrollUuid: props?.match?.params?.payroll_uuid === 'null' ? null : props?.match?.params.payroll_uuid, createPayrollFromFailedInvoices: props?.match?.params?.createPayrollFromFailedInvoices, + benefitPlanId: props?.match?.params?.benefitPlanId, rights: state.core?.user?.i_user?.rights ?? [], confirmed: state.core.confirmed, submittingMutation: state.payroll.submittingMutation,