Browse Source

Bug fix data nota tidak bisa ditumpuk

pull/11/head
Ronaldo Christnawan 5 years ago
parent
commit
713f59d94c
2 changed files with 79 additions and 79 deletions
  1. +76
    -76
      src/main/java/id/amigogroup/posterminal/FormUtamaController.java
  2. +3
    -3
      src/main/resources/fxml/FormTransaksiTunai.fxml

+ 76
- 76
src/main/java/id/amigogroup/posterminal/FormUtamaController.java View File

@@ -83,7 +83,6 @@ public class FormUtamaController implements Initializable {
private final List<Button> navigasi = new ArrayList<>(); private final List<Button> navigasi = new ArrayList<>();
private int notaState = -1; private int notaState = -1;
private String tipeTransaksiState = ""; private String tipeTransaksiState = "";
private int jumlahNota = 0;
private final char NOTA_PREV = 'p'; private final char NOTA_PREV = 'p';
private final char NOTA_NEXT = 'n'; private final char NOTA_NEXT = 'n';
public final NotaContent notaContent = new NotaContent(); public final NotaContent notaContent = new NotaContent();
@@ -176,7 +175,7 @@ public class FormUtamaController implements Initializable {


FormTransaksiTunaiController fttc = loader.getController(); FormTransaksiTunaiController fttc = loader.getController();
notaContent.setControllerTunai(fttc); notaContent.setControllerTunai(fttc);
fttc.initData(this,noNota, baru);
fttc.initData(this, noNota, baru);
} }
break; break;
case FormConstanta.TRANSAKSI_RETUR: case FormConstanta.TRANSAKSI_RETUR:
@@ -201,6 +200,7 @@ public class FormUtamaController implements Initializable {
} }


private void loadNota(char operasi) { private void loadNota(char operasi) {
int jumlahNota = navigasi.size();
switch (operasi) { switch (operasi) {
case NOTA_PREV: case NOTA_PREV:
if (notaState == -1) { if (notaState == -1) {
@@ -238,19 +238,19 @@ public class FormUtamaController implements Initializable {


private void resetShortcutToDefault() { private void resetShortcutToDefault() {
Map<KeyCombination, Runnable> listShortcuts = new HashMap<>(); Map<KeyCombination, Runnable> listShortcuts = new HashMap<>();
KeyCombination kcCetakNota = new KeyCodeCombination(KeyCode.F10); KeyCombination kcCetakNota = new KeyCodeCombination(KeyCode.F10);
Runnable rnCetakNota = () -> { Runnable rnCetakNota = () -> {
openCetakNota(); openCetakNota();
}; };
listShortcuts.put(kcCetakNota, rnCetakNota); listShortcuts.put(kcCetakNota, rnCetakNota);
KeyCombination kcTundaNota = new KeyCodeCombination(KeyCode.T, KeyCombination.CONTROL_DOWN); KeyCombination kcTundaNota = new KeyCodeCombination(KeyCode.T, KeyCombination.CONTROL_DOWN);
Runnable rnTundaNota = () -> { Runnable rnTundaNota = () -> {
//do nothing //do nothing
}; };
listShortcuts.put(kcTundaNota, rnTundaNota); listShortcuts.put(kcTundaNota, rnTundaNota);
bpMain.getScene().getAccelerators().putAll(listShortcuts); bpMain.getScene().getAccelerators().putAll(listShortcuts);
} }


@@ -407,8 +407,8 @@ public class FormUtamaController implements Initializable {


return stage; return stage;
} }
public Window getWindow(){
public Window getWindow() {
return bpMain.getScene().getWindow(); return bpMain.getScene().getWindow();
} }


@@ -420,15 +420,7 @@ public class FormUtamaController implements Initializable {


if (hasilReturn.isPresent()) { if (hasilReturn.isPresent()) {
if (hasilReturn.get().equals("Baru:Tunai")) { if (hasilReturn.get().equals("Baru:Tunai")) {
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_TUNAI)) {
setContent(null);
}

if (notaContent.getBtnTunai() != null) {
navigasi.remove(notaContent.getBtnTunai());
vbNavigasi.getChildren().remove(notaContent.getBtnTunai());
}

removeDuplicateNota(FormConstanta.TRANSAKSI_TUNAI);
Button buttonBaru = generateButtonNota(Fucout.getNoNotaTemporary(), Button buttonBaru = generateButtonNota(Fucout.getNoNotaTemporary(),
FormConstanta.TRANSAKSI_TUNAI, FormConstanta.TRANSAKSI_TUNAI,
Fucout.TEKS_TIPE_NOTA_TUNAI, Fucout.TEKS_TIPE_NOTA_TUNAI,
@@ -436,17 +428,8 @@ public class FormUtamaController implements Initializable {
navigasi.add(buttonBaru); navigasi.add(buttonBaru);
vbNavigasi.getChildren().add(buttonBaru); vbNavigasi.getChildren().add(buttonBaru);
notaContent.setBtnTunai(buttonBaru); notaContent.setBtnTunai(buttonBaru);
jumlahNota++;
} else if (hasilReturn.get().equals("Baru:Bon")) { } else if (hasilReturn.get().equals("Baru:Bon")) {
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_BON)) {
setContent(null);
}

if (notaContent.getBtnBon() != null) {
navigasi.remove(notaContent.getBtnBon());
vbNavigasi.getChildren().remove(notaContent.getBtnBon());
}

removeDuplicateNota(FormConstanta.TRANSAKSI_BON);
Button buttonBaru = generateButtonNota("B-" + Fucout.getNoNotaTemporary(), Button buttonBaru = generateButtonNota("B-" + Fucout.getNoNotaTemporary(),
FormConstanta.TRANSAKSI_BON, FormConstanta.TRANSAKSI_BON,
Fucout.TEKS_TIPE_NOTA_BON, Fucout.TEKS_TIPE_NOTA_BON,
@@ -454,17 +437,8 @@ public class FormUtamaController implements Initializable {
navigasi.add(buttonBaru); navigasi.add(buttonBaru);
vbNavigasi.getChildren().add(buttonBaru); vbNavigasi.getChildren().add(buttonBaru);
notaContent.setBtnBon(buttonBaru); notaContent.setBtnBon(buttonBaru);
jumlahNota++;
} else if (hasilReturn.get().equals("Baru:Bawa Dulu")) { } else if (hasilReturn.get().equals("Baru:Bawa Dulu")) {
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_BAWA)) {
setContent(null);
}

if (notaContent.getBtnBawa() != null) {
navigasi.remove(notaContent.getBtnBawa());
vbNavigasi.getChildren().remove(notaContent.getBtnBawa());
}

removeDuplicateNota(FormConstanta.TRANSAKSI_BAWA);
Button buttonBaru = generateButtonNota("W-" + Fucout.getNoNotaTemporary(), Button buttonBaru = generateButtonNota("W-" + Fucout.getNoNotaTemporary(),
FormConstanta.TRANSAKSI_BAWA, FormConstanta.TRANSAKSI_BAWA,
Fucout.TEKS_TIPE_NOTA_BAWA, Fucout.TEKS_TIPE_NOTA_BAWA,
@@ -472,17 +446,8 @@ public class FormUtamaController implements Initializable {
navigasi.add(buttonBaru); navigasi.add(buttonBaru);
vbNavigasi.getChildren().add(buttonBaru); vbNavigasi.getChildren().add(buttonBaru);
notaContent.setBtnBawa(buttonBaru); notaContent.setBtnBawa(buttonBaru);
jumlahNota++;
} else if (hasilReturn.get().equals("Baru:Retur")) { } else if (hasilReturn.get().equals("Baru:Retur")) {
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_RETUR)) {
setContent(null);
}

if (notaContent.getBtnRetur() != null) {
navigasi.remove(notaContent.getBtnRetur());
vbNavigasi.getChildren().remove(notaContent.getBtnRetur());
}

removeDuplicateNota(FormConstanta.TRANSAKSI_RETUR);
Button buttonBaru = generateButtonNota("R-" + Fucout.getNoNotaTemporary(), Button buttonBaru = generateButtonNota("R-" + Fucout.getNoNotaTemporary(),
FormConstanta.TRANSAKSI_RETUR, FormConstanta.TRANSAKSI_RETUR,
Fucout.TEKS_TIPE_NOTA_RETUR, Fucout.TEKS_TIPE_NOTA_RETUR,
@@ -490,31 +455,18 @@ public class FormUtamaController implements Initializable {
navigasi.add(buttonBaru); navigasi.add(buttonBaru);
vbNavigasi.getChildren().add(buttonBaru); vbNavigasi.getChildren().add(buttonBaru);
notaContent.setBtnRetur(buttonBaru); notaContent.setBtnRetur(buttonBaru);
jumlahNota++;
} else if (hasilReturn.get().contains("Checkout:")) { } else if (hasilReturn.get().contains("Checkout:")) {
String noNota = hasilReturn.get().substring(9); String noNota = hasilReturn.get().substring(9);
Button buttonBaru = null; Button buttonBaru = null;
switch (noNota.charAt(0)) { switch (noNota.charAt(0)) {
case Fucout.KODE_NOTA_BON: case Fucout.KODE_NOTA_BON:
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_BON)) {
setContent(null);
}
removeDuplicateNota(FormConstanta.TRANSAKSI_BON);
break; break;
case Fucout.KODE_NOTA_BAWA: case Fucout.KODE_NOTA_BAWA:
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_BAWA)) {
setContent(null);
}
removeDuplicateNota(FormConstanta.TRANSAKSI_BAWA);
break; break;
case Fucout.KODE_NOTA_RETUR: case Fucout.KODE_NOTA_RETUR:
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_RETUR)) {
setContent(null);
}
if (notaContent.btnRetur != null) {
notaContent.nodeRetur = null;
notaContent.controllerRetur = null;
navigasi.remove(notaContent.btnRetur);
vbNavigasi.getChildren().remove(notaContent.getBtnRetur());
}
removeDuplicateNota(FormConstanta.TRANSAKSI_RETUR);


buttonBaru = generateButtonNota(noNota, buttonBaru = generateButtonNota(noNota,
FormConstanta.TRANSAKSI_RETUR, FormConstanta.TRANSAKSI_RETUR,
@@ -523,16 +475,7 @@ public class FormUtamaController implements Initializable {
notaContent.setBtnRetur(buttonBaru); notaContent.setBtnRetur(buttonBaru);
break; break;
default: default:
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_TUNAI)) {
setContent(null);
}
if (notaContent.getBtnTunai() != null) {
notaContent.nodeRetur = null;
notaContent.controllerRetur = null;
navigasi.remove(notaContent.getBtnTunai());
vbNavigasi.getChildren().remove(notaContent.getBtnTunai());
}

removeDuplicateNota(FormConstanta.TRANSAKSI_TUNAI);
buttonBaru = generateButtonNota(noNota, buttonBaru = generateButtonNota(noNota,
FormConstanta.TRANSAKSI_TUNAI, FormConstanta.TRANSAKSI_TUNAI,
Fucout.TEKS_TIPE_NOTA_TUNAI, Fucout.TEKS_TIPE_NOTA_TUNAI,
@@ -540,22 +483,75 @@ public class FormUtamaController implements Initializable {
notaContent.setBtnTunai(buttonBaru); notaContent.setBtnTunai(buttonBaru);
break; break;
} }
if (buttonBaru != null) { if (buttonBaru != null) {
navigasi.add(buttonBaru); navigasi.add(buttonBaru);
vbNavigasi.getChildren().add(buttonBaru); vbNavigasi.getChildren().add(buttonBaru);
jumlahNota++;
} }
} }
} }
} }


public void removeNota(Button btn){
private void removeDuplicateNota(String tipe) {
switch (tipe) {
case FormConstanta.TRANSAKSI_BON:
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_BON)) {
setContent(null);
}

if (notaContent.getBtnBon() != null) {
notaContent.controllerBon = null;
notaContent.nodeBon = null;
navigasi.remove(notaContent.getBtnBon());
vbNavigasi.getChildren().remove(notaContent.getBtnBon());
}
break;
case FormConstanta.TRANSAKSI_BAWA:
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_BAWA)) {
setContent(null);
}

if (notaContent.getBtnBawa() != null) {
notaContent.controllerBawa = null;
notaContent.nodeBawa = null;
navigasi.remove(notaContent.getBtnBawa());
vbNavigasi.getChildren().remove(notaContent.getBtnBawa());
}
break;
case FormConstanta.TRANSAKSI_RETUR:
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_RETUR)) {
setContent(null);
}

if (notaContent.getBtnRetur() != null) {
notaContent.controllerRetur = null;
notaContent.nodeRetur = null;
navigasi.remove(notaContent.getBtnRetur());
vbNavigasi.getChildren().remove(notaContent.getBtnRetur());
}
break;
case FormConstanta.TRANSAKSI_TUNAI:
default:
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_TUNAI)) {
setContent(null);
}

if (notaContent.getBtnTunai() != null) {
notaContent.controllerTunai = null;
notaContent.nodeTunai = null;
navigasi.remove(notaContent.getBtnTunai());
vbNavigasi.getChildren().remove(notaContent.getBtnTunai());
}
break;
}
}

public void removeNota(Button btn) {
setContent(null); setContent(null);
navigasi.remove(btn); navigasi.remove(btn);
vbNavigasi.getChildren().remove(btn); vbNavigasi.getChildren().remove(btn);
jumlahNota--;
} }
//scan member //scan member
@FXML @FXML
void scanMemberOnPressed(KeyEvent event) { void scanMemberOnPressed(KeyEvent event) {
@@ -606,7 +602,11 @@ public class FormUtamaController implements Initializable {
private FormTransaksiTunaiController controllerTunai = null; private FormTransaksiTunaiController controllerTunai = null;
private Node nodeTunai = null; private Node nodeTunai = null;
private Button btnBawa; private Button btnBawa;
private Object controllerBawa = null;
private Node nodeBawa = null;
private Button btnBon; private Button btnBon;
private Object controllerBon = null;
private Node nodeBon = null;
private Button btnRetur; private Button btnRetur;
private FormTransaksiReturController controllerRetur = null; private FormTransaksiReturController controllerRetur = null;
private Node nodeRetur = null; private Node nodeRetur = null;


+ 3
- 3
src/main/resources/fxml/FormTransaksiTunai.fxml View File

@@ -37,7 +37,7 @@
<children> <children>
<HBox alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" spacing="5.0"> <HBox alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" spacing="5.0">
<children> <children>
<Label fx:id="txtNoNota" text="Nomor Nota">
<Label text="Nomor Nota">
<font> <font>
<Font size="14.0" /> <Font size="14.0" />
</font> </font>
@@ -57,7 +57,7 @@
</HBox> </HBox>
<HBox alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" spacing="5.0" GridPane.columnIndex="1"> <HBox alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" spacing="5.0" GridPane.columnIndex="1">
<children> <children>
<Label text="Tanggal :">
<Label text="Tanggal">
<font> <font>
<Font size="14.0" /> <Font size="14.0" />
</font> </font>
@@ -77,7 +77,7 @@
</HBox> </HBox>
<HBox alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" spacing="5.0" GridPane.columnIndex="2"> <HBox alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" spacing="5.0" GridPane.columnIndex="2">
<children> <children>
<Label fx:id="txtKasir" text="Kasir">
<Label text="Kasir">
<font> <font>
<Font size="14.0" /> <Font size="14.0" />
</font> </font>


Loading…
Cancel
Save