From c9543ccdbaa8c1105a7fd68ecd9101141c177dcc Mon Sep 17 00:00:00 2001
From: sniedzielski <52816247+sniedzielski@users.noreply.github.com>
Date: Thu, 21 Sep 2023 12:56:00 +0200
Subject: [PATCH] CM-319: Adjust payment submodule from Insurees for
PaymentLayer payments (#22)
* CM-319: added payment general view related to payment layer aspect
* CM-319: added payment to legal and finance
* CM-319: added payment searcher right
* CM-319: added payment searcher right
* CM-319: remove right check to verify issue with not displaying searcher
* CM-319: remove right check to verify issue with not displaying searcher part 2
* CM-319: fixed path to invoice
* CM-319: console log to check
* CM-319: check existing perms
* CM-319: add additional prints
* CM-319: fixed issue with not displaying searcher due to bill condition
* CM-319: fixed issue wit row disabled
* CM-319: fixed decodeId missing import
* CM-319: added missing getEnumValue
* CM-319: moved translations to payment module, added rights check to searcher
* CM-319: removed redundant imports and variables
---
src/actions.js | 88 +++++++++++
src/components/PaymentInvoiceFilter.js | 156 +++++++++++++++++++
src/components/PaymentInvoiceSearcher.js | 174 ++++++++++++++++++++++
src/constants.js | 22 +++
src/index.js | 13 +-
src/pages/PaymentInvoicesPage.js | 33 ++++
src/pickers/PaymentInvoiceStatusPicker.js | 43 ++++++
src/reducer.js | 79 ++++++++++
src/translations/en.json | 62 +++++++-
src/utils/enum.js | 3 +
src/utils/styles.js | 24 +++
11 files changed, 695 insertions(+), 2 deletions(-)
create mode 100644 src/components/PaymentInvoiceFilter.js
create mode 100644 src/components/PaymentInvoiceSearcher.js
create mode 100644 src/pages/PaymentInvoicesPage.js
create mode 100644 src/pickers/PaymentInvoiceStatusPicker.js
create mode 100644 src/utils/enum.js
create mode 100644 src/utils/styles.js
diff --git a/src/actions.js b/src/actions.js
index a0ed282..d7c3940 100644
--- a/src/actions.js
+++ b/src/actions.js
@@ -37,6 +37,30 @@ const PAYMENT_FULL_PROJECTION = mm =>
"clientMutationId",
];
+const PAYMENT_INVOICE_FULL_PROJECTION = [
+ "id",
+ "reconciliationStatus",
+ "codeExt",
+ "codeTp",
+ "codeReceipt",
+ "label",
+ "fees",
+ "amountReceived",
+ "datePayment",
+ "paymentOrigin",
+ "payerRef"
+];
+
+const DETAIL_PAYMENT_INVOICE_FULL_PROJECTION = [
+ "id",
+ "status",
+ "fees",
+ "amount",
+ "reconciliationId",
+ "reconciliationDate",
+];
+
+
export function fetchPremiumsPayments(mm, filters) {
let payload = formatPageQueryWithCount("paymentsByPremiums",
filters,
@@ -79,6 +103,24 @@ export function formatPaymentGQL(mm, payment) {
return req;
}
+const formatPaymentInvoiceGQL = (payment, subjectId, subjectType) =>
+ `
+ ${!!payment.id ? `id: "${payment.id}"` : ""}
+ ${!!subjectId ? `subjectId: "${subjectId}"` : ""}
+ ${!!subjectType ? `subjectType: "${subjectType}"` : ""}
+ ${!!payment.status ? `status: ${payment.status}` : ""}
+ ${!!payment.reconciliationStatus ? `reconciliationStatus: ${payment.reconciliationStatus}` : ""}
+ ${!!payment.codeExt ? `codeExt: "${payment.codeExt}"` : ""}
+ ${!!payment.label ? `label: "${payment.label}"` : ""}
+ ${!!payment.codeTp ? `codeTp: "${payment.codeTp}"` : ""}
+ ${!!payment.codeReceipt ? `codeReceipt: "${payment.codeReceipt}"` : ""}
+ ${!!payment.fees ? `fees: "${payment.fees}"` : ""}
+ ${!!payment.amountReceived ? `amountReceived: "${payment.amountReceived}"` : ""}
+ ${!!payment.datePayment ? `datePayment: "${payment.datePayment}"` : ""}
+ ${!!payment.paymentOrigin ? `paymentOrigin: "${payment.paymentOrigin}"` : ""}
+ ${!!payment.payerRef ? `payerRef: "${payment.payerRef}"` : ""}
+ `;
+
export function createPayment(mm, payment, clientMutationLabel) {
let mutation = formatMutation("createPayment", formatPaymentGQL(mm, payment), clientMutationLabel);
var requestedDateTime = new Date();
@@ -137,3 +179,49 @@ export function fetchPayment(mm, paymentUuid, clientMutationId) {
);
return graphql(payload, 'PAYMENT_OVERVIEW');
}
+
+
+export function fetchPaymentInvoices(params) {
+ const payload = formatPageQueryWithCount("paymentInvoice", params, PAYMENT_INVOICE_FULL_PROJECTION);
+ return graphql(payload, "PAYMENTINVOICE__PAYMENT_INVOICE");
+}
+
+export function fetchDetailPaymentInvoices(params) {
+ const payload = formatPageQueryWithCount("detailPaymentInvoice", params, DETAIL_PAYMENT_INVOICE_FULL_PROJECTION);
+ return graphql(payload, "PAYMENTINVOICE__DETAIL_PAYMENT_INVOICE");
+}
+
+export function createPaymentInvoiceWithDetail(paymentInvoice, subjectId, subjectType, clientMutationLabel) {
+ const mutation = formatMutation(
+ "createPaymentWithDetailInvoice",
+ formatPaymentInvoiceGQL(paymentInvoice, subjectId, subjectType),
+ clientMutationLabel
+ );
+ const requestedDateTime = new Date();
+ return graphql(
+ mutation.payload,
+ ["PAYMENT_MUTATION_REQ", "PAYMENTINVOICE_CREATE_PAYMENT_INVOICE_WITH_DETAIL_RESP", "PAYMENT_MUTATION_ERR"],
+ {
+ actionType: "PAYMENTINVOICE_CREATE_PAYMENT_INVOICE_WITH_DETAIL",
+ clientMutationId: mutation.clientMutationId,
+ clientMutationLabel,
+ requestedDateTime,
+ },
+ );
+}
+
+export function deletePaymentInvoice(paymentInvoice, clientMutationLabel) {
+ const paymentInvoiceUuids = `uuids: ["${paymentInvoice?.id}"]`;
+ const mutation = formatMutation("deletePaymentInvoice", paymentInvoiceUuids, clientMutationLabel);
+ const requestedDateTime = new Date();
+ return graphql(
+ mutation.payload,
+ ["PAYMENT_MUTATION_REQ", "PAYMENTINVOICE_DELETE_PAYMENT_INVOICE_RESP", "PAYMENT_MUTATION_ERR"],
+ {
+ actionType: "PAYMENTINVOICE_DELETE_PAYMENT_INVOICE",
+ clientMutationId: mutation.clientMutationId,
+ clientMutationLabel,
+ requestedDateTime,
+ },
+ );
+}
diff --git a/src/components/PaymentInvoiceFilter.js b/src/components/PaymentInvoiceFilter.js
new file mode 100644
index 0000000..a6fd67c
--- /dev/null
+++ b/src/components/PaymentInvoiceFilter.js
@@ -0,0 +1,156 @@
+import React from "react";
+import { injectIntl } from "react-intl";
+import _debounce from "lodash/debounce";
+
+import { Grid } from "@material-ui/core";
+import { withTheme, withStyles } from "@material-ui/core/styles";
+
+import { withModulesManager, formatMessage, TextInput, NumberInput, PublishedComponent } from "@openimis/fe-core";
+import { CONTAINS_LOOKUP, DEFAULT_DEBOUNCE_TIME, STARTS_WITH_LOOKUP } from "../constants";
+import PaymentInvoiceStatusPicker from "../pickers/PaymentInvoiceStatusPicker";
+
+const styles = (theme) => ({
+ form: {
+ padding: 0,
+ },
+ item: {
+ padding: theme.spacing(1),
+ },
+});
+
+const PaymentInvoiceFilter = ({ intl, classes, filters, onChangeFilters }) => {
+ const debouncedOnChangeFilters = _debounce(onChangeFilters, DEFAULT_DEBOUNCE_TIME);
+
+ const filterValue = (filterName) => filters?.[filterName]?.value;
+
+ const filterTextFieldValue = (filterName) => (filters[filterName] ? filters[filterName].value : "");
+
+ const onChangeFilter = (filterName) => (value) => {
+ debouncedOnChangeFilters([
+ {
+ id: filterName,
+ value: !!value ? value : null,
+ filter: `${filterName}: ${value}`,
+ },
+ ]);
+ };
+
+ const onChangeStringFilter =
+ (filterName, lookup = null) =>
+ (value) => {
+ lookup
+ ? debouncedOnChangeFilters([
+ {
+ id: filterName,
+ value,
+ filter: `${filterName}_${lookup}: "${value}"`,
+ },
+ ])
+ : onChangeFilters([
+ {
+ id: filterName,
+ value,
+ filter: `${filterName}: "${value}"`,
+ },
+ ]);
+ };
+
+ return (
+
+
+
+ onChangeFilters([
+ {
+ id: "reconciliationStatus",
+ value: value,
+ filter: `reconciliationStatus: "${value}"`,
+ },
+ ])
+ }
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default withModulesManager(injectIntl(withTheme(withStyles(styles)(PaymentInvoiceFilter))));
diff --git a/src/components/PaymentInvoiceSearcher.js b/src/components/PaymentInvoiceSearcher.js
new file mode 100644
index 0000000..1f76087
--- /dev/null
+++ b/src/components/PaymentInvoiceSearcher.js
@@ -0,0 +1,174 @@
+import React, { useRef, useEffect, useState } from "react";
+import { injectIntl } from "react-intl";
+import {
+ formatMessageWithValues,
+ Searcher,
+ formatDateFromISO,
+ withModulesManager,
+ coreConfirm,
+} from "@openimis/fe-core";
+import { bindActionCreators } from "redux";
+import { connect } from "react-redux";
+import { fetchPaymentInvoices, deletePaymentInvoice } from "../actions";
+import {
+ DEFAULT_PAGE_SIZE,
+ EMPTY_STRING,
+ ROWS_PER_PAGE_OPTIONS,
+} from "../constants";
+import PaymentInvoiceFilter from "./PaymentInvoiceFilter";
+import PaymentInvoiceStatusPicker from "../pickers/PaymentInvoiceStatusPicker"
+
+const PaymentInvoiceSearcher = ({
+ intl,
+ modulesManager,
+ submittingMutation,
+ mutation,
+ fetchPaymentInvoices,
+ fetchingPaymentInvoices,
+ fetchedPaymentInvoices,
+ errorPaymentInvoices,
+ paymentInvoices,
+ paymentInvoicesPageInfo,
+ paymentInvoicesTotalCount,
+}) => {
+ const [queryParams, setQueryParams] = useState([]);
+ const prevSubmittingMutationRef = useRef();
+
+ useEffect(() => {
+ if (
+ prevSubmittingMutationRef.current &&
+ !submittingMutation &&
+ ["PAYMENTINVOICE_CREATE_PAYMENT_INVOICE_WITH_DETAIL"].includes(mutation?.actionType)
+ ) {
+ refetch();
+ }
+ }, [submittingMutation]);
+
+ useEffect(() => {
+ prevSubmittingMutationRef.current = submittingMutation;
+ });
+
+ const fetch = (params) => fetchPaymentInvoices(params);
+
+ const refetch = () => fetch(queryParams);
+
+ const filtersToQueryParams = ({ filters, pageSize, beforeCursor, afterCursor, orderBy }) => {
+ const queryParams = Object.keys(filters)
+ .filter((f) => !!filters[f]["filter"])
+ .map((f) => filters[f]["filter"]);
+ !beforeCursor && !afterCursor && queryParams.push(`first: ${pageSize}`);
+ if (afterCursor) {
+ queryParams.push(`after: "${afterCursor}"`);
+ queryParams.push(`first: ${pageSize}`);
+ }
+ if (beforeCursor) {
+ queryParams.push(`before: "${beforeCursor}"`);
+ queryParams.push(`last: ${pageSize}`);
+ }
+ orderBy && queryParams.push(`orderBy: ["${orderBy}"]`);
+ setQueryParams(queryParams);
+ return queryParams;
+ };
+
+ const headers = () => [
+ "paymentInvoice.reconciliationStatus.label",
+ "paymentInvoice.codeExt",
+ "paymentInvoice.label",
+ "paymentInvoice.codeTp",
+ "paymentInvoice.codeReceipt",
+ "paymentInvoice.fees",
+ "paymentInvoice.amountReceived",
+ "paymentInvoice.datePayment",
+ "paymentInvoice.paymentOrigin",
+ "paymentInvoice.payerRef",
+ ];
+
+ const itemFormatters = () => {
+ const formatters = [
+ (paymentInvoice) => ,
+ (paymentInvoice) => paymentInvoice.codeExt,
+ (paymentInvoice) => paymentInvoice.label,
+ (paymentInvoice) => paymentInvoice.codeTp,
+ (paymentInvoice) => paymentInvoice.codeReceipt,
+ (paymentInvoice) => paymentInvoice.fees,
+ (paymentInvoice) => paymentInvoice.amountReceived,
+ (paymentInvoice) =>
+ !!paymentInvoice.datePayment
+ ? formatDateFromISO(modulesManager, intl, paymentInvoice.datePayment)
+ : EMPTY_STRING,
+ (paymentInvoice) => paymentInvoice.paymentOrigin,
+ (paymentInvoice) => paymentInvoice.payerRef,
+ ];
+
+ return formatters;
+ };
+
+ const sorts = () => [
+ ["reconciliationStatus", true],
+ ["codeExt", true],
+ ["label", true],
+ ["codeTp", true],
+ ["codeReceipt", true],
+ ["fees", true],
+ ["amountReceived", true],
+ ["datePayment", true],
+ ["paymentOrigin", true],
+ ["payerRef", true],
+ ];
+
+ const defaultFilters = () => ({
+ isDeleted: {
+ value: false,
+ filter: "isDeleted: false",
+ },
+ });
+
+ return (
+
+ );
+};
+
+const mapStateToProps = (state) => ({
+ fetchingPaymentInvoices: state.invoice.fetchingPaymentInvoices,
+ fetchedPaymentInvoices: state.invoice.fetchedPaymentInvoices,
+ errorPaymentInvoices: state.invoice.errorPaymentInvoices,
+ paymentInvoices: state.invoice.paymentInvoices,
+ paymentInvoicesPageInfo: state.invoice.paymentInvoicesPageInfo,
+ paymentInvoicesTotalCount: state.invoice.paymentInvoicesTotalCount,
+ submittingMutation: state.invoice.submittingMutation,
+ mutation: state.invoice.mutation,
+ confirmed: state.core.confirmed,
+});
+
+const mapDispatchToProps = (dispatch) => {
+ return bindActionCreators(
+ {
+ fetchPaymentInvoices,
+ deletePaymentInvoice,
+ coreConfirm
+ },
+ dispatch,
+ );
+};
+
+export default withModulesManager(injectIntl(connect(mapStateToProps, mapDispatchToProps)(PaymentInvoiceSearcher)));
diff --git a/src/constants.js b/src/constants.js
index 7ddd995..802cdf9 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -4,6 +4,28 @@ export const RIGHT_PAYMENT_ADD = 101402;
export const RIGHT_PAYMENT_EDIT = 101403;
export const RIGHT_PAYMENT_DELETE = 101404;
+export const RIGHT_BILL_PAYMENT_SEARCH = 156201;
+export const RIGHT_BILL_PAYMENT_CREATE = 156202;
+export const RIGHT_BILL_PAYMENT_UPDATE = 156203;
+export const RIGHT_BILL_PAYMENT_DELETE = 156204;
+export const RIGHT_BILL_PAYMENT_REFUND = 156206;
+
+export const DEFAULT_DEBOUNCE_TIME = 200;
+export const EMPTY_STRING = "";
+export const ROWS_PER_PAGE_OPTIONS = [10, 20, 50, 100];
+export const DEFAULT_PAGE_SIZE = 10;
+export const ENUM_PREFIX_LENGTH = 2;
+
+export const PAYMENT_MAIN_STATUS = {
+ NOT_RECONCILIATED: "0",
+ RECONCILIATED: "1",
+ REFUNDED: "2",
+ CANCELLED: "3",
+};
+
+export const CONTAINS_LOOKUP = "Icontains";
+export const STARTS_WITH_LOOKUP = "Istartswith";
+
export const MODULE_NAME = "payment";
export const PAYMENT_STATUS = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5];
diff --git a/src/index.js b/src/index.js
index 9b3e319..352a087 100644
--- a/src/index.js
+++ b/src/index.js
@@ -7,14 +7,16 @@ import PremiumsPaymentsOverview from "./components/PremiumsPaymentsOverview";
import PaymentOverviewPage from "./pages/PaymentOverviewPage";
import PaymentStatusPicker from "./pickers/PaymentStatusPicker";
import PaymentsPage from "./pages/PaymentsPage";
+import PaymentInvoicesPage from "./pages/PaymentInvoicesPage";
import PaymentPage from "./pages/PaymentPage";
import { PaymentsTabLabel, PaymentsTabPanel } from "./components/PaymentsTab";
import reducer from "./reducer";
-import { RIGHT_PAYMENT } from "./constants";
+import { RIGHT_PAYMENT, RIGHT_BILL_PAYMENT_SEARCH } from "./constants";
const ROUTE_PAYMENTS = "payment/payments";
+const ROUTE_PAYMENTS_INVOICE = "payment/paymentsInvoice";
const ROUTE_PAYMENTS_PAYMENT = "payment/new";
const ROUTE_PAYMENTS_PAYMENT_OVERVIEW = "payment/overview";
@@ -32,6 +34,7 @@ const DEFAULT_CONFIG = {
],
"core.Router": [
{ path: ROUTE_PAYMENTS, component: PaymentsPage },
+ { path: ROUTE_PAYMENTS_INVOICE, component: PaymentInvoicesPage },
{ path: ROUTE_PAYMENTS_PAYMENT+ "/:premium_uuid", component: PaymentPage },
{ path: ROUTE_PAYMENTS_PAYMENT_OVERVIEW + "/:payment_uuid", component: PaymentOverviewPage },
],
@@ -44,6 +47,14 @@ const DEFAULT_CONFIG = {
filter: rights => rights.includes(RIGHT_PAYMENT)
}
],
+ "invoice.MainMenu": [
+ {
+ text: ,
+ icon: ,
+ route: "/" + ROUTE_PAYMENTS_INVOICE,
+ filter: rights => rights.includes(RIGHT_BILL_PAYMENT_SEARCH)
+ }
+ ]
}
export const PaymentModule = (cfg) => {
diff --git a/src/pages/PaymentInvoicesPage.js b/src/pages/PaymentInvoicesPage.js
new file mode 100644
index 0000000..007ac7a
--- /dev/null
+++ b/src/pages/PaymentInvoicesPage.js
@@ -0,0 +1,33 @@
+import React, { useEffect } from "react";
+import { Helmet, withModulesManager, formatMessage, clearCurrentPaginationPage } from "@openimis/fe-core";
+import { injectIntl } from "react-intl";
+import { withTheme, withStyles } from "@material-ui/core/styles";
+import { connect, useDispatch } from "react-redux";
+import { RIGHT_BILL_PAYMENT_SEARCH } from "../constants";
+import PaymentInvoiceSearcher from "../components/PaymentInvoiceSearcher";
+import { defaultPageStyles } from "../utils/styles";
+
+const PaymentInvoicesPage = ({ intl, classes, rights }) => {
+ const dispatch = useDispatch();
+
+ useEffect(() => {
+ dispatch(clearCurrentPaginationPage());
+ }, []);
+
+ return (
+ rights.includes(RIGHT_BILL_PAYMENT_SEARCH) && (
+
+ )
+ );
+};
+
+const mapStateToProps = (state) => ({
+ rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : [],
+});
+
+export default withModulesManager(
+ injectIntl(withTheme(withStyles(defaultPageStyles)(connect(mapStateToProps)(PaymentInvoicesPage)))),
+);
diff --git a/src/pickers/PaymentInvoiceStatusPicker.js b/src/pickers/PaymentInvoiceStatusPicker.js
new file mode 100644
index 0000000..a3c395c
--- /dev/null
+++ b/src/pickers/PaymentInvoiceStatusPicker.js
@@ -0,0 +1,43 @@
+import React from "react";
+import { SelectInput } from "@openimis/fe-core";
+import { formatMessage } from "@openimis/fe-core";
+import { injectIntl } from "react-intl";
+import { PAYMENT_MAIN_STATUS } from "../constants";
+
+const PaymentInvoiceStatusPicker = ({
+ intl,
+ value,
+ label,
+ onChange,
+ readOnly = false,
+ withNull = false,
+ nullLabel = null,
+ withLabel = true,
+ required = false,
+}) => {
+ const options = Object.keys(PAYMENT_MAIN_STATUS).map((key) => ({
+ value: PAYMENT_MAIN_STATUS[key],
+ label: formatMessage(intl, "payment", `paymentInvoice.reconciliationStatus.${key}`),
+ }));
+
+ if (withNull) {
+ options.unshift({
+ value: null,
+ label: nullLabel || formatMessage(intl, "payment", "emptyLabel"),
+ });
+ }
+
+ return (
+
+ );
+};
+
+export default injectIntl(PaymentInvoiceStatusPicker);
diff --git a/src/reducer.js b/src/reducer.js
index 2e24888..2593b7a 100644
--- a/src/reducer.js
+++ b/src/reducer.js
@@ -6,7 +6,9 @@ import {
dispatchMutationResp,
dispatchMutationErr,
dispatchMutationReq,
+ decodeId,
} from '@openimis/fe-core';
+import { getEnumValue } from "./utils/enum";
function reducer(
state = {
@@ -25,6 +27,20 @@ function reducer(
errorPayment: null,
submittingMutation: false,
mutation: {},
+
+ fetchingPaymentInvoices: false,
+ errorPaymentInvoices: null,
+ fetchedPaymentInvoices: false,
+ paymentInvoices: [],
+ paymentInvoicesPageInfo: {},
+ paymentInvoicesTotalCount: 0,
+
+ fetchingDetailPaymentInvoices: false,
+ errorDetailPaymentInvoices: null,
+ fetchedDetailPaymentInvoices: false,
+ detailPaymentInvoices: [],
+ detailPaymentInvoicesPageInfo: {},
+ detailPaymentInvoicesTotalCount: 0,
},
action,
) {
@@ -119,6 +135,69 @@ function reducer(
paymentsPageInfo : { totalCount: 0 },
payment: null,
};
+
+ case 'PAYMENTINVOICE__PAYMENT_INVOICE_REQ':
+ return {
+ ...state,
+ fetchingPaymentInvoices: true,
+ fetchedPaymentInvoices: false,
+ paymentInvoices: [],
+ paymentInvoicesPageInfo: {},
+ paymentInvoicesTotalCount: 0,
+ errorPaymentInvoices: null,
+ };
+ case 'PAYMENTINVOICE__PAYMENT_INVOICE_RESP':
+ return {
+ ...state,
+ fetchingPaymentInvoices: false,
+ fetchedPaymentInvoices: true,
+ paymentInvoices: parseData(action.payload.data.paymentInvoice)?.map((paymentInvoice) => ({
+ ...paymentInvoice,
+ id: decodeId(paymentInvoice.id),
+ reconciliationStatus: getEnumValue(paymentInvoice?.reconciliationStatus),
+ })),
+ paymentInvoicesPageInfo: pageInfo(action.payload.data.paymentInvoice),
+ paymentInvoicesTotalCount: action.payload.data.paymentInvoice?.totalCount,
+ errorPaymentInvoices: formatGraphQLError(action.payload),
+ };
+ case 'PAYMENTINVOICE__PAYMENT_INVOICE_ERR':
+ return {
+ ...state,
+ fetchingPaymentInvoices: false,
+ errorPaymentInvoices: formatServerError(action.payload),
+ };
+
+ case 'PAYMENTINVOICE__DETAIL_PAYMENT_INVOICE_REQ':
+ return {
+ ...state,
+ fetchingDetailPaymentInvoices: true,
+ fetchedDetailPaymentInvoices: false,
+ detailPaymentInvoices: [],
+ detailPaymentInvoicesPageInfo: {},
+ detailPaymentInvoicesTotalCount: 0,
+ errorPaymentInvoices: null,
+ };
+ case 'PAYMENTINVOICE__DETAIL_PAYMENT_INVOICE_RESP':
+ return {
+ ...state,
+ fetchingDetailPaymentInvoices: false,
+ fetchedDetailPaymentInvoices: true,
+ detailPaymentInvoices: parseData(action.payload.data.detailPaymentInvoice)?.map((detailPaymentInvoice) => ({
+ ...detailPaymentInvoice,
+ id: decodeId(detailPaymentInvoice.id),
+ reconciliationStatus: getEnumValue(detailPaymentInvoice?.reconciliationStatus),
+ })),
+ detailPaymentInvoicesPageInfo: pageInfo(action.payload.data.detailPaymentInvoice),
+ detailPaymentInvoicesTotalCount: action.payload.data.detailPaymentInvoice?.totalCount,
+ errorDetailPaymentInvoices: formatGraphQLError(action.payload),
+ };
+ case 'PAYMENTINVOICE__DETAIL_PAYMENT_INVOICE_ERR':
+ return {
+ ...state,
+ fetchingDetailPaymentInvoices: false,
+ errorDetailPaymentInvoices: formatServerError(action.payload),
+ };
+
case 'PAYMENT_MUTATION_REQ':
return dispatchMutationReq(state, action)
case 'PAYMENT_MUTATION_ERR':
diff --git a/src/translations/en.json b/src/translations/en.json
index 1a98056..1826309 100644
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -54,5 +54,65 @@
"payment.receivedAmount_Lte": "Received amount under",
"payment.showHistory": "Show historical values",
"payment.UpdatePayment.mutationLabel": "Update payment",
- "payment.showReconciledOnly": "Show reconciled only"
+ "payment.showReconciledOnly": "Show reconciled only",
+ "paymentInvoices": {
+ "label": "Payments",
+ "searcherResultsTitle": "{paymentInvoicesTotalCount} Payments Found"
+ },
+ "paymentInvoice": {
+ "reconciliationStatus": {
+ "label": "Reconciliation Status",
+ "NOT_RECONCILIATED": "Not reconciliated",
+ "RECONCILIATED": "Reconciliated",
+ "REFUNDED": "Refunded",
+ "CANCELLED": "Cancelled"
+ },
+ "status": {
+ "label": "Status",
+ "REJECTED": "Rejected",
+ "ACCEPTED": "Accepted",
+ "REFUNDED": "Refunded",
+ "CANCELLED": "Cancelled"
+ },
+ "codeExt":"Code",
+ "label": "Label",
+ "codeTp": "Code Thirdparty",
+ "codeReceipt": "Receipt Number",
+ "fees": "Fees",
+ "amountReceived": "Amount Received",
+ "datePayment": "Payment Date",
+ "paymentOrigin": "Payment Origin",
+ "payerRef": "Payer Reference",
+ "payerName": "Payer Name",
+ "create": {
+ "label": "Create new Payment",
+ "mutationLabel": "Create Payment {paymentInvoiceLabel} for {code}"
+ },
+ "update": {
+ "label": "Update Payment",
+ "mutationLabel":"Update Payment {paymentInvoiceLabel} of {code}"
+ },
+ "delete": {
+ "confirm": {
+ "title": "Delete {paymentInvoiceLabel}?",
+ "message": "Deleting data does not mean erasing it from openIMIS database. The data will only be deactivated from the viewed list."
+ },
+ "mutationLabel": "Delete Payment {paymentInvoiceLabel} of {code}"
+ }
+ },
+ "detailPaymentInvoice": {
+ "status": {
+ "label": "Status",
+ "REJECTED": "Rejected",
+ "ACCEPTED": "Accepted",
+ "REFUNDED": "Refunded",
+ "CANCELLED": "Cancelled"
+ },
+ "fees": "Fees",
+ "amount": "Amount",
+ "reconciliationId": "Reconciliation Id",
+ "reconciliationDate": "Reconciliation Date"
+ },
+ "emptyLabel": " ",
+ "any": "Any"
}
diff --git a/src/utils/enum.js b/src/utils/enum.js
new file mode 100644
index 0000000..ed66c99
--- /dev/null
+++ b/src/utils/enum.js
@@ -0,0 +1,3 @@
+import { ENUM_PREFIX_LENGTH } from "../constants";
+
+export const getEnumValue = (enumElement) => enumElement?.substring(ENUM_PREFIX_LENGTH);
diff --git a/src/utils/styles.js b/src/utils/styles.js
new file mode 100644
index 0000000..179226d
--- /dev/null
+++ b/src/utils/styles.js
@@ -0,0 +1,24 @@
+export const defaultPageStyles = (theme) => ({
+ page: theme.page,
+ });
+
+export const defaultFilterStyles = (theme) => ({
+ form: {
+ padding: 0,
+ },
+ item: {
+ padding: theme.spacing(1),
+ },
+});
+
+export const defaultHeadPanelStyles = (theme) => ({
+ tableTitle: theme.table.title,
+ item: theme.paper.item,
+ fullHeight: {
+ height: "100%",
+ },
+});
+
+export const defaultDialogStyles = (theme) => ({
+ item: theme.paper.item,
+});