From bc799e2d79cab053d5da4b0eae6ded3dcb0b0036 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 19 Nov 2024 17:25:39 +0100 Subject: [PATCH] fix NullPointerexception --- bundle/language_en.properties | 1 + .../isf/accounting/gui/PatientBillEdit.java | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 378aa69e9a..01c4248e5e 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1197,6 +1197,7 @@ angal.newbill.payment.btn.key angal.newbill.paymentmadebeforebilldate.msg = Payment made before bill date. angal.newbill.paymentreceipt.btn = Payment Receipt angal.newbill.paymentreceipt.btn.key = N +angal.newbill.pleasefindpatientbeforeremotehim.msg = Please find patient first before remove him. angal.newbill.pleaseinsertanameforthepatient.msg = Please insert a name for the patient. angal.newbill.pleaseselectanitem.txt = Please select an item. angal.newbill.refund.btn = Refund diff --git a/src/main/java/org/isf/accounting/gui/PatientBillEdit.java b/src/main/java/org/isf/accounting/gui/PatientBillEdit.java index 4923780d49..4fa376a777 100644 --- a/src/main/java/org/isf/accounting/gui/PatientBillEdit.java +++ b/src/main/java/org/isf/accounting/gui/PatientBillEdit.java @@ -821,6 +821,7 @@ private JPanel getJPanelDate() { jPanelDate.add(getJCalendarDate()); jPanelDate.add(getJButtonPickPatient()); jPanelDate.add(getJButtonTrashPatient()); + if (!GeneralData.getGeneralData().getSINGLEUSER()) { jPanelDate.add(getJLabelUser()); } @@ -846,18 +847,20 @@ private JButton getJButtonTrashPatient() { jButtonTrashPatient.setIcon(new ImageIcon("rsc/icons/remove_patient_button.png")); jButtonTrashPatient.setToolTipText(MessageBundle.getMessage("angal.newbill.removethepatientassociatedwiththisbill.tooltip")); jButtonTrashPatient.addActionListener(actionEvent -> { - // BILL - thisBill.setBillPatient(null); - thisBill.setIsPatient(false); - thisBill.getBillPatient().setCode(0); - thisBill.setPatName(""); //$NON-NLS-1$ - thisBill.setAdmission(null); - // INTERFACE - jTextFieldPatient.setText(""); - jTextFieldPatient.setEditable(false); - jButtonPickPatient.setText(MessageBundle.getMessage("angal.newbill.findpatient.btn")); - jButtonPickPatient.setToolTipText(MessageBundle.getMessage("angal.newbill.associateapatientwiththisbill.tooltip")); - jButtonTrashPatient.setEnabled(false); + if (thisBill.getBillPatient() != null) { + // BILL + thisBill.setBillPatient(null); + thisBill.setIsPatient(false); + thisBill.setPatName(""); //$NON-NLS-1$ + thisBill.setAdmission(null); + // INTERFACE + jTextFieldPatient.setText(""); + jTextFieldPatient.setEditable(false); + jButtonPickPatient.setText(MessageBundle.getMessage("angal.newbill.findpatient.btn")); + jButtonPickPatient.setToolTipText(MessageBundle.getMessage("angal.newbill.associateapatientwiththisbill.tooltip")); + } else { + MessageDialog.info(null, MessageBundle.getMessage("angal.newbill.pleasefindpatientbeforeremotehim.msg")); + } }); } return jButtonTrashPatient;