Dialog Bayar Belum Lunas, Bayar Poin, Menampilkan Kekurangan Bayar
* [UI] Dialog Bayar Belum Lunas muncul jika menekan F10 tapi belum dibayar lunas * [Logic + UI] Bayar poin + menampilkan akumulasi poin menggunakan konversi 1 = 100.000 * [UI] Menampilkan biaya yang belum terbayar di layar checkout bayar, termasuk hasil gabungan berbagai pembayaranpull/2/head
parent
79bc063e65
commit
b8dd662f84
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
@ -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<CheckBox> daftarChkBayarSyarat;
|
||||
private List<CheckBox> 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())));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
|
||||
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/11.0.1">
|
||||
<children>
|
||||
<Label layoutX="14.0" layoutY="14.0" text="Bayar" AnchorPane.leftAnchor="4.0" AnchorPane.topAnchor="4.0">
|
||||
<font>
|
||||
<Font name="System Bold" size="16.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<HBox layoutX="4.0" layoutY="29.0" AnchorPane.leftAnchor="4.0" AnchorPane.rightAnchor="4.0" AnchorPane.topAnchor="29.0">
|
||||
<children>
|
||||
<Label text="Sisa yang kurang dibayarkan">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="lblPerluBayar" text=": -">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
<HBox.margin>
|
||||
<Insets left="5.0" />
|
||||
</HBox.margin>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
<ScrollPane fitToHeight="true" layoutX="-10.0" layoutY="29.0" minHeight="0.0" minWidth="0.0" prefHeight="40.0" style="-fx-background-color: transparent;" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="59.0">
|
||||
<content>
|
||||
<HBox spacing="5.0">
|
||||
<children>
|
||||
<CheckBox fx:id="chkTunai" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Tunai">
|
||||
<HBox.margin>
|
||||
<Insets right="10.0" />
|
||||
</HBox.margin>
|
||||
</CheckBox>
|
||||
<CheckBox fx:id="chkKartu" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Debit/Kredit">
|
||||
<HBox.margin>
|
||||
<Insets right="10.0" />
|
||||
</HBox.margin>
|
||||
</CheckBox>
|
||||
<CheckBox fx:id="chkPromo" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Voucher Promo" />
|
||||
<CheckBox fx:id="chkRetur" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Voucher Retur" />
|
||||
<CheckBox fx:id="chkGopay" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Gopay">
|
||||
<HBox.margin>
|
||||
<Insets right="10.0" />
|
||||
</HBox.margin>
|
||||
</CheckBox>
|
||||
<CheckBox fx:id="chkOvo" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="OVO">
|
||||
<HBox.margin>
|
||||
<Insets right="10.0" />
|
||||
</HBox.margin>
|
||||
</CheckBox>
|
||||
<CheckBox fx:id="chkPoin" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Poin">
|
||||
<HBox.margin>
|
||||
<Insets right="10.0" />
|
||||
</HBox.margin>
|
||||
</CheckBox>
|
||||
</children>
|
||||
</HBox>
|
||||
</content>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="14.0" right="14.0" top="5.0" />
|
||||
</padding>
|
||||
</ScrollPane>
|
||||
<ScrollPane fitToWidth="true" layoutX="8.0" layoutY="69.0" style="-fx-background-color: transparent;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="99.0">
|
||||
<content>
|
||||
<VBox fx:id="vbContent" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
Loading…
Reference in New Issue