Prefill refund dialog
This commit is contained in:
@@ -51,4 +51,11 @@ public class SaleItemResponse {
|
||||
public void setUnitPrice(BigDecimal unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getLineTotal() {
|
||||
if (unitPrice == null || quantity == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return unitPrice.multiply(BigDecimal.valueOf(quantity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,6 +371,7 @@ public class SaleController {
|
||||
|
||||
private void openRefundDialog() {
|
||||
try {
|
||||
SaleLineItem selectedSale = tvSales.getSelectionModel().getSelectedItem();
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource(
|
||||
"/org/example/petshopdesktop/dialogviews/refund-dialog-view.fxml"));
|
||||
Stage dialog = new Stage();
|
||||
@@ -378,6 +379,10 @@ public class SaleController {
|
||||
dialog.initModality(Modality.APPLICATION_MODAL);
|
||||
dialog.setTitle("Process Refund");
|
||||
dialog.setScene(new Scene(loader.load()));
|
||||
if (selectedSale != null) {
|
||||
loader.<org.example.petshopdesktop.controllers.dialogcontrollers.RefundDialogController>getController()
|
||||
.prefillSale((long) selectedSale.getSaleId());
|
||||
}
|
||||
dialog.setResizable(false);
|
||||
dialog.showAndWait();
|
||||
|
||||
|
||||
@@ -114,6 +114,18 @@ public class RefundDialogController {
|
||||
|
||||
@FXML
|
||||
void btnLoadSaleClicked(ActionEvent event) {
|
||||
loadSale();
|
||||
}
|
||||
|
||||
public void prefillSale(Long saleId) {
|
||||
if (saleId == null) {
|
||||
return;
|
||||
}
|
||||
txtSaleId.setText(String.valueOf(saleId));
|
||||
loadSale();
|
||||
}
|
||||
|
||||
private void loadSale() {
|
||||
String saleIdText = txtSaleId.getText().trim();
|
||||
if (saleIdText.isEmpty()) {
|
||||
showError("Load Sale", "Enter a transaction ID.");
|
||||
|
||||
Reference in New Issue
Block a user