Skip to content

Commit

Permalink
CM-487: initial adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Feb 6, 2024
1 parent 845daec commit da79186
Show file tree
Hide file tree
Showing 15 changed files with 415 additions and 483 deletions.
81 changes: 18 additions & 63 deletions src/actions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
formatPageQueryWithCount,
formatQuery,
decodeId,
formatGQLString,
formatMutation,
decodeId,
formatPageQueryWithCount,
formatQuery,
graphql,
} from '@openimis/fe-core';

Expand All @@ -22,66 +22,28 @@ export const PAYMENT_POINT_PROJECTION = (modulesManager) => [
`ppm ${modulesManager.getProjection('admin.UserPicker.projection')}`,
];

const BILL_FULL_PROJECTION = () => [
const BENEFIT_CONSUMPTION_PROJECTION = () => [
'id',
'isDeleted',
'jsonExt',
'dateCreated',
'dateUpdated',
'dateValidFrom',
'dateValidTo',
'replacementUuid',
'thirdpartyType',
'thirdpartyTypeName',
'thirdpartyId',
'thirdparty',
'codeTp',
'code',
'codeExt',
'dateDue',
'datePayed',
'amountDiscount',
'amountNet',
'amountTotal',
'taxAnalysis',
'status',
'currencyTpCode',
'currencyCode',
'note',
'terms',
'paymentReference',
'subjectType',
'subjectTypeName',
'subjectId',
'subject',
'dateBill',
];

const BENEFIT_PLAN_FULL_PROJECTION = () => [
'id',
'isDeleted',
'dateCreated',
'dateUpdated',
'version',
'dateValidFrom',
'dateValidTo',
'description',
'replacementUuid',
'code',
'name',
'type',
'maxBeneficiaries',
'ceilingPerBeneficiary',
'jsonExt',
'individual {firstName, lastName}',
'benefitAttachment {bill {id, code, terms}}',
];

const PAYROLL_PROJECTION = (modulesManager) => [
'id',
'name',
'paymentMethod',
`benefitPlan { ${BENEFIT_PLAN_FULL_PROJECTION().join(' ')} }`,
'paymentPlan { code }',
`paymentPoint { ${PAYMENT_POINT_PROJECTION(modulesManager).join(' ')} }`,
`bill { ${BILL_FULL_PROJECTION().join(' ')} } `,
'paymentCycle { runYear, runMonth }',
'benefitConsumption{id, code,individual {firstName, lastName}, benefitAttachment{bill{id, code, terms}}}',
'jsonExt',
'status',
'dateValidFrom',
Expand All @@ -93,26 +55,21 @@ const PAYMENT_METHOD_PROJECTION = () => [
'paymentMethods {name}',
];

const formatPaymentPointGQL = (paymentPoint) => {
const paymentPointGQL = `
const formatPaymentPointGQL = (paymentPoint) => `
${paymentPoint?.id ? `id: "${paymentPoint.id}"` : ''}
${paymentPoint?.name ? `name: "${formatGQLString(paymentPoint.name)}"` : ''}
${paymentPoint?.location ? `locationId: ${decodeId(paymentPoint.location.id)}` : ''}
${paymentPoint?.ppm ? `ppmId: "${decodeId(paymentPoint.ppm.id)}"` : ''}
`;
return paymentPointGQL;
};

const formatPayrollGQL = (payroll) => {
const payrollGQL = `
const formatPayrollGQL = (payroll) => `
${payroll?.id ? `id: "${payroll.id}"` : ''}
${payroll?.name ? `name: "${formatGQLString(payroll.name)}"` : ''}
${payroll?.paymentPoint ? `paymentPointId: "${decodeId(payroll.paymentPoint.id)}"` : ''}
${payroll?.benefitPlan ? `benefitPlanId: "${decodeId(payroll.benefitPlan.id)}"` : ''}
${payroll?.paymentPlan ? `paymentPlanId: "${decodeId(payroll.paymentPlan.id)}"` : ''}
${payroll?.paymentCycle ? `paymentCycleId: "${decodeId(payroll.paymentCycle.id)}"` : ''}
${payroll?.paymentMethod ? `paymentMethod: "${payroll.paymentMethod}"` : ''}
${payroll.includedUnpaid !== null && payroll.includedUnpaid !== undefined
? `includedUnpaid: ${payroll.includedUnpaid}` : 'includedUnpaid: false'}
${`status: ${PAYROLL_STATUS.CREATED}`}
${`status: ${PAYROLL_STATUS.PENDING_APPROVAL}`}
${
payroll.jsonExt
? `jsonExt: ${JSON.stringify(payroll.jsonExt)}`
Expand All @@ -129,8 +86,6 @@ const formatPayrollGQL = (payroll) => {
: ''
}
`;
return payrollGQL;
};

const PERFORM_MUTATION = (mutationType, mutationInput, ACTION, clientMutationLabel) => {
const mutation = formatMutation(mutationType, mutationInput, clientMutationLabel);
Expand Down Expand Up @@ -221,14 +176,14 @@ export function createPayroll(payroll, clientMutationLabel) {
);
}

export function fetchPayrollBills(modulesManager, params) {
const payload = formatPageQueryWithCount('billByPayroll', params, BILL_FULL_PROJECTION());
return graphql(payload, ACTION_TYPE.GET_PAYROLL_BILLS);
export function fetchBenefitConsumptions(modulesManager, params) {
const payload = formatPageQueryWithCount('benefitConsumption', params, BENEFIT_CONSUMPTION_PROJECTION());
return graphql(payload, ACTION_TYPE.GET_BENEFIT_CONSUMPTION);
}

export const clearPayrollBills = () => (dispatch) => {
dispatch({
type: CLEAR(ACTION_TYPE.GET_PAYROLL_BILLS),
type: CLEAR(ACTION_TYPE.GET_BENEFIT_CONSUMPTION),
});
};

Expand Down
89 changes: 46 additions & 43 deletions src/components/payroll/PayrollFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,49 +74,52 @@ function PayrollFilter({
onChange={onChangeStringFilter('name', CONTAINS_LOOKUP)}
/>
</Grid>
<ControlledField
module="payroll"
id="PayrollFilter.benefitPlan"
field={(
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="socialProtection.BenefitPlanPicker"
withNull
filters={filters}
value={filterValue('benefitPlan_Id')}
onChange={(benefitPlan) => onChangeFilters([
{
id: 'benefitPlan_Id',
value: benefitPlan,
filter: `benefitPlan_Id: "${benefitPlan?.id && decodeId(benefitPlan.id)}"`,
},
])}
/>
</Grid>
)}
/>
<ControlledField
module="payroll"
id="PayrollFilter.paymentPoint"
field={(
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="payroll.PaymentPointPicker"
withLabel
withPlaceholder
filters={filters}
value={filterValue('paymentPoint_Id')}
onChange={(paymentPoint) => onChangeFilters([
{
id: 'paymentPoint_Id',
value: paymentPoint,
filter: `paymentPoint_Id: "${paymentPoint?.id && decodeId(paymentPoint.id)}"`,
},
])}
/>
</Grid>
)}
/>
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="contributionPlan.PaymentPlanPicker"
filters={filters}
value={filterValue('paymentPlan_Id')}
onChange={(paymentPlan) => onChangeFilters([
{
id: 'paymentPlan_Id',
value: paymentPlan,
filter: `paymentPlan_Id: "${paymentPlan?.id && decodeId(paymentPlan.id)}"`,
},
])}
/>
</Grid>
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="payroll.PaymentPointPicker"
withLabel
withPlaceholder
filters={filters}
value={filterValue('paymentPoint_Id')}
onChange={(paymentPoint) => onChangeFilters([
{
id: 'paymentPoint_Id',
value: paymentPoint,
filter: `paymentPoint_Id: "${paymentPoint?.id && decodeId(paymentPoint.id)}"`,
},
])}
/>
</Grid>
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="paymentCycle.PaymentCyclePicker"
withLabel
withPlaceholder
filters={filters}
value={filterValue('paymentCycle_Id')}
onChange={(paymentCycle) => onChangeFilters([
{
id: 'paymentCycle_Id',
value: paymentCycle,
filter: `paymentCycle_Id: "${paymentCycle?.id && decodeId(paymentCycle.id)}"`,
},
])}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<PayrollStatusPicker
withNull
Expand Down
29 changes: 22 additions & 7 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const MAX_LENGTH = {

export const MODULE_NAME = 'payroll';

export const PAYROLL_BILLS_LIST_TAB_VALUE = 'payrollBillsTab';
export const BENEFIT_CONSUMPTION_LIST_TAB_VALUE = 'benefitConsumptionsTab';

export const PAYROLL_TABS_LABEL_CONTRIBUTION_KEY = 'payroll.TabPanel.label';
export const PAYROLL_TABS_PANEL_CONTRIBUTION_KEY = 'payroll.TabPanel.panel';
Expand Down Expand Up @@ -59,15 +59,30 @@ export const BOOL_OPTIONS = [
];

export const PAYROLL_STATUS = {
CREATED: 'CREATED',
ONGOING: 'ONGOING',
AWAITING_FOR_RECONCILIATION: 'AWAITING_FOR_RECONCILIATION',
PENDING_APPROVAL: 'PENDING_APPROVAL',
APPROVE_FOR_PAYMENT: 'APPROVE_FOR_PAYMENT',
REJECTED: 'REJECTED',
RECONCILIATED: 'RECONCILIATED',
};

export const PAYROLL_STATUS_LIST = [
PAYROLL_STATUS.CREATED,
PAYROLL_STATUS.ONGOING,
PAYROLL_STATUS.AWAITING_FOR_RECONCILIATION,
PAYROLL_STATUS.PENDING_APPROVAL,
PAYROLL_STATUS.APPROVE_FOR_PAYMENT,
PAYROLL_STATUS.REJECTED,
PAYROLL_STATUS.RECONCILIATED,
];

export const BENEFIT_CONSUMPTION_STATUS = {
ACCEPTED: 'ACCEPTED',
CREATED: 'CREATED',
APPROVE_FOR_PAYMENT: 'APPROVE_FOR_PAYMENT',
REJECTED: 'REJECTED',
DUPLICATE: 'DUPLICATE',
RECONCILED: 'RECONCILED',
};

export const BENEFIT_CONSUMPTION_STATUS_LIST = [
BENEFIT_CONSUMPTION_STATUS.ACCEPTED, BENEFIT_CONSUMPTION_STATUS.CREATED,
BENEFIT_CONSUMPTION_STATUS.APPROVE_FOR_PAYMENT, BENEFIT_CONSUMPTION_STATUS.REJECTED,
BENEFIT_CONSUMPTION_STATUS.DUPLICATE, BENEFIT_CONSUMPTION_STATUS.RECONCILED,
];
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import PaymentPointPage from './pages/payment-point/PaymentPointPage';
import PaymentPointsPage from './pages/payment-point/PaymentPointsPage';
import PayrollPage from './pages/payroll/PayrollPage';
import PayrollsPage from './pages/payroll/PayrollsPage';
import { PayrollBillsTabLabel, PayrollBillsTabPanel } from './pages/payroll/PayrollBillTabPanel';
import PaymentPointPicker from './components/payment-point/PaymentPointPicker';
import {
PayrollTaskItemFormatters,
Expand All @@ -23,6 +22,7 @@ import {
PayrollReconciliationTaskItemFormatters,
PayrollReconciliationTaskTableHeaders,
} from './components/tasks/PayrollReconciliationTasks';
import {BenefitConsumptionsTabLabel, BenefitConsumptionsTabPanel} from "./pages/payroll/BenefitConsumptionTabPanel";

const ROUTE_PAYMENT_POINTS = 'paymentPoints';
const ROUTE_PAYMENT_POINT = 'paymentPoints/paymentPoint';
Expand Down Expand Up @@ -60,8 +60,8 @@ const DEFAULT_CONFIG = {
filter: (rights) => rights.includes(RIGHT_PAYROLL_SEARCH),
},
],
'payroll.TabPanel.label': [PayrollBillsTabLabel],
'payroll.TabPanel.panel': [PayrollBillsTabPanel],
'payroll.TabPanel.label': [BenefitConsumptionsTabLabel],
'payroll.TabPanel.panel': [BenefitConsumptionsTabPanel],
'tasksManagement.tasks': [{
text: <FormattedMessage module="payroll" id="payroll.tasks.update.title" />,
tableHeaders: PayrollTaskTableHeaders,
Expand Down
Loading

0 comments on commit da79186

Please sign in to comment.