Skip to content

Commit

Permalink
finished first iteration for Aktenkonto. close #1955
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Dec 20, 2023
1 parent dfd44ef commit 62c4ce1
Show file tree
Hide file tree
Showing 9 changed files with 323 additions and 76 deletions.
Binary file modified j-lawyer-client/lib/j-lawyer-cloud/j-lawyer-cloud.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4218,10 +4218,27 @@ private void loadAccountEntries() {
ClientSettings settings = ClientSettings.getInstance();
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
ArchiveFileServiceRemote fileService = locator.lookupArchiveFileServiceRemote();
HashMap<String,Float> invoiceTotals=new HashMap<>();
List<CaseAccountEntry> accountEntries = fileService.getAccountEntries(this.dto.getId());
for (CaseAccountEntry cae : accountEntries) {
this.addAccountEntry(cae);
if(cae.getInvoice()!=null) {
if(!invoiceTotals.containsKey(cae.getInvoice().getId()))
invoiceTotals.put(cae.getInvoice().getId(), 0f);
invoiceTotals.put(cae.getInvoice().getId(), invoiceTotals.get(cae.getInvoice().getId())+cae.calculateTotal());
}
}
ComponentUtils.autoSizeColumns(tblAccountEntries);


for (int i = 0; i < this.pnlInvoices.getComponentCount(); i++) {
InvoiceEntryPanel ie = (InvoiceEntryPanel) this.pnlInvoices.getComponent(i);
Invoice inv = ie.getInvoice();
if(invoiceTotals.containsKey(inv.getId()))
ie.setPaidTotal(invoiceTotals.get(inv.getId()));
}


} catch (Exception ex) {
log.error("Error loading account entries", ex);
JOptionPane.showMessageDialog(this, "Fehler beim Laden des Aktenkontos: " + ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,9 +1015,23 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane4" pref="858" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane4" alignment="0" pref="849" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel14" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel13" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblPaymentsTotal" min="-2" max="-2" attributes="0"/>
<Component id="lblInvoiceTotal2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
Expand All @@ -1026,7 +1040,17 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane4" pref="589" max="32767" attributes="0"/>
<Component id="jScrollPane4" pref="537" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblInvoiceTotal2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblPaymentsTotal" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
Expand All @@ -1040,20 +1064,40 @@

<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="jTable1">
<Component class="javax.swing.JTable" name="tblPayments">
<Properties>
<Property name="autoCreateRowSorter" type="boolean" value="true"/>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="4" rowCount="4">
<Column editable="true" title="Title 1" type="java.lang.Object"/>
<Column editable="true" title="Title 2" type="java.lang.Object"/>
<Column editable="true" title="Title 3" type="java.lang.Object"/>
<Column editable="true" title="Title 4" type="java.lang.Object"/>
<Table columnCount="3" rowCount="4">
<Column editable="false" title="Datum" type="java.lang.Object"/>
<Column editable="false" title="Betrag" type="java.lang.Float"/>
<Column editable="false" title="Kommentar" type="java.lang.String"/>
</Table>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="text" type="java.lang.String" value="Zahlungseingang:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel14">
<Properties>
<Property name="text" type="java.lang.String" value="Rechnungssumme:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblInvoiceTotal2">
<Properties>
<Property name="text" type="java.lang.String" value=" "/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblPaymentsTotal">
<Properties>
<Property name="text" type="java.lang.String" value=" "/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,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.client.utils.FrameUtils;
import com.jdimension.jlawyer.client.utils.StringUtils;
import com.jdimension.jlawyer.client.utils.TableUtils;
import com.jdimension.jlawyer.persistence.AddressBean;
import com.jdimension.jlawyer.persistence.AppOptionGroupBean;
import com.jdimension.jlawyer.persistence.ArchiveFileBean;
Expand All @@ -700,15 +701,22 @@ You should also get your employer (if you work as a programmer) or school,
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import javax.swing.BoxLayout;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import static javax.swing.SwingConstants.RIGHT;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;
import org.apache.log4j.Logger;
import org.jlawyer.plugins.calculation.Cell;
import org.jlawyer.plugins.calculation.StyledCalculationTable;
Expand All @@ -724,7 +732,8 @@ public class InvoiceDialog extends javax.swing.JDialog implements EventConsumer

private static final Logger log = Logger.getLogger(InvoiceDialog.class.getName());
private final SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
private static final DecimalFormat cf = new DecimalFormat("0.00");
private final DecimalFormat cf = new DecimalFormat("0.00");
private final DecimalFormat accountEntryFormat = new DecimalFormat("#,##0.00");

private Invoice currentEntry = null;
private ArchiveFileBean caseDto = null;
Expand Down Expand Up @@ -888,6 +897,45 @@ public InvoiceDialog(ArchiveFilePanel caseView, ArchiveFileBean caseDto, java.aw
JOptionPane.showMessageDialog(this, "Fehler beim Laden der Positionsvorlagen: " + ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
}

this.tblPayments.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof Date) {
((JLabel) c).setText(df.format(value));
((JLabel) c).setHorizontalAlignment(RIGHT);
}
return c;
}

});

this.tblPayments.setDefaultRenderer(Float.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof Float) {
((JLabel) c).setText(accountEntryFormat.format((Float) value));
((JLabel) c).setHorizontalAlignment(RIGHT);
if(((float)value)<0) {
if(!isSelected)
((JLabel) c).setForeground(DefaultColorTheme.COLOR_LOGO_RED);

} else {
if(!isSelected)
((JLabel) c).setForeground(DefaultColorTheme.COLOR_LOGO_BLUE);
}
}
return c;
}

});

DateTimeStringComparator dtComparator = new DateTimeStringComparator("dd.MM.yyyy");
TableRowSorter htrs = new TableRowSorter(this.tblPayments.getModel());
htrs.setComparator(0, dtComparator);
this.tblPayments.setRowSorter(htrs);

this.setEntry(null);

this.textSearchPositionTemplateKeyReleased(null);
Expand Down Expand Up @@ -1006,18 +1054,15 @@ public final void setEntry(Invoice invoice) {
try {
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
List<CaseAccountEntry> payments = locator.lookupArchiveFileServiceRemote().getAccountEntriesForInvoice(invoice.getId());
TableUtils.clearModel(tblPayments);
float paymentsTotal=0f;
for (CaseAccountEntry ae : payments) {
// InvoicePositionEntryPanel posPanel = new InvoicePositionEntryPanel(this, this.taxRates);
//
// this.pnlInvoicePositions.add(posPanel);
// this.pnlInvoicePositions.doLayout();
// this.bumpSplitPane();
//
// posPanel.setEntry(this.currentEntry.getId(), pos);
// posPanel.updateEntryTotal();

float aeTotal=ae.calculateTotal();
paymentsTotal+=aeTotal;
((DefaultTableModel)this.tblPayments.getModel()).addRow(new Object[]{ae.getEntryDate(), aeTotal, ae.getDescription()});
}

this.lblPaymentsTotal.setText(cf.format(paymentsTotal));
ComponentUtils.autoSizeColumns(tblPayments);
} catch (Exception ex) {
log.error("Error determining invoice positions", ex);
JOptionPane.showMessageDialog(this, "Fehler beim Laden der Rechnungspositionen: " + ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
Expand Down Expand Up @@ -1107,7 +1152,11 @@ private void initComponents() {
pnlInvoicePositions = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
jScrollPane4 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
tblPayments = new javax.swing.JTable();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
lblInvoiceTotal2 = new javax.swing.JLabel();
lblPaymentsTotal = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
addComponentListener(new java.awt.event.ComponentAdapter() {
Expand Down Expand Up @@ -1625,33 +1674,75 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

jTabbedPane1.addTab("Positionen", splitMain);

jTable1.setModel(new javax.swing.table.DefaultTableModel(
tblPayments.setAutoCreateRowSorter(true);
tblPayments.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
"Datum", "Betrag", "Kommentar"
}
));
jScrollPane4.setViewportView(jTable1);
) {
Class[] types = new Class [] {
java.lang.Object.class, java.lang.Float.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false, false
};

public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}

public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jScrollPane4.setViewportView(tblPayments);

jLabel13.setText("Zahlungseingang:");

jLabel14.setText("Rechnungssumme:");

lblInvoiceTotal2.setText(" ");

lblPaymentsTotal.setText(" ");

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 858, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 849, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel14)
.addComponent(jLabel13))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblPaymentsTotal)
.addComponent(lblInvoiceTotal2))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE)
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(lblInvoiceTotal2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(lblPaymentsTotal))
.addContainerGap())
);

Expand Down Expand Up @@ -2057,6 +2148,7 @@ public void updateTotals(InvoicePositionEntryPanel ep) {
this.lblNetValue.setText(cf.format(totalNet));
this.lblInvoiceTax.setText(cf.format(totalTax));
this.lblInvoiceTotal.setText(cf.format(total));
this.lblInvoiceTotal2.setText(cf.format(total));
if(this.currentEntry!=null) {
this.currentEntry.setTotal(total);

Expand Down Expand Up @@ -2339,6 +2431,8 @@ public void windowClosing(java.awt.event.WindowEvent e) {
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
Expand All @@ -2356,20 +2450,22 @@ public void windowClosing(java.awt.event.WindowEvent e) {
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTable jTable1;
private javax.swing.JPanel lblHeader;
private javax.swing.JLabel lblInvoiceDocument;
private javax.swing.JLabel lblInvoiceNumber;
private javax.swing.JLabel lblInvoiceTax;
private javax.swing.JLabel lblInvoiceTotal;
private javax.swing.JLabel lblInvoiceTotal2;
private javax.swing.JLabel lblNetValue;
private javax.swing.JLabel lblPaymentsTotal;
private javax.swing.JLabel lblRecipient;
private javax.swing.JList<String> lstPositionTemplates;
private javax.swing.JPanel pnlInvoicePositions;
private javax.swing.JPopupMenu popCalculations;
private javax.swing.JPopupMenu popRecipients;
private javax.swing.JSplitPane splitMain;
private javax.swing.JTextArea taDescription;
private javax.swing.JTable tblPayments;
private javax.swing.JTextField textSearchPositionTemplate;
private javax.swing.JTextField txtName;
// End of variables declaration//GEN-END:variables
Expand Down
Loading

0 comments on commit 62c4ce1

Please sign in to comment.