-
Notifications
You must be signed in to change notification settings - Fork 52
(fix) O3-5200 Add validation so that once a bill has been "posted" its line items cannot be modified #516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
(fix) O3-5200 Add validation so that once a bill has been "posted" its line items cannot be modified #516
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,9 +21,11 @@ import type { | |
|
|
||
| export const mapBillProperties = (bill: PatientInvoice): MappedBill => { | ||
| const activeLineItems = bill?.lineItems?.filter((item) => !item.voided) || []; | ||
| const isSpecialStatus = bill.status === 'POSTED' || bill.status === 'PAID' || bill.status === 'ADJUSTED'; | ||
|
|
||
| const status = | ||
| activeLineItems.length > 0 | ||
| const status = isSpecialStatus | ||
| ? bill.status | ||
| : activeLineItems.length > 0 | ||
|
||
| ? activeLineItems.some((item) => item.paymentStatus === 'PENDING') | ||
| ? 'PENDING' | ||
| : 'PAID' | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -85,6 +85,7 @@ const InvoiceTable: React.FC<InvoiceTableProps> = ({ bill, isLoadingBill }) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const tableRows: Array<typeof DataTableRow> = useMemo( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| () => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filteredLineItems?.map((item, index) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const canEditBill = bill?.status === 'PENDING'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| no: `${index + 1}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: `${item.uuid}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -96,20 +97,32 @@ const InvoiceTable: React.FC<InvoiceTableProps> = ({ bill, isLoadingBill }) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| total: convertToCurrency(item.price * item.quantity, defaultCurrency), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| actionButton: ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data-testid={`edit-button-${item.uuid}`} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| renderIcon={Edit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hasIconOnly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kind="ghost" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| iconDescription={t('editThisBillItem', 'Edit this bill item')} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tooltipPosition="left" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => handleSelectBillItem(item)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {canEditBill ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data-testid={`edit-button-${item.uuid}`} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| renderIcon={Edit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hasIconOnly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kind="ghost" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| iconDescription={t('editThisBillItem', 'Edit this bill item')} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tooltipPosition="left" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => handleSelectBillItem(item)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data-tested={`edit-button-${item.uuid}`} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| renderIcon={Edit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hasIconOnly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kind="ghost" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| iconDescription={t('cannotEditThisBill', 'You can not edit this bill')} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tooltipPosition="left" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {canEditBill ? ( | |
| <Button | |
| data-testid={`edit-button-${item.uuid}`} | |
| renderIcon={Edit} | |
| hasIconOnly | |
| kind="ghost" | |
| iconDescription={t('editThisBillItem', 'Edit this bill item')} | |
| tooltipPosition="left" | |
| onClick={() => handleSelectBillItem(item)} | |
| /> | |
| ) : ( | |
| <Button | |
| data-tested={`edit-button-${item.uuid}`} | |
| renderIcon={Edit} | |
| hasIconOnly | |
| kind="ghost" | |
| disabled | |
| iconDescription={t('cannotEditThisBill', 'You can not edit this bill')} | |
| tooltipPosition="left" | |
| /> | |
| )} | |
| <Button | |
| data-testid={`edit-button-${item.uuid}`} | |
| renderIcon={Edit} | |
| hasIconOnly | |
| kind=“ghost” | |
| iconDescription={t('editThisBillItem', 'Edit this bill item’)} | |
| tooltipPosition=“left” | |
| onClick={() => handleSelectBillItem(item)} | |
| disabled={bill?.status !== ‘PENDING’} | |
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think this is the proper place to trigger a snackbar. I don’t think we need to add a safeguard in this modal at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok let me have it removed