Skip to content

Commit

Permalink
Merge branch 'release/23.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
delcroip committed Dec 16, 2023
2 parents fb19e8b + 6052ee0 commit 6f3a811
Show file tree
Hide file tree
Showing 31 changed files with 3,375 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Sonar CI pipeline
on:
push:
branches:
- main
- 'release/**'
- develop
- 'feature/**'
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6 changes: 6 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sonar.projectKey=openimis_openimis-fe-payroll_js
sonar.organization=openimis-1
sonar.projectName=openimis-fe-payroll_js

sonar.sources=src
sonar.sourceEncoding=UTF-8
244 changes: 244 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
import {
formatPageQueryWithCount,
formatQuery,
formatGQLString,
formatMutation,
decodeId,
graphql,
} from '@openimis/fe-core';

import { ACTION_TYPE, MUTATION_SERVICE } from './reducer';
import {
CLEAR, ERROR, REQUEST, SUCCESS,
} from './utils/action-type';
import { isBase64Encoded } from './utils/advanced-filters-utils';
import { PAYROLL_STATUS } from './constants';

export const PAYMENT_POINT_PROJECTION = (modulesManager) => [
'id',
'name',
'isDeleted',
`location ${modulesManager.getProjection('location.Location.FlatProjection')}`,
`ppm ${modulesManager.getProjection('admin.UserPicker.projection')}`,
];

const BILL_FULL_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',
];

const PAYROLL_PROJECTION = (modulesManager) => [
'id',
'name',
'paymentMethod',
`benefitPlan { ${BENEFIT_PLAN_FULL_PROJECTION().join(' ')} }`,
`paymentPoint { ${PAYMENT_POINT_PROJECTION(modulesManager).join(' ')} }`,
`bill { ${BILL_FULL_PROJECTION().join(' ')} } `,
'jsonExt',
'status',
'dateValidFrom',
'dateValidTo',
'isDeleted',
];

const PAYMENT_METHOD_PROJECTION = () => [
'paymentMethods {name}',
];

const formatPaymentPointGQL = (paymentPoint) => {
const paymentPointGQL = `
${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 = `
${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?.paymentMethod ? `paymentMethod: "${payroll.paymentMethod}"` : ''}
${payroll.includedUnpaid !== null && payroll.includedUnpaid !== undefined
? `includedUnpaid: ${payroll.includedUnpaid}` : 'includedUnpaid: false'}
${`status: ${PAYROLL_STATUS.CREATED}`}
${
payroll.jsonExt
? `jsonExt: ${JSON.stringify(payroll.jsonExt)}`
: ''
}
${
payroll.dateValidFrom
? `dateValidFrom: "${payroll.dateValidFrom}"`
: ''
}
${
payroll.dateValidTo
? `dateValidTo: "${payroll.dateValidTo}"`
: ''
}
`;
return payrollGQL;
};

const PERFORM_MUTATION = (mutationType, mutationInput, ACTION, clientMutationLabel) => {
const mutation = formatMutation(mutationType, mutationInput, clientMutationLabel);
const requestedDateTime = new Date();
return graphql(
mutation.payload,
[REQUEST(ACTION_TYPE.MUTATION), SUCCESS(ACTION), ERROR(ACTION_TYPE.MUTATION)],
{
actionType: ACTION,
clientMutationId: mutation.clientMutationId,
clientMutationLabel,
requestedDateTime,
},
);
};

export function fetchPaymentPoints(modulesManager, params) {
const payload = formatPageQueryWithCount('paymentPoint', params, PAYMENT_POINT_PROJECTION(modulesManager));
return graphql(payload, ACTION_TYPE.SEARCH_PAYMENT_POINTS);
}

export function fetchPaymentPoint(modulesManager, params) {
const payload = formatPageQueryWithCount('paymentPoint', params, PAYMENT_POINT_PROJECTION(modulesManager));
return graphql(payload, ACTION_TYPE.GET_PAYMENT_POINT);
}

export const clearPaymentPoint = () => (dispatch) => {
dispatch({
type: CLEAR(ACTION_TYPE.GET_PAYMENT_POINT),
});
};

export function deletePaymentPoint(paymentPoint, clientMutationLabel) {
const paymentPointUuids = `ids: ["${paymentPoint?.id}"]`;
return PERFORM_MUTATION(
MUTATION_SERVICE.PAYMENT_POINT.DELETE,
paymentPointUuids,
ACTION_TYPE.DELETE_PAYMENT_POINT,
clientMutationLabel,
);
}

export function createPaymentPoint(paymentPoint, clientMutationLabel) {
return PERFORM_MUTATION(
MUTATION_SERVICE.PAYMENT_POINT.CREATE,
formatPaymentPointGQL(paymentPoint),
ACTION_TYPE.CREATE_PAYMENT_POINT,
clientMutationLabel,
);
}

export function updatePaymentPoint(paymentPoint, clientMutationLabel) {
return PERFORM_MUTATION(
MUTATION_SERVICE.PAYMENT_POINT.UPDATE,
formatPaymentPointGQL(paymentPoint),
ACTION_TYPE.UPDATE_PAYMENT_POINT,
clientMutationLabel,
);
}

export function fetchPayrolls(modulesManager, params) {
const payload = formatPageQueryWithCount('payroll', params, PAYROLL_PROJECTION(modulesManager));
return graphql(payload, ACTION_TYPE.SEARCH_PAYROLLS);
}

export function fetchPayroll(modulesManager, params) {
const payload = formatPageQueryWithCount('payroll', params, PAYROLL_PROJECTION(modulesManager));
return graphql(payload, ACTION_TYPE.GET_PAYROLL);
}

export function deletePayrolls(payroll, clientMutationLabel) {
const uuid = isBase64Encoded(payroll.id) ? decodeId(payroll?.id) : payroll?.id;
const payrollUuids = `ids: ["${uuid}"]`;
return PERFORM_MUTATION(
MUTATION_SERVICE.PAYROLL.DELETE,
payrollUuids,
ACTION_TYPE.DELETE_PAYROLL,
clientMutationLabel,
);
}

export function createPayroll(payroll, clientMutationLabel) {
return PERFORM_MUTATION(
MUTATION_SERVICE.PAYROLL.CREATE,
formatPayrollGQL(payroll),
ACTION_TYPE.CREATE_PAYROLL,
clientMutationLabel,
);
}

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

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

export const clearPayroll = () => (dispatch) => {
dispatch({
type: CLEAR(ACTION_TYPE.GET_PAYROLL),
});
};

export function fetchPaymentMethods(params) {
const payload = formatQuery('paymentMethods', params, PAYMENT_METHOD_PROJECTION());
return graphql(payload, ACTION_TYPE.GET_PAYMENT_METHODS);
}
Loading

0 comments on commit 6f3a811

Please sign in to comment.