Bug fix data nota tidak bisa ditumpuk

pull/11/head
Ronaldo Christnawan 6 years ago
parent 5c0de8e7a2
commit 713f59d94c

@ -83,7 +83,6 @@ public class FormUtamaController implements Initializable {
private final List<Button> navigasi = new ArrayList<>();
private int notaState = -1;
private String tipeTransaksiState = "";
private int jumlahNota = 0;
private final char NOTA_PREV = 'p';
private final char NOTA_NEXT = 'n';
public final NotaContent notaContent = new NotaContent();
@ -176,7 +175,7 @@ public class FormUtamaController implements Initializable {
FormTransaksiTunaiController fttc = loader.getController();
notaContent.setControllerTunai(fttc);
fttc.initData(this,noNota, baru);
fttc.initData(this, noNota, baru);
}
break;
case FormConstanta.TRANSAKSI_RETUR:
@ -201,6 +200,7 @@ public class FormUtamaController implements Initializable {
}
private void loadNota(char operasi) {
int jumlahNota = navigasi.size();
switch (operasi) {
case NOTA_PREV:
if (notaState == -1) {
@ -408,7 +408,7 @@ public class FormUtamaController implements Initializable {
return stage;
}
public Window getWindow(){
public Window getWindow() {
return bpMain.getScene().getWindow();
}
@ -420,15 +420,7 @@ public class FormUtamaController implements Initializable {
if (hasilReturn.isPresent()) {
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(),
FormConstanta.TRANSAKSI_TUNAI,
Fucout.TEKS_TIPE_NOTA_TUNAI,
@ -436,17 +428,8 @@ public class FormUtamaController implements Initializable {
navigasi.add(buttonBaru);
vbNavigasi.getChildren().add(buttonBaru);
notaContent.setBtnTunai(buttonBaru);
jumlahNota++;
} 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(),
FormConstanta.TRANSAKSI_BON,
Fucout.TEKS_TIPE_NOTA_BON,
@ -454,17 +437,8 @@ public class FormUtamaController implements Initializable {
navigasi.add(buttonBaru);
vbNavigasi.getChildren().add(buttonBaru);
notaContent.setBtnBon(buttonBaru);
jumlahNota++;
} 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(),
FormConstanta.TRANSAKSI_BAWA,
Fucout.TEKS_TIPE_NOTA_BAWA,
@ -472,17 +446,8 @@ public class FormUtamaController implements Initializable {
navigasi.add(buttonBaru);
vbNavigasi.getChildren().add(buttonBaru);
notaContent.setBtnBawa(buttonBaru);
jumlahNota++;
} 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(),
FormConstanta.TRANSAKSI_RETUR,
Fucout.TEKS_TIPE_NOTA_RETUR,
@ -490,31 +455,18 @@ public class FormUtamaController implements Initializable {
navigasi.add(buttonBaru);
vbNavigasi.getChildren().add(buttonBaru);
notaContent.setBtnRetur(buttonBaru);
jumlahNota++;
} else if (hasilReturn.get().contains("Checkout:")) {
String noNota = hasilReturn.get().substring(9);
Button buttonBaru = null;
switch (noNota.charAt(0)) {
case Fucout.KODE_NOTA_BON:
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_BON)) {
setContent(null);
}
removeDuplicateNota(FormConstanta.TRANSAKSI_BON);
break;
case Fucout.KODE_NOTA_BAWA:
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_BAWA)) {
setContent(null);
}
removeDuplicateNota(FormConstanta.TRANSAKSI_BAWA);
break;
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,
FormConstanta.TRANSAKSI_RETUR,
@ -523,16 +475,7 @@ public class FormUtamaController implements Initializable {
notaContent.setBtnRetur(buttonBaru);
break;
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,
FormConstanta.TRANSAKSI_TUNAI,
Fucout.TEKS_TIPE_NOTA_TUNAI,
@ -540,20 +483,73 @@ public class FormUtamaController implements Initializable {
notaContent.setBtnTunai(buttonBaru);
break;
}
if (buttonBaru != null) {
navigasi.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);
navigasi.remove(btn);
vbNavigasi.getChildren().remove(btn);
jumlahNota--;
}
//scan member
@ -606,7 +602,11 @@ public class FormUtamaController implements Initializable {
private FormTransaksiTunaiController controllerTunai = null;
private Node nodeTunai = null;
private Button btnBawa;
private Object controllerBawa = null;
private Node nodeBawa = null;
private Button btnBon;
private Object controllerBon = null;
private Node nodeBon = null;
private Button btnRetur;
private FormTransaksiReturController controllerRetur = null;
private Node nodeRetur = null;

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

Loading…
Cancel
Save