From bc799e2d79cab053d5da4b0eae6ded3dcb0b0036 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 19 Nov 2024 17:25:39 +0100 Subject: [PATCH 1/5] 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; From 76bb8821e36764d75cc15c3739c254c451c7d4e2 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Wed, 20 Nov 2024 11:16:54 +0100 Subject: [PATCH 2/5] update src/main/java/org/isf/accounting/gui/PatientBillEdit.java --- .../isf/accounting/gui/PatientBillEdit.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/isf/accounting/gui/PatientBillEdit.java b/src/main/java/org/isf/accounting/gui/PatientBillEdit.java index 4fa376a777..c9a61cfd3a 100644 --- a/src/main/java/org/isf/accounting/gui/PatientBillEdit.java +++ b/src/main/java/org/isf/accounting/gui/PatientBillEdit.java @@ -846,21 +846,21 @@ private JButton getJButtonTrashPatient() { jButtonTrashPatient.setPreferredSize(new Dimension(25, 25)); jButtonTrashPatient.setIcon(new ImageIcon("rsc/icons/remove_patient_button.png")); jButtonTrashPatient.setToolTipText(MessageBundle.getMessage("angal.newbill.removethepatientassociatedwiththisbill.tooltip")); + if (thisBill.getBillPatient() == null) { + jButtonTrashPatient.setEnabled(false); + } jButtonTrashPatient.addActionListener(actionEvent -> { - 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")); - } + // 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")); + jButtonTrashPatient.setEnabled(false); }); } return jButtonTrashPatient; @@ -898,6 +898,7 @@ private void setJButtonPickPatient() { jButtonPickPatient.setText(MessageBundle.getMessage("angal.newbill.changepatient.btn")); jButtonPickPatient.setMnemonic(MessageBundle.getMnemonic("angal.newbill.changepatient.btn.key")); jButtonPickPatient.setToolTipText(MessageBundle.getMessage("angal.newbill.changethepatientassociatedwiththisbill.tooltip")); + jButtonTrashPatient.setEnabled(true); } } From 8162a5772c1d35d34b5e3feecf3d984ec9ad5f33 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Wed, 20 Nov 2024 11:19:29 +0100 Subject: [PATCH 3/5] remove message bundle added --- bundle/language_en.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 01c4248e5e..378aa69e9a 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1197,7 +1197,6 @@ 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 From e4d4c9718ea77b50cfa4aa1005da1d4aecf77814 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Wed, 20 Nov 2024 11:23:29 +0100 Subject: [PATCH 4/5] remove space added --- src/main/java/org/isf/accounting/gui/PatientBillEdit.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/isf/accounting/gui/PatientBillEdit.java b/src/main/java/org/isf/accounting/gui/PatientBillEdit.java index c9a61cfd3a..ac3c2a3496 100644 --- a/src/main/java/org/isf/accounting/gui/PatientBillEdit.java +++ b/src/main/java/org/isf/accounting/gui/PatientBillEdit.java @@ -821,7 +821,6 @@ private JPanel getJPanelDate() { jPanelDate.add(getJCalendarDate()); jPanelDate.add(getJButtonPickPatient()); jPanelDate.add(getJButtonTrashPatient()); - if (!GeneralData.getGeneralData().getSINGLEUSER()) { jPanelDate.add(getJLabelUser()); } From 51ad6fde635ea61948b872071b864c50d7ac8dc5 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Wed, 20 Nov 2024 17:42:46 +0100 Subject: [PATCH 5/5] fix NullPointerException on edit bill --- src/main/java/org/isf/accounting/gui/PatientBillEdit.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/isf/accounting/gui/PatientBillEdit.java b/src/main/java/org/isf/accounting/gui/PatientBillEdit.java index ac3c2a3496..23349004c3 100644 --- a/src/main/java/org/isf/accounting/gui/PatientBillEdit.java +++ b/src/main/java/org/isf/accounting/gui/PatientBillEdit.java @@ -897,7 +897,9 @@ private void setJButtonPickPatient() { jButtonPickPatient.setText(MessageBundle.getMessage("angal.newbill.changepatient.btn")); jButtonPickPatient.setMnemonic(MessageBundle.getMnemonic("angal.newbill.changepatient.btn.key")); jButtonPickPatient.setToolTipText(MessageBundle.getMessage("angal.newbill.changethepatientassociatedwiththisbill.tooltip")); - jButtonTrashPatient.setEnabled(true); + if (jButtonTrashPatient != null) { + jButtonTrashPatient.setEnabled(true); + } } }