public void prepareVtPred(String cradnal, int rbsrn, boolean single) { sds = new StorageDataSet(); sds.setColumns(dm.getVTPred().cloneColumns()); sds.open(); sds.insertRow(false); initParams(); QueryDataSet materijal = selectIzdatnice(cradnal, rbsrn, single); for (materijal.first(); materijal.inBounds(); materijal.next()) { if (ld.raLocate(dm.getSklad(), "CSKL", materijal.getString("CSKL"))) { if (dm.getSklad().getString("TIPSKL").equalsIgnoreCase("M")) { sds.setBigDecimal( "MAT_I", sds.getBigDecimal("MAT_I").add(materijal.getBigDecimal("IRAZ"))); } else if (dm.getSklad().getString("TIPSKL").equalsIgnoreCase("P")) { sds.setBigDecimal( "PRO_I", sds.getBigDecimal("PRO_I").add(materijal.getBigDecimal("IRAZ"))); } else if (dm.getSklad().getString("TIPSKL").equalsIgnoreCase("R")) { sds.setBigDecimal( "ROB_I", sds.getBigDecimal("ROB_I").add(materijal.getBigDecimal("IRAZ"))); } else if (dm.getSklad().getString("TIPSKL").equalsIgnoreCase("L")) { sds.setBigDecimal( "POL_I", sds.getBigDecimal("POL_I").add(materijal.getBigDecimal("IRAZ"))); } } else { throw new RuntimeException( "Skladište " + materijal.getString("CSKL") + " nisam uspio pronaæi sa raLocate !!! "); } } sds.setBigDecimal("USL_I", iznosTroskovaUsluge(cradnal, rbsrn)); faktorizacija(); }
public BigDecimal iznosTroskovaUsluge(String cradnal, int rbsrn) { BigDecimal suma = Aus.zero2; QueryDataSet rns = Rnser.getDataModule().getTempSet("cradnal='" + cradnal + "' and rbsid=" + rbsrn); rns.open(); for (rns.first(); rns.inBounds(); rns.next()) { suma = suma.add(rns.getBigDecimal("VRI")); } if (rns.rowCount() == 0) { String selectRN = "select cart,kol from stdoki where cradnal = '" + cradnal + "' and vrdok='RNL' and rbsid=" + rbsrn; QueryDataSet radninalog = hr.restart.util.Util.getNewQueryDataSet(selectRN, true); QueryDataSet normativUs = Aut.getAut().expandArt(radninalog.getInt("CART"), radninalog.getBigDecimal("KOL"), false); for (normativUs.first(); normativUs.inBounds(); normativUs.next()) { if (raVart.isUsluga(normativUs.getInt("CART"))) { // Aut.getAut().artTipa(normativUs.getInt("CART"),"U")) { suma = suma.add(dm.getArtikli().getBigDecimal("NC")) .multiply(normativUs.getBigDecimal("KOL")); } } } return suma; }
public boolean Validacija() { if (!super.Validacija()) return false; rcc.EnabDisabAll(jPanel1, false); fondSati = raIzvjestaji.getFond(fieldSet.getShort("GODINAOD"), fieldSet.getShort("MJESECOD"), true) .satiUk; gomj = fieldSet.getShort("GODINAOD") * 100 + fieldSet.getShort("MJESECOD"); _od = java.sql.Timestamp.valueOf( fieldSet.getShort("GODINAOD") + "-" + fieldSet.getShort("MJESECOD") + "-01 00:00:00.00"); _do = Util.getUtil().getLastSecondOfDay(Util.getUtil().getLastDayOfMonth(_od)); /*java.sql.Timestamp.valueOf(fieldSet.getShort("GODINAOD") + "-" + fieldSet.getShort("MJESECOD") + "-31 23:59:59.99");*/ String qst1 = "select sum(kumulrad.sati) as sati, sum(kumulrad.bruto) as bruto, sum(kumulrad.neto) as neto," + " sum(kumulrad.doprinosi) as doprinosi," + " sum(kumulrad.neto2) as neto2, sum(kumulrad.poriprir) as poriprir," + " min(kumulrad.bruto) as bmin, max(kumulrad.bruto) as bmax, min(kumulrad.netopk) as nmin, " + " max(kumulrad.netopk) as nmax" + " from kumulrad, radnici where radnici.cradnik = kumulrad.cradnik " + // "AND radnici.corg = orgpl.corg " + "AND " + getWhereQuery("radnici"); // +" AND (orgpl.datumispl between '" + _od + "'"+ // " AND '" + _do + "')" ; String qst2 = "select sum(kumulradarh.sati) as sati, sum(kumulradarh.bruto) as bruto, sum(kumulradarh.neto) as neto," + " sum(kumulradarh.doprinosi) as doprinosi," + " sum(kumulradarh.neto2) as neto2, sum(kumulradarh.poriprir) as poriprir," + " min(kumulradarh.bruto) as bmin, max(kumulradarh.bruto) as bmax, min(kumulradarh.netopk) as nmin, " + " max(kumulradarh.netopk) as nmax" + " from kumulradarh, radnici, Kumulorgarh WHERE kumulradarh.cradnik = radnici.cradnik" + " AND kumulradarh.godobr = kumulorgarh.godobr AND kumulradarh.mjobr = kumulorgarh.mjobr" + " AND kumulradarh.rbrobr = kumulorgarh.rbrobr AND kumulradarh.cvro = kumulorgarh.cvro" + " AND kumulradarh.corg = kumulorgarh.corg AND radnici.corg = kumulorgarh.corg AND " + getWhereQuery("radnici") + " AND kumulorgarh.datumispl between '" + _od + "' AND '" + _do + "' "; System.out.println("\nobradaQDS query : " + qst1); System.out.println("\narhivaQDS query : " + qst2 + "\n"); QueryDataSet obradaQDS = Util.getNewQueryDataSet(qst1); QueryDataSet arhivaQDS = Util.getNewQueryDataSet(qst2); makeRepSet(obradaQDS, arhivaQDS); maxBN(); // _od, _do); bruto0 = arhivaQDS.getBigDecimal("BRUTO").setScale(0, java.math.BigDecimal.ROUND_HALF_UP); try { if (frmParam .getParam( "pl", "splbrrad", "F", "SPL: broj radnika se dobiva iz (F)onda sati ili brojanjem (R)adnika") .equalsIgnoreCase("R")) { brojRadnika = calcBrojRadnika(); } else { brojRadnika = repSet.getBigDecimal("SATI").divide(fondSati, 2, java.math.BigDecimal.ROUND_HALF_UP); } } catch (Exception ex) { ex.printStackTrace(); brojRadnika = new java.math.BigDecimal("0"); } return true; }
private void makeRepSet(QueryDataSet obrada, QueryDataSet arhiva) { repSet = new StorageDataSet(); repSet.setColumns(obrada.cloneColumns()); repSet.open(); repSet.insertRow(false); repSet.setBigDecimal( "SATI", (obrada.getBigDecimal("SATI").add(arhiva.getBigDecimal("SATI"))) .setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); // dadd repSet.setBigDecimal( "BRUTO", (obrada.getBigDecimal("BRUTO") /*.add(arhiva.getBigDecimal("BRUTO"))*/) .setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); repSet.setBigDecimal( "NETO", (obrada.getBigDecimal("NETO").add(arhiva.getBigDecimal("NETO"))) .setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); // dadd repSet.setBigDecimal( "DOPRINOSI", (obrada.getBigDecimal("DOPRINOSI").add(arhiva.getBigDecimal("DOPRINOSI"))) .setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); repSet.setBigDecimal( "NETO2", (obrada.getBigDecimal("NETO2").add(arhiva.getBigDecimal("NETO2"))) .setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); repSet.setBigDecimal( "PORIPRIR", (obrada.getBigDecimal("PORIPRIR").add(arhiva.getBigDecimal("PORIPRIR"))) .setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); // System.out.println(obrada.getBigDecimal("BMIN") + " // obrada.getBigDecimal(\"BMIN\").compareTo(arhiva.getBigDecimal(\"BMIN\")) >= 0 "+ // arhiva.getBigDecimal("BMIN")+ " ; " + // (obrada.getBigDecimal("BMIN").compareTo(arhiva.getBigDecimal("BMIN")) >= 0)); // System.out.println("arhiva.getBigDecimal(\"BMIN\").compareTo(new // java.math.BigDecimal(\"0.00\")) != 0 " + (arhiva.getBigDecimal("BMIN").compareTo(new // java.math.BigDecimal("0.00")) != 0)); if (obrada.getBigDecimal("BMIN").compareTo(arhiva.getBigDecimal("BMIN")) <= 0 && arhiva.getBigDecimal("BMIN").compareTo(new java.math.BigDecimal("0.00")) != 0) { // System.out.println("obrada nema redova ili obrada manja oda arhive i arhiva nije // nula"); repSet.setBigDecimal( "BMIN", arhiva.getBigDecimal("BMIN").setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); } else { // System.out.println("nesto ne stima!!! ili ???"); repSet.setBigDecimal( "BMIN", obrada.getBigDecimal("BMIN").setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); } if (obrada.getBigDecimal("BMAX").compareTo(arhiva.getBigDecimal("BMAX")) >= 0) { repSet.setBigDecimal( "BMAX", obrada.getBigDecimal("BMAX").setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); maxBrutoTableName = "kumulrad"; primanjaBrutoTableName = "primanjaobr"; pomocnaBrut = "orgpl"; } else { repSet.setBigDecimal( "BMAX", arhiva.getBigDecimal("BMAX").setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); maxBrutoTableName = "kumulradarh"; primanjaBrutoTableName = "primanjaarh"; pomocnaBrut = "Kumulorgarh"; } if (obrada.getBigDecimal("NMIN").compareTo(arhiva.getBigDecimal("NMIN")) <= 0 && arhiva.getBigDecimal("NMIN").compareTo(new java.math.BigDecimal("0")) != 0) { repSet.setBigDecimal( "NMIN", arhiva.getBigDecimal("NMIN").setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); } else { repSet.setBigDecimal( "NMIN", obrada.getBigDecimal("NMIN").setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); } if (obrada.getBigDecimal("NMAX").compareTo(arhiva.getBigDecimal("NMAX")) >= 0) { repSet.setBigDecimal( "NMAX", obrada.getBigDecimal("NMAX").setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); maxNetoTableName = "kumulrad"; primanjaNetoTableName = "primanjaobr"; pomocnaNet = "orgpl"; } else { repSet.setBigDecimal( "NMAX", arhiva.getBigDecimal("NMAX").setScale(0, java.math.BigDecimal.ROUND_HALF_UP)); maxNetoTableName = "kumulradarh"; primanjaNetoTableName = "primanjaarh"; pomocnaNet = "Kumulorgarh"; } }
private void maxBN() { // java.sql.Timestamp _od, java.sql.Timestamp _do) { // System.out.println("od " + _od); // System.out.println("do " + _do); String qst3Sub1 = "", qst4Sub1 = ""; if (maxBrutoTableName.equals("kumulradarh")) { qst3Sub1 = "SELECT max(primanjaarh.bruto) as bruto FROM primanjaarh, Kumulorgarh " + "WHERE cradnik in ( " + "SELECT cradnik FROM kumulradarh WHERE bruto = ( " + "SELECT max(kumulradarh.bruto) " + "FROM kumulradarh, Kumulorgarh " + "WHERE kumulradarh.godobr = kumulorgarh.godobr " + "AND kumulradarh.mjobr = kumulorgarh.mjobr " + "AND kumulradarh.rbrobr = kumulorgarh.rbrobr " + "AND kumulradarh.cvro = kumulorgarh.cvro " + "AND kumulradarh.corg = kumulorgarh.corg " + "AND kumulorgarh.datumispl between '" + _od + "' " + "AND '" + _do + "' " + ") group by cradnik) " + "AND primanjaarh.godobr = kumulorgarh.godobr " + "AND primanjaarh.mjobr = kumulorgarh.mjobr " + "AND primanjaarh.rbrobr = kumulorgarh.rbrobr " + "AND primanjaarh.corg = kumulorgarh.corg " + "AND kumulorgarh.datumispl between '" + _od + "' " + " AND '" + _do + "'"; qst4Sub1 = "SELECT max(primanjaarh.neto) as neto FROM primanjaarh, Kumulorgarh " + "WHERE cradnik in ( " + "SELECT cradnik FROM kumulradarh WHERE netopk = ( " + "SELECT max(kumulradarh.netopk) " + "FROM kumulradarh, Kumulorgarh " + "WHERE kumulradarh.godobr = kumulorgarh.godobr " + "AND kumulradarh.mjobr = kumulorgarh.mjobr " + "AND kumulradarh.rbrobr = kumulorgarh.rbrobr " + "AND kumulradarh.cvro = kumulorgarh.cvro " + "AND kumulradarh.corg = kumulorgarh.corg " + "AND kumulorgarh.datumispl between '" + _od + "' " + "AND '" + _do + "' " + ")) " + "AND primanjaarh.godobr = kumulorgarh.godobr " + "AND primanjaarh.mjobr = kumulorgarh.mjobr " + "AND primanjaarh.rbrobr = kumulorgarh.rbrobr " + "AND primanjaarh.corg = kumulorgarh.corg " + "AND kumulorgarh.datumispl between '" + _od + "' " + " AND '" + _do + "'"; } else { qst3Sub1 = "SELECT max(primanjaobr.bruto) as bruto FROM Primanjaobr, Orgpl " + "WHERE primanjaobr.corg = orgpl.corg " + "AND Orgpl.datumispl between '" + _od + "' " + "AND '" + _do + "' "; qst4Sub1 = "SELECT max(primanjaobr.neto) as neto FROM Primanjaobr, Orgpl " + "WHERE primanjaobr.corg = orgpl.corg " + "AND Orgpl.datumispl between '" + _od + "' " + "AND '" + _do + "' "; } String qst3 = qst3Sub1; String qst4 = qst4Sub1; if (!raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_020).equals("")) { qst3 = qst3.concat(" and not ".concat(raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_020))); qst4 = qst4.concat(" and not ".concat(raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_020))); } if (!raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_030).equals("")) { qst3 = qst3.concat(" and not ".concat(raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_030))); qst4 = qst4.concat(" and not ".concat(raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_030))); } if (!raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_040).equals("")) { qst3 = qst3.concat(" and not ".concat(raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_040))); qst4 = qst4.concat(" and not ".concat(raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_040))); } if (!raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_050).equals("")) { qst3 = qst3.concat(" and not ".concat(raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_050))); qst4 = qst4.concat(" and not ".concat(raIzvjestaji.getPrimanjaWhQueryIzv(raIzvjestaji.ID_050))); } System.out.println("\nqst3 - " + qst3); System.out.println("\nqst4 - " + qst4 + "\n"); QueryDataSet brut02QDS = Util.getNewQueryDataSet(qst3); QueryDataSet neto02QDS = Util.getNewQueryDataSet(qst4); bruto10 = brut02QDS.getBigDecimal("BRUTO").setScale(0, java.math.BigDecimal.ROUND_HALF_UP); neto12 = neto02QDS.getBigDecimal("NETO").setScale(0, java.math.BigDecimal.ROUND_HALF_UP); // System.out.println("\nbruto10 : " + bruto10); // System.out.println("neto12 : " + neto12); }
protected void racunica(QueryDataSet tmpSet) { String misec; tmpSet.first(); if (getCkup().equalsIgnoreCase("")) { this.killAllReports(); this.addReport( "hr.restart.robno.repStatsMonths", "hr.restart.robno.repStatsMonths", "StatsMonths", "bla bla bla"); do { misec = tmpSet.getTimestamp("DATDOK").toString().substring(5, 7); if (!lookupData.getlookupData().raLocate(monthSet, "CPAR", tmpSet.getInt("CPAR") + "")) { monthSet.insertRow(false); monthSet.setInt("CPAR", tmpSet.getInt("CPAR")); monthSet.setBigDecimal(misec, tmpSet.getBigDecimal("IPRODSP")); monthSet.setBigDecimal("UKUPNO", tmpSet.getBigDecimal("IPRODSP")); } else { monthSet.setBigDecimal( misec, monthSet.getBigDecimal(misec).add(tmpSet.getBigDecimal("IPRODSP"))); monthSet.setBigDecimal( "UKUPNO", monthSet.getBigDecimal("UKUPNO").add(tmpSet.getBigDecimal("IPRODSP"))); } } while (tmpSet.next()); monthSet.getColumn("CART").setVisible(0); monthSet.getColumn("CART1").setVisible(0); monthSet.getColumn("BC").setVisible(0); monthSet.getColumn("NAZART").setVisible(0); if (fieldSet.getString("SLJED").equals("CPAR")) { monthSet.setSort(new SortDescriptor(new String[] {fieldSet.getString("SLJED")})); } else { monthSet.setSort( new SortDescriptor(new String[] {fieldSet.getString("SLJED")}, true, true)); this.addReport( "hr.restart.robno.RepStatParMonthsChart", "hr.restart.robno.RepStatParMonthsChart", "Top lista kupaca mjeseèno - grafikon"); } } else { this.killAllReports(); this.addReport( "hr.restart.robno.repStatsMonthsArt", "hr.restart.robno.repStatsMonths", "StatsMonthsArt", "bla bla bla"); do { misec = tmpSet.getTimestamp("DATDOK").toString().substring(5, 7); if (!lookupData.getlookupData().raLocate(monthSet, "CART", tmpSet.getInt("CART") + "")) { monthSet.insertRow(false); monthSet.setInt("CART", tmpSet.getInt("CART")); monthSet.setString("CART1", tmpSet.getString("CART1")); monthSet.setString("BC", tmpSet.getString("BC")); monthSet.setString("NAZART", tmpSet.getString("NAZART")); monthSet.setBigDecimal(misec, tmpSet.getBigDecimal("IPRODSP")); monthSet.setBigDecimal("UKUPNO", tmpSet.getBigDecimal("IPRODSP")); } else { monthSet.setBigDecimal( misec, monthSet.getBigDecimal(misec).add(tmpSet.getBigDecimal("IPRODSP"))); monthSet.setBigDecimal( "UKUPNO", monthSet.getBigDecimal("UKUPNO").add(tmpSet.getBigDecimal("IPRODSP"))); } } while (tmpSet.next()); monthSet.getColumn("CART").setVisible(0); monthSet.getColumn("CART1").setVisible(0); monthSet.getColumn("BC").setVisible(0); monthSet.getColumn("CPAR").setVisible(0); monthSet.getColumn(Aut.getAut().getCARTdependable("CART", "CART1", "BC")).setVisible(1); monthSet.setSort(new SortDescriptor(new String[] {"UKUPNO"}, true, true)); } monthSet.first(); dm.getPartneri().open(); String[] mpb = new String[] {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}; do { for (int i = 0; i < mpb.length; i++) { monthSetGraph.insertRow(false); monthSetGraph.setInt("CPAR", monthSet.getInt("CPAR")); if (lookupData .getlookupData() .raLocate(dm.getPartneri(), "CPAR", monthSet.getInt("CPAR") + "")) { monthSetGraph.setString("NAZPAR", dm.getPartneri().getString("NAZPAR")); } else { monthSetGraph.setString("NAZPAR", ""); } monthSetGraph.setBigDecimal("UKUPNO", monthSet.getBigDecimal("UKUPNO")); monthSetGraph.setString("MJESEC", mpb[i]); monthSetGraph.setBigDecimal("IZNOS", monthSet.getBigDecimal(mpb[i])); } } while (monthSet.next()); monthSetGraph.setSort(new SortDescriptor(new String[] {"UKUPNO", "CPAR"}, true, true)); monthSet.last(); setDataSetAndSums( monthSet, new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "UKUPNO" }); }