diff --git a/src/components/BillPaymentsFilter.js b/src/components/BillPaymentsFilter.js index 94b825e..f53877e 100644 --- a/src/components/BillPaymentsFilter.js +++ b/src/components/BillPaymentsFilter.js @@ -5,9 +5,8 @@ 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 { withModulesManager, TextInput, NumberInput, PublishedComponent } from "@openimis/fe-core"; import { CONTAINS_LOOKUP, DEFUALT_DEBOUNCE_TIME, STARTS_WITH_LOOKUP } from "../constants"; -import PaymentInvoiceStatusPicker from "../pickers/PaymentInvoiceStatusPicker"; const styles = (theme) => ({ form: { @@ -18,7 +17,7 @@ const styles = (theme) => ({ }, }); -const BillPaymentsFilter = ({ intl, classes, filters, onChangeFilters }) => { +const BillPaymentsFilter = ({ classes, filters, onChangeFilters }) => { const debouncedOnChangeFilters = _debounce(onChangeFilters, DEFUALT_DEBOUNCE_TIME); const filterValue = (filterName) => filters?.[filterName]?.value; @@ -57,27 +56,10 @@ const BillPaymentsFilter = ({ intl, classes, filters, onChangeFilters }) => { return ( - - - onChangeFilters([ - { - id: "reconciliationStatus", - value: value, - filter: `reconciliationStatus: "${value}"`, - }, - ]) - } - /> - @@ -85,7 +67,7 @@ const BillPaymentsFilter = ({ intl, classes, filters, onChangeFilters }) => { @@ -93,7 +75,7 @@ const BillPaymentsFilter = ({ intl, classes, filters, onChangeFilters }) => { @@ -101,7 +83,7 @@ const BillPaymentsFilter = ({ intl, classes, filters, onChangeFilters }) => { @@ -109,26 +91,42 @@ const BillPaymentsFilter = ({ intl, classes, filters, onChangeFilters }) => { + onChangeFilters([ + { + id: "fees", + value: !fee ? null : fee, + filter: fee ? `fees: "${parseFloat(fee)}"` : null, + }, + ]) + } /> + onChangeFilters([ + { + id: "amountReceived", + value: !amountReceived ? null : amountReceived, + filter: amountReceived ? `amountReceived: "${parseFloat(amountReceived)}"` : null, + }, + ]) + } /> @@ -136,19 +134,11 @@ const BillPaymentsFilter = ({ intl, classes, filters, onChangeFilters }) => { - - - ); }; diff --git a/src/components/BillPaymentsSearcher.js b/src/components/BillPaymentsSearcher.js index 38e3193..3858a69 100644 --- a/src/components/BillPaymentsSearcher.js +++ b/src/components/BillPaymentsSearcher.js @@ -1,5 +1,11 @@ import React, { useRef, useEffect, useState } from "react"; +import { bindActionCreators } from "redux"; +import { connect } from "react-redux"; import { injectIntl } from "react-intl"; + +import { IconButton, Tooltip } from "@material-ui/core"; +import DeleteIcon from "@material-ui/icons/Delete"; + import { formatMessage, formatMessageWithValues, @@ -8,20 +14,15 @@ import { withModulesManager, coreConfirm, } from "@openimis/fe-core"; -import { bindActionCreators } from "redux"; -import { connect } from "react-redux"; -import { fetchPaymentInvoices, deletePaymentInvoice } from "../actions"; +import { fetchBillPayments, deleteBillPayment } from "../actions"; import { DEFAULT_PAGE_SIZE, EMPTY_STRING, RIGHT_BILL_PAYMENT_DELETE, ROWS_PER_PAGE_OPTIONS, } from "../constants"; -import BillPaymentsFilter from "./BillPaymentsFilter"; -import PaymentInvoiceStatusPicker from "../pickers/PaymentInvoiceStatusPicker" -import DeleteIcon from "@material-ui/icons/Delete"; -import { IconButton, Tooltip } from "@material-ui/core"; import { ACTION_TYPE } from "../reducer"; +import BillPaymentsFilter from "./BillPaymentsFilter"; const BillPaymentsSearcher = ({ intl, @@ -29,38 +30,37 @@ const BillPaymentsSearcher = ({ rights, bill, setConfirmedAction, - deletePaymentInvoice, submittingMutation, mutation, coreConfirm, confirmed, - fetchPaymentInvoices, - fetchingPaymentInvoices, - fetchedPaymentInvoices, - errorPaymentInvoices, - paymentInvoices, - paymentInvoicesPageInfo, - paymentInvoicesTotalCount, + fetchBillPayments, + fetchingBillPayments, + fetchedBillPayments, + errorBillPayments, + billPayments, + billPaymentsPageInfo, + billPaymentsTotalCount, }) => { const [queryParams, setQueryParams] = useState([]); - const [paymentInvoiceToDelete, setPaymentInvoiceToDelete] = useState(null); - const [deletedPaymentInvoiceUuids, setDeletedPaymentInvoiceUuids] = useState([]); + const [billPaymentToDelete, setBillPaymentToDelete] = useState(null); + const [deletedBillPaymentUuids, setDeletedBillPaymentUuids] = useState([]); const prevSubmittingMutationRef = useRef(); - useEffect(() => paymentInvoiceToDelete && openDeletePaymentInvoiceConfirmDialog(), [paymentInvoiceToDelete]); + useEffect(() => billPaymentToDelete && openDeleteBillPaymentConfirmDialog(), [billPaymentToDelete]); useEffect(() => { - if (paymentInvoiceToDelete && confirmed) { - setDeletedPaymentInvoiceUuids([...deletedPaymentInvoiceUuids, paymentInvoiceToDelete.id]); + if (billPaymentToDelete && confirmed) { + setDeletedBillPaymentUuids([...deletedBillPaymentUuids, billPaymentToDelete.id]); } - paymentInvoiceToDelete && confirmed !== null && setPaymentInvoiceToDelete(null); + billPaymentToDelete && confirmed !== null && setBillPaymentToDelete(null); }, [confirmed]); useEffect(() => { if ( prevSubmittingMutationRef.current && !submittingMutation && - [ACTION_TYPE.CREATE_PAYMENT_INVOICE_WITH_DETAIL, ACTION_TYPE.UPDATE_BILL_PAYMENT].includes(mutation?.actionType) + [ACTION_TYPE.CREATE_BILL_PAYMENT, ACTION_TYPE.UPDATE_BILL_PAYMENT].includes(mutation?.actionType) ) { refetch(); } @@ -70,28 +70,28 @@ const BillPaymentsSearcher = ({ prevSubmittingMutationRef.current = submittingMutation; }); - const deletePaymentInvoiceCallback = () => - deletePaymentInvoice( - paymentInvoiceToDelete, - formatMessageWithValues(intl, "invoice", "paymentInvoice.delete.mutationLabel", { - paymentInvoiceLabel: paymentInvoiceToDelete?.label, - code: bill?.code, + const deleteBillPaymentCallback = () => + deleteBillPayment( + billPaymentToDelete, + formatMessageWithValues(intl, "invoice", "billPayment.delete.mutationLabel", { + billPaymentLabel: billPaymentToDelete?.label, + billCode: bill?.code, }), ); - const openDeletePaymentInvoiceConfirmDialog = () => { - setConfirmedAction(() => deletePaymentInvoiceCallback); + const openDeleteBillPaymentConfirmDialog = () => { + setConfirmedAction(() => deleteBillPaymentCallback); coreConfirm( - formatMessageWithValues(intl, "invoice", "paymentInvoice.delete.confirm.title", { - paymentInvoiceLabel: paymentInvoiceToDelete?.label, + formatMessageWithValues(intl, "invoice", "billPayment.delete.confirm.title", { + billPaymentLabel: billPaymentToDelete?.label, }), - formatMessage(intl, "invoice", "paymentInvoice.delete.confirm.message"), + formatMessage(intl, "invoice", "billPayment.delete.confirm.message"), ); }; - const onDelete = (paymentInvoice) => setPaymentInvoiceToDelete(paymentInvoice); + const onDelete = (billPayment) => setBillPaymentToDelete(billPayment); - const fetch = (params) => fetchPaymentInvoices(params); + const fetch = (params) => fetchBillPayments(params); const refetch = () => fetch(queryParams); @@ -114,41 +114,36 @@ const BillPaymentsSearcher = ({ }; const headers = () => [ - "paymentInvoice.reconciliationStatus.label", - "paymentInvoice.codeExt", - "paymentInvoice.label", - "paymentInvoice.codeTp", - "paymentInvoice.codeReceipt", - "paymentInvoice.fees", - "paymentInvoice.amountReceived", - "paymentInvoice.datePayment", - "paymentInvoice.paymentOrigin", - "paymentInvoice.payerRef", + "billPayment.codeExt", + "billPayment.label", + "billPayment.codeTp", + "billPayment.codeReceipt", + "billPayment.fees", + "billPayment.amountReceived", + "billPayment.datePayment", ]; 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) + (billPayment) => billPayment.codeExt, + (billPayment) => billPayment.label, + (billPayment) => billPayment.codeTp, + (billPayment) => billPayment.codeReceipt, + (billPayment) => billPayment.fees, + (billPayment) => billPayment.amountReceived, + (billPayment) => + billPayment.datePayment + ? formatDateFromISO(modulesManager, intl, billPayment.datePayment) : EMPTY_STRING, - (paymentInvoice) => paymentInvoice.paymentOrigin, - (paymentInvoice) => paymentInvoice.payerRef, + (billPayment) => billPayment.paymentOrigin, ]; if (rights.includes(RIGHT_BILL_PAYMENT_DELETE)) { - formatters.push((paymentInvoice) => ( + formatters.push((billPayment) => ( onDelete(paymentInvoice)} - disabled={deletedPaymentInvoiceUuids.includes(paymentInvoice.id)} + onClick={() => onDelete(billPayment)} + disabled={deletedBillPaymentUuids.includes(billPayment.id)} > @@ -159,7 +154,6 @@ const BillPaymentsSearcher = ({ }; const sorts = () => [ - ["reconciliationStatus", true], ["codeExt", true], ["label", true], ["codeTp", true], @@ -168,13 +162,12 @@ const BillPaymentsSearcher = ({ ["amountReceived", true], ["datePayment", true], ["paymentOrigin", true], - ["payerRef", true], ]; const defaultFilters = () => ({ subjectIds: { value: bill?.id, - filter: `subjectIds: ["${bill?.id}"]`, + filter: `id: "${bill?.id}"`, }, isDeleted: { value: false, @@ -182,7 +175,7 @@ const BillPaymentsSearcher = ({ }, }); - const isRowDisabled = (_, paymentInvoice) => deletedPaymentInvoiceUuids.includes(paymentInvoice.id); + const isRowDisabled = (_, billPayment) => deletedBillPaymentUuids.includes(billPayment.id); return ( !!bill?.id && ( @@ -190,13 +183,13 @@ const BillPaymentsSearcher = ({ module="bill" FilterPane={BillPaymentsFilter} fetch={fetch} - items={paymentInvoices} - itemsPageInfo={paymentInvoicesPageInfo} - fetchingItems={fetchingPaymentInvoices} - fetchedItems={fetchedPaymentInvoices} - errorItems={errorPaymentInvoices} - tableTitle={formatMessageWithValues(intl, "invoice", "paymentInvoices.searcherResultsTitle", { - paymentInvoicesTotalCount, + items={billPayments} + itemsPageInfo={billPaymentsPageInfo} + fetchingItems={fetchingBillPayments} + fetchedItems={fetchedBillPayments} + errorItems={errorBillPayments} + tableTitle={formatMessageWithValues(intl, "invoice", "billPayments.searcherResultsTitle", { + billPaymentsTotalCount, })} filtersToQueryParams={filtersToQueryParams} headers={headers} @@ -214,12 +207,12 @@ const BillPaymentsSearcher = ({ }; 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, + fetchingBillPayments: state.invoice.fetchingBillPayments, + fetchedBillPayments: state.invoice.fetchedBillPayments, + errorBillPayments: state.invoice.errorBillPayments, + billPayments: state.invoice.billPayments, + billPaymentsPageInfo: state.invoice.billPaymentsPageInfo, + billPaymentsTotalCount: state.invoice.billPaymentsTotalCount, submittingMutation: state.invoice.submittingMutation, mutation: state.invoice.mutation, confirmed: state.core.confirmed, @@ -228,8 +221,8 @@ const mapStateToProps = (state) => ({ const mapDispatchToProps = (dispatch) => { return bindActionCreators( { - fetchPaymentInvoices, - deletePaymentInvoice, + fetchBillPayments, + deleteBillPayment, coreConfirm }, dispatch, diff --git a/src/components/BillSearcher.js b/src/components/BillSearcher.js index 3adb06f..3a973c3 100644 --- a/src/components/BillSearcher.js +++ b/src/components/BillSearcher.js @@ -1,5 +1,12 @@ import React, { useState, useCallback, useEffect, useRef } from "react"; +import { bindActionCreators } from "redux"; +import { connect } from "react-redux"; import { injectIntl } from "react-intl"; + +import { IconButton, Tooltip, Button, Dialog, DialogActions, DialogTitle, DialogContent } from "@material-ui/core"; +import EditIcon from "@material-ui/icons/Edit"; +import DeleteIcon from "@material-ui/icons/Delete"; + import { withModulesManager, formatMessage, @@ -10,28 +17,20 @@ import { journalize, withHistory, historyPush, - downloadExport + downloadExport, } from "@openimis/fe-core"; -import { bindActionCreators } from "redux"; -import { connect } from "react-redux"; import { fetchBills, deleteBill, fetchBillsExport } from "../actions"; import { DEFAULT_PAGE_SIZE, ROWS_PER_PAGE_OPTIONS, EMPTY_STRING, - RIGHT_BILL_UPDATE, + RIGHT_BILL_SEARCH, RIGHT_BILL_DELETE, STATUS, } from "../constants"; import BillFilter from "./BillFilter"; import InvoiceStatusPicker from "../pickers/InvoiceStatusPicker"; import { getSubjectAndThirdpartyTypePicker } from "../util/subject-and-thirdparty-picker"; -import { IconButton, Tooltip, Button, - Dialog, - DialogActions, - DialogTitle,} from "@material-ui/core"; -import EditIcon from "@material-ui/icons/Edit"; -import DeleteIcon from "@material-ui/icons/Delete"; const BillSearcher = ({ intl, @@ -53,15 +52,13 @@ const BillSearcher = ({ billsPageInfo, billsTotalCount, billsExport, - billsExportPageInfo, - billsExportTotalCount, errorBillsExport, actions, - actionsContributionKey + actionsContributionKey, }) => { const [billToDelete, setBillToDelete] = useState(null); const [deletedBillUuids, setDeletedBillUuids] = useState([]); - const [failedExport, setFailedExport] = useState(false) + const [failedExport, setFailedExport] = useState(false); const prevSubmittingMutationRef = useRef(); useEffect(() => billToDelete && openConfirmDialog(), [billToDelete]); @@ -75,14 +72,18 @@ const BillSearcher = ({ }, [confirmed]); useEffect(() => { - setFailedExport(true) - }, [errorBillsExport]) + if (errorBillsExport) { + setFailedExport(true); + } + }, [errorBillsExport]); useEffect(() => { if (billsExport) { - downloadExport(billsExport, 'bill_export.csv')(); + downloadExport(billsExport, "bill_export.csv")(); } - }, [billsExport]) + + return setFailedExport(false); + }, [billsExport]); useEffect(() => { prevSubmittingMutationRef.current && !submittingMutation && journalize(mutation); @@ -112,7 +113,7 @@ const BillSearcher = ({ formatMessage(intl, "bill", "delete.confirm.message"), ), [billToDelete], - ); + ); const fetch = (params) => fetchBills(params); @@ -125,7 +126,7 @@ const BillSearcher = ({ "bill.amountTotal", "bill.status.label", ]; - if (rights.includes(RIGHT_BILL_UPDATE)) { + if (rights.includes(RIGHT_BILL_SEARCH)) { headers.push("emptyLabel"); } return headers; @@ -136,12 +137,11 @@ const BillSearcher = ({ (bill) => getSubjectAndThirdpartyTypePicker(modulesManager, bill.subjectTypeName, bill.subject), (bill) => getSubjectAndThirdpartyTypePicker(modulesManager, bill.thirdpartyTypeName, bill.thirdparty), (bill) => bill.code, - (bill) => - !!bill.dateBill ? formatDateFromISO(modulesManager, intl, bill.dateBill) : EMPTY_STRING, + (bill) => (!!bill.dateBill ? formatDateFromISO(modulesManager, intl, bill.dateBill) : EMPTY_STRING), (bill) => bill.amountTotal, (bill) => , ]; - if (rights.includes(RIGHT_BILL_UPDATE)) { + if (rights.includes(RIGHT_BILL_SEARCH)) { formatters.push((bill) => ( modulesManager.getRef("bill.route.bill") + "/" + bill?.id; const onDoubleClick = (bill, newTab = false) => - rights.includes(RIGHT_BILL_UPDATE) && + rights.includes(RIGHT_BILL_SEARCH) && !deletedBillUuids.includes(bill.id) && historyPush(modulesManager, history, "bill.route.bill", [bill?.id], newTab); @@ -198,74 +198,76 @@ const BillSearcher = ({ }, }); - const exportFields = () => ({ - 'id': 'ID', - 'userCreated.username': "User", - 'amount_total': "AmountTotal", - "subjectTypeName": "Subject", - 'thirdpartyTypeName': "SenderType", - 'thirdparty': "" - }) - return (
- - - {failedExport && ( - - {errorBillsExport} - - - - - )} + + {failedExport && ( + + {errorBillsExport?.message} + + {`${errorBillsExport?.code}: `} + {errorBillsExport?.detail} + + + + + + )}
); }; @@ -280,7 +282,6 @@ const mapStateToProps = (state) => ({ confirmed: state.core.confirmed, submittingMutation: state.invoice.submittingMutation, mutation: state.invoice.mutation, - fetchingBillsExport: state.invoice.fetchingBillsExport, fetchedBillsExport: state.invoice.fetchedBillsExport, billsExport: state.invoice.billsExport, @@ -302,6 +303,4 @@ const mapDispatchToProps = (dispatch) => { ); }; -export default withHistory( - withModulesManager(injectIntl(connect(mapStateToProps, mapDispatchToProps)(BillSearcher))), -); +export default withHistory(withModulesManager(injectIntl(connect(mapStateToProps, mapDispatchToProps)(BillSearcher)))); diff --git a/src/constants.js b/src/constants.js index c0d1c87..6338d51 100644 --- a/src/constants.js +++ b/src/constants.js @@ -103,6 +103,7 @@ export const THIRDPARTY_TYPE_OPTIONS_BILL = [ } ]; +export const WORKER_VOUCHER_HEAD_PANEL_CONTRIB = "workerVoucher.VoucherHeadPanel"; export const INVOICE_SUBJECT_AND_THIRDPARTY_PICKER_CONTRIBUTION_KEY = "invoice.SubjectAndThirdpartyPicker"; export const INVOICE_SUBJECT_AND_THIRDPARTY_PICKER_PROPS = { TYPE: "type", @@ -173,3 +174,7 @@ export const EMPTY_EVENT_MESSAGE = { eventType: EVENT_TYPE.MESSAGE, message: "", }; + +export const DEFAULT = { + IS_WORKER: false, +}; diff --git a/src/menus/LegalAndFinanceMainMenu.js b/src/menus/LegalAndFinanceMainMenu.js index 54d68c5..08ddf60 100644 --- a/src/menus/LegalAndFinanceMainMenu.js +++ b/src/menus/LegalAndFinanceMainMenu.js @@ -3,9 +3,15 @@ import { injectIntl } from "react-intl"; import { connect } from "react-redux"; import { DoubleArrow } from "@material-ui/icons"; import { formatMessage, MainMenuContribution, withModulesManager } from "@openimis/fe-core"; -import { LEGAL_AND_FINANCE_MAIN_MENU_CONTRIBUTION_KEY } from "../constants"; +import { + LEGAL_AND_FINANCE_MAIN_MENU_CONTRIBUTION_KEY, + RIGHT_INVOICE_SEARCH, + RIGHT_BILL_SEARCH, + RIGHT_BILL_AMEND, + RIGHT_INVOICE_AMEND, + DEFAULT, +} from "../constants"; import { withStyles } from "@material-ui/core/styles"; -import { RIGHT_INVOICE_SEARCH, RIGHT_BILL_SEARCH, RIGHT_BILL_AMEND, RIGHT_INVOICE_AMEND } from "./../constants" const DoubleArrowFlipped = withStyles({ root: { @@ -13,37 +19,52 @@ const DoubleArrowFlipped = withStyles({ }, })(DoubleArrow); - const LegalAndFinanceMainMenu = (props) => { - const entries = [] + const { modulesManager, rights, intl } = props; + const isWorker = modulesManager.getConf("fe-core", "isWorker", DEFAULT.IS_WORKER); + + const entries = []; + + if (isWorker) { + if (rights.includes(RIGHT_BILL_SEARCH || RIGHT_BILL_AMEND)) { + entries.push({ + text: formatMessage(intl, "invoice", "menu.bills"), + icon: , + route: "/bills", + }); + } - if (!!props.rights.filter((r) => r >= RIGHT_INVOICE_SEARCH && r <= RIGHT_INVOICE_AMEND).length) { + if (!entries.length) return null; + + return ; + } + + if (rights.filter((r) => r >= RIGHT_INVOICE_SEARCH && r <= RIGHT_INVOICE_AMEND).length) { // RIGHT_SEARCH is shared by HF & HQ staff) entries.push({ - text: formatMessage(props.intl, "invoice", "menu.invoices"), + text: formatMessage(intl, "invoice", "menu.invoices"), icon: , route: "/invoices", }); } - if (!!props.rights.filter((r) => r >= RIGHT_BILL_SEARCH && r <= RIGHT_BILL_AMEND).length) { + if (rights.filter((r) => r >= RIGHT_BILL_SEARCH && r <= RIGHT_BILL_AMEND).length) { // RIGHT_SEARCH is shared by HF & HQ staff) entries.push({ - text: formatMessage(props.intl, "invoice", "menu.bills"), + text: formatMessage(intl, "invoice", "menu.bills"), icon: , route: "/bills", }); } - + entries.push( - ...props.modulesManager + ...modulesManager .getContribs(LEGAL_AND_FINANCE_MAIN_MENU_CONTRIBUTION_KEY) - .filter((c) => !c.filter || c.filter(props.rights)), + .filter((c) => !c.filter || c.filter(rights)), ); + if (!entries.length) return null; - return ( - - ); + return ; }; const mapStateToProps = (state) => ({ diff --git a/src/pages/BillPage.js b/src/pages/BillPage.js index e92290e..7e100bf 100644 --- a/src/pages/BillPage.js +++ b/src/pages/BillPage.js @@ -1,4 +1,11 @@ import React, { useState, useRef, useEffect } from "react"; +import { bindActionCreators } from "redux"; +import { connect } from "react-redux"; +import { injectIntl } from "react-intl"; + +import { withTheme, withStyles } from "@material-ui/core/styles"; +import DeleteIcon from "@material-ui/icons/Delete"; + import { Form, Helmet, @@ -7,19 +14,14 @@ import { formatMessageWithValues, coreConfirm, journalize, - decodeId, + useModulesManager, } from "@openimis/fe-core"; -import { injectIntl } from "react-intl"; -import { bindActionCreators } from "redux"; -import { connect } from "react-redux"; -import { withTheme, withStyles } from "@material-ui/core/styles"; -import { RIGHT_BILL_UPDATE, STATUS } from "../constants"; import { fetchBill, deleteBill } from "../actions"; +import { STATUS, RIGHT_BILL_SEARCH, DEFAULT, WORKER_VOUCHER_HEAD_PANEL_CONTRIB } from "../constants"; import BillHeadPanel from "../components/BillHeadPanel"; -import DeleteIcon from "@material-ui/icons/Delete"; -import { getEnumValue } from "../util/enum"; import BillTabPanel from "../components/BillTabPanel"; import { ACTION_TYPE } from "../reducer"; +import { getEnumValue } from "../util/enum"; const styles = (theme) => ({ page: theme.page, @@ -40,9 +42,11 @@ const BillPage = ({ mutation, journalize, }) => { + const modulesManager = useModulesManager(); const [editedBill, setEditedBill] = useState({}); const [confirmedAction, setConfirmedAction] = useState(() => null); const prevSubmittingMutationRef = useRef(); + const isWorker = modulesManager.getConf("fe-core", "isWorker", DEFAULT.IS_WORKER); useEffect(() => { if (!!billUuid) { @@ -97,8 +101,10 @@ const BillPage = ({ }, ]; + const VoucherHeadPanel = modulesManager.getContribs(WORKER_VOUCHER_HEAD_PANEL_CONTRIB)?.[0]; + return ( - rights.includes(RIGHT_BILL_UPDATE) && ( + rights.includes(RIGHT_BILL_SEARCH) && (
({ @@ -15,7 +16,7 @@ const styles = (theme) => ({ const BILL_SEARCHER_ACTION_CONTRIBUTION_KEY = "invoice.bill.SelectionAction"; const BillsPage = (props) => { - const { intl, classes, rights } = props; + const { classes, rights } = props; const dispatch = useDispatch(); useEffect(() => { @@ -23,6 +24,7 @@ const BillsPage = (props) => { }, []); let actions = []; + return ( rights.includes(RIGHT_BILL_SEARCH) && (
diff --git a/src/pages/InvoicePage.js b/src/pages/InvoicePage.js index 94a8adf..c4e6d2f 100644 --- a/src/pages/InvoicePage.js +++ b/src/pages/InvoicePage.js @@ -125,7 +125,6 @@ const mapStateToProps = (state, props) => ({ invoice: state.invoice.invoice, errorInvoice: state.invoice.errorInvoice, policyHolders: state.policyHolder.policyHolders, - confirmed: state.core.confirmed, submittingMutation: state.invoice.submittingMutation, mutation: state.invoice.mutation, }); diff --git a/src/reducer.js b/src/reducer.js index c780699..fda17dc 100644 --- a/src/reducer.js +++ b/src/reducer.js @@ -343,8 +343,8 @@ function reducer( ...bill, id: decodeId(bill.id), status: getEnumValue(bill?.status), - subjectTypeNameLabel: (bill?.subjectTypeName).replace(/\s/g, ""), - thirdpartyTypeNameLabel: (bill?.thirdpartyTypeName).replace(/\s/g, ""), + subjectTypeNameLabel: (bill?.subjectTypeName)?.replace(/\s/g, ""), + thirdpartyTypeNameLabel: (bill?.thirdpartyTypeName)?.replace(/\s/g, ""), }))?.[0], errorBill: null, };