Skip to content

Commit

Permalink
Merge pull request #21 from openimis/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
xgill authored Aug 6, 2020
2 parents 07009e7 + 0cb0a56 commit 095734e
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 @@ -214,5 +214,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 095734e

Please sign in to comment.