Skip to content
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

OP-1363 | Fix NullPointerexception #2089

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
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
1 change: 1 addition & 0 deletions bundle/language_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 the patient first before trying to remove him.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "him"/"her" is not very professional here, also I don't think the suggestion make sense (no one wants to find a record in order to suddenly remove it).

Why we don't make just the button doing nothing if patient is null?
Also, we can disable the button when no patient is selected

angal.newbill.pleaseinsertanameforthepatient.msg = Please insert a name for the patient.
angal.newbill.pleaseselectanitem.txt = Please select an item.
angal.newbill.refund.btn = Refund
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/org/isf/accounting/gui/PatientBillEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ private JPanel getJPanelDate() {
jPanelDate.add(getJCalendarDate());
jPanelDate.add(getJButtonPickPatient());
jPanelDate.add(getJButtonTrashPatient());

if (!GeneralData.getGeneralData().getSINGLEUSER()) {
jPanelDate.add(getJLabelUser());
}
Expand All @@ -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("");
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, "angal.newbill.pleasefindpatientbeforeremotehim.msg");
}
});
}
return jButtonTrashPatient;
Expand Down