Author: mallon Date: 2012-07-18 15:40:02 +0200 (Wed, 18 Jul 2012) New Revision: 3538 Url: http://chorem.org/repositories/revision/lima/3538 Log: fixes #692 Correction de la remise ?\195?\160 z?\195?\169ro des totaux d?\195?\169bit / cr?\195?\169dit / solde lors d'un lettrage ou delettrage. 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/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java 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-18 12:32:38 UTC (rev 3537) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2012-07-18 13:40:02 UTC (rev 3538) @@ -267,8 +267,11 @@ for (Object transactionOrEntry : transactionAndEntries) { if(transactionOrEntry instanceof Entry) { if (transactionOrEntry.equals(entry)) { - //'-1' for precedent... - return (Entry)getObjectAt(transactionAndEntries.indexOf(transactionOrEntry)-1); + if (getObjectAt(transactionAndEntries.indexOf(transactionOrEntry)-1) instanceof Entry){ + return (Entry)getObjectAt(transactionAndEntries.indexOf(transactionOrEntry)-1); + } else { + return null; + } } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-07-18 12:32:38 UTC (rev 3537) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-07-18 13:40:02 UTC (rev 3538) @@ -351,7 +351,10 @@ int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { //int firstentryBookrow = tableModel.getFirstEntry(indexSelectedRow); - Entry precedentEntry = tableModel.getPrecedentEntry((Entry)tableModel.getObjectAt(indexSelectedRow)); + Entry precedentEntry = null; + if (tableModel.getObjectAt(indexSelectedRow) instanceof Entry) { + precedentEntry = tableModel.getPrecedentEntry((Entry)tableModel.getObjectAt(indexSelectedRow)); + } if (log.isInfoEnabled()) { log.info("Selected row : " + indexSelectedRow); @@ -376,7 +379,7 @@ BigDecimal tvaTax = null; //Calculation of tva tax only if first entry is a sale - if (precedentEntry.getAccount()!= null){ + if (precedentEntry != null && precedentEntry.getAccount()!= null){ defaultAccount = precedentEntry.getAccount().getAccountNumber(); if (defaultAccount.equals("410") || defaultAccount.equals("418")){ tvaTax = (precedentEntry.getAmount()).multiply(tvaPercentAdd); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-18 12:32:38 UTC (rev 3537) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-18 13:40:02 UTC (rev 3538) @@ -62,21 +62,16 @@ public void setSelectionInterval(int row, int column){ if ( isSelectionEmpty() || !isSelectedIndex(row)){ - super.clearSelection(); - lineSelected = row; String currentLettring = getCurrentLettring(); - setValueIsAdjusting(true); - try { //select entries with the same letter of the selected entry for(Entry entry : getEntries()){ if (StringUtils.isNotBlank(entry.getLettering())){ if (entry.getLettering().equals(currentLettring)){ int entryToSelect = letteringTableModel.getIndexOfEntry(entry); - System.out.println("there : " + entryToSelect); super.addSelectionInterval(entryToSelect, entryToSelect); } } @@ -93,7 +88,6 @@ * @param lettering state of attributes lettered and unlettered in editModel * */ public void updateBalanceAndLetteringButton(boolean lettering){ - editModel.resetDebitCreditBalance(); Entry selectedEntry; @@ -111,9 +105,9 @@ } //to reinitialize model attribute - public void resetAttribute(){ + /*public void resetAttribute(){ clearSelection(); - } + }*/ public List<Entry> getEntries(){ return letteringTableModel.getEntries(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-18 12:32:38 UTC (rev 3537) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-18 13:40:02 UTC (rev 3538) @@ -9,15 +9,15 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -94,7 +94,7 @@ @Override public void propertyChange(PropertyChangeEvent evt) { editModel.resetDebitCreditBalance(); - view.getLettringAndUnlettringSelectionModel().resetAttribute(); + view.getLettringAndUnlettringSelectionModel().clearSelection(); updateAllEntries(); } }); @@ -106,7 +106,7 @@ @Override public void propertyChange(PropertyChangeEvent evt) { editModel.resetDebitCreditBalance(); - view.getLettringAndUnlettringSelectionModel().resetAttribute(); + view.getLettringAndUnlettringSelectionModel().clearSelection(); updateAllEntries(); } }); @@ -210,7 +210,7 @@ if (row > 0) { comboBox.setSelectedIndex(row - 1); } - view.getLettringAndUnlettringSelectionModel().resetAttribute(); + view.getLettringAndUnlettringSelectionModel().clearSelection(); } /** @@ -225,20 +225,22 @@ if (row < size - 1) { comboBox.setSelectedIndex(row + 1); } - view.getLettringAndUnlettringSelectionModel().resetAttribute(); + view.getLettringAndUnlettringSelectionModel().clearSelection(); } /**Add a group of three letters to n entries*/ public void addLetter() { String newLetters = financialTransactionService.getNextLetters(); changeLetter(newLetters); - view.getEditModel().setLettred(false); + editModel.setLettred(false); + editModel.resetDebitCreditBalance(); } /**Remove a group of three letters to n entries*/ public void removeLetter() { changeLetter(null); - view.getEditModel().setUnLettred(false); + editModel.setUnLettred(false); + editModel.resetDebitCreditBalance(); } /**Add or remove a group of three letters to n entries*/ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java 2012-07-18 12:32:38 UTC (rev 3537) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java 2012-07-18 13:40:02 UTC (rev 3538) @@ -56,19 +56,14 @@ * */ @Override public void setSelectionInterval(int row, int column) { - if (!letteringNotExist(row)) { delegate = letteringSelectionModel; - //to reinitialize model attribute when delegation change - unlettringSelectionModel.resetAttribute(); + clearSelection(); } else { delegate = unlettringSelectionModel; - letteringSelectionModel.resetAttribute(); } - delegate.setSelectionInterval(row, column); - } /**return true if lettering is null, or not null but empty @@ -80,15 +75,9 @@ entry = letteringTableModel.getEntryAt(row); String lettering = entry.getLettering(); emptyOrNull = (lettering==null||lettering.isEmpty()); - return emptyOrNull; } - public void resetAttribute(){ - letteringSelectionModel.resetAttribute(); - unlettringSelectionModel.resetAttribute(); - } - @Override public void addSelectionInterval(int index0, int index1) { delegate.addSelectionInterval(index0, index1); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java 2012-07-18 12:32:38 UTC (rev 3537) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java 2012-07-18 13:40:02 UTC (rev 3538) @@ -91,9 +91,9 @@ } /**to reinitialize model attribute*/ - public void resetAttribute(){ + /*public void resetAttribute(){ clearSelection(); - } + }*/ @Override public int getSelectionMode() {