void update() { Employee e = view.get(); try { if (old == null) { if (!e.isEmpty()) { service.create(e); old = e; } } else if (!old.equals(e)) { service.update(e); old = e; } } catch (EmployeeException ex) { MessagePopup.warning( this, MessageUtil.getMessage("employee.update.warning") + ":\n" + ex.getMessage()); GemLogger.logException(ex); } }
@Override public int tiersExport(String path, Vector<OrderLine> orderLines) throws IOException, SQLException { // OrderLine e = null; int errors = 0; boolean m1 = false; boolean m2 = false; String message = ""; StringBuilder logMessage = new StringBuilder(); String m1prefix = MessageUtil.getMessage("account.error"); String m2prefix = MessageUtil.getMessage("matching.account.error"); String logpath = path + ".log"; PrintWriter out = new PrintWriter(new FileWriter(path)); for (int i = 0, n = orderLines.size(); i < n; i++) { e = orderLines.elementAt(i); if (!AccountUtil.isPersonalAccount(e.getAccount())) { errors++; logMessage .append(m1prefix) .append(" -> ") .append(e) .append(" [") .append(e.getAccount()) .append("]") .append(TextUtil.LINE_SEPARATOR); m1 = true; continue; } int p = getPersonalAccountId(e.getAccount().getId()); if (p == 0) { errors++; logMessage .append(m2prefix) .append(" -> ") .append(e.getAccount()) .append(TextUtil.LINE_SEPARATOR); m2 = true; continue; } Account c = getAccount(p); String m = nf.format(Math.abs(e.getAmount()) / 100.0); // le montant doit être positif String codeJournal = getCodeJournal(e.getAccount().getId()); String f = (e.getInvoice() == null) ? "" : e.getInvoice(); out.print( TextUtil.padWithTrailingZeros(c.getNumber(), 10) + "#" + dateFormat.format(e.getDate().getDate()) + "#" + codeJournal + "#" + TextUtil.padWithTrailingSpaces(e.getDocument(), 10) + "#" + TextUtil.padWithTrailingSpaces(TextUtil.truncate(e.getLabel(), 24), 24) + "#" + TextUtil.padWithLeadingZeros(m, 13) + "#" + (e.getAmount() < 0 ? cd : dc) // cd Crédit + "#" + TextUtil.padWithTrailingSpaces(e.getCostAccount().getNumber(), 10) + "#" + (char) 13); out.print( TextUtil.padWithTrailingZeros(getAccount(e), 10) // compte client + "#" + dateFormat.format(e.getDate().getDate()) + "#" + codeJournal + "#" + TextUtil.padWithTrailingSpaces(f, 10) + "#" + TextUtil.padWithTrailingSpaces(TextUtil.truncate(e.getLabel(), 24), 24) + "#" + TextUtil.padWithLeadingZeros(m, 13) + "#" + (e.getAmount() < 0 ? dc : cd) // dc Débit + "#" + TextUtil.padWithTrailingSpaces("", 10) + "#" + (char) 13); // CR (Carriage return, retour à la ligne) } out.close(); if (logMessage.length() > 0) { PrintWriter log = new PrintWriter(new FileWriter(logpath)); log.println(logMessage.toString()); log.close(); } if (errors > 0) { if (m1) { message += MessageUtil.getMessage("personal.account.export.warning"); } if (m2) { message += MessageUtil.getMessage("no.revenue.matching.warning"); } String err = MessageUtil.getMessage("error.count.warning", errors); String l = MessageUtil.getMessage("see.log.file", path); MessagePopup.warning(null, err + message + l); } return errors; }