| @@ -27,7 +27,7 @@ public class App extends Application { | |||||
| Scene scene = new Scene(root); | Scene scene = new Scene(root); | ||||
| System.out.println(Fucout.getNoNotaTemporary()); | |||||
| System.out.println("Contoh Generate No Nota Temporary :" + Fucout.getNoNotaTemporary()); | |||||
| stage.setScene(scene); | stage.setScene(scene); | ||||
| stage.setTitle(Fucout.APP_TITLE); | stage.setTitle(Fucout.APP_TITLE); | ||||
| @@ -5,8 +5,11 @@ | |||||
| */ | */ | ||||
| package id.amigogroup.posterminal.bayar; | package id.amigogroup.posterminal.bayar; | ||||
| import id.amigogroup.posterminal.util.Fucout; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.ResourceBundle; | import java.util.ResourceBundle; | ||||
| import java.util.logging.Level; | import java.util.logging.Level; | ||||
| import java.util.logging.Logger; | import java.util.logging.Logger; | ||||
| @@ -16,6 +19,7 @@ import javafx.fxml.FXMLLoader; | |||||
| import javafx.fxml.Initializable; | import javafx.fxml.Initializable; | ||||
| import javafx.scene.Node; | import javafx.scene.Node; | ||||
| import javafx.scene.control.CheckBox; | import javafx.scene.control.CheckBox; | ||||
| import javafx.scene.control.Label; | |||||
| import javafx.scene.layout.VBox; | import javafx.scene.layout.VBox; | ||||
| /** | /** | ||||
| @@ -25,36 +29,71 @@ import javafx.scene.layout.VBox; | |||||
| */ | */ | ||||
| public class FormBayarController implements Initializable { | public class FormBayarController implements Initializable { | ||||
| @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 | @FXML | ||||
| private VBox vbContent; | private VBox vbContent; | ||||
| @FXML | |||||
| private Label lblGrandTotal; | |||||
| private final String BAYAR_TUNAI = "Tunai"; | private final String BAYAR_TUNAI = "Tunai"; | ||||
| private final String BAYAR_KARTU = "Debit/Kredit"; | private final String BAYAR_KARTU = "Debit/Kredit"; | ||||
| private final String BAYAR_RETUR = "Voucher Retur"; | |||||
| private final String BAYAR_PROMO = "Voucher Promo"; | private final String BAYAR_PROMO = "Voucher Promo"; | ||||
| private final String BAYAR_RETUR = "Voucher Retur"; | |||||
| private final String BAYAR_GOPAY = "GoPay"; | private final String BAYAR_GOPAY = "GoPay"; | ||||
| private final String BAYAR_OVO = "OVO"; | private final String BAYAR_OVO = "OVO"; | ||||
| private final String BAYAR_POIN = "Poin"; | private final String BAYAR_POIN = "Poin"; | ||||
| private List<CheckBox> daftarChkBayar; | |||||
| public int totalBayar = 178800; | |||||
| public class BayarContent { | public class BayarContent { | ||||
| Node nodeTunai; | Node nodeTunai; | ||||
| int bayarTunai; | |||||
| Node nodeKartu; | Node nodeKartu; | ||||
| Node nodeRetur; | |||||
| int bayarKartu; | |||||
| Node nodePromo; | Node nodePromo; | ||||
| int bayarPromo; | |||||
| Node nodeRetur; | |||||
| int bayarRetur; | |||||
| Node nodeGopay; | Node nodeGopay; | ||||
| Node nodeOvo; | Node nodeOvo; | ||||
| Node nodePoin; | Node nodePoin; | ||||
| } | } | ||||
| private BayarContent kumpulanContent = new BayarContent(); | |||||
| public BayarContent kumpulanContent = new BayarContent(); | |||||
| public FormBayarController() { | |||||
| daftarChkBayar = new ArrayList<>(); | |||||
| } | |||||
| /** | /** | ||||
| * Initializes the controller class. | * Initializes the controller class. | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public void initialize(URL url, ResourceBundle rb) { | public void initialize(URL url, ResourceBundle rb) { | ||||
| // TODO | |||||
| 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); | |||||
| } | } | ||||
| @FXML | @FXML | ||||
| @@ -65,10 +104,13 @@ public class FormBayarController implements Initializable { | |||||
| try { | try { | ||||
| switch (chkSource.getText()) { | switch (chkSource.getText()) { | ||||
| case BAYAR_TUNAI: | case BAYAR_TUNAI: | ||||
| chkSyaratValueOnChanged(chkSource); | |||||
| if (kumpulanContent.nodeTunai == null && chkSource.selectedProperty().get()) { | if (kumpulanContent.nodeTunai == null && chkSource.selectedProperty().get()) { | ||||
| loader.setLocation(getClass().getResource("/fxml/FormBayarTunai.fxml")); | loader.setLocation(getClass().getResource("/fxml/FormBayarTunai.fxml")); | ||||
| node = loader.load(); | node = loader.load(); | ||||
| FormBayarTunaiController fbtc = loader.getController(); | |||||
| fbtc.initData(this); | |||||
| vbContent.getChildren().add(node); | vbContent.getChildren().add(node); | ||||
| kumpulanContent.nodeTunai = node; | kumpulanContent.nodeTunai = node; | ||||
| } else { | } else { | ||||
| @@ -143,4 +185,24 @@ public class FormBayarController implements Initializable { | |||||
| Logger.getLogger(FormBayarController.class.getName()).log(Level.SEVERE, null, 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); | |||||
| } | |||||
| } | |||||
| } else { | |||||
| for (CheckBox chk : daftarChkBayar) { | |||||
| if (chk != chkSyarat) { | |||||
| if (chk.selectedProperty().get()) { | |||||
| chk.fire(); | |||||
| } | |||||
| chk.setDisable(true); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -5,9 +5,14 @@ | |||||
| */ | */ | ||||
| package id.amigogroup.posterminal.bayar; | package id.amigogroup.posterminal.bayar; | ||||
| import id.amigogroup.posterminal.util.Fucout; | |||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.ResourceBundle; | import java.util.ResourceBundle; | ||||
| import javafx.fxml.FXML; | |||||
| import javafx.fxml.Initializable; | import javafx.fxml.Initializable; | ||||
| import javafx.scene.control.Label; | |||||
| import javafx.scene.control.TextField; | |||||
| import javafx.scene.input.KeyEvent; | |||||
| /** | /** | ||||
| * FXML Controller class | * FXML Controller class | ||||
| @@ -16,12 +21,40 @@ import javafx.fxml.Initializable; | |||||
| */ | */ | ||||
| public class FormBayarTunaiController implements Initializable { | public class FormBayarTunaiController implements Initializable { | ||||
| @FXML | |||||
| private TextField fldBayar; | |||||
| @FXML | |||||
| private Label lblKembalian; | |||||
| private FormBayarController parent; | |||||
| /** | /** | ||||
| * Initializes the controller class. | * Initializes the controller class. | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public void initialize(URL url, ResourceBundle rb) { | public void initialize(URL url, ResourceBundle rb) { | ||||
| // TODO | |||||
| } | |||||
| Fucout.forceFieldInteger(fldBayar, Integer.MAX_VALUE); | |||||
| } | |||||
| public void initData(FormBayarController parent) { | |||||
| this.parent = parent; | |||||
| } | |||||
| @FXML | |||||
| void fldBayarOnKeyReleased(KeyEvent event) { | |||||
| if (parent != null && parent.kumpulanContent.nodeTunai != null | |||||
| && !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("-"); | |||||
| } | |||||
| } catch (NumberFormatException nfe) { | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -5,11 +5,13 @@ | |||||
| */ | */ | ||||
| package id.amigogroup.posterminal.util; | package id.amigogroup.posterminal.util; | ||||
| import java.text.NumberFormat; | |||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.time.LocalDate; | import java.time.LocalDate; | ||||
| import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
| import java.time.ZoneId; | import java.time.ZoneId; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Locale; | |||||
| import javafx.beans.value.ChangeListener; | import javafx.beans.value.ChangeListener; | ||||
| import javafx.beans.value.ObservableValue; | import javafx.beans.value.ObservableValue; | ||||
| import javafx.scene.Node; | import javafx.scene.Node; | ||||
| @@ -104,6 +106,24 @@ public class Fucout { | |||||
| return DATE_FORMAT.format(tanggal); | return DATE_FORMAT.format(tanggal); | ||||
| } | } | ||||
| public static String formatRibuan(Integer thousand) { | |||||
| if (thousand == null) { | |||||
| return ""; | |||||
| } | |||||
| NumberFormat nf = NumberFormat.getInstance(Locale.forLanguageTag("in-ID")); | |||||
| return nf.format(thousand); | |||||
| } | |||||
| public static String formatRupiah(Integer price) { | |||||
| if (price == null) { | |||||
| return ""; | |||||
| } | |||||
| NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.forLanguageTag("in-ID")); | |||||
| return nf.format(price); | |||||
| } | |||||
| public static boolean checkBirthday(Date tanggal) { | public static boolean checkBirthday(Date tanggal) { | ||||
| return checkBirthday(toLocalDate(tanggal)); | return checkBirthday(toLocalDate(tanggal)); | ||||
| } | } | ||||
| @@ -9,7 +9,6 @@ | |||||
| <?import javafx.scene.layout.StackPane?> | <?import javafx.scene.layout.StackPane?> | ||||
| <?import javafx.scene.layout.VBox?> | <?import javafx.scene.layout.VBox?> | ||||
| <?import javafx.scene.text.Font?> | <?import javafx.scene.text.Font?> | ||||
| <?import javafx.scene.text.Text?> | |||||
| <AnchorPane id="AnchorPane" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="450.0" stylesheets="@../styles/pos_styles.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="id.amigogroup.posterminal.bayar.FormBayarController"> | <AnchorPane id="AnchorPane" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="450.0" stylesheets="@../styles/pos_styles.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="id.amigogroup.posterminal.bayar.FormBayarController"> | ||||
| <children> | <children> | ||||
| @@ -22,29 +21,29 @@ | |||||
| <content> | <content> | ||||
| <HBox spacing="5.0"> | <HBox spacing="5.0"> | ||||
| <children> | <children> | ||||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Tunai"> | |||||
| <CheckBox fx:id="chkTunai" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Tunai"> | |||||
| <HBox.margin> | <HBox.margin> | ||||
| <Insets right="10.0" /> | <Insets right="10.0" /> | ||||
| </HBox.margin> | </HBox.margin> | ||||
| </CheckBox> | </CheckBox> | ||||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Debit/Kredit"> | |||||
| <CheckBox fx:id="chkKartu" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Debit/Kredit"> | |||||
| <HBox.margin> | <HBox.margin> | ||||
| <Insets right="10.0" /> | <Insets right="10.0" /> | ||||
| </HBox.margin> | </HBox.margin> | ||||
| </CheckBox> | </CheckBox> | ||||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Voucher Promo" /> | |||||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Voucher Retur" /> | |||||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Gopay"> | |||||
| <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> | <HBox.margin> | ||||
| <Insets right="10.0" /> | <Insets right="10.0" /> | ||||
| </HBox.margin> | </HBox.margin> | ||||
| </CheckBox> | </CheckBox> | ||||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="OVO"> | |||||
| <CheckBox fx:id="chkOvo" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="OVO"> | |||||
| <HBox.margin> | <HBox.margin> | ||||
| <Insets right="10.0" /> | <Insets right="10.0" /> | ||||
| </HBox.margin> | </HBox.margin> | ||||
| </CheckBox> | </CheckBox> | ||||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Poin"> | |||||
| <CheckBox fx:id="chkPoin" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Poin"> | |||||
| <HBox.margin> | <HBox.margin> | ||||
| <Insets right="10.0" /> | <Insets right="10.0" /> | ||||
| </HBox.margin> | </HBox.margin> | ||||
| @@ -63,14 +62,14 @@ | |||||
| </ScrollPane> | </ScrollPane> | ||||
| <StackPane id="price-background" alignment="CENTER_RIGHT" layoutX="77.0" layoutY="245.0" maxHeight="1.7976931348623157E308" prefHeight="55.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"> | <StackPane id="price-background" alignment="CENTER_RIGHT" layoutX="77.0" layoutY="245.0" maxHeight="1.7976931348623157E308" prefHeight="55.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"> | ||||
| <children> | <children> | ||||
| <Text fx:id="lblGrandTotal" fill="#fbff00" strokeType="OUTSIDE" strokeWidth="0.0" text="Rp99.999.999,00"> | |||||
| <Label fx:id="lblGrandTotal" text="Rp99.999.999,00" textAlignment="RIGHT" textFill="YELLOW"> | |||||
| <font> | <font> | ||||
| <Font name="System Bold" size="36.0" /> | <Font name="System Bold" size="36.0" /> | ||||
| </font> | </font> | ||||
| <StackPane.margin> | <StackPane.margin> | ||||
| <Insets right="14.0" /> | <Insets right="14.0" /> | ||||
| </StackPane.margin> | </StackPane.margin> | ||||
| </Text> | |||||
| </Label> | |||||
| </children> | </children> | ||||
| <opaqueInsets> | <opaqueInsets> | ||||
| <Insets /> | <Insets /> | ||||
| @@ -33,7 +33,7 @@ | |||||
| <Insets bottom="2.5" /> | <Insets bottom="2.5" /> | ||||
| </GridPane.margin> | </GridPane.margin> | ||||
| </Label> | </Label> | ||||
| <TextField alignment="CENTER_RIGHT" GridPane.columnIndex="1"> | |||||
| <TextField fx:id="fldBayar" alignment="CENTER_RIGHT" onKeyReleased="#fldBayarOnKeyReleased" GridPane.columnIndex="1"> | |||||
| <GridPane.margin> | <GridPane.margin> | ||||
| <Insets bottom="2.5" left="5.0" right="2.5" /> | <Insets bottom="2.5" left="5.0" right="2.5" /> | ||||
| </GridPane.margin> | </GridPane.margin> | ||||
| @@ -43,11 +43,11 @@ | |||||
| <Insets top="2.5" /> | <Insets top="2.5" /> | ||||
| </GridPane.margin> | </GridPane.margin> | ||||
| </Label> | </Label> | ||||
| <TextField alignment="CENTER_RIGHT" GridPane.columnIndex="1" GridPane.rowIndex="1"> | |||||
| <GridPane.margin> | |||||
| <Label fx:id="lblKembalian" text="-" GridPane.columnIndex="1" GridPane.rowIndex="1"> | |||||
| <GridPane.margin> | |||||
| <Insets left="5.0" right="2.5" top="2.5" /> | <Insets left="5.0" right="2.5" top="2.5" /> | ||||
| </GridPane.margin> | |||||
| </TextField> | |||||
| </GridPane.margin> | |||||
| </Label> | |||||
| </children> | </children> | ||||
| </GridPane> | </GridPane> | ||||
| </AnchorPane> | </AnchorPane> | ||||