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