Skip to content

Commit

Permalink
CM-766: adjust payroll to be created from benefit plan (#40)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan <[email protected]>
  • Loading branch information
jdolkowski and Jan authored Mar 11, 2024
1 parent 6da7aaf commit b0c251f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/components/payroll/PayrollHeadPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -114,6 +114,7 @@ class PayrollHeadPanel extends FormPanel {
onChange={(paymentPlan) => this.updateAttribute('paymentPlan', paymentPlan)}
value={payroll?.paymentPlan}
readOnly={readOnly}
benefitPlanId={benefitPlanId}
/>
</Grid>
<Grid item xs={3} className={classes.item}>
Expand Down
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -61,14 +61,18 @@ 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 },
{ path: `${ROUTE_PAYMENT_POINT}/:payment_point_uuid?`, component: PaymentPointPage },
{ 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': [
{
Expand Down
8 changes: 7 additions & 1 deletion src/pages/payroll/PayrollPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function PayrollPage({
clearConfirm,
createPayrollFromFailedInvoices,
journalize,
benefitPlanId,
}) {
const modulesManager = useModulesManager();
const classes = useStyles();
Expand Down Expand Up @@ -138,6 +139,9 @@ function PayrollPage({
editedPayroll,
formatMessageWithValues('payroll.mutation.create', mutationLabel(payroll)),
);
if (benefitPlanId) {
back();
}
};

const actions = [];
Expand Down Expand Up @@ -169,6 +173,7 @@ function PayrollPage({
payroll={payroll}
readOnly={readOnly}
isPayrollFromFailedInvoices={isPayrollFromFailedInvoices}
benefitPlanId={benefitPlanId}
/>
</div>
)
Expand All @@ -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,
Expand Down

0 comments on commit b0c251f

Please sign in to comment.