Subversion Repository Public Repository

TransPort_Tracking

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.transtracking.views;

import com.bestray.transtracking.controller.BalanceSheetController;
import com.bestray.transtracking.controller.ClientCollectionController;
import com.bestray.transtracking.controller.JobEntryController;
import com.bestray.transtracking.controller.PaymentVoucherController;
import com.bestray.transtracking.controller.ReceiptVoucherController;
import com.bestray.transtracking.dto.ClientCollectionSearchDTO;
import com.bestray.transtracking.dto.JobEntrySearchDTO;
import com.bestray.transtracking.dto.PaymentVoucherSearchDTO;
import com.bestray.transtracking.dto.VehicleExpenseSearchDTO;
import com.bestray.transtracking.reports.ClientBalanceSheetReport;
import com.bestray.transtracking.reports.PartyBalanceSheetReport;
import com.bestray.trastrack.domain.ClientUser;
import com.bestray.trastrack.domain.JobEntryDetails;
import com.bestray.trastrack.domain.Party;
import com.bestray.trastrack.domain.VehicleExpenseByParty;
import com.bestray.trastrack.domain.PaymentDetailsByParty;
import com.bestray.trastrack.domain.ClientCollectionDetails;
import java.awt.Color;
import java.awt.Component;
import java.util.Date;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;

/**
 *
 * @author Bitu
 */
public class BalanceSheet extends javax.swing.JPanel {

    /**
     * Creates new form BalanceSheet
     */
    public BalanceSheet() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        namelb = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        fromDate = new org.jdesktop.swingx.JXDatePicker();
        toDate = new org.jdesktop.swingx.JXDatePicker();
        namecombo = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        serviceAmtTb = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        totPaymenttb = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        totBalancetb = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        slectionTypeBox = new javax.swing.JComboBox();
        jScrollPane3 = new javax.swing.JScrollPane();
        servicetable = new javax.swing.JTable(){
            public boolean isCellEditable(int row, int column){
                return false;
            }
            public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
                Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
                if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
                    c.setForeground(Color.BLACK);
                    c.setBackground(new Color(200, 225, 250));
                }
                else if(rowIndex % 2 == 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else if(rowIndex % 2 != 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else {
                    c.setForeground(Color.BLACK);
                    c.setBackground(getBackground());
                }
                return c;
            }
        };
        jScrollPane4 = new javax.swing.JScrollPane();
        clientcollectiontable = new javax.swing.JTable(){
            public boolean isCellEditable(int row, int column){
                return false;
            }
            public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
                Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
                if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
                    c.setForeground(Color.BLACK);
                    c.setBackground(new Color(200, 225, 250));
                }
                else if(rowIndex % 2 == 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else if(rowIndex % 2 != 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else {
                    c.setForeground(Color.BLACK);
                    c.setBackground(getBackground());
                }
                return c;
            }
        };
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        searchButton = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(200, 225, 250));
        setOpaque(false);
        setPreferredSize(new java.awt.Dimension(1037, 441));

        jPanel1.setBackground(new java.awt.Color(200, 225, 250));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setOpaque(false);
        jPanel1.setPreferredSize(new java.awt.Dimension(1037, 383));

        namelb.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        namelb.setText("Name :");

        jLabel3.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel3.setText("Date From :");

        jLabel4.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel4.setText("Date To :");

        fromDate.setFormats(new String[] { "dd/MM/yyyy" });
        fromDate.setDate(new Date());

        toDate.setFormats(new String[] { "dd/MM/yyyy" });
        toDate.setDate(new Date());

        namecombo.setModel(new javax.swing.DefaultComboBoxModel());
        AutoCompleteDecorator.decorate(this.namecombo);
        namecombo.setSelectedIndex(-1);

        jLabel1.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel1.setText("Total  Service Amount (INR) :");

        serviceAmtTb.setEditable(false);

        jLabel5.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel5.setText("Total Paid Amount (INR):");

        totPaymenttb.setEditable(false);

        jLabel6.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel6.setText("Balance :");

        totBalancetb.setEditable(false);

        jLabel7.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel7.setText("Select Client / Party  :");

        slectionTypeBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { selectionType.CLIENT.getDescription(), selectionType.PARTY.getDescription()}));
        slectionTypeBox.setSelectedIndex(-1);
        slectionTypeBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                slectionTypeBoxItemStateChanged(evt);
            }
        });

        servicetable.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        servicetable.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, null, null}
            },
            new String [] {
                "Service Date", "Service Type", "Service Amount"
            }
        ));
        servicetable.setRowHeight(20);
        jScrollPane3.setViewportView(servicetable);

        clientcollectiontable.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        clientcollectiontable.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}
            },
            new String [] {
                "Paid Date", "Paid Amount"
            }
        ));
        clientcollectiontable.setRowHeight(20);
        jScrollPane4.setViewportView(clientcollectiontable);
        clientcollectiontable.getColumnModel().getColumn(0).setPreferredWidth(3);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(204, 0, 0));
        jLabel8.setText("*");

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(204, 0, 0));
        jLabel9.setText("*");

        searchButton.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        searchButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search.png"))); // NOI18N
        searchButton.setText("Search");
        searchButton.setOpaque(false);
        searchButton.setPreferredSize(new java.awt.Dimension(85, 25));
        searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchButtonActionPerformed(evt);
            }
        });

        jButton1.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pdf-icon.png"))); // NOI18N
        jButton1.setText("Export to PDF");
        jButton1.setOpaque(false);
        jButton1.setPreferredSize(new java.awt.Dimension(85, 25));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Excel-icon.png"))); // NOI18N
        jButton2.setText("Export to EXCEL");
        jButton2.setOpaque(false);
        jButton2.setPreferredSize(new java.awt.Dimension(85, 25));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(433, 433, 433)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(totBalancetb, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 462, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(311, 311, 311)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel9))
                                .addGap(2, 2, 2)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(namelb, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(namecombo, 0, 278, Short.MAX_VALUE)
                                    .addComponent(slectionTypeBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(309, 309, 309)
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(fromDate, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(toDate, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(203, 203, 203)
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(serviceAmtTb, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(totPaymenttb, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {serviceAmtTb, totPaymenttb});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(slectionTypeBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(namelb)
                    .addComponent(namecombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(fromDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(toDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(serviceAmtTb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(totPaymenttb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(totBalancetb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jScrollPane3, jScrollPane4});

        jLabel14.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 14)); // NOI18N
        jLabel14.setText("Client / Party Balance Sheet");

        jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Truck2.png"))); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 1017, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addGap(2, 2, 2)
                        .addComponent(jLabel14)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel14)
                    .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 386, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void slectionTypeBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_slectionTypeBoxItemStateChanged
        if(slectionTypeBox.getSelectedItem()!=null){
            
            String selectedValue = (String)slectionTypeBox.getSelectedItem();
            if(selectedValue.equals(selectionType.CLIENT.getDescription())){
                namelb.setText("Client Name :");
                populateClientNames();
                namecombo.setModel(new javax.swing.DefaultComboBoxModel(clientList));
                namecombo.setSelectedIndex(-1);
            }else if(selectedValue.equals(selectionType.PARTY.getDescription())){
                namelb.setText("Party Name :");
                populatePartyNames();
                namecombo.setModel(new javax.swing.DefaultComboBoxModel(partylist));
                namecombo.setSelectedIndex(-1);
            }
           //System.out.println("Selected Value "+selectedValue);
            
        }
    }//GEN-LAST:event_slectionTypeBoxItemStateChanged

    private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed
        // TODO add your handling code here:
       // doSearch();
       try{
        if(!slectionTypeBox.getSelectedItem().toString().equalsIgnoreCase("Party")){
            JobEntrySearchDTO search = new JobEntrySearchDTO();
            ClientCollectionSearchDTO search2 = new ClientCollectionSearchDTO();
            try{
            ClientUser client = (ClientUser)namecombo.getSelectedItem();
            search.setClientId(client.getId());
            search2.setClientname(client.getId());
            search.setSearchFrom(fromDate.getDate());
            search2.setSearchFrom(fromDate.getDate());
            search.setSearchTo(toDate.getDate());
            search2.setSearchTo(toDate.getDate());
            search(search);
            searchcollection(search2);
            }catch(Exception e){
                JOptionPane.showMessageDialog(null, "Select Client Name");
                namecombo.requestFocus();
            }
            
        }else{
            VehicleExpenseSearchDTO expensesearch = new VehicleExpenseSearchDTO();
            PaymentVoucherSearchDTO paymentsearch = new PaymentVoucherSearchDTO();
            try{
            Party partyname = (Party)namecombo.getSelectedItem();
            expensesearch.setPartyId(partyname.getId());
            paymentsearch.setPartyname(partyname.getId());
            expensesearch.setSearchFrom(fromDate.getDate());
            paymentsearch.setSearchFrom(fromDate.getDate());
            expensesearch.setSearchTo(toDate.getDate());
            paymentsearch.setSearchTo(toDate.getDate());
            searchExp(expensesearch);
            searchPay(paymentsearch);
            }catch(Exception e){
                JOptionPane.showMessageDialog(null, "Select Party Name");
                namecombo.requestFocus();
            }
            
            //System.out.println("Dont do anything...");
        }
        }catch(Exception e){
           JOptionPane.showMessageDialog(null, "Select Search Type");
            slectionTypeBox.requestFocus();
       }
        

    }//GEN-LAST:event_searchButtonActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        int reply = JOptionPane.showConfirmDialog(null, "Do you want to download the Report ?", "Balance Sheet Report", JOptionPane.YES_NO_OPTION);  
        if (reply == JOptionPane.YES_OPTION){  
        try{
            if(slectionTypeBox.getSelectedItem()==null){
                JOptionPane.showMessageDialog(null, "You have not choosed client or party ");
            }
            else if(slectionTypeBox.getSelectedItem().toString().equalsIgnoreCase("Client")){
                if(namecombo.getSelectedItem()==null){
                    JOptionPane.showMessageDialog(null, "You have not choosed Client Name ");
                }
                else{
                    
                    populateTablesForClient();
                    
                    ClientBalanceSheetReport clientBalanceSheetReport=new ClientBalanceSheetReport();
                    String clientName = namecombo.getSelectedItem().toString();
                    from=fromDate.getDate();
                    to=toDate.getDate();
                    clientBalanceSheetReport.getPdfReport(clientName,from,to,totBalancetb.getText());
                    reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Client Collection Report", JOptionPane.YES_NO_OPTION);  
                    if (reply == JOptionPane.YES_OPTION){  
                        clientBalanceSheetReport.openPdfReport();
                    } 
                }
            }
            else if(slectionTypeBox.getSelectedItem().toString().equalsIgnoreCase("Party")){
                if(namecombo.getSelectedItem()==null){
                    JOptionPane.showMessageDialog(null, "You have not choosed Party Name ");
                }
                else{
                    
                    populateTablesForParty();
                    
                    PartyBalanceSheetReport partyBalanceSheetReport=new PartyBalanceSheetReport();
                    String partyName = namecombo.getSelectedItem().toString();
                    from=fromDate.getDate();
                    to=toDate.getDate();
                    partyBalanceSheetReport.getPdfReport(partyName,from,to,totBalancetb.getText());
                    reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Client Collection Report", JOptionPane.YES_NO_OPTION);  
                    if (reply == JOptionPane.YES_OPTION)  
                    {  
                        partyBalanceSheetReport.openPdfReport();
                    } 
                }
            }
        }
        catch(Exception e){
            String error=e.getMessage();
            JOptionPane.showMessageDialog(null, error+"\n So, Document can't be Generated");
        }
        }//outer if
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        int reply = JOptionPane.showConfirmDialog(null, "Do you want to download the Report ?", "Balance Sheet Report", JOptionPane.YES_NO_OPTION);  
        if (reply == JOptionPane.YES_OPTION){  
        try{
            if(slectionTypeBox.getSelectedItem()==null){
                JOptionPane.showMessageDialog(null, "You have not choosed client or party ");
            }
            else if(slectionTypeBox.getSelectedItem().toString().equalsIgnoreCase("Client")){
                if(namecombo.getSelectedItem()==null){
                    JOptionPane.showMessageDialog(null, "You have not choosed Client Name ");
                }
                else{
                    
                    populateTablesForClient();
                    
                    ClientBalanceSheetReport clientBalanceSheetReport=new ClientBalanceSheetReport();
                    String clientName = namecombo.getSelectedItem().toString();
                    from=fromDate.getDate();
                    to=toDate.getDate();
                    clientBalanceSheetReport.getXlsReport(clientName,from,to,totBalancetb.getText());
                    reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Client Collection Report", JOptionPane.YES_NO_OPTION);  
                    if (reply == JOptionPane.YES_OPTION)  
                    {  
                        clientBalanceSheetReport.openXlsReport();
                    } 
                }
            }
            else if(slectionTypeBox.getSelectedItem().toString().equalsIgnoreCase("Party")){
                if(namecombo.getSelectedItem()==null){
                    JOptionPane.showMessageDialog(null, "You have not choosed Party Name ");
                }
                else{
                    
                    populateTablesForParty();
                    
                    PartyBalanceSheetReport partyBalanceSheetReport=new PartyBalanceSheetReport();
                    String partyName = namecombo.getSelectedItem().toString();
                    from=fromDate.getDate();
                    to=toDate.getDate();
                    partyBalanceSheetReport.getXlsReport(partyName,from,to,totBalancetb.getText());
                    reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Client Collection Report", JOptionPane.YES_NO_OPTION);  
                    if (reply == JOptionPane.YES_OPTION)  
                    {  
                        partyBalanceSheetReport.openXlsReport();
                    } 
                }
            }
        }
        catch(Exception e){
            String error=e.getMessage();
            JOptionPane.showMessageDialog(null, error+"\n So, Document can't be Generated");
        }
        }//outer if
    }//GEN-LAST:event_jButton2ActionPerformed
    private Date from,to;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable clientcollectiontable;
    private org.jdesktop.swingx.JXDatePicker fromDate;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JComboBox namecombo;
    private javax.swing.JLabel namelb;
    private javax.swing.JButton searchButton;
    private javax.swing.JTextField serviceAmtTb;
    private javax.swing.JTable servicetable;
    private javax.swing.JComboBox slectionTypeBox;
    private org.jdesktop.swingx.JXDatePicker toDate;
    private javax.swing.JTextField totBalancetb;
    private javax.swing.JTextField totPaymenttb;
    // End of variables declaration//GEN-END:variables
    ClientCollectionController clientcontroller;
    ReceiptVoucherController partycontroller;
    BalanceSheetController balancecontroller;
    PaymentVoucherController paymentvouchercontroller;
    private JobEntryController jobcontroller;
    private Vector<ClientUser> clientList = new Vector<ClientUser>();
    private Vector<Party> partylist = new Vector<Party>();
    private Vector<Vector<String>> serviceData = new Vector<Vector<String>>();
    private Vector<Vector<String>> jobentryData = new Vector<Vector<String>>();
    private Vector<Vector<String>> expenseentryData = new Vector<Vector<String>>();
    private Vector<Vector<String>> paymententryData = new Vector<Vector<String>>();
    private Vector<Vector<String>> clientCollectionData = new Vector<Vector<String>>();
    Vector header = new Vector<String>();
    Vector collectionheader = new Vector<String>();
    TableRowSorter<TableModel> sorter;
    TableRowSorter<TableModel> sorter2;
    /*private void doSearch() {
        //try{
        if(!slectionTypeBox.getSelectedItem().toString().equalsIgnoreCase("Party")){
            JobEntrySearchDTO search = new JobEntrySearchDTO();
            ClientUser client = (ClientUser)namecombo.getSelectedItem();
            search.setVehicleId(client.getId());
            search.setSearchFrom(fromDate.getDate());
            search.setSearchTo(toDate.getDate());
            search(search);
        //}
       // }catch(Exception e){
           JOptionPane.showMessageDialog(null, "No Records..."); 
       // }
        }
    }*/

    private void populateClientNames() {
        //clientcontroller = new ClientCollectionController();
        jobcontroller = new JobEntryController();
        clientList=jobcontroller.getClientSearchList();        
    }

    private void populatePartyNames() {
        //partycontroller = new ReceiptVoucherController();
        paymentvouchercontroller = new PaymentVoucherController();
        partylist = paymentvouchercontroller.getAllPartyNameList();
    }
    
    private void search(JobEntrySearchDTO search) {
        balancecontroller=new BalanceSheetController();
        JobEntryDetails jobDetail =  balancecontroller.getSearchResults(search);
        if(jobDetail != null){
        jobentryData = jobDetail.getReturnList();
        serviceAmtTb.setText(jobDetail.getTotalAmount().toString());
        }
        servicetable.setModel(new javax.swing.table.DefaultTableModel(jobentryData, header()));
        servicetable.getColumnModel().getColumn(0).setPreferredWidth(70);
        servicetable.getColumnModel().getColumn(0).setMaxWidth(70);
        servicetable.getColumnModel().getColumn(3).setPreferredWidth(70);
        servicetable.getColumnModel().getColumn(3).setMaxWidth(70);
        sorter = new TableRowSorter<TableModel>();
        sorter = new TableRowSorter<TableModel>(servicetable.getModel());
        servicetable.setRowSorter(sorter);
        
    }
    private Vector<String> header(){
        header = new Vector<String>();
        header.add("Date");
        header.add("Vehicle Number");
        header.add("From - To Location");
        header.add("Quantity");
        header.add("Amount");
        return header;
    }
    private Vector<String> collection_header(){
        collectionheader = new Vector<String>();
        collectionheader.add("Paid Date");
        collectionheader.add("Paid Amount");
        collectionheader.add("Remarks");
        return collectionheader;
    }

    private void searchcollection(ClientCollectionSearchDTO search2) {
        balancecontroller=new BalanceSheetController();
        ClientCollectionDetails collectionDetails = balancecontroller.getCollectionSearchResults(search2);
        clientCollectionData=collectionDetails.getReturnList();
        totPaymenttb.setText(String.valueOf(collectionDetails.getTotalAmount()));
        Double totBalance = Double.parseDouble(serviceAmtTb.getText()) - Double.parseDouble(totPaymenttb.getText());
        totBalancetb.setText(String.valueOf(totBalance));
        clientcollectiontable.setModel(new javax.swing.table.DefaultTableModel(clientCollectionData, collection_header()));
        clientcollectiontable.getColumnModel().getColumn(0).setPreferredWidth(90);
        clientcollectiontable.getColumnModel().getColumn(0).setMaxWidth(90);
        clientcollectiontable.getColumnModel().getColumn(0).setPreferredWidth(100);
        clientcollectiontable.getColumnModel().getColumn(0).setMaxWidth(100);
        sorter2 = new TableRowSorter<TableModel>();
        sorter2 = new TableRowSorter<TableModel>(clientcollectiontable.getModel());
        clientcollectiontable.setRowSorter(sorter2);
    }

    private void searchExp(VehicleExpenseSearchDTO expensesearch) {
        balancecontroller=new BalanceSheetController();
        VehicleExpenseByParty VehExpense = balancecontroller.getExpenseSearchResults(expensesearch);
        expenseentryData = VehExpense.getReturnList();
        serviceAmtTb.setText(String.valueOf(VehExpense.getTotalExpenseAmount())); 
       servicetable.setModel(new javax.swing.table.DefaultTableModel(expenseentryData, expense_header()));
        sorter = new TableRowSorter<TableModel>();
        sorter = new TableRowSorter<TableModel>(servicetable.getModel());
        servicetable.setRowSorter(sorter);
        
    }
    private Vector<String> expense_header(){
        header = new Vector<String>();
        header.add("Service Date");
        header.add("Service Type");
        header.add("Service Amount");
        return header;
    }

    private void searchPay(PaymentVoucherSearchDTO paymentsearch) {
        balancecontroller=new BalanceSheetController();
       PaymentDetailsByParty  paymentDetails = balancecontroller.getPaymentSearchResults(paymentsearch);
        paymententryData = paymentDetails.getReturnList();
        totPaymenttb.setText(String.valueOf(paymentDetails.getTotalAmount()));
        Double totBalance = Double.parseDouble(serviceAmtTb.getText()) - Double.parseDouble(totPaymenttb.getText());
        totBalancetb.setText(String.valueOf(totBalance));
        clientcollectiontable.setModel(new javax.swing.table.DefaultTableModel(paymententryData, collection_header()));
        sorter = new TableRowSorter<TableModel>();
        sorter = new TableRowSorter<TableModel>(clientcollectiontable.getModel());
        clientcollectiontable.setRowSorter(sorter);
    }

    private void populateTablesForClient() {
        JobEntrySearchDTO search = new JobEntrySearchDTO();
        ClientCollectionSearchDTO search2 = new ClientCollectionSearchDTO();
        ClientUser client = (ClientUser)namecombo.getSelectedItem();
        search.setClientId(client.getId());
        search2.setClientname(client.getId());
        search.setSearchFrom(fromDate.getDate());
        search2.setSearchFrom(fromDate.getDate());
        search.setSearchTo(toDate.getDate());
        search2.setSearchTo(toDate.getDate());
        search(search);
        searchcollection(search2);
    }

    private void populateTablesForParty() {
        VehicleExpenseSearchDTO expensesearch = new VehicleExpenseSearchDTO();
        PaymentVoucherSearchDTO paymentsearch = new PaymentVoucherSearchDTO();
        Party partyname = (Party)namecombo.getSelectedItem();
        expensesearch.setPartyId(partyname.getId());
        paymentsearch.setPartyname(partyname.getId());
        expensesearch.setSearchFrom(fromDate.getDate());
        paymentsearch.setSearchFrom(fromDate.getDate());
        expensesearch.setSearchTo(toDate.getDate());
        paymentsearch.setSearchTo(toDate.getDate());
        searchExp(expensesearch);
        searchPay(paymentsearch);
    }

    
enum selectionType{
    CLIENT("Client"),
    PARTY("Party");
    private String description;
   private selectionType(String description) {
            this.description = description;
        }
    public String getDescription() {
            return description;
        }
}
}

Commits for TransPort_Tracking/TransPortTracking/src/main/java/com/bestray/transtracking/views/BalanceSheet.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Sat 28 Jul, 2018 05:29:14 +0000