|
|
|
@@ -5,6 +5,9 @@ |
|
|
|
*/ |
|
|
|
package id.amigogroup.posterminal.transaksi; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode; |
|
|
|
import id.amigogroup.posterminal.api.AmigoPosRx; |
|
|
|
import id.amigogroup.posterminal.model.Barang; |
|
|
|
import id.amigogroup.posterminal.model.DNotaRetur; |
|
|
|
@@ -105,7 +108,7 @@ public class FormTransaksiReturController implements Initializable { |
|
|
|
@FXML |
|
|
|
private Label lblTambahKeTabelRetur; |
|
|
|
private TableColumn<TabelBarangTunai, Button> tcAction; |
|
|
|
|
|
|
|
|
|
|
|
private final AmigoPosRx posRx = new AmigoPosRx(); |
|
|
|
private String noNota = ""; |
|
|
|
private final ObservableList<TabelBarangTunai> daftarTabelPenjualan = FXCollections.observableArrayList(); |
|
|
|
@@ -161,18 +164,18 @@ public class FormTransaksiReturController implements Initializable { |
|
|
|
daftarTabelRetur.clear(); |
|
|
|
|
|
|
|
for (DNotaTunai dNotaTunai : daftarNotaTunai) { |
|
|
|
//Button |
|
|
|
Button btnAction = ButtonUtility.generateButton(ButtonUtility.CLOSE_ICON); |
|
|
|
//Button |
|
|
|
Button btnAction = ButtonUtility.generateButton(ButtonUtility.CLOSE_ICON); |
|
|
|
btnAction.setOnAction((t) -> { |
|
|
|
Alert alert = AlertUtil.getAlertDialogKonfirmasi( |
|
|
|
AlertUtil.DIALOG_KONFIRMASI_MESSAGE, |
|
|
|
"Yakin ingin menghapus barang?"); |
|
|
|
alert.initOwner(apMain.getScene().getWindow()); |
|
|
|
alert.show(); |
|
|
|
|
|
|
|
AlertUtil.DIALOG_KONFIRMASI_MESSAGE, |
|
|
|
"Yakin ingin menghapus barang?"); |
|
|
|
alert.initOwner(apMain.getScene().getWindow()); |
|
|
|
alert.show(); |
|
|
|
|
|
|
|
}); |
|
|
|
TextField fldPramuniaga = new TextField(dNotaTunai.getKodePram()); |
|
|
|
|
|
|
|
|
|
|
|
String namaBarang = "..."; |
|
|
|
if (AmigoPosCache.getInstance().getDaftarBarang().containsKey(dNotaTunai.getKdBarang())) { |
|
|
|
Barang barang = AmigoPosCache.getInstance().getDaftarBarang() |
|
|
|
@@ -198,7 +201,7 @@ public class FormTransaksiReturController implements Initializable { |
|
|
|
|
|
|
|
tbt.setData(dNotaTunai); |
|
|
|
daftarTabelPenjualan.add(tbt); |
|
|
|
|
|
|
|
|
|
|
|
if (!AmigoPosCache.getInstance().getDaftarBarang().containsKey(dNotaTunai.getKdBarang())) { |
|
|
|
posRx.getBarangByKodeBarang(dNotaTunai.getKdBarang()).subscribe(getBarangObserver); |
|
|
|
} |
|
|
|
@@ -208,7 +211,37 @@ public class FormTransaksiReturController implements Initializable { |
|
|
|
@FXML |
|
|
|
void fldNotaPenjualanOnKeyPressed(KeyEvent event) { |
|
|
|
if (event.getCode() == KeyCode.ENTER) { |
|
|
|
posRx.getDNotaTunaiByNoNota(fldNotaPenjualan.getText()).subscribe(getDNotaTunaiObserver); |
|
|
|
Disposable disposable = posRx.validasiMNotaTunaiByNoNotaTanggal(fldNotaPenjualan.getText()) |
|
|
|
.subscribe((response) -> { |
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
JsonNode jsonNode = mapper.readTree(response.string()); |
|
|
|
ObjectNode node = jsonNode.deepCopy(); |
|
|
|
|
|
|
|
if (node.get("result") != null && node.get("result").asBoolean()) { |
|
|
|
posRx.getDNotaTunaiByNoNota(fldNotaPenjualan.getText()).subscribe(getDNotaTunaiObserver); |
|
|
|
} else { |
|
|
|
Alert alert = AlertUtil.getAlertError( |
|
|
|
"Nota Tidak Bisa Digunakan", |
|
|
|
node.get("message").asText()); |
|
|
|
alert.initOwner(apMain.getScene().getWindow()); |
|
|
|
alert.show(); |
|
|
|
} |
|
|
|
}, (error) -> { |
|
|
|
if (error instanceof HttpException) { |
|
|
|
switch (((HttpException) error).code()) { |
|
|
|
case HttpURLConnection.HTTP_NOT_FOUND: |
|
|
|
Platform.runLater(() -> { |
|
|
|
Alert alert = AlertUtil.getAlertError( |
|
|
|
AlertUtil.ERROR_TIDAK_DITEMUKAN_TITLE, |
|
|
|
"Data nota tidak ditemukan."); |
|
|
|
alert.initOwner(apMain.getScene().getWindow()); |
|
|
|
alert.show(); |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
AmigoPosRx.handleGenericError(error, apMain.getScene().getWindow()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|