public Object getValue(SpreadSheetCellValueContext context) { SQLRowAccessor row = context.getRow(); BigDecimal percent = row.getBigDecimal("POURCENT_FACTURABLE"); BigDecimal amount = row.getBigDecimal("MONTANT_FACTURABLE"); Acompte a = new Acompte(percent, amount); return a.toPlainString(); }
public static double getTimeSpent(SQLRowAccessor row) { double time = 0; final Collection<? extends SQLRowAccessor> rTimes = row.getReferentRows(row.getTable().getTable("AFFAIRE_TEMPS")); for (SQLRowAccessor r : rTimes) { time += r.getFloat("TEMPS"); } return time; }
public static int getHours(SQLRowAccessor row) { int h = 0; final String code = row.getForeign("ID_UNITE_VENTE").getString("CODE"); if (code.equals("h")) { h += row.getLong("QTE_UNITAIRE") * row.getLong("QTE"); } else if (code.equals("j")) { h += row.getLong("QTE_UNITAIRE") * row.getLong("QTE") * 8; } return h; }
@Override public void show(SQLRowAccessor r) { final String fieldName0 = getFields().get(0).getName(); final String fieldName1 = getFields().get(1).getName(); if (r.getFields().contains(fieldName0) && r.getFields().contains(fieldName1)) { String cp = r.getString(fieldName0); String name = r.getString(fieldName1); final Ville villeFromVilleEtCode = Ville.getVilleFromVilleEtCode(name + " (" + cp + ")"); // get a matching Ville if (villeFromVilleEtCode != null) { this.getWrapper().setValue(villeFromVilleEtCode); } else { this.getWrapper().setValue(new Ville(name, 0, 0, 0, cp)); } } }
@Override public void select(final SQLRowAccessor r) { if (r != null) { this.numeroUniqueDevis.setIdSelected(r.getID()); } if (r == null || r.getIDNumber() == null) super.select(r); else { System.err.println(r); final SQLRowValues rVals = r.asRowValues(); final SQLRowValues vals = new SQLRowValues(r.getTable()); vals.load(rVals, createSet("ID_CLIENT")); vals.setID(rVals.getID()); System.err.println("Select CLIENT"); super.select(vals); rVals.remove("ID_CLIENT"); super.select(rVals); } // super.select(r); if (r != null) { this.table.insertFrom("ID_DEVIS", r.getID()); // this.radioEtat.setVisible(r.getID() > getTable().getUndefinedID()); if (getTable().contains("SITE_DIFF")) setSiteEnabled(r.getBoolean("SITE_DIFF"), Type_Diff.SITE); if (getTable().contains("DONNEUR_DIFF")) setSiteEnabled(r.getBoolean("DONNEUR_DIFF"), Type_Diff.DONNEUR_ORDRE); } }
private BigDecimal getAvancement(SQLRowAccessor r) { Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_COMMANDE_CLIENT")); long totalFact = 0; long total = r.getLong("T_HT"); for (SQLRowAccessor row : rows) { if (!row.isForeignEmpty("ID_SAISIE_VENTE_FACTURE")) { SQLRowAccessor rowFact = row.getForeign("ID_SAISIE_VENTE_FACTURE"); Long l = rowFact.getLong("T_HT"); totalFact += l; } } if (total > 0) { return new BigDecimal(totalFact) .divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION) .movePointRight(2) .setScale(2, RoundingMode.HALF_UP); } else { return BigDecimal.ONE.movePointRight(2); } }
public static final Date calculDate(SQLRowAccessor rowMdr, Date currentDate) { return calculDate(rowMdr.getInt("AJOURS"), rowMdr.getInt("LENJOUR"), currentDate); }
@Override public JComponent getRenderer(final SQLRowAccessor row, int maxWidth) { final JPanel p = new JPanel(); p.setLayout(new VFlowLayout(VFlowLayout.TOP, 2, 2, true)); p.setBorder(BorderFactory.createLineBorder(new Color(206, 226, 255))); final String number = row.getForeign("ID_COMMANDE_CLIENT").getString("NUMERO"); final String customer = row.getForeign("ID_COMMANDE_CLIENT").getForeign("ID_CLIENT").getString("NOM"); // Amount final long amount = row.getBigDecimal("T_PV_HT") .setScale(2, BigDecimal.ROUND_HALF_UP) .movePointRight(2) .longValue(); String total = GestionDevise.currencyToString(amount, true) + " € HT"; final long totalAmount = row.getForeign("ID_COMMANDE_CLIENT").getLong("T_HT"); if (totalAmount != amount) { total += ", commande de " + GestionDevise.currencyToString(totalAmount, true) + " € HT"; } // Hours int h = getHours(row); p.add(new JLabelBold(number + " " + customer)); p.add(new JLabel(total)); if (h > 0) { p.add(new JLabel(h + " heures prévues")); } if (row.getTable().getDBRoot().contains("AFFAIRE_TEMPS")) { // Time spend double time = getTimeSpent(row); final JLabel lTime = new JLabel(time + " heures passées"); if (time > h) { lTime.setFont(lTime.getFont().deriveFont(Font.BOLD)); lTime.setForeground(new Color(255, 135, 30)); } if (time > 0) { p.add(lTime); } } p.setBackground(new Color(239, 243, 248)); p.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { final SQLRowAccessor foreign = row.getForeign("ID_COMMANDE_CLIENT"); EditFrame frame = new EditFrame( ComptaPropsConfiguration.getInstanceCompta() .getDirectory() .getElement(foreign.getTable()), EditPanel.MODIFICATION); frame.selectionId(foreign.getID()); FrameUtil.showPacked(frame); } } }); return p; }