diff --git a/src/main/java/id/amigogroup/posterminal/FormUtamaController.java b/src/main/java/id/amigogroup/posterminal/FormUtamaController.java index 5bcec0c..c0300a6 100644 --- a/src/main/java/id/amigogroup/posterminal/FormUtamaController.java +++ b/src/main/java/id/amigogroup/posterminal/FormUtamaController.java @@ -72,6 +72,8 @@ public class FormUtamaController implements Initializable { @FXML private Label lblMemberNonMember; @FXML + private Label lblKodePelanggan; + @FXML private Label lblNamaPelanggan; @FXML private Label lblTglLahirPelanggan; @@ -96,11 +98,11 @@ public class FormUtamaController implements Initializable { */ @Override public void initialize(URL url, ResourceBundle rb) { - //Kode Nur Indah Suciati (00334), Kode Wuryaningsih/RT (010004) + //Kode Sri Sumarmi (i140411), Nur Indah Suciati (00334), Kode Wuryaningsih/RT (010004) updateLabelMemberNonMember(); Platform.runLater(() -> { - posRx.getPelangganByKodeMember("00334").subscribe(pelangganObserver); + posRx.getPelangganByKodeMember("i140411").subscribe(pelangganObserver); }); if (SystemValue.karyawanLogin != null) { @@ -116,7 +118,7 @@ public class FormUtamaController implements Initializable { jumlahNota = 3; btnTunai1Static.setOnAction((event) -> { - posRx.getPelangganByKodeMember("010004").subscribe(pelangganObserver); +// posRx.getPelangganByKodeMember("010004").subscribe(pelangganObserver); setContent(loadNota("", FormConstanta.TRANSAKSI_TUNAI)); updateSelectedNota(event); tipeNotaState = Fucout.TIPE_NOTA_TUNAI; @@ -140,6 +142,7 @@ public class FormUtamaController implements Initializable { alertUltah.initOwner(bpMain.getScene().getWindow()); alertUltah.show(); } + lblKodePelanggan.setText(Fucout.getTextColon(p.getAlias())); lblNamaPelanggan.setText(Fucout.getTextColon(p.getNama())); lblTglLahirPelanggan.setText(Fucout.getTextColon(Fucout.formatTanggal(p.getTglLahir()))); lblNoTelpPelanggan.setText(Fucout.getTextColon( diff --git a/src/main/java/id/amigogroup/posterminal/bayar/BayarContent.java b/src/main/java/id/amigogroup/posterminal/bayar/BayarContent.java new file mode 100644 index 0000000..9a7b78d --- /dev/null +++ b/src/main/java/id/amigogroup/posterminal/bayar/BayarContent.java @@ -0,0 +1,236 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package id.amigogroup.posterminal.bayar; + +import javafx.scene.Node; + +/** + * + * @author ronal + */ +public class BayarContent { + + private Node nodeTunai; + private int bayarTunai; + private Node nodeKartu; + private int bayarKartu; + private Node nodePromo; + private int bayarPromo; + private Node nodeRetur; + private int bayarRetur; + private Node nodeGopay; + private Node nodeOvo; + private Node nodePoin; + private int bayarPoin; + + private int totalPerluBayar = 178800; + private int totalBayar = 0; + + private void hitungBayar() { + totalBayar = bayarTunai + bayarKartu + bayarPromo + bayarRetur + bayarPoin; + } + + /** + * @return the nodeTunai + */ + public Node getNodeTunai() { + return nodeTunai; + } + + /** + * @param nodeTunai the nodeTunai to set + */ + public void setNodeTunai(Node nodeTunai) { + this.nodeTunai = nodeTunai; + } + + /** + * @return the bayarTunai + */ + public int getBayarTunai() { + return bayarTunai; + } + + /** + * @param bayarTunai the bayarTunai to set + */ + public void setBayarTunai(int bayarTunai) { + this.bayarTunai = bayarTunai; + hitungBayar(); + } + + /** + * @return the nodeKartu + */ + public Node getNodeKartu() { + return nodeKartu; + } + + /** + * @param nodeKartu the nodeKartu to set + */ + public void setNodeKartu(Node nodeKartu) { + this.nodeKartu = nodeKartu; + } + + /** + * @return the bayarKartu + */ + public int getBayarKartu() { + return bayarKartu; + } + + /** + * @param bayarKartu the bayarKartu to set + */ + public void setBayarKartu(int bayarKartu) { + this.bayarKartu = bayarKartu; + hitungBayar(); + } + + /** + * @return the nodePromo + */ + public Node getNodePromo() { + return nodePromo; + } + + /** + * @param nodePromo the nodePromo to set + */ + public void setNodePromo(Node nodePromo) { + this.nodePromo = nodePromo; + } + + /** + * @return the bayarPromo + */ + public int getBayarPromo() { + return bayarPromo; + } + + /** + * @param bayarPromo the bayarPromo to set + */ + public void setBayarPromo(int bayarPromo) { + this.bayarPromo = bayarPromo; + hitungBayar(); + } + + /** + * @return the nodeRetur + */ + public Node getNodeRetur() { + return nodeRetur; + } + + /** + * @param nodeRetur the nodeRetur to set + */ + public void setNodeRetur(Node nodeRetur) { + this.nodeRetur = nodeRetur; + } + + /** + * @return the bayarRetur + */ + public int getBayarRetur() { + return bayarRetur; + } + + /** + * @param bayarRetur the bayarRetur to set + */ + public void setBayarRetur(int bayarRetur) { + this.bayarRetur = bayarRetur; + hitungBayar(); + } + + /** + * @return the nodeGopay + */ + public Node getNodeGopay() { + return nodeGopay; + } + + /** + * @param nodeGopay the nodeGopay to set + */ + public void setNodeGopay(Node nodeGopay) { + this.nodeGopay = nodeGopay; + } + + /** + * @return the nodeOvo + */ + public Node getNodeOvo() { + return nodeOvo; + } + + /** + * @param nodeOvo the nodeOvo to set + */ + public void setNodeOvo(Node nodeOvo) { + this.nodeOvo = nodeOvo; + } + + /** + * @return the nodePoin + */ + public Node getNodePoin() { + return nodePoin; + } + + /** + * @param nodePoin the nodePoin to set + */ + public void setNodePoin(Node nodePoin) { + this.nodePoin = nodePoin; + } + + /** + * @return the bayarPoin + */ + public int getBayarPoin() { + return bayarPoin; + } + + /** + * @param bayarPoin the bayarPoin to set + */ + public void setBayarPoin(int bayarPoin) { + this.bayarPoin = bayarPoin; + hitungBayar(); + } + + /** + * @return the totalPerluBayar + */ + public int getTotalPerluBayar() { + return totalPerluBayar; + } + + /** + * @param totalPerluBayar the totalPerluBayar to set + */ + public void setTotalPerluBayar(int totalPerluBayar) { + this.totalPerluBayar = totalPerluBayar; + } + + /** + * @return the totalBayar + */ + public int getTotalBayar() { + return totalBayar; + } + + /** + * @param totalBayar the totalBayar to set + */ + public void setTotalBayar(int totalBayar) { + this.totalBayar = totalBayar; + } +} diff --git a/src/main/java/id/amigogroup/posterminal/bayar/BayarInterface.java b/src/main/java/id/amigogroup/posterminal/bayar/BayarInterface.java new file mode 100644 index 0000000..51471b9 --- /dev/null +++ b/src/main/java/id/amigogroup/posterminal/bayar/BayarInterface.java @@ -0,0 +1,25 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package id.amigogroup.posterminal.bayar; + +import javafx.scene.Node; + +/** + * + * @author ronal + */ +public interface BayarInterface { + final String BAYAR_TUNAI = "Tunai"; + final String BAYAR_KARTU = "Debit/Kredit"; + final String BAYAR_PROMO = "Voucher Promo"; + final String BAYAR_RETUR = "Voucher Retur"; + final String BAYAR_GOPAY = "GoPay"; + final String BAYAR_OVO = "OVO"; + final String BAYAR_POIN = "Poin"; + + public BayarContent getBayarContent(); + public void updateKurangBayarView(); +} diff --git a/src/main/java/id/amigogroup/posterminal/bayar/DialogSelesaiBayarTidakLunasController.java b/src/main/java/id/amigogroup/posterminal/bayar/DialogSelesaiBayarTidakLunasController.java new file mode 100644 index 0000000..6ff73b3 --- /dev/null +++ b/src/main/java/id/amigogroup/posterminal/bayar/DialogSelesaiBayarTidakLunasController.java @@ -0,0 +1,226 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package id.amigogroup.posterminal.bayar; + +import id.amigogroup.posterminal.pencarian.DialogCariBarangController; +import id.amigogroup.posterminal.util.Fucout; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Node; +import javafx.scene.Parent; +import javafx.scene.control.CheckBox; +import javafx.scene.control.Dialog; +import javafx.scene.control.Label; +import javafx.scene.layout.VBox; +import javafx.stage.Window; + +/** + * FXML Controller class + * + * @author ronal + */ +public class DialogSelesaiBayarTidakLunasController extends Dialog implements Initializable, BayarInterface { + + @FXML + private CheckBox chkTunai; + @FXML + private CheckBox chkKartu; + @FXML + private CheckBox chkPromo; + @FXML + private CheckBox chkRetur; + @FXML + private CheckBox chkGopay; + @FXML + private CheckBox chkOvo; + @FXML + private CheckBox chkPoin; + @FXML + private VBox vbContent; + @FXML + private Label lblPerluBayar; + + private BayarInterface parent; + private int kurangBayar; + + private List daftarChkBayarSyarat; + private List daftarChkBayarOpsional; + public BayarContent bayarContent = new BayarContent(); + + /** + * Initializes the controller class. + */ + @Override + public void initialize(URL url, ResourceBundle rb) { + daftarChkBayarSyarat.add(chkTunai); + daftarChkBayarSyarat.add(chkKartu); + daftarChkBayarOpsional.add(chkPromo); + daftarChkBayarOpsional.add(chkRetur); + daftarChkBayarOpsional.add(chkGopay); + daftarChkBayarOpsional.add(chkOvo); + daftarChkBayarOpsional.add(chkPoin); + } + + public DialogSelesaiBayarTidakLunasController(BayarInterface parent, int kurangBayar) { + this.daftarChkBayarSyarat = new ArrayList<>(); + this.daftarChkBayarOpsional = new ArrayList<>(); + this.parent = parent; + bayarContent.setTotalPerluBayar(kurangBayar); + + try { + Window window = getDialogPane().getScene().getWindow(); + window.setOnCloseRequest(event -> this.close()); + + FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/DialogSelesaiBayarTidakLunas.fxml")); + loader.setController(this); + Parent root = loader.load(); + getDialogPane().setContent(root); + + setTitle("Pembayaran Belum Lunas!"); + lblPerluBayar.setText(Fucout.getTextColon(Fucout.formatRupiah( + bayarContent.getTotalPerluBayar()))); + } catch (IOException e) { + Logger.getLogger(DialogCariBarangController.class + .getName()).log(Level.SEVERE, null, e); + } + } + + @FXML + void chkPilihanOnAction(ActionEvent event) { + CheckBox chkSource = (CheckBox) event.getSource(); + FXMLLoader loader = new FXMLLoader(); + Node node = null; + try { + switch (chkSource.getText()) { + case FormBayarController.BAYAR_TUNAI: + if (bayarContent.getNodeTunai() == null && chkSource.selectedProperty().get()) { + loader.setLocation(getClass().getResource("/fxml/FormBayarTunai.fxml")); + node = loader.load(); + + FormBayarTunaiController fbtc = loader.getController(); + fbtc.initData(this); + vbContent.getChildren().add(node); + bayarContent.setNodeTunai(node); + } else { + if (bayarContent.getNodeTunai() != null) { + vbContent.getChildren().remove(bayarContent.getNodeTunai()); + bayarContent.setNodeTunai(null); + } + } + break; + case FormBayarController.BAYAR_KARTU: + if (bayarContent.getNodeKartu() == null && chkSource.selectedProperty().get()) { + loader.setLocation(getClass().getResource("/fxml/FormBayarKartu.fxml")); + node = loader.load(); + + vbContent.getChildren().add(node); + bayarContent.setNodeKartu(node); + } else { + if (bayarContent.getNodeKartu() != null) { + vbContent.getChildren().remove(bayarContent.getNodeKartu()); + bayarContent.setNodeKartu(null); + } + } + break; + case FormBayarController.BAYAR_RETUR: + if (bayarContent.getNodeRetur() == null && chkSource.selectedProperty().get()) { + loader.setLocation(getClass().getResource("/fxml/FormBayarRetur.fxml")); + node = loader.load(); + + vbContent.getChildren().add(node); + bayarContent.setNodeRetur(node); + } else { + if (bayarContent.getNodeRetur() != null) { + vbContent.getChildren().remove(bayarContent.getNodeRetur()); + bayarContent.setNodeRetur(null); + } + } + break; + case FormBayarController.BAYAR_PROMO: + if (bayarContent.getNodePromo() == null && chkSource.selectedProperty().get()) { + loader.setLocation(getClass().getResource("/fxml/FormBayarVoucherPromo.fxml")); + node = loader.load(); + + vbContent.getChildren().add(node); + bayarContent.setNodePromo(node); + } else { + if (bayarContent.getNodePromo() != null) { + vbContent.getChildren().remove(bayarContent.getNodePromo()); + bayarContent.setNodePromo(null); + } + } + break; + case FormBayarController.BAYAR_GOPAY: + break; + case FormBayarController.BAYAR_OVO: + break; + case FormBayarController.BAYAR_POIN: + if (bayarContent.getNodePoin() == null && chkSource.selectedProperty().get()) { + loader.setLocation(getClass().getResource("/fxml/FormBayarPoin.fxml")); + node = loader.load(); + + vbContent.getChildren().add(node); + bayarContent.setNodePoin(node); + } else { + if (bayarContent.getNodePoin() != null) { + vbContent.getChildren().remove(bayarContent.getNodePoin()); + bayarContent.setNodePoin(null); + } + } + break; + } + + if (daftarChkBayarSyarat.contains(chkSource)) { + chkSyaratValueOnChanged(); + } + } catch (IOException ex) { + Logger.getLogger(FormBayarController.class.getName()).log(Level.SEVERE, null, ex); + } + } + + private void chkSyaratValueOnChanged() { + boolean isSyaratTerpenuhi = false; + for (CheckBox chkSyarat : daftarChkBayarSyarat) { + if (chkSyarat.selectedProperty().get()) { + isSyaratTerpenuhi = true; + break; + } + } + + if (isSyaratTerpenuhi) { + for (CheckBox chk : daftarChkBayarOpsional) { + chk.setDisable(false); + } + } else { + for (CheckBox chk : daftarChkBayarOpsional) { + if (chk.selectedProperty().get()) { + chk.fire(); + } + chk.setDisable(true); + } + } + } + + @Override + public BayarContent getBayarContent() { + return bayarContent; + } + + @Override + public void updateKurangBayarView() { + lblPerluBayar.setText(Fucout.getTextColon(Fucout.formatRupiah( + bayarContent.getTotalPerluBayar() - bayarContent.getTotalBayar()))); + } +} diff --git a/src/main/java/id/amigogroup/posterminal/bayar/FormBayarController.java b/src/main/java/id/amigogroup/posterminal/bayar/FormBayarController.java index dd69e4f..62aaa21 100644 --- a/src/main/java/id/amigogroup/posterminal/bayar/FormBayarController.java +++ b/src/main/java/id/amigogroup/posterminal/bayar/FormBayarController.java @@ -9,10 +9,13 @@ import id.amigogroup.posterminal.util.Fucout; import java.io.IOException; import java.net.URL; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; +import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; @@ -20,6 +23,10 @@ import javafx.fxml.Initializable; import javafx.scene.Node; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyCodeCombination; +import javafx.scene.input.KeyCombination; +import javafx.scene.layout.AnchorPane; import javafx.scene.layout.VBox; /** @@ -27,8 +34,10 @@ import javafx.scene.layout.VBox; * * @author ronal */ -public class FormBayarController implements Initializable { +public class FormBayarController implements Initializable, BayarInterface { + @FXML + private AnchorPane apContent; @FXML private CheckBox chkTunai; @FXML @@ -44,41 +53,19 @@ public class FormBayarController implements Initializable { @FXML private CheckBox chkPoin; @FXML + private Label lblKurangBayar; + @FXML private VBox vbContent; @FXML private Label lblGrandTotal; - private final String BAYAR_TUNAI = "Tunai"; - private final String BAYAR_KARTU = "Debit/Kredit"; - private final String BAYAR_PROMO = "Voucher Promo"; - private final String BAYAR_RETUR = "Voucher Retur"; - private final String BAYAR_GOPAY = "GoPay"; - private final String BAYAR_OVO = "OVO"; - private final String BAYAR_POIN = "Poin"; - - private List daftarChkBayar; - - public int totalBayar = 178800; - - public class BayarContent { - - Node nodeTunai; - int bayarTunai; - Node nodeKartu; - int bayarKartu; - Node nodePromo; - int bayarPromo; - Node nodeRetur; - int bayarRetur; - Node nodeGopay; - Node nodeOvo; - Node nodePoin; - } - - public BayarContent kumpulanContent = new BayarContent(); + private final List daftarChkBayarSyarat; + private final List daftarChkBayarOpsional; + public BayarContent bayarContent = new BayarContent(); public FormBayarController() { - daftarChkBayar = new ArrayList<>(); + daftarChkBayarSyarat = new ArrayList<>(); + daftarChkBayarOpsional = new ArrayList<>(); } /** @@ -86,14 +73,40 @@ public class FormBayarController implements Initializable { */ @Override public void initialize(URL url, ResourceBundle rb) { - lblGrandTotal.setText(Fucout.formatRupiah(totalBayar)); - daftarChkBayar.add(chkTunai); - daftarChkBayar.add(chkKartu); - daftarChkBayar.add(chkPromo); - daftarChkBayar.add(chkRetur); - daftarChkBayar.add(chkGopay); - daftarChkBayar.add(chkOvo); - daftarChkBayar.add(chkPoin); + lblGrandTotal.setText(Fucout.formatRupiah(bayarContent.getTotalPerluBayar())); + lblKurangBayar.setText(Fucout.formatRupiah(bayarContent.getTotalPerluBayar())); + daftarChkBayarSyarat.add(chkTunai); + daftarChkBayarSyarat.add(chkKartu); + daftarChkBayarOpsional.add(chkPromo); + daftarChkBayarOpsional.add(chkRetur); + daftarChkBayarOpsional.add(chkGopay); + daftarChkBayarOpsional.add(chkOvo); + daftarChkBayarOpsional.add(chkPoin); + + initShortcuts(); + } + + private void initShortcuts() { + Map listShortcuts = new HashMap<>(); + + KeyCombination kcSelesaiBayar = new KeyCodeCombination(KeyCode.F10); + Runnable rnSelesaiBayar = () -> { + if (bayarContent.getTotalBayar() >= bayarContent.getTotalPerluBayar()) { + + } else { + DialogSelesaiBayarTidakLunasController dsbtlc + = new DialogSelesaiBayarTidakLunasController(this, + bayarContent.getTotalPerluBayar() + - bayarContent.getTotalBayar()); + dsbtlc.initOwner(apContent.getScene().getWindow()); + dsbtlc.show(); + } + }; + listShortcuts.put(kcSelesaiBayar, rnSelesaiBayar); + + Platform.runLater(() -> { + apContent.getScene().getAccelerators().putAll(listShortcuts); + }); } @FXML @@ -104,61 +117,70 @@ public class FormBayarController implements Initializable { try { switch (chkSource.getText()) { case BAYAR_TUNAI: - chkSyaratValueOnChanged(chkSource); - if (kumpulanContent.nodeTunai == null && chkSource.selectedProperty().get()) { + if (bayarContent.getNodeTunai() == null && chkSource.selectedProperty().get()) { loader.setLocation(getClass().getResource("/fxml/FormBayarTunai.fxml")); node = loader.load(); FormBayarTunaiController fbtc = loader.getController(); fbtc.initData(this); vbContent.getChildren().add(node); - kumpulanContent.nodeTunai = node; + bayarContent.setNodeTunai(node); } else { - if (kumpulanContent.nodeTunai != null) { - vbContent.getChildren().remove(kumpulanContent.nodeTunai); - kumpulanContent.nodeTunai = null; + if (bayarContent.getNodeTunai() != null) { + vbContent.getChildren().remove(bayarContent.getNodeTunai()); + bayarContent.setNodeTunai(null); + bayarContent.setBayarTunai(0); + updateKurangBayarView(); } } break; case BAYAR_KARTU: - if (kumpulanContent.nodeKartu == null && chkSource.selectedProperty().get()) { + if (bayarContent.getNodeKartu() == null && chkSource.selectedProperty().get()) { loader.setLocation(getClass().getResource("/fxml/FormBayarKartu.fxml")); node = loader.load(); + FormBayarKartuController fbkc = loader.getController(); + fbkc.initData(this); vbContent.getChildren().add(node); - kumpulanContent.nodeKartu = node; + bayarContent.setNodeKartu(node); } else { - if (kumpulanContent.nodeKartu != null) { - vbContent.getChildren().remove(kumpulanContent.nodeKartu); - kumpulanContent.nodeKartu = null; + if (bayarContent.getNodeKartu() != null) { + vbContent.getChildren().remove(bayarContent.getNodeKartu()); + bayarContent.setNodeKartu(null); + bayarContent.setBayarKartu(0); + updateKurangBayarView(); } } break; case BAYAR_RETUR: - if (kumpulanContent.nodeRetur == null && chkSource.selectedProperty().get()) { + if (bayarContent.getNodeRetur() == null && chkSource.selectedProperty().get()) { loader.setLocation(getClass().getResource("/fxml/FormBayarRetur.fxml")); node = loader.load(); vbContent.getChildren().add(node); - kumpulanContent.nodeRetur = node; + bayarContent.setNodeRetur(node); } else { - if (kumpulanContent.nodeRetur != null) { - vbContent.getChildren().remove(kumpulanContent.nodeRetur); - kumpulanContent.nodeRetur = null; + if (bayarContent.getNodeRetur() != null) { + vbContent.getChildren().remove(bayarContent.getNodeRetur()); + bayarContent.setNodeRetur(null); + bayarContent.setBayarRetur(0); + updateKurangBayarView(); } } break; case BAYAR_PROMO: - if (kumpulanContent.nodePromo == null && chkSource.selectedProperty().get()) { + if (bayarContent.getNodePromo() == null && chkSource.selectedProperty().get()) { loader.setLocation(getClass().getResource("/fxml/FormBayarVoucherPromo.fxml")); node = loader.load(); vbContent.getChildren().add(node); - kumpulanContent.nodePromo = node; + bayarContent.setNodePromo(node); } else { - if (kumpulanContent.nodePromo != null) { - vbContent.getChildren().remove(kumpulanContent.nodePromo); - kumpulanContent.nodePromo = null; + if (bayarContent.getNodePromo() != null) { + vbContent.getChildren().remove(bayarContent.getNodePromo()); + bayarContent.setNodePromo(null); + bayarContent.setBayarPromo(0); + updateKurangBayarView(); } } break; @@ -167,42 +189,64 @@ public class FormBayarController implements Initializable { case BAYAR_OVO: break; case BAYAR_POIN: - if (kumpulanContent.nodePoin == null && chkSource.selectedProperty().get()) { + if (bayarContent.getNodePoin() == null && chkSource.selectedProperty().get()) { loader.setLocation(getClass().getResource("/fxml/FormBayarPoin.fxml")); node = loader.load(); - + + FormBayarPoinController fbpc = loader.getController(); + fbpc.initData(this); vbContent.getChildren().add(node); - kumpulanContent.nodePoin = node; + bayarContent.setNodePoin(node); } else { - if (kumpulanContent.nodePoin != null) { - vbContent.getChildren().remove(kumpulanContent.nodePoin); - kumpulanContent.nodePoin = null; + if (bayarContent.getNodePoin() != null) { + vbContent.getChildren().remove(bayarContent.getNodePoin()); + bayarContent.setNodePoin(null); + bayarContent.setBayarPoin(0); + updateKurangBayarView(); } } break; } + + if (daftarChkBayarSyarat.contains(chkSource)) { + chkSyaratValueOnChanged(); + } } catch (IOException ex) { Logger.getLogger(FormBayarController.class.getName()).log(Level.SEVERE, null, ex); } } - private void chkSyaratValueOnChanged(CheckBox chkSyarat) { - if (kumpulanContent.nodeTunai == null && chkSyarat.selectedProperty().get()) { - for (CheckBox chk : daftarChkBayar) { - if (chk != chkSyarat) { - chk.setDisable(false); - } + private void chkSyaratValueOnChanged() { + boolean isSyaratTerpenuhi = false; + for (CheckBox chkSyarat : daftarChkBayarSyarat) { + if (chkSyarat.selectedProperty().get()) { + isSyaratTerpenuhi = true; + break; + } + } + + if (isSyaratTerpenuhi) { + for (CheckBox chk : daftarChkBayarOpsional) { + chk.setDisable(false); } } else { - for (CheckBox chk : daftarChkBayar) { - if (chk != chkSyarat) { - if (chk.selectedProperty().get()) { - chk.fire(); - } - chk.setDisable(true); + for (CheckBox chk : daftarChkBayarOpsional) { + if (chk.selectedProperty().get()) { + chk.fire(); } + chk.setDisable(true); } } + } + @Override + public BayarContent getBayarContent() { + return bayarContent; + } + + @Override + public void updateKurangBayarView() { + lblKurangBayar.setText(Fucout.formatRupiah( + bayarContent.getTotalPerluBayar() - bayarContent.getTotalBayar())); } } diff --git a/src/main/java/id/amigogroup/posterminal/bayar/FormBayarKartuController.java b/src/main/java/id/amigogroup/posterminal/bayar/FormBayarKartuController.java index 2557ca4..c20e7ef 100644 --- a/src/main/java/id/amigogroup/posterminal/bayar/FormBayarKartuController.java +++ b/src/main/java/id/amigogroup/posterminal/bayar/FormBayarKartuController.java @@ -31,6 +31,7 @@ public class FormBayarKartuController implements Initializable { @FXML private TextField fldNoKartu4; + private BayarInterface parent; /** * Initializes the controller class. */ @@ -39,6 +40,13 @@ public class FormBayarKartuController implements Initializable { initComponents(); } + public void initData(BayarInterface parent) { + this.parent = parent; + + parent.getBayarContent().setBayarKartu(50000); + parent.updateKurangBayarView(); + } + private void initComponents() { Fucout.forceFieldInteger(fldNoKartu1, 4); Fucout.forceFieldInteger(fldNoKartu2, 4); diff --git a/src/main/java/id/amigogroup/posterminal/bayar/FormBayarPoinController.java b/src/main/java/id/amigogroup/posterminal/bayar/FormBayarPoinController.java index 1319e79..1d55697 100644 --- a/src/main/java/id/amigogroup/posterminal/bayar/FormBayarPoinController.java +++ b/src/main/java/id/amigogroup/posterminal/bayar/FormBayarPoinController.java @@ -5,9 +5,15 @@ */ package id.amigogroup.posterminal.bayar; +import id.amigogroup.posterminal.SystemValue; +import id.amigogroup.posterminal.util.Fucout; import java.net.URL; import java.util.ResourceBundle; +import javafx.fxml.FXML; import javafx.fxml.Initializable; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyEvent; /** * FXML Controller class @@ -16,12 +22,45 @@ import javafx.fxml.Initializable; */ public class FormBayarPoinController implements Initializable { + @FXML + private TextField fldPoin; + @FXML + private Label lblPoin; + + private BayarInterface parent; + /** * Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { - // TODO - } - + int poin = 0; + if (SystemValue.member != null) { + lblPoin.setText(Fucout.getTextColon( + String.valueOf(SystemValue.member.getPoin()))); + poin = SystemValue.member.getPoin(); + } + Fucout.forceFieldInteger(fldPoin, poin); + } + + public void initData(BayarInterface parent) { + this.parent = parent; + } + + @FXML + void fldPoinOnKeyReleased(KeyEvent event) { + int poin = 0; + if (!fldPoin.getText().equals("")) { + try { + poin = Integer.parseInt(fldPoin.getText()); + } catch (NumberFormatException nfe) { + } + } + if (parent != null && parent.getBayarContent().getNodePoin() != null) { + parent.getBayarContent().setBayarPoin(poin * Fucout.KONVERSI_POIN); + parent.updateKurangBayarView(); + } + + } + } diff --git a/src/main/java/id/amigogroup/posterminal/bayar/FormBayarTunaiController.java b/src/main/java/id/amigogroup/posterminal/bayar/FormBayarTunaiController.java index 4c2e324..4317e73 100644 --- a/src/main/java/id/amigogroup/posterminal/bayar/FormBayarTunaiController.java +++ b/src/main/java/id/amigogroup/posterminal/bayar/FormBayarTunaiController.java @@ -26,7 +26,7 @@ public class FormBayarTunaiController implements Initializable { @FXML private Label lblKembalian; - private FormBayarController parent; + private BayarInterface parent; /** * Initializes the controller class. @@ -36,24 +36,31 @@ public class FormBayarTunaiController implements Initializable { Fucout.forceFieldInteger(fldBayar, Integer.MAX_VALUE); } - public void initData(FormBayarController parent) { + public void initData(BayarInterface parent) { this.parent = parent; } @FXML void fldBayarOnKeyReleased(KeyEvent event) { - if (parent != null && parent.kumpulanContent.nodeTunai != null - && !fldBayar.getText().equals("")) { + int bayar = 0; + if (!fldBayar.getText().equals("")) { try { - int bayar = Integer.parseInt(fldBayar.getText()); - if (parent.totalBayar < bayar) { - int kembali = bayar - parent.totalBayar; - lblKembalian.setText(Fucout.formatRibuan(kembali)); - } else { - lblKembalian.setText("-"); - } + bayar = Integer.parseInt(fldBayar.getText()); } catch (NumberFormatException nfe) { + } + } + + if (parent != null && parent.getBayarContent().getNodeTunai() != null) { + parent.getBayarContent().setBayarTunai(bayar); + parent.updateKurangBayarView(); + if (parent.getBayarContent().getTotalPerluBayar() < + parent.getBayarContent().getTotalBayar()) { + int kembali = parent.getBayarContent().getTotalBayar() + - parent.getBayarContent().getTotalPerluBayar(); + lblKembalian.setText(Fucout.formatRibuan(kembali)); + } else { + lblKembalian.setText("-"); } } } diff --git a/src/main/java/id/amigogroup/posterminal/model/Pelanggan.java b/src/main/java/id/amigogroup/posterminal/model/Pelanggan.java index 795168b..62a841c 100644 --- a/src/main/java/id/amigogroup/posterminal/model/Pelanggan.java +++ b/src/main/java/id/amigogroup/posterminal/model/Pelanggan.java @@ -113,7 +113,7 @@ public class Pelanggan { @JsonProperty("saldonetbon") private Integer saldonetbon; @JsonProperty("poin") - private Integer poin; + private int poin; @JsonProperty("gambar") private String gambar; @JsonProperty("firebase_uid") @@ -430,12 +430,12 @@ public class Pelanggan { } @JsonProperty("poin") - public Integer getPoin() { + public int getPoin() { return poin; } @JsonProperty("poin") - public void setPoin(Integer poin) { + public void setPoin(int poin) { this.poin = poin; } diff --git a/src/main/java/id/amigogroup/posterminal/util/Fucout.java b/src/main/java/id/amigogroup/posterminal/util/Fucout.java index 0575758..2f8fa13 100644 --- a/src/main/java/id/amigogroup/posterminal/util/Fucout.java +++ b/src/main/java/id/amigogroup/posterminal/util/Fucout.java @@ -32,6 +32,9 @@ public class Fucout { public static final String TIPE_NOTA_BAWA = "Bawa Dulu"; public static final String TIPE_NOTA_RETUR = "Retur"; + //VALUES + public static final int KONVERSI_POIN = 100000; + //IMAGES URL public static final String APP_ICON = "/assets/logo-mini-squared.png"; @@ -123,17 +126,18 @@ public class Fucout { return nf.format(price); } - + public static boolean checkBirthday(Date tanggal) { return checkBirthday(toLocalDate(tanggal)); } + public static boolean checkBirthday(LocalDate tanggal) { if (tanggal == null) { return false; } LocalDate now = LocalDate.now(); - return tanggal.getMonthValue() == now.getMonthValue() && - tanggal.getDayOfMonth() == now.getDayOfMonth(); + return tanggal.getMonthValue() == now.getMonthValue() + && tanggal.getDayOfMonth() == now.getDayOfMonth(); } public static LocalDate toLocalDate(Date date) { diff --git a/src/main/resources/fxml/DialogSelesaiBayarTidakLunas.fxml b/src/main/resources/fxml/DialogSelesaiBayarTidakLunas.fxml new file mode 100644 index 0000000..ee0e86d --- /dev/null +++ b/src/main/resources/fxml/DialogSelesaiBayarTidakLunas.fxml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/fxml/FormBayar.fxml b/src/main/resources/fxml/FormBayar.fxml index d6005ac..0ddde74 100644 --- a/src/main/resources/fxml/FormBayar.fxml +++ b/src/main/resources/fxml/FormBayar.fxml @@ -10,7 +10,7 @@ - + - + @@ -55,14 +55,19 @@ - + + -