| @@ -27,7 +27,7 @@ public class App extends Application { | |||
| Scene scene = new Scene(root); | |||
| System.out.println(Fucout.getNoNotaTemporary()); | |||
| System.out.println("Contoh Generate No Nota Temporary :" + Fucout.getNoNotaTemporary()); | |||
| stage.setScene(scene); | |||
| stage.setTitle(Fucout.APP_TITLE); | |||
| @@ -5,8 +5,11 @@ | |||
| */ | |||
| package id.amigogroup.posterminal.bayar; | |||
| 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; | |||
| @@ -16,6 +19,7 @@ import javafx.fxml.FXMLLoader; | |||
| import javafx.fxml.Initializable; | |||
| import javafx.scene.Node; | |||
| import javafx.scene.control.CheckBox; | |||
| import javafx.scene.control.Label; | |||
| import javafx.scene.layout.VBox; | |||
| /** | |||
| @@ -25,36 +29,71 @@ import javafx.scene.layout.VBox; | |||
| */ | |||
| 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 | |||
| private VBox vbContent; | |||
| @FXML | |||
| private Label lblGrandTotal; | |||
| private final String BAYAR_TUNAI = "Tunai"; | |||
| 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_RETUR = "Voucher Retur"; | |||
| private final String BAYAR_GOPAY = "GoPay"; | |||
| private final String BAYAR_OVO = "OVO"; | |||
| private final String BAYAR_POIN = "Poin"; | |||
| private List<CheckBox> daftarChkBayar; | |||
| public int totalBayar = 178800; | |||
| public class BayarContent { | |||
| Node nodeTunai; | |||
| int bayarTunai; | |||
| Node nodeKartu; | |||
| Node nodeRetur; | |||
| int bayarKartu; | |||
| Node nodePromo; | |||
| int bayarPromo; | |||
| Node nodeRetur; | |||
| int bayarRetur; | |||
| Node nodeGopay; | |||
| Node nodeOvo; | |||
| Node nodePoin; | |||
| } | |||
| private BayarContent kumpulanContent = new BayarContent(); | |||
| public BayarContent kumpulanContent = new BayarContent(); | |||
| public FormBayarController() { | |||
| daftarChkBayar = new ArrayList<>(); | |||
| } | |||
| /** | |||
| * Initializes the controller class. | |||
| */ | |||
| @Override | |||
| 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 | |||
| @@ -65,10 +104,13 @@ public class FormBayarController implements Initializable { | |||
| try { | |||
| switch (chkSource.getText()) { | |||
| case BAYAR_TUNAI: | |||
| chkSyaratValueOnChanged(chkSource); | |||
| if (kumpulanContent.nodeTunai == 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; | |||
| } else { | |||
| @@ -143,4 +185,24 @@ public class FormBayarController implements Initializable { | |||
| 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; | |||
| 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 +21,40 @@ import javafx.fxml.Initializable; | |||
| */ | |||
| public class FormBayarTunaiController implements Initializable { | |||
| @FXML | |||
| private TextField fldBayar; | |||
| @FXML | |||
| private Label lblKembalian; | |||
| private FormBayarController parent; | |||
| /** | |||
| * Initializes the controller class. | |||
| */ | |||
| @Override | |||
| 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; | |||
| import java.text.NumberFormat; | |||
| import java.text.SimpleDateFormat; | |||
| import java.time.LocalDate; | |||
| import java.time.LocalDateTime; | |||
| import java.time.ZoneId; | |||
| import java.util.Date; | |||
| import java.util.Locale; | |||
| import javafx.beans.value.ChangeListener; | |||
| import javafx.beans.value.ObservableValue; | |||
| import javafx.scene.Node; | |||
| @@ -104,6 +106,24 @@ public class Fucout { | |||
| 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) { | |||
| return checkBirthday(toLocalDate(tanggal)); | |||
| } | |||
| @@ -9,7 +9,6 @@ | |||
| <?import javafx.scene.layout.StackPane?> | |||
| <?import javafx.scene.layout.VBox?> | |||
| <?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"> | |||
| <children> | |||
| @@ -22,29 +21,29 @@ | |||
| <content> | |||
| <HBox spacing="5.0"> | |||
| <children> | |||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Tunai"> | |||
| <CheckBox fx:id="chkTunai" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Tunai"> | |||
| <HBox.margin> | |||
| <Insets right="10.0" /> | |||
| </HBox.margin> | |||
| </CheckBox> | |||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Debit/Kredit"> | |||
| <CheckBox fx:id="chkKartu" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Debit/Kredit"> | |||
| <HBox.margin> | |||
| <Insets right="10.0" /> | |||
| </HBox.margin> | |||
| </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> | |||
| <Insets right="10.0" /> | |||
| </HBox.margin> | |||
| </CheckBox> | |||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="OVO"> | |||
| <CheckBox fx:id="chkOvo" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="OVO"> | |||
| <HBox.margin> | |||
| <Insets right="10.0" /> | |||
| </HBox.margin> | |||
| </CheckBox> | |||
| <CheckBox mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Poin"> | |||
| <CheckBox fx:id="chkPoin" disable="true" mnemonicParsing="false" onAction="#chkPilihanOnAction" text="Poin"> | |||
| <HBox.margin> | |||
| <Insets right="10.0" /> | |||
| </HBox.margin> | |||
| @@ -63,14 +62,14 @@ | |||
| </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"> | |||
| <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 name="System Bold" size="36.0" /> | |||
| </font> | |||
| <StackPane.margin> | |||
| <Insets right="14.0" /> | |||
| </StackPane.margin> | |||
| </Text> | |||
| </Label> | |||
| </children> | |||
| <opaqueInsets> | |||
| <Insets /> | |||
| @@ -33,7 +33,7 @@ | |||
| <Insets bottom="2.5" /> | |||
| </GridPane.margin> | |||
| </Label> | |||
| <TextField alignment="CENTER_RIGHT" GridPane.columnIndex="1"> | |||
| <TextField fx:id="fldBayar" alignment="CENTER_RIGHT" onKeyReleased="#fldBayarOnKeyReleased" GridPane.columnIndex="1"> | |||
| <GridPane.margin> | |||
| <Insets bottom="2.5" left="5.0" right="2.5" /> | |||
| </GridPane.margin> | |||
| @@ -43,11 +43,11 @@ | |||
| <Insets top="2.5" /> | |||
| </GridPane.margin> | |||
| </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" /> | |||
| </GridPane.margin> | |||
| </TextField> | |||
| </GridPane.margin> | |||
| </Label> | |||
| </children> | |||
| </GridPane> | |||
| </AnchorPane> | |||