maade it so sales display points earned
This commit is contained in:
@@ -199,6 +199,12 @@ public class SaleController {
|
||||
@FXML
|
||||
private Label lblLoyaltyDiscount;
|
||||
|
||||
@FXML
|
||||
private HBox hbPointsToEarn;
|
||||
|
||||
@FXML
|
||||
private Label lblPointsToEarn;
|
||||
|
||||
private final ObservableList<SaleCartItem> cartItems = FXCollections.observableArrayList();
|
||||
private final ObservableList<SaleLineItem> saleItems = FXCollections.observableArrayList();
|
||||
private FilteredList<SaleLineItem> filteredSales;
|
||||
@@ -389,12 +395,15 @@ public class SaleController {
|
||||
|
||||
task.setOnSucceeded(event -> {
|
||||
selectedCustomerData = task.getValue();
|
||||
if (selectedCustomerData != null && selectedCustomerData.getLoyaltyPoints() != null && selectedCustomerData.getLoyaltyPoints() >= 20) {
|
||||
lblLoyaltyPoints.setText(selectedCustomerData.getLoyaltyPoints() + " pts available");
|
||||
if (selectedCustomerData != null) {
|
||||
int pts = selectedCustomerData.getLoyaltyPoints() != null ? selectedCustomerData.getLoyaltyPoints() : 0;
|
||||
lblLoyaltyPoints.setText(pts + " pts available");
|
||||
lblLoyaltyPoints.setVisible(true);
|
||||
lblLoyaltyPoints.setManaged(true);
|
||||
chkUseLoyaltyPoints.setVisible(true);
|
||||
chkUseLoyaltyPoints.setManaged(true);
|
||||
boolean canRedeem = pts >= 20;
|
||||
chkUseLoyaltyPoints.setVisible(canRedeem);
|
||||
chkUseLoyaltyPoints.setManaged(canRedeem);
|
||||
if (!canRedeem) chkUseLoyaltyPoints.setSelected(false);
|
||||
} else {
|
||||
lblLoyaltyPoints.setVisible(false);
|
||||
lblLoyaltyPoints.setManaged(false);
|
||||
@@ -701,6 +710,8 @@ public class SaleController {
|
||||
hbCouponDiscount.setManaged(false);
|
||||
hbLoyaltyDiscount.setVisible(false);
|
||||
hbLoyaltyDiscount.setManaged(false);
|
||||
hbPointsToEarn.setVisible(false);
|
||||
hbPointsToEarn.setManaged(false);
|
||||
cbCustomer.setValue(null);
|
||||
selectedCustomerData = null;
|
||||
lblLoyaltyPoints.setVisible(false);
|
||||
@@ -875,6 +886,16 @@ public class SaleController {
|
||||
}
|
||||
|
||||
lblCartTotal.setText(currency.format(Math.max(0, total.doubleValue())));
|
||||
|
||||
if (selectedCustomerData != null) {
|
||||
int pointsToEarn = (int) Math.max(0, total.doubleValue());
|
||||
lblPointsToEarn.setText("+" + pointsToEarn + " pts");
|
||||
hbPointsToEarn.setVisible(true);
|
||||
hbPointsToEarn.setManaged(true);
|
||||
} else {
|
||||
hbPointsToEarn.setVisible(false);
|
||||
hbPointsToEarn.setManaged(false);
|
||||
}
|
||||
}
|
||||
|
||||
private BigDecimal calculateCouponDiscount(BigDecimal subtotal) {
|
||||
|
||||
@@ -173,6 +173,12 @@
|
||||
<Label fx:id="lblCartTotal" text="" textFill="#2c3e50"><font><Font name="System Bold" size="16.0" /></font></Label>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="hbPointsToEarn" spacing="8.0" alignment="CENTER_LEFT" visible="false" managed="false">
|
||||
<children>
|
||||
<Label text="Points to earn:" textFill="#4ECDC4"><font><Font size="12.0" /></font></Label>
|
||||
<Label fx:id="lblPointsToEarn" text="+0 pts" textFill="#4ECDC4"><font><Font size="12.0" /></font></Label>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</VBox>
|
||||
<FlowPane hgap="8.0" prefWrapLength="220.0" vgap="8.0">
|
||||
|
||||
Reference in New Issue
Block a user