From dd50c337637ed583f5fccb1061ac1045dc6ea906 Mon Sep 17 00:00:00 2001 From: ELVIS-KATO Date: Thu, 13 Nov 2025 10:29:46 +0300 Subject: [PATCH 1/5] Added a validation to disable edit when bill is posted --- src/bill-item-actions/edit-bill-item.modal.tsx | 16 ++++++++++++++++ src/billing.resource.ts | 1 + translations/en.json | 4 +++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/bill-item-actions/edit-bill-item.modal.tsx b/src/bill-item-actions/edit-bill-item.modal.tsx index 88905f9e..c9c86351 100644 --- a/src/bill-item-actions/edit-bill-item.modal.tsx +++ b/src/bill-item-actions/edit-bill-item.modal.tsx @@ -86,6 +86,22 @@ const EditBillLineItemModal: React.FC = ({ bill, clo }, [quantity, price]); const onSubmit = async (data: BillLineItemForm) => { +<<<<<<< HEAD +======= + if (bill?.status === 'POSTED') { + showSnackbar({ + title: t('cannotEditPostedBilled', 'Cannot edit posted bill'), + subtitle: t( + 'postedBillCannotBeModified', + 'This bill has been modfied and it cannot be modified. Contact administrator for help', + ), + kind: 'error', + }); + return; + } + const url = `${apiBasePath}bill`; + +>>>>>>> 63c080a (Added a validation to disable edit when bill is posted) const newItem = { ...item, quantity: data.quantity, diff --git a/src/billing.resource.ts b/src/billing.resource.ts index bd46fa7a..71bdd304 100644 --- a/src/billing.resource.ts +++ b/src/billing.resource.ts @@ -22,6 +22,7 @@ import type { export const mapBillProperties = (bill: PatientInvoice): MappedBill => { const activeLineItems = bill?.lineItems?.filter((item) => !item.voided) || []; + const isSpecialStatus = bill.status === 'POSTED'; return { id: bill?.id, diff --git a/translations/en.json b/translations/en.json index 1e1267f8..c03985af 100644 --- a/translations/en.json +++ b/translations/en.json @@ -245,5 +245,7 @@ "uuidRequired": "UUID is required", "validationError": "Validation error", "visitTime": "Visit time", - "waiverForm": "Waiver form" + "waiverForm": "Waiver form", + "cannotEditPostedBill" : "Cannot edit a posted bill", + "postedBillCannotBeModified": "This bill has been posted and its line items cannot be modified" } From b1faf8c07fcacb653c04112627e9879804710383 Mon Sep 17 00:00:00 2001 From: ELVIS-KATO Date: Fri, 21 Nov 2025 15:49:56 +0300 Subject: [PATCH 2/5] Only pending bills can be edited --- src/bill-item-actions/edit-bill-item.modal.tsx | 16 ---------------- src/billing.resource.ts | 2 +- translations/en.json | 4 ++-- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/bill-item-actions/edit-bill-item.modal.tsx b/src/bill-item-actions/edit-bill-item.modal.tsx index c9c86351..88905f9e 100644 --- a/src/bill-item-actions/edit-bill-item.modal.tsx +++ b/src/bill-item-actions/edit-bill-item.modal.tsx @@ -86,22 +86,6 @@ const EditBillLineItemModal: React.FC = ({ bill, clo }, [quantity, price]); const onSubmit = async (data: BillLineItemForm) => { -<<<<<<< HEAD -======= - if (bill?.status === 'POSTED') { - showSnackbar({ - title: t('cannotEditPostedBilled', 'Cannot edit posted bill'), - subtitle: t( - 'postedBillCannotBeModified', - 'This bill has been modfied and it cannot be modified. Contact administrator for help', - ), - kind: 'error', - }); - return; - } - const url = `${apiBasePath}bill`; - ->>>>>>> 63c080a (Added a validation to disable edit when bill is posted) const newItem = { ...item, quantity: data.quantity, diff --git a/src/billing.resource.ts b/src/billing.resource.ts index 71bdd304..a5d6176b 100644 --- a/src/billing.resource.ts +++ b/src/billing.resource.ts @@ -22,7 +22,7 @@ import type { export const mapBillProperties = (bill: PatientInvoice): MappedBill => { const activeLineItems = bill?.lineItems?.filter((item) => !item.voided) || []; - const isSpecialStatus = bill.status === 'POSTED'; + const isSpecialStatus = bill.status === 'POSTED' || bill.status === 'PAID' || bill.status === 'ADJUSTED'; return { id: bill?.id, diff --git a/translations/en.json b/translations/en.json index c03985af..c076b57f 100644 --- a/translations/en.json +++ b/translations/en.json @@ -246,6 +246,6 @@ "validationError": "Validation error", "visitTime": "Visit time", "waiverForm": "Waiver form", - "cannotEditPostedBill" : "Cannot edit a posted bill", - "postedBillCannotBeModified": "This bill has been posted and its line items cannot be modified" + "cannotEditThisBill" : "You can not edit this bill", + "onlyPendingBillsCanBeEdited": "Only PENDING bills can be edited" } From f684d0d2bc0159a5def57189bd4bd91db9cfc8c6 Mon Sep 17 00:00:00 2001 From: ELVIS-KATO Date: Fri, 5 Dec 2025 06:37:12 +0300 Subject: [PATCH 3/5] Updated the changes requested --- src/billing.resource.ts | 1 - translations/en.json | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/billing.resource.ts b/src/billing.resource.ts index a5d6176b..bd46fa7a 100644 --- a/src/billing.resource.ts +++ b/src/billing.resource.ts @@ -22,7 +22,6 @@ 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'; return { id: bill?.id, diff --git a/translations/en.json b/translations/en.json index c076b57f..1e1267f8 100644 --- a/translations/en.json +++ b/translations/en.json @@ -245,7 +245,5 @@ "uuidRequired": "UUID is required", "validationError": "Validation error", "visitTime": "Visit time", - "waiverForm": "Waiver form", - "cannotEditThisBill" : "You can not edit this bill", - "onlyPendingBillsCanBeEdited": "Only PENDING bills can be edited" + "waiverForm": "Waiver form" } From e4a6e3a6ec031891b2c555d50052517fa458c826 Mon Sep 17 00:00:00 2001 From: NethmiRodrigo Date: Wed, 10 Dec 2025 18:08:55 +0530 Subject: [PATCH 4/5] Resolve merge conflicts --- src/invoice/invoice-table.component.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/invoice/invoice-table.component.tsx b/src/invoice/invoice-table.component.tsx index 4caebe92..8cc22cb9 100644 --- a/src/invoice/invoice-table.component.tsx +++ b/src/invoice/invoice-table.component.tsx @@ -115,7 +115,8 @@ const InvoiceTable: React.FC = ({ bill, isLoadingBill, onMuta label={t('editThisBillItem', 'Edit this bill item')} kind="ghost" tooltipPosition="left" - onClick={() => handleSelectBillItem(item)}> + onClick={() => handleSelectBillItem(item)} + disabled={bill?.status !== 'PENDING'}> @@ -124,14 +125,23 @@ const InvoiceTable: React.FC = ({ bill, isLoadingBill, onMuta label={t('deleteBillLineItem', 'Delete this bill line item')} kind="ghost" tooltipPosition="left" - onClick={() => handleDeleteLineItem(item)}> + onClick={() => handleDeleteLineItem(item)} + disabled={bill?.status !== 'PENDING'}> ), }; }) ?? [], - [filteredLineItems, bill?.receiptNumber, defaultCurrency, t, handleSelectBillItem, handleDeleteLineItem], + [ + filteredLineItems, + bill?.receiptNumber, + defaultCurrency, + t, + handleSelectBillItem, + handleDeleteLineItem, + bill?.status, + ], ); if (isLoadingBill) { From baaeb95ff6c7fcc0587b7cfa0882756ce7d3b57f Mon Sep 17 00:00:00 2001 From: NethmiRodrigo Date: Wed, 10 Dec 2025 18:15:11 +0530 Subject: [PATCH 5/5] Update unit test --- src/invoice/invoice-table.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/invoice/invoice-table.test.tsx b/src/invoice/invoice-table.test.tsx index 70e3b9b1..6490ee4e 100644 --- a/src/invoice/invoice-table.test.tsx +++ b/src/invoice/invoice-table.test.tsx @@ -163,7 +163,7 @@ describe('InvoiceTable', () => { it('should open edit modal when edit button is clicked', async () => { const user = userEvent.setup(); - render(); + render(); const editButton = screen.getByTestId('edit-button-1'); await user.click(editButton); @@ -172,7 +172,7 @@ describe('InvoiceTable', () => { expect(mockShowModal).toHaveBeenCalledWith( 'edit-bill-line-item-modal', expect.objectContaining({ - bill: defaultBill, + bill: { ...defaultBill, status: 'PENDING' }, item: expect.objectContaining({ uuid: '1' }), onMutate: mockOnMutate, }),