Skip to content

Commit

Permalink
CM-319: Adjust payment submodule from Insurees for PaymentLayer payme…
Browse files Browse the repository at this point in the history
…nts (#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
  • Loading branch information
sniedzielski authored Sep 21, 2023
1 parent 860688c commit c9543cc
Show file tree
Hide file tree
Showing 11 changed files with 695 additions and 2 deletions.
88 changes: 88 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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,
},
);
}
156 changes: 156 additions & 0 deletions src/components/PaymentInvoiceFilter.js
Original file line number Diff line number Diff line change
@@ -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 (
<Grid container className={classes.form}>
<Grid item xs={2} className={classes.item}>
<PaymentInvoiceStatusPicker
label="paymentInvoice.reconciliationStatus.label"
withNull
nullLabel={formatMessage(intl, "payment", "any")}
value={filterValue("reconciliationStatus")}
onChange={(value) =>
onChangeFilters([
{
id: "reconciliationStatus",
value: value,
filter: `reconciliationStatus: "${value}"`,
},
])
}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<TextInput
module="payment"
label="paymentInvoice.codeExt"
value={filterTextFieldValue("codeExt")}
onChange={onChangeStringFilter("codeExt", CONTAINS_LOOKUP)}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<TextInput
module="payment"
label="paymentInvoice.label"
value={filterTextFieldValue("label")}
onChange={onChangeStringFilter("label", STARTS_WITH_LOOKUP)}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<TextInput
module="payment"
label="paymentInvoice.codeTp"
value={filterTextFieldValue("codeTp")}
onChange={onChangeStringFilter("codeTp", CONTAINS_LOOKUP)}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<TextInput
module="payment"
label="paymentInvoice.codeReceipt"
value={filterTextFieldValue("codeReceipt")}
onChange={onChangeStringFilter("codeReceipt", CONTAINS_LOOKUP)}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="payment"
label="paymentInvoice.fees"
min={0}
value={filterValue("fees")}
onChange={onChangeFilter("fees")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="payment"
label="paymentInvoice.amountReceived"
min={0}
value={filterValue("amountReceived")}
onChange={onChangeFilter("amountReceived")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<PublishedComponent
pubRef="core.DatePicker"
module="payment"
label="paymentInvoice.datePayment"
value={filterValue("datePayment")}
onChange={onChangeStringFilter("datePayment")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<TextInput
module="payment"
label="paymentInvoice.paymentOrigin"
value={filterTextFieldValue("paymentOrigin")}
onChange={onChangeStringFilter("paymentOrigin", CONTAINS_LOOKUP)}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<TextInput
module="payment"
label="paymentInvoice.payerRef"
value={filterTextFieldValue("payerRef")}
onChange={onChangeStringFilter("payerRef", CONTAINS_LOOKUP)}
/>
</Grid>
</Grid>
);
};

export default withModulesManager(injectIntl(withTheme(withStyles(styles)(PaymentInvoiceFilter))));
Loading

0 comments on commit c9543cc

Please sign in to comment.