Skip to content

Commit

Permalink
Merge pull request #20 from openimis/OMT-232_pricelist_filtering
Browse files Browse the repository at this point in the history
Omt 232 pricelist filtering
  • Loading branch information
xgill authored Aug 6, 2020
2 parents 0355c81 + 7a6d853 commit 0cb0a56
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
25 changes: 15 additions & 10 deletions src/components/ClaimChildPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { connect } from "react-redux";
import { injectIntl } from 'react-intl';
import { withTheme, withStyles } from "@material-ui/core/styles";
import {
formatAmount, formatMessage, formatMessageWithValues, NumberInput, Table,
PublishedComponent, AmountInput, TextInput, decodeId, withModulesManager
formatAmount, formatMessage, formatMessageWithValues, decodeId, withModulesManager,
NumberInput, Table, PublishedComponent, AmountInput, TextInput, Error
} from "@openimis/fe-core";
import { IconButton, Paper } from "@material-ui/core";
import DeleteIcon from "@material-ui/icons/Delete";
Expand Down Expand Up @@ -81,14 +81,8 @@ class ClaimChildPanel extends Component {
}

_price = (v) => {
let id = decodeId(v.id);
if (!!this.props.edited.healthFacility &&
!!this.props.edited.healthFacility[`${this.props.type}sPricelist`] &&
!!this.props[`${this.props.type}sPricelists`][this.props.edited.healthFacility[`${this.props.type}sPricelist`].id][id]
) {
return this.props[`${this.props.type}sPricelists`][this.props.edited.healthFacility[`${this.props.type}sPricelist`].id][id]
}
return v.price;
let id = decodeId(v.id)
return this.props[`${this.props.type}sPricelists`][this.props.edited.healthFacility[`${this.props.type}sPricelist`].id][id] || v.price;
}

_onChangeItem = (idx, attr, v) => {
Expand Down Expand Up @@ -134,6 +128,16 @@ class ClaimChildPanel extends Component {
render() {
const { intl, classes, edited, type, picker, forReview, fetchingPricelist, readOnly = false } = this.props;
if (!edited) return null;
if (
!this.props.edited.healthFacility ||
!this.props.edited.healthFacility[`${this.props.type}sPricelist`] ||
!this.props.edited.healthFacility[`${this.props.type}sPricelist`].id) {
return (
<Paper className={classes.paper}>
<Error error={{ message: formatMessage(intl, "claim", `${this.props.type}sPricelist.missing`) }} />
</Paper>
)
}
const totalClaimed = _.round(this.state.data.reduce(
(sum, r) => sum + claimedAmount(r), 0),
2
Expand All @@ -159,6 +163,7 @@ class ClaimChildPanel extends Component {
(i, idx) => <PublishedComponent
readOnly={!!forReview || readOnly}
pubRef={picker} withLabel={false} value={i[type]}
filteredOnPriceList={edited.healthFacility[`${this.props.type}sPricelist`].id}
refDate={edited.dateClaimed}
onChange={v => this._onChangeItem(idx, type, v)}
/>,
Expand Down
4 changes: 3 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,7 @@
"claim.deleteClaimAttachment.confirm.message": "Are you sure you want to delete claim attachment {file}?",
"claim.ClaimAttachment.delete.mutationLabel": "Deleted attachment {file} from claim {code}",
"claim.ClaimAttachment.create.mutationLabel": "Added attachment {file} to claim {code}",
"claim.ClaimAttachment.update.mutationLabel": "Updated attachment {file} of claim {code}"
"claim.ClaimAttachment.update.mutationLabel": "Updated attachment {file} of claim {code}",
"claim.servicesPricelist.missing": "No services prices list registered for health facility",
"claim.itemsPricelist.missing": "No items prices list registered for health facility"
}

0 comments on commit 0cb0a56

Please sign in to comment.