diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/InvoicePositionTemplatesSetupDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/InvoicePositionTemplatesSetupDialog.java index 3828f56c2..193d45722 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/InvoicePositionTemplatesSetupDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/InvoicePositionTemplatesSetupDialog.java @@ -668,6 +668,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.client.utils.ComponentUtils; import com.jdimension.jlawyer.persistence.InvoicePositionTemplate; import com.jdimension.jlawyer.services.JLawyerServiceLocator; +import java.math.BigDecimal; import java.util.List; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; @@ -1012,9 +1013,9 @@ private void cmdAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST: InvoicePositionTemplate tpl = new InvoicePositionTemplate(); tpl.setName(newNameObject.toString()); tpl.setDescription(""); - tpl.setTaxRate(19f); - tpl.setUnitPrice(0f); - tpl.setUnits(1); + tpl.setTaxRate(BigDecimal.valueOf(19f)); + tpl.setUnitPrice(BigDecimal.ZERO); + tpl.setUnits(BigDecimal.ONE); InvoicePositionTemplate savedTpl = locator.lookupInvoiceServiceRemote().addInvoicePositionTemplate(tpl); ((DefaultTableModel) this.tblTemplates.getModel()).addRow(new Object[]{savedTpl, savedTpl.getDescription()}); @@ -1083,9 +1084,9 @@ private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST InvoicePositionTemplate tpl = (InvoicePositionTemplate) this.tblTemplates.getValueAt(row, 0); tpl.setName(this.txtName.getText()); tpl.setDescription(this.taDescription.getText()); - tpl.setTaxRate(taxRate.floatValue()); - tpl.setUnitPrice(unitPrice.floatValue()); - tpl.setUnits(units.floatValue()); + tpl.setTaxRate(BigDecimal.valueOf(taxRate.floatValue())); + tpl.setUnitPrice(BigDecimal.valueOf(unitPrice.floatValue())); + tpl.setUnits(BigDecimal.valueOf(units.floatValue())); ClientSettings settings = ClientSettings.getInstance(); try { diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/TimesheetPositionTemplatesSetupDialog.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/TimesheetPositionTemplatesSetupDialog.form index e77cc2e72..dc3ba01b9 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/TimesheetPositionTemplatesSetupDialog.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/TimesheetPositionTemplatesSetupDialog.form @@ -50,7 +50,7 @@ - + diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/TimesheetPositionTemplatesSetupDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/TimesheetPositionTemplatesSetupDialog.java index e002377e8..d12b517d8 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/TimesheetPositionTemplatesSetupDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/TimesheetPositionTemplatesSetupDialog.java @@ -668,6 +668,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.client.utils.ComponentUtils; import com.jdimension.jlawyer.persistence.TimesheetPositionTemplate; import com.jdimension.jlawyer.services.JLawyerServiceLocator; +import java.math.BigDecimal; import java.util.List; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; @@ -998,8 +999,8 @@ private void cmdAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST: TimesheetPositionTemplate tpl = new TimesheetPositionTemplate(); tpl.setName(newNameObject.toString()); tpl.setDescription(""); - tpl.setTaxRate(19f); - tpl.setUnitPrice(0f); + tpl.setTaxRate(BigDecimal.valueOf(19f)); + tpl.setUnitPrice(BigDecimal.ZERO); TimesheetPositionTemplate savedTpl = locator.lookupTimesheetServiceRemote().addTimesheetPositionTemplate(tpl); ((DefaultTableModel) this.tblTemplates.getModel()).addRow(new Object[]{savedTpl, savedTpl.getDescription()}); @@ -1052,8 +1053,8 @@ private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST TimesheetPositionTemplate tpl = (TimesheetPositionTemplate) this.tblTemplates.getValueAt(row, 0); tpl.setName(this.txtName.getText()); tpl.setDescription(this.taDescription.getText()); - tpl.setTaxRate(taxRate.floatValue()); - tpl.setUnitPrice(unitPrice.floatValue()); + tpl.setTaxRate(BigDecimal.valueOf(taxRate.floatValue())); + tpl.setUnitPrice(BigDecimal.valueOf(unitPrice.floatValue())); ClientSettings settings = ClientSettings.getInstance(); try { diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/AddressPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/AddressPanel.java index 94fbb6fbe..ea2af5ecd 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/AddressPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/AddressPanel.java @@ -715,6 +715,7 @@ import java.awt.datatransfer.StringSelection; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.Period; @@ -1112,7 +1113,7 @@ public void setAddressDTO(AddressBean dto) { } this.invoicesPerCase.clear(); - HashMap cumulatedInvoiceValues = this.getCumulatedInvoicesValue(invoices); + HashMap cumulatedInvoiceValues = this.getCumulatedInvoicesValue(invoices); for (Invoice inv : invoices) { if (!this.invoicesPerCase.containsKey(inv.getArchiveFileKey().getId())) { this.invoicesPerCase.put(inv.getArchiveFileKey().getId(), new ArrayList<>()); @@ -1130,7 +1131,7 @@ public void setAddressDTO(AddressBean dto) { chart.addSeries("offen - 2. Mahnstufe", cumulatedInvoiceValues.get(Invoice.STATUS_OPEN_REMINDER2)); chart.addSeries("offen - 3. Mahnstufe", cumulatedInvoiceValues.get(Invoice.STATUS_OPEN_REMINDER3)); chart.addSeries("bezahlt", cumulatedInvoiceValues.get(Invoice.STATUS_PAID)); - chart.addSeries("storniert", -1f * cumulatedInvoiceValues.get(Invoice.STATUS_CANCELLED)); + chart.addSeries("storniert", BigDecimal.valueOf(-1f).multiply(cumulatedInvoiceValues.get(Invoice.STATUS_CANCELLED))); chart.getStyler().setLegendVisible(true); chart.getStyler().setLegendPosition(Styler.LegendPosition.InsideNE); chart.getStyler().setSumVisible(true); @@ -1167,20 +1168,20 @@ public void setAddressDTO(AddressBean dto) { this.pnlInvoicesChart.add(xchartPanel, BorderLayout.CENTER); } - private HashMap getCumulatedInvoicesValue(List invoices) { - HashMap cumulatedInvoiceValues = new HashMap<>(); - cumulatedInvoiceValues.put(Invoice.STATUS_NEW, 0f); - cumulatedInvoiceValues.put(Invoice.STATUS_OPEN, 0f); - cumulatedInvoiceValues.put(Invoice.STATUS_OPEN_NONENFORCEABLE, 0f); - cumulatedInvoiceValues.put(Invoice.STATUS_OPEN_REMINDER1, 0f); - cumulatedInvoiceValues.put(Invoice.STATUS_OPEN_REMINDER2, 0f); - cumulatedInvoiceValues.put(Invoice.STATUS_OPEN_REMINDER3, 0f); - cumulatedInvoiceValues.put(Invoice.STATUS_PAID, 0f); - cumulatedInvoiceValues.put(Invoice.STATUS_CANCELLED, 0f); + private HashMap getCumulatedInvoicesValue(List invoices) { + HashMap cumulatedInvoiceValues = new HashMap<>(); + cumulatedInvoiceValues.put(Invoice.STATUS_NEW, BigDecimal.ZERO); + cumulatedInvoiceValues.put(Invoice.STATUS_OPEN, BigDecimal.ZERO); + cumulatedInvoiceValues.put(Invoice.STATUS_OPEN_NONENFORCEABLE, BigDecimal.ZERO); + cumulatedInvoiceValues.put(Invoice.STATUS_OPEN_REMINDER1, BigDecimal.ZERO); + cumulatedInvoiceValues.put(Invoice.STATUS_OPEN_REMINDER2, BigDecimal.ZERO); + cumulatedInvoiceValues.put(Invoice.STATUS_OPEN_REMINDER3, BigDecimal.ZERO); + cumulatedInvoiceValues.put(Invoice.STATUS_PAID, BigDecimal.ZERO); + cumulatedInvoiceValues.put(Invoice.STATUS_CANCELLED, BigDecimal.ZERO); for (Invoice inv : invoices) { if (inv.getInvoiceType().isTurnOver()) { - float f = cumulatedInvoiceValues.get(inv.getStatus()); - f = f + inv.getTotalGross(); + BigDecimal f = cumulatedInvoiceValues.get(inv.getStatus()); + f = f.add(inv.getTotalGross()); cumulatedInvoiceValues.put(inv.getStatus(), f); } } @@ -3688,7 +3689,7 @@ private void fillCasesForContactPanel(Collection allCa lce.setOwnReference(aFile.getReference()); if (this.invoicesPerCase.containsKey(aFile.getArchiveFileKey().getId())) { - HashMap invoicesForCase = this.getCumulatedInvoicesValue(this.invoicesPerCase.get(aFile.getArchiveFileKey().getId())); + HashMap invoicesForCase = this.getCumulatedInvoicesValue(this.invoicesPerCase.get(aFile.getArchiveFileKey().getId())); lce.setInvoicesByStatus(invoicesForCase); } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/CaseForContactEntry.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/CaseForContactEntry.java index e0b73b53e..89c455927 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/CaseForContactEntry.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/CaseForContactEntry.java @@ -664,6 +664,7 @@ package com.jdimension.jlawyer.client.editors.addresses; import java.awt.Color; +import java.math.BigDecimal; import java.util.HashMap; import themes.colors.DefaultColorTheme; @@ -680,7 +681,7 @@ public class CaseForContactEntry { private String reason=null; private String role=null; private boolean archived=false; - protected HashMap invoicesByStatus=null; + protected HashMap invoicesByStatus=null; private Color roleForeground=DefaultColorTheme.COLOR_LOGO_BLUE; @@ -803,14 +804,14 @@ public void setOwnReference(String ownReference) { /** * @return the invoicesByStatus */ - public HashMap getInvoicesByStatus() { + public HashMap getInvoicesByStatus() { return invoicesByStatus; } /** * @param invoicesByStatus the invoicesByStatus to set */ - public void setInvoicesByStatus(HashMap invoicesByStatus) { + public void setInvoicesByStatus(HashMap invoicesByStatus) { this.invoicesByStatus = invoicesByStatus; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/CaseForContactEntryPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/CaseForContactEntryPanel.java index 437021abb..c1f1af303 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/CaseForContactEntryPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/addresses/CaseForContactEntryPanel.java @@ -678,6 +678,7 @@ import com.jdimension.jlawyer.services.JLawyerServiceLocator; import java.awt.Color; import java.awt.Component; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.util.HashMap; import javax.swing.JOptionPane; @@ -742,11 +743,11 @@ public void setEntry(CaseForContactEntry entry) { this.lblArchived.setText(""); } - HashMap invoices=e.getInvoicesByStatus(); + HashMap invoices=e.getInvoicesByStatus(); this.lblTotal.setText(""); DecimalFormat df=new DecimalFormat("0.00"); if(invoices!=null) { - float total=invoices.get(Invoice.STATUS_NEW) + invoices.get(Invoice.STATUS_OPEN) + invoices.get(Invoice.STATUS_OPEN_REMINDER1) + invoices.get(Invoice.STATUS_OPEN_REMINDER2) + invoices.get(Invoice.STATUS_OPEN_REMINDER3) + invoices.get(Invoice.STATUS_OPEN_NONENFORCEABLE) - invoices.get(Invoice.STATUS_PAID) - invoices.get(Invoice.STATUS_CANCELLED); + BigDecimal total=invoices.get(Invoice.STATUS_NEW).add(invoices.get(Invoice.STATUS_OPEN)).add(invoices.get(Invoice.STATUS_OPEN_REMINDER1)).add(invoices.get(Invoice.STATUS_OPEN_REMINDER2)).add(invoices.get(Invoice.STATUS_OPEN_REMINDER3).add(invoices.get(Invoice.STATUS_OPEN_NONENFORCEABLE)).subtract(invoices.get(Invoice.STATUS_PAID)).subtract(invoices.get(Invoice.STATUS_CANCELLED))); StringBuilder sb=new StringBuilder(); sb.append("Umsatzrelevante Werte gesamt: ").append(df.format(total)).append("
"); sb.append(""); @@ -758,7 +759,7 @@ public void setEntry(CaseForContactEntry entry) { sb.append(""); sb.append("
neu:").append(df.format(invoices.get(Invoice.STATUS_NEW))).append("
bezahlt:").append(df.format(invoices.get(Invoice.STATUS_PAID))).append("
storniert:").append(df.format(invoices.get(Invoice.STATUS_CANCELLED))).append("
"); this.lblTotal.setText(df.format(total)); - if(total>0) + if(total.compareTo(BigDecimal.ZERO)>0) this.lblTotal.setForeground(DefaultColorTheme.COLOR_LOGO_RED); else this.lblTotal.setForeground(DefaultColorTheme.COLOR_LOGO_GREEN); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchivalDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchivalDialog.java index eb9af8ffd..8c72f6e8a 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchivalDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchivalDialog.java @@ -673,6 +673,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.persistence.Timesheet; import com.jdimension.jlawyer.services.CalendarServiceRemote; import com.jdimension.jlawyer.services.JLawyerServiceLocator; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; @@ -709,7 +710,7 @@ public class ArchivalDialog extends javax.swing.JDialog { * @param totalEscrowDiff * @param totalExpendituresDiff */ - public ArchivalDialog(java.awt.Frame parent, boolean modal, String caseId, JTable tblReviews, JPanel invoicesPanel, JPanel timesheetsPanel, float totalEscrowDiff, float totalExpendituresDiff) { + public ArchivalDialog(java.awt.Frame parent, boolean modal, String caseId, JTable tblReviews, JPanel invoicesPanel, JPanel timesheetsPanel, BigDecimal totalEscrowDiff, BigDecimal totalExpendituresDiff) { super(parent, modal); initComponents(); @@ -818,13 +819,13 @@ public ArchivalDialog(java.awt.Frame parent, boolean modal, String caseId, JTabl } - if(totalEscrowDiff!=0) { + if(!totalEscrowDiff.equals(BigDecimal.ZERO)) { this.lblEscrow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/cancel.png"))); this.chkEscrow.setEnabled(true); this.lblEscrow.setText("Aktenkonto: Fremdgelder nicht ausgeglichen"); } - if(totalExpendituresDiff!=0) { + if(!totalExpendituresDiff.equals(BigDecimal.ZERO)) { this.lblExpenditures.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/cancel.png"))); this.chkExpenditures.setEnabled(true); this.lblExpenditures.setText("Aktenkonto: Auslagen nicht ausgeglichen"); @@ -1194,7 +1195,7 @@ public static void main(String args[]) { /* Create and display the dialog */ java.awt.EventQueue.invokeLater(() -> { - ArchivalDialog dialog = new ArchivalDialog(new javax.swing.JFrame(), true, null, null, null, null, 0f, 0f); + ArchivalDialog dialog = new ArchivalDialog(new javax.swing.JFrame(), true, null, null, null, null, BigDecimal.ZERO, BigDecimal.ZERO); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java index a90e7b7a4..389ed4e92 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java @@ -784,6 +784,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; @@ -4457,15 +4458,15 @@ private void loadAccountEntries() { ClientSettings settings = ClientSettings.getInstance(); JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); ArchiveFileServiceRemote fileService = locator.lookupArchiveFileServiceRemote(); - HashMap invoiceTotals = new HashMap<>(); + HashMap invoiceTotals = new HashMap<>(); List accountEntries = fileService.getAccountEntries(this.dto.getId()); for (CaseAccountEntry cae : accountEntries) { this.addAccountEntryRow(cae); if (cae.getInvoice() != null) { if (!invoiceTotals.containsKey(cae.getInvoice().getId())) { - invoiceTotals.put(cae.getInvoice().getId(), 0f); + invoiceTotals.put(cae.getInvoice().getId(), BigDecimal.ZERO); } - invoiceTotals.put(cae.getInvoice().getId(), invoiceTotals.get(cae.getInvoice().getId()) + cae.calculateTotal()); + invoiceTotals.put(cae.getInvoice().getId(), invoiceTotals.get(cae.getInvoice().getId()).add(cae.calculateTotal())); } } ComponentUtils.autoSizeColumns(tblAccountEntries); @@ -4477,7 +4478,7 @@ private void loadAccountEntries() { if (invoiceTotals.containsKey(inv.getId())) { ie.setPaidTotal(inv.getTotalGross(), invoiceTotals.get(inv.getId()), inv.getCurrency()); } else { - ie.setPaidTotal(inv.getTotalGross(), 0f, inv.getCurrency()); + ie.setPaidTotal(inv.getTotalGross(), BigDecimal.ZERO, inv.getCurrency()); } } @@ -6394,12 +6395,12 @@ private void chkArchivedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F if (this.tblAccountEntries.getRowCount() == 0) { this.loadAccountEntries(); } - float totalEscrow = 0f; - float totalExpenditures = 0f; + BigDecimal totalEscrow = BigDecimal.ZERO; + BigDecimal totalExpenditures = BigDecimal.ZERO; for (int r = 0; r < this.tblAccountEntries.getRowCount(); r++) { AccountEntryRowIdentifier ident = (AccountEntryRowIdentifier) this.tblAccountEntries.getValueAt(r, 0); - totalEscrow = totalEscrow + ident.getAccountEntry().getEscrowIn() - ident.getAccountEntry().getEscrowOut(); - totalExpenditures = totalExpenditures + ident.getAccountEntry().getExpendituresIn() - ident.getAccountEntry().getExpendituresOut(); + totalEscrow = totalEscrow.add(ident.getAccountEntry().getEscrowIn()).subtract(ident.getAccountEntry().getEscrowOut()); + totalExpenditures = totalExpenditures.add(ident.getAccountEntry().getExpendituresIn()).subtract(ident.getAccountEntry().getExpendituresOut()); } ArchivalDialog dlg = new ArchivalDialog(EditorsRegistry.getInstance().getMainWindow(), true, this.dto.getId(), this.tblReviewReasons, this.pnlInvoices, this.pnlTimesheets, totalEscrow, totalExpenditures); @@ -6642,33 +6643,33 @@ private void mnuSendEpostLetterActionPerformed(java.awt.event.ActionEvent evt) { }//GEN-LAST:event_mnuSendEpostLetterActionPerformed private void addAccountEntryRow(CaseAccountEntry e) { - ((DefaultTableModel) this.tblAccountEntries.getModel()).addRow(new Object[]{new AccountEntryRowIdentifier(e), e.getContact(), e.getEarnings(), e.getSpendings(), e.getEscrowIn(), e.getEscrowOut(), e.getExpendituresIn(), e.getExpendituresOut(), e.getInvoice(), e.getDescription()}); + ((DefaultTableModel) this.tblAccountEntries.getModel()).addRow(new Object[]{new AccountEntryRowIdentifier(e), e.getContact(), e.getEarnings().floatValue(), e.getSpendings().floatValue(), e.getEscrowIn().floatValue(), e.getEscrowOut().floatValue(), e.getExpendituresIn().floatValue(), e.getExpendituresOut().floatValue(), e.getInvoice(), e.getDescription()}); this.updateAccountTotals(); } private void updateAccountTotals() { - float tEarnings = 0f; - float tSpendings = 0f; - float tEscrowIn = 0f; - float tEscrowOut = 0f; - float tExpIn = 0f; - float tExpOut = 0f; + BigDecimal tEarnings = BigDecimal.ZERO; + BigDecimal tSpendings = BigDecimal.ZERO; + BigDecimal tEscrowIn = BigDecimal.ZERO; + BigDecimal tEscrowOut = BigDecimal.ZERO; + BigDecimal tExpIn = BigDecimal.ZERO; + BigDecimal tExpOut = BigDecimal.ZERO; for (int r = 0; r < this.tblAccountEntries.getRowCount(); r++) { AccountEntryRowIdentifier id = (AccountEntryRowIdentifier) this.tblAccountEntries.getValueAt(r, 0); CaseAccountEntry e = id.getAccountEntry(); - tEarnings += e.getEarnings(); - tSpendings += e.getSpendings(); - tEscrowIn += e.getEscrowIn(); - tEscrowOut += e.getEscrowOut(); - tExpIn += e.getExpendituresIn(); - tExpOut += e.getExpendituresOut(); + tEarnings = tEarnings.add(e.getEarnings()); + tSpendings = tSpendings.add(e.getSpendings()); + tEscrowIn =tEscrowIn.add(e.getEscrowIn()); + tEscrowOut =tEscrowOut.add(e.getEscrowOut()); + tExpIn =tExpIn.add(e.getExpendituresIn()); + tExpOut =tExpOut.add(e.getExpendituresOut()); } - float tEarningsSpendings = tEarnings - tSpendings; - float tEscrow = tEscrowIn - tEscrowOut; - float tExp = tExpIn - tExpOut; + BigDecimal tEarningsSpendings = tEarnings.subtract(tSpendings); + BigDecimal tEscrow = tEscrowIn.subtract(tEscrowOut); + BigDecimal tExp = tExpIn.subtract(tExpOut); this.lblEarnings.setText(accountEntryFormat.format(tEarnings)); this.lblSpendings.setText(accountEntryFormat.format(tSpendings)); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/CaseAccountEntryPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/CaseAccountEntryPanel.java index b7b9db729..c8d1628d6 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/CaseAccountEntryPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/CaseAccountEntryPanel.java @@ -671,6 +671,7 @@ You should also get your employer (if you work as a programmer) or school, import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @@ -1164,12 +1165,12 @@ public CaseAccountEntry getEntry() throws Exception { this.entry.setEntryDate(this.df.parse(this.txtDate.getText())); this.entry.setContact(this.recipientAddress); this.entry.setDescription(this.taDescription.getText()); - this.entry.setEarnings(((Number) txtEarnings.getValue()).floatValue()); - this.entry.setSpendings(((Number) txtSpendings.getValue()).floatValue()); - this.entry.setEscrowIn(((Number) txtEscrowIn.getValue()).floatValue()); - this.entry.setEscrowOut(((Number) txtEscrowOut.getValue()).floatValue()); - this.entry.setExpendituresIn(((Number) txtExpendituresIn.getValue()).floatValue()); - this.entry.setExpendituresOut(((Number) txtExpendituresOut.getValue()).floatValue()); + this.entry.setEarnings(BigDecimal.valueOf(((Number) txtEarnings.getValue()).floatValue())); + this.entry.setSpendings(BigDecimal.valueOf(((Number) txtSpendings.getValue()).floatValue())); + this.entry.setEscrowIn(BigDecimal.valueOf(((Number) txtEscrowIn.getValue()).floatValue())); + this.entry.setEscrowOut(BigDecimal.valueOf(((Number) txtEscrowOut.getValue()).floatValue())); + this.entry.setExpendituresIn(BigDecimal.valueOf(((Number) txtExpendituresIn.getValue()).floatValue())); + this.entry.setExpendituresOut(BigDecimal.valueOf(((Number) txtExpendituresOut.getValue()).floatValue())); if (this.cmbInvoice.getSelectedItem() instanceof Invoice) { this.entry.setInvoice((Invoice) this.cmbInvoice.getSelectedItem()); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/GirocodeDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/GirocodeDialog.java index 706da6d0a..d0ce48bef 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/GirocodeDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/GirocodeDialog.java @@ -672,6 +672,7 @@ You should also get your employer (if you work as a programmer) or school, import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; +import java.math.BigDecimal; import java.text.DecimalFormat; import javax.swing.ImageIcon; import javax.swing.JOptionPane; @@ -697,7 +698,7 @@ public class GirocodeDialog extends javax.swing.JDialog { * @param amount * @param purpose */ - public GirocodeDialog(InvoiceDialog parent, boolean modal, String senderPrincipalId, float amount, String purpose) { + public GirocodeDialog(InvoiceDialog parent, boolean modal, String senderPrincipalId, BigDecimal amount, String purpose) { super(parent, modal); initComponents(); @@ -875,7 +876,7 @@ public static void main(String args[]) { /* Create and display the dialog */ java.awt.EventQueue.invokeLater(() -> { - GirocodeDialog dialog = new GirocodeDialog(null, true, null, 0f, null); + GirocodeDialog dialog = new GirocodeDialog(null, true, null, BigDecimal.ZERO, null); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceDialog.java index 4959f9608..15916f77c 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceDialog.java @@ -703,6 +703,7 @@ You should also get your employer (if you work as a programmer) or school, import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -1124,10 +1125,10 @@ public final void setEntry(Invoice invoice) { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); List payments = locator.lookupArchiveFileServiceRemote().getAccountEntriesForInvoice(invoice.getId()); TableUtils.clearModel(tblPayments); - float paymentsTotal = 0f; + BigDecimal paymentsTotal = BigDecimal.ZERO; for (CaseAccountEntry ae : payments) { - float aeTotal = ae.calculateTotal(); - paymentsTotal += aeTotal; + BigDecimal aeTotal = ae.calculateTotal(); + paymentsTotal = paymentsTotal.add(aeTotal); ((DefaultTableModel) this.tblPayments.getModel()).addRow(new Object[]{ae.getEntryDate(), aeTotal, ae.getDescription()}); } this.lblPaymentsTotal.setText(cf.format(paymentsTotal)); @@ -2195,11 +2196,11 @@ private StyledCalculationTable getTimesheetPositionsAsTable(List taxRateToTaxTotal = new HashMap<>(); + HashMap taxRateToTaxTotal = new HashMap<>(); int rowcount = 0; @@ -2222,28 +2223,28 @@ private StyledCalculationTable getInvoicePositionsAsTable(String language) { if (c instanceof InvoicePositionEntryPanel) { InvoicePosition pos = ((InvoicePositionEntryPanel) c).getEntry(); - float u = pos.getUnits(); - float up = pos.getUnitPrice(); - float t = pos.getTaxRate(); + BigDecimal u = pos.getUnits(); + BigDecimal up = pos.getUnitPrice(); + BigDecimal t = pos.getTaxRate(); if (!taxRateToTaxTotal.containsKey(t)) { - taxRateToTaxTotal.put(t, 0f); + taxRateToTaxTotal.put(t, BigDecimal.ZERO); } if (this.chkTaxes.isSelected()) { - float taxForPosition = (u * up * (t / 100f)); - taxRateToTaxTotal.put(t, taxRateToTaxTotal.get(t) + taxForPosition); - totalTax = totalTax + taxForPosition; + BigDecimal taxForPosition = (u.multiply(up).multiply(t.divide(BigDecimal.valueOf(100f)))); + taxRateToTaxTotal.put(t, taxRateToTaxTotal.get(t).add(taxForPosition)); + totalTax = totalTax.add(taxForPosition); } - total = total + (u * up * (1 + t / 100f)); + total = total.add(u.multiply(up).multiply(BigDecimal.ONE.add(t.divide(BigDecimal.valueOf(100f))))); - totalNet = totalNet + (u * up); + totalNet = totalNet.add(u.multiply(up)); positionIndex = positionIndex + 1; if (StringUtils.isEmpty(pos.getDescription())) { - ct.addRow("" + positionIndex, pos.getName(), cf.format(pos.getUnits()), cf.format(pos.getUnitPrice()), percentageFormat.format(t), cf.format(u * up) + " " + this.cmbCurrency.getSelectedItem()); + ct.addRow("" + positionIndex, pos.getName(), cf.format(pos.getUnits()), cf.format(pos.getUnitPrice()), percentageFormat.format(t), cf.format(u.multiply(up)) + " " + this.cmbCurrency.getSelectedItem()); } else { - ct.addRow("" + positionIndex, pos.getName() + ": " + pos.getDescription(), cf.format(pos.getUnits()), cf.format(pos.getUnitPrice()), percentageFormat.format(t), cf.format(u * up) + " " + this.cmbCurrency.getSelectedItem()); + ct.addRow("" + positionIndex, pos.getName() + ": " + pos.getDescription(), cf.format(pos.getUnits()), cf.format(pos.getUnitPrice()), percentageFormat.format(t), cf.format(u.multiply(up)) + " " + this.cmbCurrency.getSelectedItem()); } rowcount = rowcount + 1; @@ -2256,28 +2257,28 @@ private StyledCalculationTable getInvoicePositionsAsTable(String language) { int footerRowNet = -1; ArrayList footerRowTaxes = new ArrayList<>(); int footerRowTotal = -1; - Map taxRateToTaxTotalSorted = new TreeMap<>(taxRateToTaxTotal); + Map taxRateToTaxTotalSorted = new TreeMap<>(taxRateToTaxTotal); if ("EN".equalsIgnoreCase(language)) { footerRowNet = ct.addRow("", "Net", "", "", "", cf.format(totalNet) + " " + this.cmbCurrency.getSelectedItem()); - for (float taxRate : taxRateToTaxTotalSorted.keySet()) { + for (BigDecimal taxRate : taxRateToTaxTotalSorted.keySet()) { footerRowTaxes.add(ct.addRow("", "Tax " + percentageFormat.format(taxRate) + "%", "", "", "", cf.format(taxRateToTaxTotal.get(taxRate)) + " " + this.cmbCurrency.getSelectedItem())); } footerRowTotal = ct.addRow("", "Balance Due", "", "", "", lblInvoiceTotal.getText() + " " + this.cmbCurrency.getSelectedItem()); } else if ("FR".equalsIgnoreCase(language)) { footerRowNet = ct.addRow("", "Sous Total", "", "", "", cf.format(totalNet) + " " + this.cmbCurrency.getSelectedItem()); - for (float taxRate : taxRateToTaxTotalSorted.keySet()) { + for (BigDecimal taxRate : taxRateToTaxTotalSorted.keySet()) { footerRowTaxes.add(ct.addRow("", "TPS " + percentageFormat.format(taxRate) + "%", "", "", "", cf.format(taxRateToTaxTotal.get(taxRate)) + " " + this.cmbCurrency.getSelectedItem())); } footerRowTotal = ct.addRow("", "Montant Dû", "", "", "", lblInvoiceTotal.getText() + " " + this.cmbCurrency.getSelectedItem()); } else if ("NL".equalsIgnoreCase(language)) { footerRowNet = ct.addRow("", "Subtotal", "", "", "", cf.format(totalNet) + " " + this.cmbCurrency.getSelectedItem()); - for (float taxRate : taxRateToTaxTotalSorted.keySet()) { + for (BigDecimal taxRate : taxRateToTaxTotalSorted.keySet()) { footerRowTaxes.add(ct.addRow("", "BTW " + percentageFormat.format(taxRate) + "%", "", "", "", cf.format(taxRateToTaxTotal.get(taxRate)) + " " + this.cmbCurrency.getSelectedItem())); } footerRowTotal = ct.addRow("", "Totaal te betalen", "", "", "", lblInvoiceTotal.getText() + " " + this.cmbCurrency.getSelectedItem()); } else { footerRowNet = ct.addRow("", "Netto", "", "", "", cf.format(totalNet) + " " + this.cmbCurrency.getSelectedItem()); - for (float taxRate : taxRateToTaxTotalSorted.keySet()) { + for (BigDecimal taxRate : taxRateToTaxTotalSorted.keySet()) { footerRowTaxes.add(ct.addRow("", "USt. " + percentageFormat.format(taxRate) + "%", "", "", "", cf.format(taxRateToTaxTotal.get(taxRate)) + " " + this.cmbCurrency.getSelectedItem())); } footerRowTotal = ct.addRow("", "Zahlbetrag", "", "", "", lblInvoiceTotal.getText() + " " + this.cmbCurrency.getSelectedItem()); @@ -2371,23 +2372,23 @@ public void updateTotals(InvoicePositionEntryPanel ep) { ep.updateEntryTotal(); } - float totalTax = 0f; - float totalGross = 0f; - float totalNet = 0f; + BigDecimal totalTax = BigDecimal.ZERO; + BigDecimal totalGross = BigDecimal.ZERO; + BigDecimal totalNet = BigDecimal.ZERO; for (Component c : this.pnlInvoicePositions.getComponents()) { if (c instanceof InvoicePositionEntryPanel) { InvoicePosition pos = ((InvoicePositionEntryPanel) c).getEntry(); - float u = pos.getUnits(); - float up = pos.getUnitPrice(); - float t = pos.getTaxRate(); + BigDecimal u = pos.getUnits(); + BigDecimal up = pos.getUnitPrice(); + BigDecimal t = pos.getTaxRate(); - totalNet = totalNet + (u * up); + totalNet = totalNet.add(u.multiply(up)); if (this.chkTaxes.isSelected()) { - totalTax = totalTax + (u * up * (t / 100f)); - totalGross = totalGross + (u * up * (1 + t / 100f)); + totalTax = totalTax.add(u.multiply(up).multiply(t.divide(BigDecimal.valueOf(100f)))); + totalGross = totalGross.add(u.multiply(up).multiply(BigDecimal.ONE.add(t.divide(BigDecimal.valueOf(100f))))); } else { - totalGross = totalGross + (u * up); + totalGross = totalGross.add(u.multiply(up)); } } } @@ -2429,10 +2430,10 @@ private void cmdAddPositionActionPerformed(java.awt.event.ActionEvent evt) {//GE pos.setInvoice(this.currentEntry); pos.setName("Name"); pos.setPosition(this.pnlInvoicePositions.getComponentCount() + 1); - pos.setTaxRate(19f); - pos.setTotal(0f); - pos.setUnitPrice(0f); - pos.setUnits(1f); + pos.setTaxRate(BigDecimal.valueOf(19f)); + pos.setTotal(BigDecimal.ZERO); + pos.setUnitPrice(BigDecimal.ZERO); + pos.setUnits(BigDecimal.ONE); this.addPosition(pos); @@ -2661,7 +2662,7 @@ private void cmdApplyPositionTemplateActionPerformed(java.awt.event.ActionEvent pos.setName(tpl.getName()); pos.setPosition(this.pnlInvoicePositions.getComponentCount() + 1); pos.setTaxRate(tpl.getTaxRate()); - pos.setTotal(tpl.getUnits() * tpl.getUnitPrice() * (1 + tpl.getTaxRate())); + pos.setTotal(tpl.getUnits().multiply(tpl.getUnitPrice()).multiply(BigDecimal.ONE.add(tpl.getTaxRate()))); pos.setUnitPrice(tpl.getUnitPrice()); pos.setUnits(tpl.getUnits()); @@ -2739,10 +2740,10 @@ private void cmdTimesheetPositionsActionPerformed(java.awt.event.ActionEvent evt private void cmdGiroCodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdGiroCodeActionPerformed try { - float amount = 0f; + BigDecimal amount = BigDecimal.ZERO; boolean validAmount = false; try { - amount = cf.parse(this.lblInvoiceTotal.getText()).floatValue(); + amount = BigDecimal.valueOf(cf.parse(this.lblInvoiceTotal.getText()).floatValue()); validAmount = true; } catch (Throwable t) { log.error("error parsing invoice total: " + this.lblInvoiceTotal.getText(), t); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceEntryPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceEntryPanel.java index da6d14717..71932e946 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceEntryPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceEntryPanel.java @@ -674,6 +674,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.services.JLawyerServiceLocator; import java.awt.Color; import java.awt.Container; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -697,7 +698,7 @@ public class InvoiceEntryPanel extends javax.swing.JPanel { private Invoice invoice = null; private List addresses = null; - private float paid = 0f; + private BigDecimal paid = BigDecimal.ZERO; /** * Creates new form InvoiceEntryPanel @@ -709,12 +710,12 @@ public InvoiceEntryPanel(ArchiveFilePanel caseView) { this.caseView = caseView; } - public void setPaidTotal(float totalGross, float paid, String currency) { - if (paid != Float.MIN_VALUE) { + public void setPaidTotal(BigDecimal totalGross, BigDecimal paid, String currency) { + if (paid != BigDecimal.valueOf(Float.MIN_VALUE)) { this.paid = paid; } this.lblPaidTotal.setText(totalFormat.format(this.paid) + " " + currency); - this.lblOpen.setText(totalFormat.format(totalGross - this.paid) + " " + currency); + this.lblOpen.setText(totalFormat.format(totalGross.subtract(this.paid)) + " " + currency); } @@ -759,8 +760,8 @@ public void setEntry(ArchiveFileBean caseDto, Invoice invoice, List this.lblRecipient.setText(" "); } - this.lblTotalNet.setText(totalFormat.format(invoice.getTotal()) + " " + invoice.getCurrency()); - this.lblTotalGross.setText(totalFormat.format(invoice.getTotalGross()) + " " + invoice.getCurrency()); + this.lblTotalNet.setText(totalFormat.format(invoice.getTotal().floatValue()) + " " + invoice.getCurrency()); + this.lblTotalGross.setText(totalFormat.format(invoice.getTotalGross().floatValue()) + " " + invoice.getCurrency()); this.cmdMarkAsPayed.setEnabled(invoice.getStatus() != Invoice.STATUS_PAID && invoice.getStatus() != Invoice.STATUS_CANCELLED); @@ -982,7 +983,7 @@ private void cmdOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST FrameUtils.centerDialog(dlg, EditorsRegistry.getInstance().getMainWindow()); dlg.setVisible(true); this.setEntry(caseDto, dlg.getEntry(), addresses); - this.setPaidTotal(dlg.getEntry().getTotalGross(), Float.MIN_VALUE, dlg.getEntry().getCurrency()); + this.setPaidTotal(dlg.getEntry().getTotalGross(), BigDecimal.valueOf(Float.MIN_VALUE), dlg.getEntry().getCurrency()); }//GEN-LAST:event_cmdOpenActionPerformed private void cmdDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdDeleteActionPerformed @@ -1016,7 +1017,7 @@ private void cmdMarkAsPayedActionPerformed(java.awt.event.ActionEvent evt) {//GE this.invoice.setStatus(Invoice.STATUS_PAID); ClientSettings settings = ClientSettings.getInstance(); - float currentPaid = 0f; + BigDecimal currentPaid = BigDecimal.ZERO; try { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); locator.lookupArchiveFileServiceRemote().updateInvoice(this.caseDto.getId(), this.invoice); @@ -1024,24 +1025,24 @@ private void cmdMarkAsPayedActionPerformed(java.awt.event.ActionEvent evt) {//GE List payments = locator.lookupArchiveFileServiceRemote().getAccountEntriesForInvoice(invoice.getId()); for (CaseAccountEntry ce : payments) { - currentPaid = currentPaid + ce.getEarnings() - ce.getSpendings(); + currentPaid = currentPaid.add(ce.getEarnings()).subtract(ce.getSpendings()); } this.setEntry(caseDto, this.invoice, addresses); - if(this.invoice.getTotalGross() - currentPaid > 0) { + if(this.invoice.getTotalGross().subtract(currentPaid).compareTo(BigDecimal.ZERO) > 0) { CaseAccountEntry entry = new CaseAccountEntry(); entry.setArchiveFileKey(caseDto); entry.setContact(this.invoice.getContact()); entry.setDescription(""); - entry.setEarnings(invoice.getTotalGross() - currentPaid); + entry.setEarnings(invoice.getTotalGross().subtract(currentPaid)); entry.setEntryDate(new Date()); - entry.setEscrowIn(0f); - entry.setEscrowOut(0f); - entry.setExpendituresIn(0f); - entry.setExpendituresOut(0f); + entry.setEscrowIn(BigDecimal.ZERO); + entry.setEscrowOut(BigDecimal.ZERO); + entry.setExpendituresIn(BigDecimal.ZERO); + entry.setExpendituresOut(BigDecimal.ZERO); entry.setInvoice(invoice); - entry.setSpendings(0f); + entry.setSpendings(BigDecimal.ZERO); boolean confirmed = this.caseView.addAccountEntry(entry); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoicePositionEntryPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoicePositionEntryPanel.java index bd04f3aad..f47a7a292 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoicePositionEntryPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoicePositionEntryPanel.java @@ -668,6 +668,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.persistence.InvoicePosition; import com.jdimension.jlawyer.services.JLawyerServiceLocator; import java.awt.Container; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.List; @@ -760,23 +761,23 @@ public InvoicePosition getEntry() { clone.setName(this.txtName.getText()); clone.setDescription(this.taDescription.getText()); try { - clone.setTaxRate(this.taxRateFormat.parse(this.cmbTaxRate.getSelectedItem().toString()).floatValue()); + clone.setTaxRate(BigDecimal.valueOf(this.taxRateFormat.parse(this.cmbTaxRate.getSelectedItem().toString()).floatValue())); } catch (Exception ex) { - clone.setTaxRate(0f); + clone.setTaxRate(BigDecimal.ZERO); JOptionPane.showMessageDialog(this, "fehlerhafter Steuersatz: " + ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); } //this.updateEntryTotal(); - clone.setTotal((Float) this.txtTotal.getValue()); + clone.setTotal(BigDecimal.valueOf((Float) this.txtTotal.getValue())); if(this.txtUnitPrice.getValue()==null) - clone.setUnitPrice(0f); + clone.setUnitPrice(BigDecimal.ZERO); else - clone.setUnitPrice(((Number) this.txtUnitPrice.getValue()).floatValue()); + clone.setUnitPrice(BigDecimal.valueOf(((Number) this.txtUnitPrice.getValue()).floatValue())); if(this.txtUnits.getValue()==null) - clone.setUnits(1f); + clone.setUnits(BigDecimal.ONE); else - clone.setUnits(((Number) this.txtUnits.getValue()).floatValue()); + clone.setUnits(BigDecimal.valueOf(((Number) this.txtUnits.getValue()).floatValue())); return clone; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetBillingDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetBillingDialog.java index cdfb549d1..b273dc2f9 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetBillingDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetBillingDialog.java @@ -674,6 +674,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.services.ArchiveFileServiceRemote; import com.jdimension.jlawyer.services.JLawyerServiceLocator; import java.awt.event.MouseEvent; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.List; @@ -900,8 +901,8 @@ private void cmdBillingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI ip.setUnitPrice(p.getUnitPrice()); ip.setInvoice(this.invoice); ip.setTaxRate(p.getTaxRate()); - ip.setUnits(0f); - ip.setTotal(0f); + ip.setUnits(BigDecimal.ZERO); + ip.setTotal(BigDecimal.ZERO); aggregatedPositions.put(identifier, ip); } InvoicePosition ip = aggregatedPositions.get(identifier); @@ -909,7 +910,7 @@ private void cmdBillingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI double roundedMinutes = Math.ceil(totalMinutes / p.getTimesheet().getInterval()) * p.getTimesheet().getInterval(); float roundedMinutesFloat = new Float(roundedMinutes); //float total=roundedMinutesFloat/60f*unitPrice.floatValue(); - ip.setUnits(ip.getUnits()+roundedMinutesFloat/60f); + ip.setUnits(ip.getUnits().add(BigDecimal.valueOf(roundedMinutesFloat/60f))); try { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetDialog.java index 9ae5c7679..189687ff4 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetDialog.java @@ -677,6 +677,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.server.constants.OptionConstants; import com.jdimension.jlawyer.services.JLawyerServiceLocator; import java.awt.Component; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; @@ -1198,7 +1199,7 @@ private void fillCurrentEntry() throws Exception { this.currentEntry.setName(this.txtName.getText()); this.currentEntry.setStatus(this.currentEntry.getStatusInt(this.cmbStatus.getSelectedItem().toString())); this.currentEntry.setInterval(Integer.parseInt(this.cmbTimesheetInterval.getSelectedItem().toString())); - this.currentEntry.setLimit(this.currencyFormat.parse(this.txtTimesheetLimit.getText()).floatValue()); + this.currentEntry.setLimit(BigDecimal.valueOf(this.currencyFormat.parse(this.txtTimesheetLimit.getText()).floatValue())); this.currentEntry.setLimited(this.chkTimesheetLimit.isSelected()); } @@ -1324,14 +1325,14 @@ public void updateTotals(TimesheetPositionEntryPanel ep) { ep.updateEntryTotal(Integer.parseInt(this.cmbTimesheetInterval.getSelectedItem().toString())); } - float total = 0f; - float totalTax = 0f; + BigDecimal total = BigDecimal.ZERO; + BigDecimal totalTax = BigDecimal.ZERO; for (Component tsp : this.pnlTimesheetPositions.getComponents()) { TimesheetPositionEntryPanel tspep = (TimesheetPositionEntryPanel) tsp; TimesheetPosition pos = tspep.getEntry(); - total = total + pos.getTotal(); - totalTax = totalTax + (pos.getTotal() * (pos.getTaxRate() / 100f)); + total = total.add(pos.getTotal()); + totalTax = totalTax.add(pos.getTotal().multiply(pos.getTaxRate().divide(BigDecimal.valueOf(100f)))); } this.lblTimesheetTotal.setText(cf.format(total)); @@ -1339,11 +1340,11 @@ public void updateTotals(TimesheetPositionEntryPanel ep) { this.txtTimesheetTotal.setText(cf.format(total)); if (this.chkTimesheetLimit.isSelected()) { - int prgValue = new Float((new Float(total).intValue() / ((Number) this.txtTimesheetLimit.getValue()).floatValue()) * 100f).intValue(); + int prgValue = new Float((total.intValue() / ((Number) this.txtTimesheetLimit.getValue()).floatValue()) * 100f).intValue(); this.prgTimesheetStatus.setMaximum(Math.max(prgValue, 100)); this.prgTimesheetStatus.setMinimum(0); try { - this.prgTimesheetStatus.setValue(new Float((new Float(total).intValue() / ((Number) this.txtTimesheetLimit.getValue()).floatValue()) * 100f).intValue()); + this.prgTimesheetStatus.setValue(new Float((total.intValue() / ((Number) this.txtTimesheetLimit.getValue()).floatValue()) * 100f).intValue()); } catch (Throwable th) { log.error("unable to calculate timesheet progress", th); this.prgTimesheetStatus.setValue(0); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetLogDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetLogDialog.java index 5af124c5a..849e20db2 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetLogDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetLogDialog.java @@ -675,6 +675,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.services.TimesheetServiceRemote; import java.awt.Component; import java.awt.event.KeyEvent; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Timer; @@ -933,7 +934,7 @@ public void newTimesheetLogEntry(Timesheet timesheet) { tsp.setPrincipal(UserSettings.getInstance().getCurrentUser().getPrincipalId()); tsp.setStarted(null); tsp.setStopped(null); - tsp.setTotal(0f); + tsp.setTotal(BigDecimal.ZERO); tlep.setEntry(timesheet.getArchiveFileKey(), timesheet, tsp); // add at the very top of the list diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetLogEntryPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetLogEntryPanel.java index 335a0a15e..ae871ffdf 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetLogEntryPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetLogEntryPanel.java @@ -675,6 +675,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.services.JLawyerServiceLocator; import java.awt.Color; import java.awt.event.KeyEvent; +import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -972,8 +973,8 @@ public void startStop() { this.entry.setTaxRate(this.templates.get(this.cmbTemplate.getEditor().getItem().toString()).getTaxRate()); this.entry.setUnitPrice(this.templates.get(this.cmbTemplate.getEditor().getItem().toString()).getUnitPrice()); } else { - this.entry.setTaxRate(19f); - this.entry.setUnitPrice(0f); + this.entry.setTaxRate(BigDecimal.valueOf(19f)); + this.entry.setUnitPrice(BigDecimal.ZERO); } try { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); @@ -1066,8 +1067,8 @@ private void saveManualEntry () { this.entry.setUnitPrice(this.templates.get(this.cmbTemplate.getEditor().getItem().toString()).getUnitPrice()); } else { // should not happen, because the combobox is not editable - this.entry.setTaxRate(19f); - this.entry.setUnitPrice(0f); + this.entry.setTaxRate(BigDecimal.valueOf(19f)); + this.entry.setUnitPrice(BigDecimal.ZERO); } Date start=new Date(); @@ -1117,8 +1118,8 @@ private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST this.entry.setUnitPrice(this.templates.get(this.cmbTemplate.getEditor().getItem().toString()).getUnitPrice()); } else { // should not happen, because the combobox is not editable - this.entry.setTaxRate(19f); - this.entry.setUnitPrice(0f); + this.entry.setTaxRate(BigDecimal.valueOf(19f)); + this.entry.setUnitPrice(BigDecimal.ZERO); } Date dStart=(Date)this.txtStart.getValue(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetPositionEntryPanel.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetPositionEntryPanel.form index 8367fd635..cd60fc268 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetPositionEntryPanel.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetPositionEntryPanel.form @@ -66,19 +66,20 @@ - - - - - - - - + + + + + + + + + + -
diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetPositionEntryPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetPositionEntryPanel.java index 41e4c54e1..665228b92 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetPositionEntryPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/TimesheetPositionEntryPanel.java @@ -670,6 +670,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.persistence.TimesheetPosition; import com.jdimension.jlawyer.services.JLawyerServiceLocator; import java.awt.Container; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Date; @@ -835,17 +836,17 @@ public TimesheetPosition getEntry() { clone.setName(this.txtName.getText()); clone.setDescription(this.taDescription.getText()); try { - clone.setTaxRate(this.taxRateFormat.parse(this.cmbTaxRate.getSelectedItem().toString()).floatValue()); + clone.setTaxRate(BigDecimal.valueOf(this.taxRateFormat.parse(this.cmbTaxRate.getSelectedItem().toString()).floatValue())); } catch (Exception ex) { - clone.setTaxRate(0f); + clone.setTaxRate(BigDecimal.ZERO); JOptionPane.showMessageDialog(this, "fehlerhafter Steuersatz: " + ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); } - clone.setTotal((Float) this.txtTotal.getValue()); + clone.setTotal(BigDecimal.valueOf((Float) this.txtTotal.getValue())); if(this.txtUnitPrice.getValue()==null) - clone.setUnitPrice(0f); + clone.setUnitPrice(BigDecimal.ZERO); else - clone.setUnitPrice(((Number) this.txtUnitPrice.getValue()).floatValue()); + clone.setUnitPrice(BigDecimal.valueOf(((Number) this.txtUnitPrice.getValue()).floatValue())); return clone; } @@ -984,18 +985,18 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(txtStarted, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel4) - .addComponent(txtStopped, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel3) - .addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtUnitPrice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel2) - .addComponent(lblBilled)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lblBilled) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtStarted, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4) + .addComponent(txtStopped, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3) + .addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtUnitPrice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, 0)) + .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lblIndicator, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); }// //GEN-END:initComponents diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/TimesheetUtils.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/TimesheetUtils.java index 90dafaeec..091b93eb5 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/TimesheetUtils.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/TimesheetUtils.java @@ -677,7 +677,7 @@ public class TimesheetUtils { public static void renderPieChartLabel(PieChartLabel pie, Timesheet ts) { if(ts.isLimited()) { - pie.setToolTipText("" + (int)ts.getPercentageDone() + "% von maximal " + new DecimalFormat("0.00").format(ts.getLimit())); + pie.setToolTipText("" + (int)ts.getPercentageDone() + "% von maximal " + new DecimalFormat("0.00").format(ts.getLimit().floatValue())); pie.setPercentage(Math.min((int)ts.getPercentageDone(), 100)); if(ts.getPercentageDone()<80) pie.setFillColor(DefaultColorTheme.COLOR_LOGO_GREEN); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/einvoice/EInvoiceUtils.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/einvoice/EInvoiceUtils.java index c55f1ea3c..7bf702922 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/einvoice/EInvoiceUtils.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/einvoice/EInvoiceUtils.java @@ -795,11 +795,11 @@ public static org.mustangproject.Invoice getEInvoice(com.jdimension.jlawyer.pers // line items for (InvoicePosition pos : positions) { - float taxRate = pos.getTaxRate(); + BigDecimal taxRate = pos.getTaxRate(); if (!caseInvoice.isSmallBusiness()) { - taxRate = 0f; + taxRate = BigDecimal.ZERO; } - i.addItem(new Item(new Product(pos.getName(), pos.getDescription(), "C62", new BigDecimal(taxRate)), /*price*/ new BigDecimal(pos.getUnitPrice()), /*qty*/ new BigDecimal(pos.getUnits()))); + i.addItem(new Item(new Product(pos.getName(), pos.getDescription(), "C62", taxRate), /*price*/ pos.getUnitPrice(), /*qty*/ pos.getUnits())); } return i; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.java index 7d2488a76..2209c2582 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.java @@ -1345,7 +1345,7 @@ private void setInvoice(Invoice linkedInvoice) { if(linkedInvoice.getDueDate()!=null) dueDate=dfDate.format(linkedInvoice.getDueDate()); lblInvoice.setText(linkedInvoice.getInvoiceType().getDisplayName() + " " + linkedInvoice.getInvoiceNumber()); - lblInvoice.setToolTipText("" + linkedInvoice.getInvoiceType().getDisplayName() + " " + linkedInvoice.getInvoiceNumber() + "
" + linkedInvoice.getStatusString() + "
fällig: " + dueDate + "
Betrag: " + currencyFormat.format(linkedInvoice.getTotalGross()) + " " + linkedInvoice.getCurrency()+ ""); + lblInvoice.setToolTipText("" + linkedInvoice.getInvoiceType().getDisplayName() + " " + linkedInvoice.getInvoiceNumber() + "
" + linkedInvoice.getStatusString() + "
fällig: " + dueDate + "
Betrag: " + currencyFormat.format(linkedInvoice.getTotalGross().floatValue()) + " " + linkedInvoice.getCurrency()+ ""); lblInvoice.setForeground(DefaultColorTheme.COLOR_LOGO_RED); } else { diff --git a/j-lawyer-server-api/src/com/jdimension/jlawyer/services/InvoiceServiceRemote.java b/j-lawyer-server-api/src/com/jdimension/jlawyer/services/InvoiceServiceRemote.java index f2c757250..95ebeec4f 100644 --- a/j-lawyer-server-api/src/com/jdimension/jlawyer/services/InvoiceServiceRemote.java +++ b/j-lawyer-server-api/src/com/jdimension/jlawyer/services/InvoiceServiceRemote.java @@ -666,6 +666,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.persistence.InvoicePool; import com.jdimension.jlawyer.persistence.InvoicePositionTemplate; import com.jdimension.jlawyer.persistence.InvoiceType; +import java.math.BigDecimal; import java.util.List; import javax.ejb.Remote; @@ -699,6 +700,6 @@ public interface InvoiceServiceRemote { void removeInvoiceType(InvoiceType invoiceType) throws Exception; - byte[] getGiroCode(String senderPrincipalId, float amount, String purpose) throws Exception; + byte[] getGiroCode(String senderPrincipalId, BigDecimal amount, String purpose) throws Exception; } diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/CaseAccountEntry.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/CaseAccountEntry.java index 5aa2557f3..3dffe0a9f 100644 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/CaseAccountEntry.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/CaseAccountEntry.java @@ -664,6 +664,7 @@ package com.jdimension.jlawyer.persistence; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; import javax.persistence.*; import javax.xml.bind.annotation.XmlRootElement; @@ -711,23 +712,23 @@ public class CaseAccountEntry implements Serializable { @Column(name = "description") private String description; - @Column(name = "in_earnings") - private float earnings=0f; + @Column(name = "in_earnings", precision = 10, scale = 2) + private BigDecimal earnings=BigDecimal.ZERO; - @Column(name = "out_spendings") - private float spendings=0f; + @Column(name = "out_spendings", precision = 10, scale = 2) + private BigDecimal spendings=BigDecimal.ZERO; - @Column(name = "in_escrow") - private float escrowIn=0f; + @Column(name = "in_escrow", precision = 10, scale = 2) + private BigDecimal escrowIn=BigDecimal.ZERO; - @Column(name = "out_escrow") - private float escrowOut=0f; + @Column(name = "out_escrow", precision = 10, scale = 2) + private BigDecimal escrowOut=BigDecimal.ZERO; - @Column(name = "in_expenditure") - private float expendituresIn=0f; + @Column(name = "in_expenditure", precision = 10, scale = 2) + private BigDecimal expendituresIn=BigDecimal.ZERO; - @Column(name = "out_expenditure") - private float expendituresOut=0f; + @Column(name = "out_expenditure", precision = 10, scale = 2) + private BigDecimal expendituresOut=BigDecimal.ZERO; public CaseAccountEntry() { @@ -737,8 +738,8 @@ public CaseAccountEntry(String id) { this.id = id; } - public float calculateTotal() { - return getEarnings()+getEscrowIn()+getExpendituresIn()-getSpendings()-getEscrowOut()-getExpendituresOut(); + public BigDecimal calculateTotal() { + return getEarnings().add(getEscrowIn()).add(getExpendituresIn()).subtract(getSpendings()).subtract(getEscrowOut()).subtract(getExpendituresOut()); } @Override @@ -867,84 +868,84 @@ public void setDescription(String description) { /** * @return the earnings */ - public float getEarnings() { + public BigDecimal getEarnings() { return earnings; } /** * @param earnings the earnings to set */ - public void setEarnings(float earnings) { + public void setEarnings(BigDecimal earnings) { this.earnings = earnings; } /** * @return the spendings */ - public float getSpendings() { + public BigDecimal getSpendings() { return spendings; } /** * @param spendings the spendings to set */ - public void setSpendings(float spendings) { + public void setSpendings(BigDecimal spendings) { this.spendings = spendings; } /** * @return the escrowIn */ - public float getEscrowIn() { + public BigDecimal getEscrowIn() { return escrowIn; } /** * @param escrowIn the escrowIn to set */ - public void setEscrowIn(float escrowIn) { + public void setEscrowIn(BigDecimal escrowIn) { this.escrowIn = escrowIn; } /** * @return the escrowOut */ - public float getEscrowOut() { + public BigDecimal getEscrowOut() { return escrowOut; } /** * @param escrowOut the escrowOut to set */ - public void setEscrowOut(float escrowOut) { + public void setEscrowOut(BigDecimal escrowOut) { this.escrowOut = escrowOut; } /** * @return the expendituresIn */ - public float getExpendituresIn() { + public BigDecimal getExpendituresIn() { return expendituresIn; } /** * @param expendituresIn the expendituresIn to set */ - public void setExpendituresIn(float expendituresIn) { + public void setExpendituresIn(BigDecimal expendituresIn) { this.expendituresIn = expendituresIn; } /** * @return the expendituresOut */ - public float getExpendituresOut() { + public BigDecimal getExpendituresOut() { return expendituresOut; } /** * @param expendituresOut the expendituresOut to set */ - public void setExpendituresOut(float expendituresOut) { + public void setExpendituresOut(BigDecimal expendituresOut) { this.expendituresOut = expendituresOut; } diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/Invoice.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/Invoice.java index b496f2e4e..2c0ad4415 100644 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/Invoice.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/Invoice.java @@ -664,6 +664,7 @@ package com.jdimension.jlawyer.persistence; import java.io.Serializable; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -761,11 +762,11 @@ public class Invoice implements Serializable { @Column(name = "sender_id") private String sender; - @Column(name = "total") - protected float total=0f; + @Column(name = "total", precision = 10, scale = 2) + protected BigDecimal total=BigDecimal.ZERO; - @Column(name = "total_gross") - private float totalGross=0f; + @Column(name = "total_gross", precision = 10, scale = 2) + private BigDecimal totalGross=BigDecimal.ZERO; @JoinColumn(name = "invoice_document", referencedColumnName = "id") @OneToOne(fetch = FetchType.EAGER) @@ -1052,14 +1053,14 @@ public void setInvoiceType(InvoiceType invoiceType) { /** * @return the total */ - public float getTotal() { + public BigDecimal getTotal() { return total; } /** * @param total the total to set */ - public void setTotal(float total) { + public void setTotal(BigDecimal total) { this.total = total; } @@ -1108,14 +1109,14 @@ public void setLastPoolId(String lastPoolId) { /** * @return the totalGross */ - public float getTotalGross() { + public BigDecimal getTotalGross() { return totalGross; } /** * @param totalGross the totalGross to set */ - public void setTotalGross(float totalGross) { + public void setTotalGross(BigDecimal totalGross) { this.totalGross = totalGross; } diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/InvoicePosition.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/InvoicePosition.java index 1055f5d22..e2ddef5a9 100644 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/InvoicePosition.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/InvoicePosition.java @@ -664,6 +664,7 @@ package com.jdimension.jlawyer.persistence; import java.io.Serializable; +import java.math.BigDecimal; import javax.persistence.*; import javax.xml.bind.annotation.XmlRootElement; @@ -694,17 +695,17 @@ public class InvoicePosition implements Serializable { @Column(name = "position") protected int position; - @Column(name = "tax_rate") - protected float taxRate; + @Column(name = "tax_rate", precision = 10, scale = 2) + protected BigDecimal taxRate=BigDecimal.ZERO; - @Column(name = "units") - protected float units; + @Column(name = "units", precision = 10, scale = 2) + protected BigDecimal units=BigDecimal.ZERO; - @Column(name = "unit_price") - protected float unitPrice; + @Column(name = "unit_price", precision = 10, scale = 2) + protected BigDecimal unitPrice=BigDecimal.ZERO; - @Column(name = "total") - protected float total; + @Column(name = "total", precision = 10, scale = 2) + protected BigDecimal total=BigDecimal.ZERO; @JoinColumn(name = "invoice_id", referencedColumnName = "id") @ManyToOne @@ -804,14 +805,14 @@ public void setPosition(int position) { /** * @return the taxRate */ - public float getTaxRate() { + public BigDecimal getTaxRate() { return taxRate; } /** * @param taxRate the taxRate to set */ - public void setTaxRate(float taxRate) { + public void setTaxRate(BigDecimal taxRate) { this.taxRate = taxRate; } @@ -832,42 +833,42 @@ public void setInvoice(Invoice invoice) { /** * @return the units */ - public float getUnits() { + public BigDecimal getUnits() { return units; } /** * @param units the units to set */ - public void setUnits(float units) { + public void setUnits(BigDecimal units) { this.units = units; } /** * @return the unitPrice */ - public float getUnitPrice() { + public BigDecimal getUnitPrice() { return unitPrice; } /** * @param unitPrice the unitPrice to set */ - public void setUnitPrice(float unitPrice) { + public void setUnitPrice(BigDecimal unitPrice) { this.unitPrice = unitPrice; } /** * @return the total */ - public float getTotal() { + public BigDecimal getTotal() { return total; } /** * @param total the total to set */ - public void setTotal(float total) { + public void setTotal(BigDecimal total) { this.total = total; } diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/InvoicePositionTemplate.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/InvoicePositionTemplate.java index f98ed542b..8ada92c3f 100644 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/InvoicePositionTemplate.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/InvoicePositionTemplate.java @@ -664,6 +664,7 @@ package com.jdimension.jlawyer.persistence; import java.io.Serializable; +import java.math.BigDecimal; import javax.persistence.*; import javax.xml.bind.annotation.XmlRootElement; @@ -692,14 +693,14 @@ public class InvoicePositionTemplate implements Serializable { @Column(name = "description") protected String description; - @Column(name = "tax_rate") - protected float taxRate; + @Column(name = "tax_rate", precision = 10, scale = 2) + protected BigDecimal taxRate=BigDecimal.ZERO; - @Column(name = "units") - protected float units; + @Column(name = "units", precision = 10, scale = 2) + protected BigDecimal units=BigDecimal.ZERO; - @Column(name = "unit_price") - protected float unitPrice; + @Column(name = "unit_price", precision = 10, scale = 2) + protected BigDecimal unitPrice=BigDecimal.ZERO; public InvoicePositionTemplate() { @@ -781,42 +782,42 @@ public void setDescription(String description) { /** * @return the taxRate */ - public float getTaxRate() { + public BigDecimal getTaxRate() { return taxRate; } /** * @param taxRate the taxRate to set */ - public void setTaxRate(float taxRate) { + public void setTaxRate(BigDecimal taxRate) { this.taxRate = taxRate; } /** * @return the units */ - public float getUnits() { + public BigDecimal getUnits() { return units; } /** * @param units the units to set */ - public void setUnits(float units) { + public void setUnits(BigDecimal units) { this.units = units; } /** * @return the unitPrice */ - public float getUnitPrice() { + public BigDecimal getUnitPrice() { return unitPrice; } /** * @param unitPrice the unitPrice to set */ - public void setUnitPrice(float unitPrice) { + public void setUnitPrice(BigDecimal unitPrice) { this.unitPrice = unitPrice; } diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/Timesheet.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/Timesheet.java index 3f32e35c6..d70ec7f17 100644 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/Timesheet.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/Timesheet.java @@ -664,6 +664,7 @@ package com.jdimension.jlawyer.persistence; import java.io.Serializable; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import javax.persistence.*; @@ -706,8 +707,8 @@ public class Timesheet implements Serializable { @Column(name = "limited") protected boolean limited=true; - @Column(name = "limit_net") - protected float limit=0f; + @Column(name = "limit_net", precision = 10, scale = 2) + protected BigDecimal limit=BigDecimal.ZERO; @Column(name = "pct_done") private float percentageDone=0f; @@ -834,14 +835,14 @@ public void setLimited(boolean limited) { /** * @return the limit */ - public float getLimit() { + public BigDecimal getLimit() { return limit; } /** * @param limit the limit to set */ - public void setLimit(float limit) { + public void setLimit(BigDecimal limit) { this.limit = limit; } diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/TimesheetPosition.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/TimesheetPosition.java index 8015f60fd..742d02a54 100644 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/TimesheetPosition.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/TimesheetPosition.java @@ -664,6 +664,7 @@ package com.jdimension.jlawyer.persistence; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; import javax.persistence.*; import javax.xml.bind.annotation.XmlRootElement; @@ -696,18 +697,18 @@ public class TimesheetPosition implements Serializable { @Column(name = "description") protected String description; - @Column(name = "tax_rate") - protected float taxRate; + @Column(name = "tax_rate", precision = 10, scale = 2) + protected BigDecimal taxRate=BigDecimal.ZERO; @JoinColumn(name = "timesheet_id", referencedColumnName = "id") @ManyToOne protected Timesheet timesheet; - @Column(name = "unit_price") - protected float unitPrice; + @Column(name = "unit_price", precision = 10, scale = 2) + protected BigDecimal unitPrice=BigDecimal.ZERO; - @Column(name = "total") - protected float total; + @Column(name = "total", precision = 10, scale = 2) + protected BigDecimal total=BigDecimal.ZERO; @Column(name = "principal") protected String principal; @@ -804,40 +805,40 @@ public void setDescription(String description) { /** * @return the taxRate */ - public float getTaxRate() { + public BigDecimal getTaxRate() { return taxRate; } /** * @param taxRate the taxRate to set */ - public void setTaxRate(float taxRate) { + public void setTaxRate(BigDecimal taxRate) { this.taxRate = taxRate; } /** * @return the unitPrice */ - public float getUnitPrice() { + public BigDecimal getUnitPrice() { return unitPrice; } /** * @param unitPrice the unitPrice to set */ - public void setUnitPrice(float unitPrice) { + public void setUnitPrice(BigDecimal unitPrice) { this.unitPrice = unitPrice; } /** * @return the total */ - public float getTotal() { + public BigDecimal getTotal() { return total; } - public float calculateTotal(int intervalMinutes) { - float positionTotal = 0f; + public BigDecimal calculateTotal(int intervalMinutes) { + BigDecimal positionTotal = BigDecimal.ZERO; if (started != null && stopped != null && started.getTime() < stopped.getTime()) { float totalMinutes = ((float) (stopped.getTime() - started.getTime())) / 1000f / 60f; if (intervalMinutes == 0) { @@ -845,8 +846,8 @@ public float calculateTotal(int intervalMinutes) { } double roundedMinutes = Math.ceil(totalMinutes / intervalMinutes) * intervalMinutes; float roundedMinutesFloat = new Float(roundedMinutes); - if (this.unitPrice != 0) { - positionTotal = roundedMinutesFloat / 60f * this.unitPrice; + if (!this.unitPrice.equals(BigDecimal.ZERO)) { + positionTotal = this.unitPrice.multiply(BigDecimal.valueOf(roundedMinutes).divide(BigDecimal.valueOf(60d))); } } return positionTotal; @@ -855,7 +856,7 @@ public float calculateTotal(int intervalMinutes) { /** * @param total the total to set */ - public void setTotal(float total) { + public void setTotal(BigDecimal total) { this.total = total; } diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/TimesheetPositionTemplate.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/TimesheetPositionTemplate.java index 8f4cd60c8..13b5434c5 100644 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/TimesheetPositionTemplate.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/TimesheetPositionTemplate.java @@ -664,6 +664,7 @@ package com.jdimension.jlawyer.persistence; import java.io.Serializable; +import java.math.BigDecimal; import java.text.DecimalFormat; import javax.persistence.*; import javax.xml.bind.annotation.XmlRootElement; @@ -693,11 +694,11 @@ public class TimesheetPositionTemplate implements Serializable { @Column(name = "description") protected String description; - @Column(name = "tax_rate") - protected float taxRate; + @Column(name = "tax_rate", precision = 10, scale = 2) + protected BigDecimal taxRate=BigDecimal.ZERO; - @Column(name = "unit_price") - protected float unitPrice; + @Column(name = "unit_price", precision = 10, scale = 2) + protected BigDecimal unitPrice=BigDecimal.ZERO; public TimesheetPositionTemplate() { } @@ -779,28 +780,28 @@ public void setDescription(String description) { /** * @return the taxRate */ - public float getTaxRate() { + public BigDecimal getTaxRate() { return taxRate; } /** * @param taxRate the taxRate to set */ - public void setTaxRate(float taxRate) { + public void setTaxRate(BigDecimal taxRate) { this.taxRate = taxRate; } /** * @return the unitPrice */ - public float getUnitPrice() { + public BigDecimal getUnitPrice() { return unitPrice; } /** * @param unitPrice the unitPrice to set */ - public void setUnitPrice(float unitPrice) { + public void setUnitPrice(BigDecimal unitPrice) { this.unitPrice = unitPrice; } diff --git a/j-lawyer-server-entities/src/java/db/migration/V3_0_0_3__FloatsToDecimal.sql b/j-lawyer-server-entities/src/java/db/migration/V3_0_0_3__FloatsToDecimal.sql new file mode 100644 index 000000000..acd50fca7 --- /dev/null +++ b/j-lawyer-server-entities/src/java/db/migration/V3_0_0_3__FloatsToDecimal.sql @@ -0,0 +1,32 @@ +ALTER TABLE case_account_entries MODIFY COLUMN in_escrow DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE case_account_entries MODIFY COLUMN out_escrow DECIMAL(10,2) DEFAULT 0.00 NOT NULL; + +ALTER TABLE case_account_entries MODIFY COLUMN in_earnings DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE case_account_entries MODIFY COLUMN out_spendings DECIMAL(10,2) DEFAULT 0.00 NOT NULL; + +ALTER TABLE case_account_entries MODIFY COLUMN in_expenditure DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE case_account_entries MODIFY COLUMN out_expenditure DECIMAL(10,2) DEFAULT 0.00 NOT NULL; + +ALTER TABLE invoices MODIFY COLUMN total DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE invoices MODIFY COLUMN total_gross DECIMAL(10,2) DEFAULT 0.00 NOT NULL; + +ALTER TABLE invoice_positions MODIFY COLUMN tax_rate DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE invoice_positions MODIFY COLUMN units DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE invoice_positions MODIFY COLUMN unit_price DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE invoice_positions MODIFY COLUMN total DECIMAL(10,2) DEFAULT 0.00 NOT NULL; + +ALTER TABLE invoice_position_tpls MODIFY COLUMN tax_rate DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE invoice_position_tpls MODIFY COLUMN units DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE invoice_position_tpls MODIFY COLUMN unit_price DECIMAL(10,2) DEFAULT 0.00 NOT NULL; + +ALTER TABLE timesheets MODIFY COLUMN limit_net DECIMAL(10,2) DEFAULT 0.00 NOT NULL; + +ALTER TABLE timesheet_positions MODIFY COLUMN tax_rate DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE timesheet_positions MODIFY COLUMN unit_price DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE timesheet_positions MODIFY COLUMN total DECIMAL(10,2) DEFAULT 0.00 NOT NULL; + +ALTER TABLE timesheet_position_tpls MODIFY COLUMN tax_rate DECIMAL(10,2) DEFAULT 0.00 NOT NULL; +ALTER TABLE timesheet_position_tpls MODIFY COLUMN unit_price DECIMAL(10,2) DEFAULT 0.00 NOT NULL; + +insert into server_settings(settingKey, settingValue) values('jlawyer.server.database.version','3.0.0.3') ON DUPLICATE KEY UPDATE settingValue = '3.0.0.3'; +commit; \ No newline at end of file diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java index 8ba91b456..ca1c256bb 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java @@ -688,6 +688,7 @@ import com.jdimension.jlawyer.server.utils.ServerStringUtils; import com.jdimension.jlawyer.server.utils.StringUtils; import java.io.*; +import java.math.BigDecimal; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -5043,8 +5044,8 @@ public Invoice addInvoice(String caseId, InvoicePool invoicePool, InvoiceType in i.setDescription(""); i.setSmallBusiness(pool.isSmallBusiness()); i.setInvoiceType(iType); - i.setTotal(0f); - i.setTotalGross(0f); + i.setTotal(BigDecimal.ZERO); + i.setTotalGross(BigDecimal.ZERO); i.setCurrency(currency); i.setLastPoolId(pool.getId()); i.setPaymentType(Invoice.PAYMENTTYPE_BANKTRANSFER); @@ -5131,11 +5132,11 @@ private void updateInvoiceTotal(String invoiceId) throws Exception { if (positions == null) { positions = new ArrayList<>(); } - float newTotalNet = 0f; - float newTotalGross = 0f; + BigDecimal newTotalNet = BigDecimal.ZERO; + BigDecimal newTotalGross = BigDecimal.ZERO; for (InvoicePosition p : positions) { - newTotalNet = newTotalNet + p.getTotal(); - newTotalGross = newTotalGross + (p.getTotal() * (1 + p.getTaxRate() / 100f)); + newTotalNet = newTotalNet.add(p.getTotal()); + newTotalGross = newTotalGross.add(p.getTotal().multiply((BigDecimal.ONE.add(p.getTaxRate().divide(BigDecimal.valueOf(100f)))))); } invoice.setTotal(newTotalNet); invoice.setTotalGross(newTotalGross); @@ -5674,15 +5675,15 @@ private float getTimesheetPercentageDone(Timesheet ts) { return 0f; // avoid div by zero - if(ts.getLimit()==0f) + if(ts.getLimit().equals(BigDecimal.ZERO)) return 0f; List positions=this.timesheetPositionsFacade.findByTimesheet(ts); - float currentTotal=0f; + BigDecimal currentTotal=BigDecimal.ZERO; for(TimesheetPosition p: positions) { - currentTotal=currentTotal+p.calculateTotal(ts.getInterval()); + currentTotal=currentTotal.add(p.calculateTotal(ts.getInterval())); } - return currentTotal / ts.getLimit() * 100f; + return currentTotal.divide(ts.getLimit()).multiply(BigDecimal.valueOf(100f)).floatValue(); } @@ -6020,7 +6021,7 @@ public TimesheetPosition timesheetPositionStart(String timesheetId, TimesheetPos newPos.setTaxRate(position.getTaxRate()); newPos.setTimesheet(sheet); newPos.setUnitPrice(position.getUnitPrice()); - newPos.setTotal(0f); + newPos.setTotal(BigDecimal.ZERO); newPos.setId(id); this.timesheetPositionsFacade.create(newPos); return this.timesheetPositionsFacade.find(id); diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/InvoiceService.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/InvoiceService.java index b0430f1c0..f6d83f6ab 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/InvoiceService.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/InvoiceService.java @@ -690,6 +690,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.server.utils.InvoiceNumberGenerator; import com.jdimension.jlawyer.server.utils.ServerStringUtils; import java.io.ByteArrayOutputStream; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.NumberFormat; @@ -1051,7 +1052,7 @@ private void publishOutgoingMailRequest(OutgoingMailRequest req) { @Override @RolesAllowed({"loginRole"}) - public byte[] getGiroCode(String senderPrincipalId, float amount, String purpose) throws Exception { + public byte[] getGiroCode(String senderPrincipalId, BigDecimal amount, String purpose) throws Exception { if(senderPrincipalId==null) throw new Exception("Girocode kann nicht erstellt werden - kein Absender angegeben"); diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/InvoiceServiceLocal.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/InvoiceServiceLocal.java index 2d57dc6e3..55fa3de7d 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/InvoiceServiceLocal.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/InvoiceServiceLocal.java @@ -664,6 +664,7 @@ You should also get your employer (if you work as a programmer) or school, package com.jdimension.jlawyer.services; import com.jdimension.jlawyer.persistence.InvoicePool; +import java.math.BigDecimal; import java.util.List; import javax.ejb.Local; @@ -680,6 +681,6 @@ public interface InvoiceServiceLocal { void checkInvoicesDue(); - byte[] getGiroCode(String senderPrincipalId, float amount, String purpose) throws Exception; + byte[] getGiroCode(String senderPrincipalId, BigDecimal amount, String purpose) throws Exception; }