Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CM-487: add task tab to payroll #24

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const PAYROLL_PROJECTION = (modulesManager) => [
'id',
'name',
'paymentMethod',
'paymentPlan { code }',
'paymentPlan { code, id, name, benefitPlan }',
`paymentPoint { ${PAYMENT_POINT_PROJECTION(modulesManager).join(' ')} }`,
'paymentCycle { runYear, runMonth }',
'benefitConsumption{id, code,individual {firstName, lastName}, benefitAttachment{bill{id, code, terms}}}',
Expand Down
4 changes: 2 additions & 2 deletions src/components/payroll/PayrollFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
MODULE_NAME,
} from '../../constants';
import PayrollStatusPicker from './PayrollStatusPicker';
import PaymentMethodPicker from './PaymentMethodPicker';
import PaymentMethodPicker from '../../pickers/PaymentMethodPicker';

const useStyles = makeStyles((theme) => ({
form: {
Expand Down Expand Up @@ -130,7 +130,7 @@ function PayrollFilter({
{
id: 'status',
value,
filter: `status: ${value}`,
filter: value ? `status: ${value}` : EMPTY_STRING,
},
])}
/>
Expand Down
11 changes: 6 additions & 5 deletions src/components/payroll/PayrollHeadPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
import React from 'react';
import { injectIntl } from 'react-intl';

import { Checkbox, FormControlLabel, Grid } from '@material-ui/core';
import { Grid } from '@material-ui/core';
import { withStyles, withTheme } from '@material-ui/core/styles';

import {
ControlledField,
formatMessage,
FormPanel,
PublishedComponent,
TextInput,
withModulesManager,
decodeId,

Check failure on line 14 in src/components/payroll/PayrollHeadPanel.js

View workflow job for this annotation

GitHub Actions / lint

'decodeId' is defined but never used
} from '@openimis/fe-core';
import AdvancedFiltersDialog from './AdvancedFiltersDialog';
import { CLEARED_STATE_FILTER } from '../../constants';
import PayrollStatusPicker from './PayrollStatusPicker';
import PaymentMethodPicker from './PaymentMethodPicker';
import PaymentMethodPicker from '../../pickers/PaymentMethodPicker';

const styles = (theme) => ({
tableTitle: theme.table.title,
Expand Down Expand Up @@ -78,7 +78,9 @@
return (
<>
<AdvancedFiltersDialog
object={payroll.benefitPlan}
object={payroll?.paymentPlan?.benefitPlan
? JSON.parse(JSON.parse(payroll.paymentPlan.benefitPlan))
: null}
objectToSave={payroll}
moduleName="social_protection"
objectType="BenefitPlan"
Expand All @@ -104,7 +106,6 @@
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="contributionPlan.PaymentPlanPicker"
withNull
required
filterLabels={false}
onChange={(paymentPlan) => this.updateAttribute('paymentPlan', paymentPlan)}
Expand Down
7 changes: 6 additions & 1 deletion src/components/payroll/PayrollTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const useStyles = makeStyles((theme) => ({
},
}));

function PayrollTab({ rights, setConfirmedAction, payrollUuid }) {
function PayrollTab({
rights, setConfirmedAction, payrollUuid, isInTask,
}) {
const classes = useStyles();

const [activeTab, setActiveTab] = useState(BENEFIT_CONSUMPTION_LIST_TAB_VALUE);
Expand All @@ -50,6 +52,8 @@ function PayrollTab({ rights, setConfirmedAction, payrollUuid }) {
onChange={handleChange}
isSelected={isSelected}
tabStyle={tabStyle}
payrollUuid={payrollUuid}
isInTask={isInTask}
/>
</Grid>
<Contributions
Expand All @@ -58,6 +62,7 @@ function PayrollTab({ rights, setConfirmedAction, payrollUuid }) {
value={activeTab}
setConfirmedAction={setConfirmedAction}
payrollUuid={payrollUuid}
isInTask={isInTask}
/>
</Paper>
);
Expand Down
59 changes: 59 additions & 0 deletions src/components/payroll/PayrollTaskTabPanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Tab } from '@material-ui/core';
import { PublishedComponent, useTranslations, useModulesManager } from '@openimis/fe-core';
import {
MODULE_NAME, PAYROLL_TASK_TAB_VALUE,
} from '../../constants';

function PayrollTaskTabLabel({
onChange, tabStyle, isSelected, modulesManager, payrollUuid, isInTask,
}) {
const { formatMessage } = useTranslations(MODULE_NAME, modulesManager);
if (!payrollUuid || isInTask) {
return null;
}
return (
<Tab
onChange={onChange}
className={tabStyle(PAYROLL_TASK_TAB_VALUE)}
selected={isSelected(PAYROLL_TASK_TAB_VALUE)}
value={PAYROLL_TASK_TAB_VALUE}
label={formatMessage('PayrollTaskTab.label')}
/>
);
}

function PayrollTaskTabPanel({ value, payrollUuid, isInTask }) {
const modulesManager = useModulesManager();
const dispatch = useDispatch();
const fetchTask = modulesManager.getRef('tasksManagement.fetchTask');
const task = useSelector((state) => state.tasksManagement?.task);
useEffect(() => {
dispatch(fetchTask(modulesManager, ['entityType: "Payroll"', `entityId: "${payrollUuid}"`]));
}, [payrollUuid]);

if (isInTask) return null;

return (
<PublishedComponent
pubRef="policyHolder.TabPanel"
module="payroll"
index={PAYROLL_TASK_TAB_VALUE}
value={value}
>
{
payrollUuid && (
<PublishedComponent
pubRef="tasksManagement.taskDetailsPage"
module="payroll"
task={task}
hideBody
/>
)
}
</PublishedComponent>
);
}

export { PayrollTaskTabLabel, PayrollTaskTabPanel };
7 changes: 5 additions & 2 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const MAX_LENGTH = {
export const MODULE_NAME = 'payroll';

export const BENEFIT_CONSUMPTION_LIST_TAB_VALUE = 'benefitConsumptionsTab';
export const PAYROLL_TASK_TAB_VALUE = 'payrollTaskTab';

export const PAYROLL_TABS_LABEL_CONTRIBUTION_KEY = 'payroll.TabPanel.label';
export const PAYROLL_TABS_PANEL_CONTRIBUTION_KEY = 'payroll.TabPanel.panel';
Expand Down Expand Up @@ -62,14 +63,14 @@ export const PAYROLL_STATUS = {
PENDING_APPROVAL: 'PENDING_APPROVAL',
APPROVE_FOR_PAYMENT: 'APPROVE_FOR_PAYMENT',
REJECTED: 'REJECTED',
RECONCILIATED: 'RECONCILIATED',
RECONCILED: 'RECONCILED',
};

export const PAYROLL_STATUS_LIST = [
PAYROLL_STATUS.PENDING_APPROVAL,
PAYROLL_STATUS.APPROVE_FOR_PAYMENT,
PAYROLL_STATUS.REJECTED,
PAYROLL_STATUS.RECONCILIATED,
PAYROLL_STATUS.RECONCILED,
];

export const BENEFIT_CONSUMPTION_STATUS = {
Expand All @@ -86,3 +87,5 @@ export const BENEFIT_CONSUMPTION_STATUS_LIST = [
BENEFIT_CONSUMPTION_STATUS.APPROVE_FOR_PAYMENT, BENEFIT_CONSUMPTION_STATUS.REJECTED,
BENEFIT_CONSUMPTION_STATUS.DUPLICATE, BENEFIT_CONSUMPTION_STATUS.RECONCILED,
];

export const BENEFIT_PLAN_CONTENT_TYPE_ID = 175;
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
PayrollReconciliationTaskItemFormatters,
PayrollReconciliationTaskTableHeaders,
} from './components/tasks/PayrollReconciliationTasks';
import {BenefitConsumptionsTabLabel, BenefitConsumptionsTabPanel} from "./components/payroll/BenefitConsumptionTabPanel";
import { BenefitConsumptionsTabLabel, BenefitConsumptionsTabPanel } from './components/payroll/BenefitConsumptionTabPanel';

Check failure on line 25 in src/index.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 123. Maximum allowed is 120
import { PayrollTaskTabLabel, PayrollTaskTabPanel } from './components/payroll/PayrollTaskTabPanel';

const ROUTE_PAYMENT_POINTS = 'paymentPoints';
const ROUTE_PAYMENT_POINT = 'paymentPoints/paymentPoint';
Expand Down Expand Up @@ -60,8 +61,8 @@
filter: (rights) => rights.includes(RIGHT_PAYROLL_SEARCH),
},
],
'payroll.TabPanel.label': [BenefitConsumptionsTabLabel],
'payroll.TabPanel.panel': [BenefitConsumptionsTabPanel],
'payroll.TabPanel.label': [BenefitConsumptionsTabLabel, PayrollTaskTabLabel],
'payroll.TabPanel.panel': [BenefitConsumptionsTabPanel, PayrollTaskTabPanel],
'tasksManagement.tasks': [{
text: <FormattedMessage module="payroll" id="payroll.tasks.update.title" />,
tableHeaders: PayrollTaskTableHeaders,
Expand Down
4 changes: 3 additions & 1 deletion src/pages/payroll/PayrollPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ function PayrollPage({
rights.includes(RIGHT_PAYROLL_CREATE) && (
<div className={classes.page}>
<Form
key={payrollUuid}
module="payroll"
title={formatMessageWithValues('payrollPage.title', pageTitle(payroll))}
titleParams={pageTitle(payroll)}
openDirty
openDirty={!payrollUuid}
benefitPlan={editedPayroll}
edited={editedPayroll}
onEditedChanged={setEditedPayroll}
Expand All @@ -169,6 +170,7 @@ function PayrollPage({
setConfirmedAction={setConfirmedAction}
saveTooltip={formatMessage('tooltip.save')}
payrollUuid={payrollUuid}
isInTask={!!taskPayrollUuid}
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { SelectInput } from '@openimis/fe-core';
import { fetchPaymentMethods } from '../../actions';
import { fetchPaymentMethods } from '../actions';

function PaymentMethodPicker({
value,
Expand Down
2 changes: 1 addition & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"payroll.payroll.payrollStatusPicker.PENDING_APPROVAL": "PENDING APPROVAL",
"payroll.payroll.payrollStatusPicker.APPROVE_FOR_PAYMENT": "APPROVE FOR PAYMENT",
"payroll.payroll.payrollStatusPicker.REJECTED": "REJECTED",
"payroll.payroll.payrollStatusPicker.RECONCILIATED": "RECONCILIATED",
"payroll.payroll.payrollStatusPicker.RECONCILED": "RECONCILED",
"payroll.paymentMethod": "Payment Method",
"payroll.tasks.update.title": "Approve Payroll Tasks",
"payroll.tasks.reconciliation.title": "Payroll Reconciliation Tasks",
Expand Down
Loading