Skip to content

Commit

Permalink
OM-255: adjust the bill view to moldova use case
Browse files Browse the repository at this point in the history
  • Loading branch information
olewandowski1 committed Sep 3, 2024
1 parent 3a0714a commit 87f7763
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 249 deletions.
41 changes: 20 additions & 21 deletions src/components/BillEventsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { BILL_EVENTS_TAB_VALUE, RIGHT_BILL_EVENT_SEARCH, RIGHT_BILL_EVENT_CREATE
import BillEventsSearcher from "./BillEventsSearcher";
import CreateBillEventMessageDialog from "../dialogs/BillEventMessageDialog";


const BillEventsTabLabel = ({ intl, rights, onChange, tabStyle, isSelected }) =>
rights?.includes(RIGHT_BILL_EVENT_SEARCH) && (
const BillEventsTabLabel = ({ intl, rights, onChange, tabStyle, isSelected, isWorker }) =>
rights?.includes(RIGHT_BILL_EVENT_SEARCH) &&
!isWorker && (
<Tab
onChange={onChange}
className={tabStyle(BILL_EVENTS_TAB_VALUE)}
Expand All @@ -17,24 +17,23 @@ const BillEventsTabLabel = ({ intl, rights, onChange, tabStyle, isSelected }) =>
/>
);


const BillEventsTabPanel = ({ rights, value, bill }) => (
<PublishedComponent pubRef="policyHolder.TabPanel" module="bill" index={BILL_EVENTS_TAB_VALUE} value={value}>
{rights?.includes(RIGHT_BILL_EVENT_CREATE_MESSAGE) && (
<Grid container justify="flex-end" alignItems="center" spacing={1}>
<Grid item>
<Typography>
<FormattedMessage module="invoice" id="billEventMessage.create.label" />
</Typography>
</Grid>
<Grid item>
<CreateBillEventMessageDialog bill={bill} />
const BillEventsTabPanel = ({ isWorker, rights, value, bill }) =>
!isWorker && (
<PublishedComponent pubRef="policyHolder.TabPanel" module="bill" index={BILL_EVENTS_TAB_VALUE} value={value}>
{rights?.includes(RIGHT_BILL_EVENT_CREATE_MESSAGE) && (
<Grid container justify="flex-end" alignItems="center" spacing={1}>
<Grid item>
<Typography>
<FormattedMessage module="invoice" id="billEventMessage.create.label" />
</Typography>
</Grid>
<Grid item>
<CreateBillEventMessageDialog bill={bill} />
</Grid>
</Grid>
</Grid>
)}
<BillEventsSearcher bill={bill} />
</PublishedComponent>
);

)}
<BillEventsSearcher bill={bill} />
</PublishedComponent>
);

export { BillEventsTabLabel, BillEventsTabPanel };
66 changes: 37 additions & 29 deletions src/components/BillFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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, DEFUALT_DEBOUNCE_TIME } from "../constants";
import { CONTAINS_LOOKUP, DEFAULT, DEFUALT_DEBOUNCE_TIME } from "../constants";
import InvoiceStatusPicker from "../pickers/InvoiceStatusPicker";
import ThirdPartyTypePickerBill from "../pickers/ThirdPartyTypePickerBill";
import SubjectTypePickerBill from "../pickers/SubjectTypePickerBill";
Expand All @@ -20,7 +20,9 @@ const styles = (theme) => ({
},
});

const BillFilter = ({ intl, classes, filters, onChangeFilters }) => {
const BillFilter = ({ intl, classes, filters, onChangeFilters, modulesManager }) => {
const isWorker = modulesManager.getConf("fe-core", "isWorker", DEFAULT.IS_WORKER);

const debouncedOnChangeFilters = _debounce(onChangeFilters, DEFUALT_DEBOUNCE_TIME);

const filterValue = (filterName) => filters?.[filterName]?.value;
Expand Down Expand Up @@ -60,24 +62,28 @@ const BillFilter = ({ intl, classes, filters, onChangeFilters }) => {

return (
<Grid container className={classes.form}>
<Grid item xs={2} className={classes.item}>
<SubjectTypePickerBill
label="subject"
withNull
nullLabel={formatMessage(intl, "bill", "any")}
value={filterValue("subjectType")}
onChange={onChangeStringFilter("subjectType")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<ThirdPartyTypePickerBill
label="thirdparty"
withNull
nullLabel={formatMessage(intl, "bill", "any")}
value={filterValue("thirdpartyType")}
onChange={onChangeStringFilter("thirdpartyType")}
/>
</Grid>
{!isWorker && (
<>
<Grid item xs={2} className={classes.item}>
<SubjectTypePickerBill
label="subject"
withNull
nullLabel={formatMessage(intl, "bill", "any")}
value={filterValue("subjectType")}
onChange={onChangeStringFilter("subjectType")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<ThirdPartyTypePickerBill
label="thirdparty"
withNull
nullLabel={formatMessage(intl, "bill", "any")}
value={filterValue("thirdpartyType")}
onChange={onChangeStringFilter("thirdpartyType")}
/>
</Grid>
</>
)}
<Grid item xs={2} className={classes.item}>
<TextInput
module="bill"
Expand Down Expand Up @@ -121,15 +127,17 @@ const BillFilter = ({ intl, classes, filters, onChangeFilters }) => {
}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
label="amountTotal"
min={0}
value={filterValue("amountTotal")}
onChange={onChangeDecimalFilter("amountTotal")}
/>
</Grid>
{!isWorker && (
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
label="amountTotal"
min={0}
value={filterValue("amountTotal")}
onChange={onChangeDecimalFilter("amountTotal")}
/>
</Grid>
)}
</Grid>
);
};
Expand Down
100 changes: 54 additions & 46 deletions src/components/BillLineItemsFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import _debounce from "lodash/debounce";
import { Grid } from "@material-ui/core";
import { withTheme, withStyles } from "@material-ui/core/styles";

import { TextInput, NumberInput } from "@openimis/fe-core";
import { CONTAINS_LOOKUP, DEFUALT_DEBOUNCE_TIME } from "../constants";
import { TextInput, NumberInput, useModulesManager } from "@openimis/fe-core";
import { CONTAINS_LOOKUP, DEFAULT, DEFUALT_DEBOUNCE_TIME } from "../constants";

const styles = (theme) => ({
form: {
Expand All @@ -17,6 +17,10 @@ const styles = (theme) => ({
});

const BillLineItemsFilter = ({ classes, filters, onChangeFilters }) => {
const modulesManager = useModulesManager();

const isWorker = modulesManager.getConf("fe-core", "isWorker", DEFAULT.IS_WORKER);

const debouncedOnChangeFilters = _debounce(onChangeFilters, DEFUALT_DEBOUNCE_TIME);

const filterValue = (filterName) => filters?.[filterName]?.value;
Expand Down Expand Up @@ -71,14 +75,6 @@ const BillLineItemsFilter = ({ classes, filters, onChangeFilters }) => {
onChange={onChangeStringFilter("description", CONTAINS_LOOKUP)}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<TextInput
module="bill"
label="billItem.ledgerAccount"
value={filterTextFieldValue("ledgerAccount")}
onChange={onChangeStringFilter("ledgerAccount", CONTAINS_LOOKUP)}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
Expand All @@ -88,33 +84,6 @@ const BillLineItemsFilter = ({ classes, filters, onChangeFilters }) => {
onChange={onChangeFilter("quantity")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
label="billItem.unitPrice"
min={0}
value={filterValue("unitPrice")}
onChange={onChangeFilter("unitPrice")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
label="billItem.discount"
min={0}
value={filterValue("discount")}
onChange={onChangeFilter("discount")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
label="billItem.deduction"
min={0}
value={filterValue("deduction")}
onChange={onChangeFilter("deduction")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
Expand All @@ -124,15 +93,54 @@ const BillLineItemsFilter = ({ classes, filters, onChangeFilters }) => {
onChange={onChangeFilter("amountTotal")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
label="billItem.amountNet"
min={0}
value={filterValue("amountNet")}
onChange={onChangeFilter("amountNet")}
/>
</Grid>
{!isWorker && (
<>
<Grid item xs={2} className={classes.item}>
<TextInput
module="bill"
label="billItem.ledgerAccount"
value={filterTextFieldValue("ledgerAccount")}
onChange={onChangeStringFilter("ledgerAccount", CONTAINS_LOOKUP)}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
label="billItem.unitPrice"
min={0}
value={filterValue("unitPrice")}
onChange={onChangeFilter("unitPrice")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
label="billItem.discount"
min={0}
value={filterValue("discount")}
onChange={onChangeFilter("discount")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
label="billItem.deduction"
min={0}
value={filterValue("deduction")}
onChange={onChangeFilter("deduction")}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<NumberInput
module="bill"
label="billItem.amountNet"
min={0}
value={filterValue("amountNet")}
onChange={onChangeFilter("amountNet")}
/>
</Grid>
</>
)}
</Grid>
);
};
Expand Down
Loading

0 comments on commit 87f7763

Please sign in to comment.