public void autoKembali() { double total_tmp = 0; double bayar_tmp = 0; double hutang_tmp = 0; double kembali_tmp = 0; if (!bayar.getText().equals("")) { try { bayar_tmp = Double.parseDouble(bayar.getText().replaceAll("\\,", "")); } catch (Exception e) { App.printErr(e); } } try { total.commitEdit(); total_tmp = Double.parseDouble(total.getValue() + ""); } catch (Exception e) { total.setText("0"); } if (total_tmp > bayar_tmp) { hutang_tmp = total_tmp - bayar_tmp; } else { kembali_tmp = bayar_tmp - total_tmp; } k.setValue(hutang_tmp); kembali.setValue(kembali_tmp); try { k.commitEdit(); kembali.commitEdit(); } catch (ParseException e) { App.printErr(e); } }
public boolean validate(ODatabaseDocumentTx db) { if (!(code.getText().equalsIgnoreCase("AUTO") || code.getText().trim().equalsIgnoreCase(""))) { long tmp = App.getPenjualanDao().getCountByColumn(db, PenjualanDao.code, code.getText()); if (tmp > 0) { codea = ""; App.showErrorDataSudahAda(db, PenjualanDao.fcode); return false; } } codea = code.getText(); tgla = tgl.getDate(); if (tgla == null) { tgl.setDate(new Date()); tgla = new Date(); App.showErrorFieldEmpty(db, PenjualanDao.ftgl); return false; } if (cust == null) { pelanggan.setText(""); App.showErrorFieldEmpty(db, PenjualanDao.fpelanggan); return false; } else { pelanggana = cust; } try { hargaa = Double.parseDouble(harga.getValue() + ""); if (hargaa < 0) { return false; } } catch (Exception e) { harga.setText("1"); try { harga.commitEdit(); } catch (ParseException e1) { } App.printErr(e); return false; } try { jmla = Double.parseDouble(jml.getValue() + ""); if (jmla <= 0) { App.showErrorJumlahTidakFalid(); } } catch (Exception e) { jml.setText(""); App.showErrorFieldEmpty(db, PenjualanDao.fjml); return false; } try { diskon.commitEdit(); diskona = Double.parseDouble(diskon.getValue() + ""); if (diskona < 0) { App.showErrorNotValid(db, PenjualanDao.fdiskon); } } catch (Exception e) { App.showErrorFieldEmpty(db, PenjualanDao.fdiskon); App.printErr(e); return false; } try { diskonp.commitEdit(); diskonpa = Double.parseDouble(diskonp.getValue() + ""); if (diskonpa < 0) { App.showErrorNotValid(db, PenjualanDao.fdiskonp); } } catch (Exception e) { App.showErrorFieldEmpty(db, PenjualanDao.fdiskonp); App.printErr(e); return false; } try { if (bayar.getText().equals("")) { App.showErrorFieldEmpty(db, PenjualanDao.fbayar); return false; } String stmp = bayar.getText().replaceAll("\\,", ""); if (stmp == null || stmp.equalsIgnoreCase("")) { App.showErrorFieldEmpty(db, PenjualanDao.fbayar); return false; } bayara = Double.parseDouble(stmp); if (bayara < 0) { App.showErrorNotValid(db, PenjualanDao.fbayar); } } catch (Exception e) { App.showErrorFieldEmpty(db, PenjualanDao.fbayar); App.printErr(e); return false; } try { k.commitEdit(); ka = Double.parseDouble(k.getValue() + ""); } catch (Exception e) { App.printErr(e); return false; } try { total1.commitEdit(); total1a = Double.parseDouble(total1.getValue() + ""); } catch (Exception e) { App.printErr(e); return false; } try { total.commitEdit(); totala = Double.parseDouble(total.getValue() + ""); } catch (Exception e) { App.printErr(e); return false; } if (ka > 0) { da = bayara; notea = App.getT(db, "Hutang"); } else { da = totala; notea = App.getT(db, "Lunas"); } producta = DataUser.getProduct(); return true; }