Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/bill-item-actions/edit-bill-item.modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ const EditBillLineItemModal: React.FC<EditBillLineItemModalProps> = ({ bill, clo
}, [quantity, price]);

const onSubmit = async (data: BillLineItemForm) => {
// if (bill?.status === 'PENDING') {
// showSnackbar({
// title: t('cannotEditThisBill', 'You can not edit this bill'),
// subtitle: t('onlyPendingBillsCanBeEdited', 'Only pending bills can be edited'),
// kind: 'error',
// });
// return;
// }
const url = `${apiBasePath}bill`;

const newItem = {
Expand Down
6 changes: 3 additions & 3 deletions src/billing.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import type {

export const mapBillProperties = (bill: PatientInvoice): MappedBill => {
const activeLineItems = bill?.lineItems?.filter((item) => !item.voided) || [];

const status =
activeLineItems.length > 0
const status =
activeLineItems.length > 0
? activeLineItems.some((item) => item.paymentStatus === 'PENDING')
? 'PENDING'
: 'PAID'
Expand Down
22 changes: 12 additions & 10 deletions src/invoice/invoice-table.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand All @@ -96,20 +97,21 @@ 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)}
/>
<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'}
/>
</span>
),
};
}) ?? [],
[filteredLineItems, bill?.receiptNumber, defaultCurrency, t, handleSelectBillItem],
[filteredLineItems, bill?.receiptNumber, defaultCurrency, t, handleSelectBillItem, bill?.status],
);

if (isLoadingBill) {
Expand Down