public void autoHarga() { double harga_tmp = 0; double jumlah_tmp = 0; double total1_tmp = 0; double diskon_tmp = 0; double diskonp_tmp = 0; double total_tmp = 0; double bayar_tmp = 0; try { harga.commitEdit(); harga_tmp = Double.parseDouble(harga.getValue() + ""); } catch (Exception e) { App.printErr(e); } try { jml.commitEdit(); jumlah_tmp = Double.parseDouble(jml.getValue() + ""); } catch (Exception e) { // App.showErrorJumlahTidakFalid(); jml.setText(""); App.printErr(e); } total1_tmp = harga_tmp * jumlah_tmp; total1.setValue(total1_tmp); try { diskon.commitEdit(); diskon_tmp = Double.parseDouble(diskon.getValue() + ""); } catch (Exception e) { diskon.setText("0"); App.printErr(e); } try { diskonp.commitEdit(); diskonp_tmp = Double.parseDouble(diskonp.getValue() + ""); } catch (Exception e) { diskonp.setText("0"); App.printErr(e); } double diskonp_rp = 0; if (diskonp_tmp > 0) { diskonp_rp = total1_tmp * diskonp_tmp / 100; } double total_diskon = diskon_tmp + diskonp_rp; App.info(total_diskon + ""); total_tmp = total1_tmp - total_diskon; total.setValue(total_tmp); try { total.commitEdit(); } catch (ParseException e) { App.printErr(e); } autoKembali(); }
@Override public void aksiReset() { code.setText("AUTO"); tgl.setDate(new Date()); clearText(pelanggan); cust = null; clearText(jml); double p = DataUser.getProduct().field(ProductDao.harga); harga.setValue(p); clearText(total1); diskon.setText("0"); diskonp.setText("0.00"); clearText(total); bayar.setText(""); k.setText("0"); kembali.setText("0"); setCursor(); }
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; }