Skip to content

Commit

Permalink
updated floats to bigdecimal. #2681
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Nov 22, 2024
1 parent fe6d438 commit d1498e4
Show file tree
Hide file tree
Showing 34 changed files with 343 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()});
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtName" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="lblError" pref="5" max="32767" attributes="0"/>
<Component id="lblError" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="258" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane2" max="32767" attributes="0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()});
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1112,7 +1113,7 @@ public void setAddressDTO(AddressBean dto) {
}

this.invoicesPerCase.clear();
HashMap<Integer, Float> cumulatedInvoiceValues = this.getCumulatedInvoicesValue(invoices);
HashMap<Integer, BigDecimal> cumulatedInvoiceValues = this.getCumulatedInvoicesValue(invoices);
for (Invoice inv : invoices) {
if (!this.invoicesPerCase.containsKey(inv.getArchiveFileKey().getId())) {
this.invoicesPerCase.put(inv.getArchiveFileKey().getId(), new ArrayList<>());
Expand All @@ -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);
Expand Down Expand Up @@ -1167,20 +1168,20 @@ public void setAddressDTO(AddressBean dto) {
this.pnlInvoicesChart.add(xchartPanel, BorderLayout.CENTER);
}

private HashMap<Integer, Float> getCumulatedInvoicesValue(List<Invoice> invoices) {
HashMap<Integer, Float> 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<Integer, BigDecimal> getCumulatedInvoicesValue(List<Invoice> invoices) {
HashMap<Integer, BigDecimal> 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);
}
}
Expand Down Expand Up @@ -3688,7 +3689,7 @@ private void fillCasesForContactPanel(Collection<ArchiveFileAddressesBean> allCa
lce.setOwnReference(aFile.getReference());

if (this.invoicesPerCase.containsKey(aFile.getArchiveFileKey().getId())) {
HashMap<Integer, Float> invoicesForCase = this.getCumulatedInvoicesValue(this.invoicesPerCase.get(aFile.getArchiveFileKey().getId()));
HashMap<Integer, BigDecimal> invoicesForCase = this.getCumulatedInvoicesValue(this.invoicesPerCase.get(aFile.getArchiveFileKey().getId()));
lce.setInvoicesByStatus(invoicesForCase);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -680,7 +681,7 @@ public class CaseForContactEntry {
private String reason=null;
private String role=null;
private boolean archived=false;
protected HashMap<Integer, Float> invoicesByStatus=null;
protected HashMap<Integer, BigDecimal> invoicesByStatus=null;
private Color roleForeground=DefaultColorTheme.COLOR_LOGO_BLUE;


Expand Down Expand Up @@ -803,14 +804,14 @@ public void setOwnReference(String ownReference) {
/**
* @return the invoicesByStatus
*/
public HashMap<Integer, Float> getInvoicesByStatus() {
public HashMap<Integer, BigDecimal> getInvoicesByStatus() {
return invoicesByStatus;
}

/**
* @param invoicesByStatus the invoicesByStatus to set
*/
public void setInvoicesByStatus(HashMap<Integer, Float> invoicesByStatus) {
public void setInvoicesByStatus(HashMap<Integer, BigDecimal> invoicesByStatus) {
this.invoicesByStatus = invoicesByStatus;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -742,11 +743,11 @@ public void setEntry(CaseForContactEntry entry) {
this.lblArchived.setText("");
}

HashMap<Integer,Float> invoices=e.getInvoicesByStatus();
HashMap<Integer,BigDecimal> 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("<html><b>Umsatzrelevante Werte gesamt: ").append(df.format(total)).append("</b><br/>");
sb.append("<table><tr><td>neu:</td><td>").append(df.format(invoices.get(Invoice.STATUS_NEW))).append("</td></tr>");
Expand All @@ -758,7 +759,7 @@ public void setEntry(CaseForContactEntry entry) {
sb.append("<tr><td>bezahlt:</td><td>").append(df.format(invoices.get(Invoice.STATUS_PAID))).append("</td></tr>");
sb.append("<tr><td>storniert:</td><td>").append(df.format(invoices.get(Invoice.STATUS_CANCELLED))).append("</td></tr></table></html>");
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit d1498e4

Please sign in to comment.