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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.transtracking.service.impl;

import com.bestray.transporttracking.DataSourceObject;
import com.bestray.transtracking.dao.EmployeeDao;
import com.bestray.transtracking.dao.PaymentVoucherDao;
import com.bestray.transtracking.dao.impl.EmployeeDaoImpl;
import com.bestray.transtracking.dao.impl.PaymentVoucherDaoImpl;
import com.bestray.transtracking.dto.PaymentVoucherSearchDTO;
import com.bestray.transtracking.exceptions.TransTrackException;
import com.bestray.transtracking.service.PaymentVoucherService;
import com.bestray.trastrack.domain.Employee;
import com.bestray.trastrack.domain.Party;
import com.bestray.trastrack.domain.PaymentVoucher;
import com.bestray.trastrack.domain.ViewDomain;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.DataSource;

/**
 *
 * @author Bitu
 */
public class PaymentVoucherServiceImpl implements PaymentVoucherService {

    private PaymentVoucherDao paymentdao;
    private EmployeeDao employeeDao;
    DataSource ds;

    public PaymentVoucherServiceImpl() {
        ds = DataSourceObject.getDataSourceObject();
    }

    /*public List<Party> getPartyNameList() {
     paymentdao = new PaymentVoucherDaoImpl( DataSourceObject.getDataSourceObject());
     return paymentdao.findallReceipt();
     }
     public PaymentVoucher getTotalPartyBalance(Long partyId) {
     paymentdao = new PaymentVoucherDaoImpl( DataSourceObject.getDataSourceObject());
     return paymentdao.getTotalPartyBalance(partyId);
     }*/
    public List<Employee> getEmployeeNameList() {
        try {
            paymentdao = new PaymentVoucherDaoImpl(DataSourceObject.getDataSourceObject());
            return paymentdao.findAllEmployees();
        } catch (Exception ex) {
            Logger.getLogger(PaymentVoucherServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in fetching Employee Name List");
        }
    }

    public boolean collectPayment(PaymentVoucher payment) {
        try {
            paymentdao = new PaymentVoucherDaoImpl(DataSourceObject.getDataSourceObject());
            if (payment.getId() != null && payment.getId() > 0) {
                paymentdao.updatePayment(payment);
            } else {
                if (payment.getId() == null) {
                    paymentdao.savePayment(payment);
                }
            }
            return true;
        } catch (Exception ex) {
            Logger.getLogger(PaymentVoucherServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in fetching Collection Payment");
        }
    }

    public List<PaymentVoucher> getSearchResult(PaymentVoucherSearchDTO search) {
        try {
            DataSource ds = DataSourceObject.getDataSourceObject();
            //vehicleService = new VehicleServiceImpl();
            paymentdao = new PaymentVoucherDaoImpl(ds);
            employeeDao = new EmployeeDaoImpl(ds);
            List<PaymentVoucher> results = paymentdao.getSearchResults(search);
            for (PaymentVoucher object : results) {
                object.setEmployee(employeeDao.findEmplRegistraion(object.getEmployee_name_id()));
                //object.setClient(clientdao.findClientRegistraion(object.getClient_id()));
                //object.setVehicle(vehicleService.getVehicleRegistrationDetails(object.getVehicleId()));
            }
            return results;

        } catch (Exception ex) {
            Logger.getLogger(PaymentVoucherServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in fetching Payment Voucher");
        }
    }

    public PaymentVoucher getLastBalance(Long partyId) {
        try {
            paymentdao = new PaymentVoucherDaoImpl(ds);
            return paymentdao.getLastBalance(partyId);
        } catch (Exception ex) {
            Logger.getLogger(PaymentVoucherServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in fetching Last Balance");
        }
    }

    public ViewDomain getTotalOilBalance(Long partyId) {
        try {
            paymentdao = new PaymentVoucherDaoImpl(ds);
            return paymentdao.getTotalOilBalance(partyId);
        } catch (Exception ex) {
            Logger.getLogger(PaymentVoucherServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Party Information cannot be deleted");
        }
    }

    public ViewDomain getTotalPaymentBalance(Long partyId) {
        try {
            paymentdao = new PaymentVoucherDaoImpl(ds);
            return paymentdao.getTotalPaymentBalance(partyId);
        } catch (Exception ex) {
            Logger.getLogger(PaymentVoucherServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in fetching total Payment Balance");
        }
    }

    public ViewDomain getTotalExpenseBalance(Long partyId) {
        try {
            paymentdao = new PaymentVoucherDaoImpl(ds);
            return paymentdao.getTotalExpenseBalance(partyId);
        } catch (Exception ex) {
            Logger.getLogger(PaymentVoucherServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in fetching total expense balance");
        }
    }

    public PaymentVoucher getPaymentChangeById(Long id) {
        try {
            paymentdao = new PaymentVoucherDaoImpl(ds);
            return paymentdao.findById(id);
        } catch (Exception ex) {
            Logger.getLogger(PaymentVoucherServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in fetching Payment Voucher");
        }
    }

    public void delete(Long id) {
        //PaymentVoucher payment = paymentdao.findPaymentDetails(clientId); 
        try {
            paymentdao = new PaymentVoucherDaoImpl(ds);
            paymentdao.delete(id);
        } catch (Exception ex) {
            Logger.getLogger(PartyServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in deleting Payment Voucher");
        }
    }

    public List<Party> getAllPartyNameList() throws TransTrackException {
        try {
            paymentdao = new PaymentVoucherDaoImpl(DataSourceObject.getDataSourceObject());
            return paymentdao.findAllPartysNames();
        } catch (Exception ex) {
            Logger.getLogger(PaymentVoucherServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in fetching Employee Name List");
        }
    }

    public ViewDomain getPayment(Long partyId) throws TransTrackException {
        try {
            paymentdao = new PaymentVoucherDaoImpl(ds);
            return paymentdao.getTotalPayment(partyId);
        } catch (Exception ex) {
            Logger.getLogger(PaymentVoucherServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in fetching total expense balance");
        }
    }
}

Commits for TransPort_Tracking/TransPortTracking/src/main/java/com/bestray/transtracking/service/impl/PaymentVoucherServiceImpl.java

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