branch feature/1287-compute-summary-on-lettering created (now 4c283cf)
This is an automated email from the git hooks/post-receive script. New change to branch feature/1287-compute-summary-on-lettering in repository lima. See http://git.chorem.org/lima.git at 4c283cf refs #1287 ajout du montant total pour à l'onglet Lettrage This branch includes the following new commits: new 4c283cf refs #1287 ajout du montant total pour à l'onglet Lettrage The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 4c283cf46d268e9ca7bd509a12d7802246cf38b8 Author: dcosse <cosse@codelutin.com> Date: Wed Sep 9 12:50:14 2015 +0200 refs #1287 ajout du montant total pour à l'onglet Lettrage -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1287-compute-summary-on-lettering in repository lima. See http://git.chorem.org/lima.git commit 4c283cf46d268e9ca7bd509a12d7802246cf38b8 Author: dcosse <cosse@codelutin.com> Date: Wed Sep 9 12:50:14 2015 +0200 refs #1287 ajout du montant total pour à l'onglet Lettrage --- .../FinancialTransactionViewHandler.java | 14 +++--- .../lima/ui/lettering/LetteringEditModel.java | 52 ++++++++++++++----- .../lima/ui/lettering/LetteringViewHandler.java | 58 ++++++++++++++++------ .../resources/i18n/lima-swing_en_GB.properties | 2 +- .../resources/i18n/lima-swing_fr_FR.properties | 2 +- 5 files changed, 91 insertions(+), 37 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java index c4b7466..5add965 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java @@ -149,14 +149,14 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo @Override public void tableChanged(TableModelEvent e) { - boolean mustRecompute = e.getType() == TableModelEvent.DELETE - || e.getType() == TableModelEvent.INSERT - || (e.getType() == TableModelEvent.UPDATE && - (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == 4 || e.getColumn() == 5)); + boolean mustRecompute = e.getType() == TableModelEvent.DELETE + || e.getType() == TableModelEvent.INSERT + || (e.getType() == TableModelEvent.UPDATE && + (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == 4 || e.getColumn() == 5)); - if (mustRecompute) { - computeBalanceStatusText(); - } + if (mustRecompute) { + computeBalanceStatusText(); + } } }); diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java index c400009..cfbee73 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java @@ -53,6 +53,10 @@ public class LetteringEditModel implements Serializable { protected BigDecimal credit = BigDecimal.ZERO; protected BigDecimal sold = BigDecimal.ZERO; + protected BigDecimal tableDebit = BigDecimal.ZERO; + protected BigDecimal tableCredit = BigDecimal.ZERO; + protected BigDecimal tableSold = BigDecimal.ZERO; + public boolean isEqualized() { return equalized; } @@ -69,9 +73,9 @@ public class LetteringEditModel implements Serializable { public void setLettred(boolean lettred) { boolean oldLettrer = isLettred(); - if(lettred && (sold == BigDecimal.ZERO || sold.doubleValue() == 0)){ - this.lettred = lettred; - }else{ + if(lettred && (BigDecimal.ZERO.equals(sold))){ + this.lettred = true; + } else{ this.lettred = false; } firePropertyChange(PROPERTY_LETTRED, oldLettrer, this.lettred); @@ -94,9 +98,9 @@ public class LetteringEditModel implements Serializable { public void setDebit(BigDecimal debit) { BigDecimal oldDebit = getDebit(); - if (debit != BigDecimal.ZERO){ + if (!BigDecimal.ZERO.equals(debit)){ this.debit = debit.add(oldDebit); - }else{ + } else{ this.debit = BigDecimal.ZERO; } @@ -110,9 +114,9 @@ public class LetteringEditModel implements Serializable { public void setCredit(BigDecimal credit) { BigDecimal oldCredit = getCredit(); - if (credit != BigDecimal.ZERO){ + if (!BigDecimal.ZERO.equals(credit)){ this.credit = credit.add(oldCredit); - }else{ + } else{ this.credit=BigDecimal.ZERO; } @@ -123,26 +127,50 @@ public class LetteringEditModel implements Serializable { return sold; } - public void setSolde(BigDecimal solde, boolean credit) { + public void setSold(BigDecimal solde, boolean credit) { BigDecimal oldSolde = getSold(); - if (solde != BigDecimal.ZERO){ + if (!BigDecimal.ZERO.equals(solde)){ if (credit){ this.sold = oldSolde.subtract(solde); - }else{ + } else{ this.sold = oldSolde.add(solde); } - }else{ + } else{ this.sold =BigDecimal.ZERO; } firePropertyChange(PROPERTY_SOLD, oldSolde, this.sold); } + public BigDecimal getTableDebit() { + return tableDebit; + } + + public void setTableDebit(BigDecimal tableDebit) { + this.tableDebit = tableDebit; + } + + public BigDecimal getTableCredit() { + return tableCredit; + } + + public void setTableCredit(BigDecimal tableCredit) { + this.tableCredit = tableCredit; + } + + public BigDecimal getTableSold() { + return tableSold; + } + + public void setTableSold(BigDecimal tableSold) { + this.tableSold = tableSold; + } + public void resetDebitCreditBalance(){ setDebit(BigDecimal.ZERO); setCredit(BigDecimal.ZERO); - setSolde(BigDecimal.ZERO, false); + setSold(BigDecimal.ZERO, false); } public void addPropertyChangeListener(PropertyChangeListener listener) { diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java index fd77b1a..ab9bc87 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java @@ -41,17 +41,13 @@ import org.chorem.lima.business.exceptions.LockedFinancialPeriodException; import org.chorem.lima.business.exceptions.UnbalancedEntriesException; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.EntryImpl; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.ui.combobox.AccountComboBox; import org.chorem.lima.util.BigDecimalToString; import org.chorem.lima.util.ErrorHelper; -import javax.swing.AbstractAction; -import javax.swing.ActionMap; -import javax.swing.InputMap; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.KeyStroke; +import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; @@ -148,11 +144,13 @@ public class LetteringViewHandler{ updateSoldStatus(); updateAllEntries(); - } public void updateSoldStatus() { view.getBalanceStatusLabel().setText(t("lima.lettering.balanceStatus", + BigDecimalToString.format(editModel.getTableDebit()), + BigDecimalToString.format(editModel.getTableCredit()), + BigDecimalToString.format(editModel.getTableSold()), BigDecimalToString.format(editModel.getDebit()), BigDecimalToString.format(editModel.getCredit()), BigDecimalToString.format(editModel.getSold()))); @@ -254,7 +252,7 @@ public class LetteringViewHandler{ && firstSelectedEntryAmount.subtract(secondSelectedEntryAmount).abs().compareTo(BigDecimal.ONE) <0) ) { onButtonModeChanged(ButtonMode.EQUALIZED); } - }else { + } else { if (log.isDebugEnabled()) { log.debug("!2 rows selected"); } @@ -326,11 +324,41 @@ public class LetteringViewHandler{ } } + public void setValuesForEntries() { + if (editModel != null) { + Entry resultDebit = new EntryImpl(); + Entry resultCredit = new EntryImpl(); + Entry resultSold = new EntryImpl(); + + resultDebit.setAmount(BigDecimal.ZERO); + resultCredit.setAmount(BigDecimal.ZERO); + resultSold.setAmount(BigDecimal.ZERO); + + LetteringTableModel tableModel = view.getTableModel(); + for (int i = 0; i < tableModel.getRowCount(); i ++){ + Entry rowEntry = tableModel.get(i); + if (rowEntry.isDebit()) { + resultDebit.setAmount(resultDebit.getAmount().add(rowEntry.getAmount())); + resultSold.setAmount(resultSold.getAmount().subtract(rowEntry.getAmount())); + } else { + resultCredit.setAmount(resultCredit.getAmount().add(rowEntry.getAmount())); + resultSold.setAmount(resultSold.getAmount().add(rowEntry.getAmount())); + } + } + resultSold.setDebit(resultSold.getAmount().compareTo(BigDecimal.ZERO) < 0); + + editModel.setTableDebit(resultDebit.getAmount()); + editModel.setTableCredit(resultCredit.getAmount()); + editModel.setTableSold(resultSold.getAmount()); + updateSoldStatus(); + } + } + public void onBalanceChanged(Entry balance) { if (balance == null) { editModel.setCredit(BigDecimal.ZERO); editModel.setDebit(BigDecimal.ZERO); - editModel.setSolde(BigDecimal.ZERO, false); + editModel.setSold(BigDecimal.ZERO, false); } else { balanceCalculation(balance.getAmount(), balance.isDebit()); } @@ -350,16 +378,14 @@ public class LetteringViewHandler{ } if (debitVal.equals(BigDecimal.ZERO)){ - if (!creditVal.equals(BigDecimal.ZERO)){ - editModel.setCredit(creditVal); - editModel.setSolde(creditVal, true); + editModel.setSold(creditVal, true); } - }else if (creditVal.equals(BigDecimal.ZERO)){ + } else if (creditVal.equals(BigDecimal.ZERO)){ editModel.setDebit(debitVal); - editModel.setSolde(debitVal, false); - }else{ + editModel.setSold(debitVal, false); + } else{ onBalanceChanged(null); } } @@ -426,7 +452,6 @@ public class LetteringViewHandler{ } public void updateAllEntries() { - if (initializationComplete && filter.getAccount() != null && filter.getDateStart() != null @@ -438,6 +463,7 @@ public class LetteringViewHandler{ } onBalanceChanged(null); + setValuesForEntries(); } /**To make the difference between two selected entries and diff --git a/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties index 1bfb522..34c335c 100644 --- a/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties +++ b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties @@ -442,7 +442,7 @@ lima.lettering.account=Accounts lima.lettering.account.aAll=All lima.lettering.account.back=← lima.lettering.account.next=→ -lima.lettering.balanceStatus= +lima.lettering.balanceStatus=<html>Debit\: <b>%s</b> - Credit\: <b>%s</b> - Sold\: <b>%s</b>. Selected entries\: Debit\: <b>%s</b> - Credit\: <b>%s</b> - Sold\: <b>%s</b> lima.lettering.checkAll=All lima.lettering.checkLettredEntry=Lettered lima.lettering.checkNoLettredEntry=Not lettered diff --git a/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties b/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties index 54a9304..30662b2 100644 --- a/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties +++ b/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties @@ -453,7 +453,7 @@ lima.lettering.account=Comptes lima.lettering.account.aAll=TOUS lima.lettering.account.back=← lima.lettering.account.next=→ -lima.lettering.balanceStatus=<html>Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b> +lima.lettering.balanceStatus=<html>Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b>. Entrées sélectionnées\: Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b> lima.lettering.checkAll=Toutes lima.lettering.checkLettredEntry=Lettrées lima.lettering.checkNoLettredEntry=Non-lettrées -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm