Author: mallon Date: 2012-07-24 18:39:43 +0200 (Tue, 24 Jul 2012) New Revision: 3553 Url: http://chorem.org/repositories/revision/lima/3553 Log: refs #710 Correction permettant de ne plus avoir de ligne a zero lorsqu une des deux cellules (Debit / credit) est seulement editee. Reste le surlignage en rouge lors de la creation d une entree (Et donc avec des valeurs par defaut a zero pour le debit / credit). Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java trunk/lima-swing/src/main/resources/log4j.properties Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2012-07-24 14:56:32 UTC (rev 3552) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2012-07-24 16:39:43 UTC (rev 3553) @@ -175,6 +175,7 @@ } } else if (result instanceof Entry) { Entry currentEntry = (Entry) result; + switch (column) { case 0: result = null; // date @@ -228,7 +229,7 @@ /** * Obtain the first entry book of the current transaction. * - * @param selectedRow + * @param selectedRow row selected * @return first entry index */ public int getFirstEntry(int selectedRow) { @@ -292,7 +293,7 @@ Object currentRow = transactionAndEntries.get(row); - FinancialTransaction currentFinancialTransaction = null; + FinancialTransaction currentFinancialTransaction; if (currentRow instanceof FinancialTransaction) { currentFinancialTransaction = (FinancialTransaction) currentRow; switch (column) { @@ -306,96 +307,98 @@ financialTransactionService.updateFinancialTransaction(currentFinancialTransaction); } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry) currentRow; - currentFinancialTransaction = currentEntry.getFinancialTransaction(); - boolean updateTransaction = false; - switch (column) { - case 1: - String voucher = ((String) value).trim(); + /*To stay with one value in debit or credit*/ + if ( !value.equals(BigDecimal.ZERO) && !value.equals(BigDecimal.valueOf(Double.valueOf("00.00")))) { + Entry currentEntry = (Entry) currentRow; + currentFinancialTransaction = currentEntry.getFinancialTransaction(); + boolean updateTransaction = false; + switch (column) { + case 1: + String voucher = ((String) value).trim(); - int firstEntryRow = getFirstEntry(row); - if (row == firstEntryRow) { + int firstEntryRow = getFirstEntry(row); + if (row == firstEntryRow) { - // let's update the voucher of all entries of - // the transaction + // let's update the voucher of all entries of + // the transaction - for (Entry entry : currentFinancialTransaction.getEntry()) { - entry.setVoucher(voucher); + for (Entry entry : currentFinancialTransaction.getEntry()) { + entry.setVoucher(voucher); + } + updateTransaction = true; + } else { + + // not on first row, just update this entry voucher + currentEntry.setVoucher(voucher); } - updateTransaction = true; - } else { + break; + case 2: + Account account = (Account) value; + currentEntry.setAccount(account); + // let's copy the account description + String description1 = account.getLabel(); + firstEntryRow = getFirstEntry(row); + if (row == firstEntryRow) { + // let's update the description of all entries of + // the transaction - // not on first row, just update this entry voucher - currentEntry.setVoucher(voucher); - } - break; - case 2: - Account account = (Account) value; - currentEntry.setAccount(account); - // let's copy the account description - String description1 = account.getLabel(); - firstEntryRow = getFirstEntry(row); - if (row == firstEntryRow) { - // let's update the description of all entries of - // the transaction - - for (Entry entry : currentFinancialTransaction.getEntry()) { - entry.setDescription(description1); + for (Entry entry : currentFinancialTransaction.getEntry()) { + entry.setDescription(description1); + } + updateTransaction = true; + } else { + // not on first row, just update this entry description + currentEntry.setDescription(description1); } - updateTransaction = true; - } else { - // not on first row, just update this entry description - currentEntry.setDescription(description1); - } - break; - case 3: - String description = ((String) value).trim(); - firstEntryRow = getFirstEntry(row); - if (row == firstEntryRow) { + break; + case 3: + String description = ((String) value).trim(); + firstEntryRow = getFirstEntry(row); + if (row == firstEntryRow) { - // let's update the description of all entries of - // the transaction + // let's update the description of all entries of + // the transaction - for (Entry entry : currentFinancialTransaction.getEntry()) { - entry.setDescription(description); + for (Entry entry : currentFinancialTransaction.getEntry()) { + entry.setDescription(description); + } + updateTransaction = true; + } else { + + // not on first row, just update this entry description + currentEntry.setDescription(description); } - updateTransaction = true; - } else { + break; + case 4: + currentEntry.setAmount((BigDecimal) value); + currentEntry.setDebit(true); + break; + case 5: + currentEntry.setAmount((BigDecimal) value); + currentEntry.setDebit(false); + break; + } - // not on first row, just update this entry description - currentEntry.setDescription(description); + // some modification must update all other + // first row modification update following rows + if (updateTransaction) { + // FIXME echatellier 20120413 make a single service call + for (Entry entry : currentFinancialTransaction.getEntry()) { + financialTransactionService.updateEntry(entry); } - break; - case 4: - currentEntry.setAmount((BigDecimal) value); - currentEntry.setDebit(true); - break; - case 5: - currentEntry.setAmount((BigDecimal) value); - currentEntry.setDebit(false); - break; - } - - // some modification must update all other - // first row modification update following rows - if (updateTransaction) { - // FIXME echatellier 20120413 make a single service call - for (Entry entry : currentFinancialTransaction.getEntry()) { - financialTransactionService.updateEntry(entry); + } else { + financialTransactionService.updateEntry(currentEntry); } - } else { - financialTransactionService.updateEntry(currentEntry); + // FIXME echatellier 20120413 une modification des dates fait que l'ordre + // devient faux + int trIndex = indexOf(currentFinancialTransaction); + int endIndex = trIndex; + if (currentFinancialTransaction.getEntry() != null) { + endIndex += currentFinancialTransaction.getEntry().size(); + } + fireTableRowsUpdated(trIndex, endIndex); } } - - // FIXME echatellier 20120413 une modification des dates fait que l'ordre - // devient faux - int trIndex = indexOf(currentFinancialTransaction); - int endIndex = trIndex; - if (currentFinancialTransaction.getEntry() != null) { - endIndex += currentFinancialTransaction.getEntry().size(); - } - fireTableRowsUpdated(trIndex, endIndex); } public Object getElementAt(int row) { @@ -431,7 +434,7 @@ /** * Insert new row. * - * @param object + * @param object object to insert */ public void addRow(Object object) { transactionAndEntries.add(object); Modified: trunk/lima-swing/src/main/resources/log4j.properties =================================================================== --- trunk/lima-swing/src/main/resources/log4j.properties 2012-07-24 14:56:32 UTC (rev 3552) +++ trunk/lima-swing/src/main/resources/log4j.properties 2012-07-24 16:39:43 UTC (rev 3553) @@ -42,3 +42,4 @@ log4j.logger.org.chorem.lima.ui.lettering.LetteringViewHandler=DEBUG log4j.logger.org.chorem.lima.ui.lettering.LettringSelectionModel=DEBUG log4j.logger.org.chorem.lima.ui.lettering.LetteringEditModel=DEBUG +log4j.logger.org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel=DEBUG