diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java index 055a4bd..b11945e 100644 --- a/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java @@ -26,6 +26,7 @@ import lombok.extern.slf4j.Slf4j; import javax.swing.*; import java.awt.*; +import java.util.ArrayList; @Slf4j public class PaymentGatewayPaymentSense implements PaymentGateway { @@ -34,13 +35,26 @@ public class PaymentGatewayPaymentSense implements PaymentGateway { public PaymentGatewayPaymentSense() { } - Window getPaymentWindow() { - for (Window window : Window.getWindows()) { - if (window.isActive()) { - return window; + Window getPaymentWindow(double amount) { + if (amount > 0) { + ArrayList paymentWindows = new ArrayList<>(); + for (Window window : Window.getWindows()) { + if (window instanceof JPaymentSelectReceipt) { + paymentWindows.add((JPaymentSelectReceipt) window); + } } + return paymentWindows.get(paymentWindows.size()-1); } - return null; + else { + ArrayList paymentWindows = new ArrayList<>(); + for (Window window : Window.getWindows()) { + if (window instanceof JPaymentSelectRefund) { + paymentWindows.add((JPaymentSelectRefund) window); + } + } + return paymentWindows.get(paymentWindows.size()-1); + } + } /**