Subversion Repositories SmartDukaan

Rev

Rev 2061 | Rev 2310 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2061 Rev 2090
Line 139... Line 139...
139
        headerRow.createCell(1).setCellValue("Gateway");
139
        headerRow.createCell(1).setCellValue("Gateway");
140
        headerRow.createCell(2).setCellValue("Txn Id");
140
        headerRow.createCell(2).setCellValue("Txn Id");
141
        headerRow.createCell(3).setCellValue("Amount");
141
        headerRow.createCell(3).setCellValue("Amount");
142
        headerRow.createCell(4).setCellValue("Payment Status");
142
        headerRow.createCell(4).setCellValue("Payment Status");
143
        headerRow.createCell(5).setCellValue("Payment Status Description");
143
        headerRow.createCell(5).setCellValue("Payment Status Description");
-
 
144
        headerRow.createCell(6).setCellValue("Gateway Txn Status");
144
        headerRow.createCell(6).setCellValue("Reference Code");
145
        headerRow.createCell(7).setCellValue("Reference Code");
145
        headerRow.createCell(7).setCellValue("Transaction Time");
146
        headerRow.createCell(8).setCellValue("Transaction Time");
146
 
147
 
147
        headerRow.createCell(8).setCellValue("Customer Id");
148
        headerRow.createCell(9).setCellValue("Customer Id");
148
        headerRow.createCell(9).setCellValue("Name");
149
        headerRow.createCell(10).setCellValue("Name");
149
        headerRow.createCell(10).setCellValue("MobileNo");
150
        headerRow.createCell(11).setCellValue("MobileNo");
150
        headerRow.createCell(11).setCellValue("Address");
151
        headerRow.createCell(12).setCellValue("Address");
151
        headerRow.getCell(11).setCellStyle(styleWT);
152
        headerRow.getCell(12).setCellStyle(styleWT);
152
        headerRow.createCell(12).setCellValue("Pincode");
153
        headerRow.createCell(13).setCellValue("Pincode");
153
        headerRow.createCell(13).setCellValue("City");
154
        headerRow.createCell(14).setCellValue("City");
154
        headerRow.createCell(14).setCellValue("State");
155
        headerRow.createCell(15).setCellValue("State");
155
        headerRow.createCell(15).setCellValue("Email");
156
        headerRow.createCell(16).setCellValue("Email");
156
 
157
 
157
        headerRow.createCell(16).setCellValue("Order Id");
158
        headerRow.createCell(17).setCellValue("Order Id");
158
        headerRow.createCell(17).setCellValue("Order Status");
159
        headerRow.createCell(18).setCellValue("Order Status");
159
        headerRow.createCell(18).setCellValue("Order Status Description");
160
        headerRow.createCell(19).setCellValue("Order Status Description");
160
 
161
 
161
        headerRow.createCell(19).setCellValue("Item Id");
162
        headerRow.createCell(20).setCellValue("Item Id");
162
        headerRow.createCell(20).setCellValue("Product Group");
163
        headerRow.createCell(21).setCellValue("Product Group");
163
        headerRow.createCell(21).setCellValue("Brand");
164
        headerRow.createCell(22).setCellValue("Brand");
164
        headerRow.createCell(22).setCellValue("Model Name");
165
        headerRow.createCell(23).setCellValue("Model Name");
165
        headerRow.createCell(23).setCellValue("Model Number");
166
        headerRow.createCell(24).setCellValue("Model Number");
166
        headerRow.createCell(24).setCellValue("Qty");
167
        headerRow.createCell(25).setCellValue("Qty");
167
 
168
 
168
        int addrColWidth = 35;
169
        int addrColWidth = 35;
169
        paymentSheet.setColumnWidth(10, 256 * addrColWidth); // set width of address column to 35 characters
170
        paymentSheet.setColumnWidth(12, 256 * addrColWidth); // set width of address column to 35 characters
170
        List<Order> orders;
171
        List<Order> orders;
171
        long txnId;
172
        long txnId;
172
        Row contentRow;
173
        Row contentRow;
173
        Calendar calendar = Calendar.getInstance();
174
        Calendar calendar = Calendar.getInstance();
174
        DateFormat formatter = new SimpleDateFormat("EEE, dd-MMM-yyyy hh:mm a");
175
        DateFormat formatter = new SimpleDateFormat("EEE, dd-MMM-yyyy hh:mm a");
Line 184... Line 185...
184
                        gateway = pClient.getPaymentGateway(payment.getGatewayId());
185
                        gateway = pClient.getPaymentGateway(payment.getGatewayId());
185
                        gateWays.put(payment.getGatewayId(), gateway);
186
                        gateWays.put(payment.getGatewayId(), gateway);
186
                    } catch (PaymentException e) {
187
                    } catch (PaymentException e) {
187
                        e.printStackTrace();
188
                        e.printStackTrace();
188
                    } 
189
                    } 
189
                }*/
190
                }
-
 
191
                contentRow.createCell(1).setCellValue(gateway != null ? gateway.getName() : payment.getGatewayId()+"");*/
190
                contentRow.createCell(1).setCellValue(payment.getGatewayId());
192
                contentRow.createCell(1).setCellValue(payment.getGatewayId());
191
 
193
 
192
                contentRow.createCell(2).setCellValue(payment.getMerchantTxnId());
194
                contentRow.createCell(2).setCellValue(payment.getMerchantTxnId());
193
                contentRow.createCell(3).setCellValue(payment.getAmount());
195
                contentRow.createCell(3).setCellValue(payment.getAmount());
194
                contentRow.getCell(3).setCellStyle(styleAmount);
196
                contentRow.getCell(3).setCellStyle(styleAmount);
195
                contentRow.createCell(4).setCellValue(payment.getStatus().name());
197
                contentRow.createCell(4).setCellValue(payment.getStatus().name());
196
                contentRow.createCell(5).setCellValue(payment.getDescription());
198
                contentRow.createCell(5).setCellValue(payment.getDescription());
-
 
199
                contentRow.createCell(6).setCellValue(payment.getGatewayTxnStatus());
197
                contentRow.createCell(6).setCellValue(payment.getReferenceCode());
200
                contentRow.createCell(7).setCellValue(payment.getReferenceCode());
198
                calendar.setTimeInMillis(payment.getInitTimestamp());
201
                calendar.setTimeInMillis(payment.getInitTimestamp());
199
                contentRow.createCell(7).setCellValue(formatter.format(calendar.getTime()));
202
                contentRow.createCell(8).setCellValue(formatter.format(calendar.getTime()));
200
 
203
 
201
                txnId = tClient.getTransaction(payment.getMerchantTxnId()).getId();
204
                txnId = tClient.getTransaction(payment.getMerchantTxnId()).getId();
202
                orders = tClient.getOrdersForTransaction(txnId, payment.getUserId());
205
                orders = tClient.getOrdersForTransaction(txnId, payment.getUserId());
203
                List<LineItem> lineItems;
206
                List<LineItem> lineItems;
204
 
207
 
205
                String address = "";
208
                String address = "";
206
                float rowHeight = paymentSheet.getDefaultRowHeightInPoints();
209
                float rowHeight = paymentSheet.getDefaultRowHeightInPoints();
207
                if (orders == null || orders.isEmpty()) {
210
                if (orders == null || orders.isEmpty()) {
208
                    continue;
211
                    continue;
209
                }
212
                }
210
                contentRow.createCell(8).setCellValue(orders.get(0).getCustomer_id());
213
                contentRow.createCell(9).setCellValue(orders.get(0).getCustomer_id());
211
                contentRow.createCell(9).setCellValue(orders.get(0).getCustomer_name());
214
                contentRow.createCell(10).setCellValue(orders.get(0).getCustomer_name());
212
                contentRow.createCell(10).setCellValue(orders.get(0).getCustomer_mobilenumber());
215
                contentRow.createCell(11).setCellValue(orders.get(0).getCustomer_mobilenumber());
213
                address = orders.get(0).getCustomer_address1() + ", " + orders.get(0).getCustomer_address2();
216
                address = orders.get(0).getCustomer_address1() + ", " + orders.get(0).getCustomer_address2();
214
                contentRow.createCell(11).setCellValue(address);
217
                contentRow.createCell(12).setCellValue(address);
215
                contentRow.getCell(11).setCellStyle(styleWT);
218
                contentRow.getCell(12).setCellStyle(styleWT);
216
                int maxLength = Math.max(address.length(), paymentSheet.getDefaultColumnWidth());
219
                int maxLength = Math.max(address.length(), paymentSheet.getDefaultColumnWidth());
217
                contentRow.setHeightInPoints((maxLength / addrColWidth + 1) * rowHeight); // Setting Row Height
220
                contentRow.setHeightInPoints((maxLength / addrColWidth + 1) * rowHeight); // Setting Row Height
218
                contentRow.createCell(12).setCellValue(orders.get(0).getCustomer_pincode());
221
                contentRow.createCell(13).setCellValue(orders.get(0).getCustomer_pincode());
219
                contentRow.createCell(13).setCellValue(orders.get(0).getCustomer_city());
222
                contentRow.createCell(14).setCellValue(orders.get(0).getCustomer_city());
220
                contentRow.createCell(14).setCellValue(orders.get(0).getCustomer_state());
223
                contentRow.createCell(15).setCellValue(orders.get(0).getCustomer_state());
221
                contentRow.createCell(15).setCellValue(orders.get(0).getCustomer_email());
224
                contentRow.createCell(16).setCellValue(orders.get(0).getCustomer_email());
222
 
225
 
223
                for (Order o : orders) {
226
                for (Order o : orders) {
224
                    paymentSerialNo++;
227
                    paymentSerialNo++;
225
                    contentRow = paymentSheet.createRow(paymentSerialNo);
228
                    contentRow = paymentSheet.createRow(paymentSerialNo);
226
 
229
 
227
                    contentRow.createCell(16).setCellValue(o.getId());
230
                    contentRow.createCell(17).setCellValue(o.getId());
228
                    contentRow.createCell(17).setCellValue(o.getStatus().name());
231
                    contentRow.createCell(18).setCellValue(o.getStatus().name());
229
                    contentRow.createCell(18).setCellValue(o.getStatusDescription());
232
                    contentRow.createCell(19).setCellValue(o.getStatusDescription());
230
 
233
 
231
                    lineItems = tClient.getLineItemsForOrder(o.getId());
234
                    lineItems = tClient.getLineItemsForOrder(o.getId());
232
                    for (LineItem i : lineItems) {
235
                    for (LineItem i : lineItems) {
233
                        /*
236
                        /*
234
                         * Right now there can be only one line item in an
237
                         * Right now there can be only one line item in an
Line 238... Line 241...
238
                         */
241
                         */
239
                        // paymentSerialNo++;
242
                        // paymentSerialNo++;
240
                        // contentRow =
243
                        // contentRow =
241
                        // paymentSheet.createRow(paymentSerialNo);
244
                        // paymentSheet.createRow(paymentSerialNo);
242
 
245
 
243
                        contentRow.createCell(19).setCellValue(i.getId());
246
                        contentRow.createCell(20).setCellValue(i.getId());
244
                        contentRow.createCell(20).setCellValue(i.getProductGroup());
247
                        contentRow.createCell(21).setCellValue(i.getProductGroup());
245
                        contentRow.createCell(21).setCellValue(i.getBrand());
248
                        contentRow.createCell(22).setCellValue(i.getBrand());
246
                        contentRow.createCell(22).setCellValue(i.getModel_name());
249
                        contentRow.createCell(23).setCellValue(i.getModel_name());
247
                        contentRow.createCell(23).setCellValue(i.getModel_number());
250
                        contentRow.createCell(24).setCellValue(i.getModel_number());
248
                        contentRow.createCell(24).setCellValue(i.getQuantity());
251
                        contentRow.createCell(25).setCellValue(i.getQuantity());
249
                    }
252
                    }
250
                }
253
                }
251
            } catch (TransactionServiceException e) {
254
            } catch (TransactionServiceException e) {
252
                e.printStackTrace();
255
                e.printStackTrace();
253
            } catch (TException e) {
256
            } catch (TException e) {
254
                e.printStackTrace();
257
                e.printStackTrace();
255
            }
258
            }
256
        }
259
        }
257
 
260
 
258
        for (int i = 0; i <= 24; i++) {
261
        for (int i = 0; i <= 25; i++) {
259
            if (i == 11) // Address Column is of fixed size with wrap text style
262
            if (i == 12) // Address Column is of fixed size with wrap text style
260
                continue;
263
                continue;
261
            paymentSheet.autoSizeColumn(i);
264
            paymentSheet.autoSizeColumn(i);
262
        }
265
        }
263
 
266
 
264
        // Write the workbook to the output stream
267
        // Write the workbook to the output stream
Line 274... Line 277...
274
    public static void main(String[] args) {
277
    public static void main(String[] args) {
275
        DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
278
        DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
276
        Date startDate = null, endDate = null;
279
        Date startDate = null, endDate = null;
277
        try {
280
        try {
278
            startDate = df.parse("01/01/2011");
281
            startDate = df.parse("01/01/2011");
279
            endDate = df.parse("04/30/2011");
282
            endDate = df.parse("06/30/2011");
280
            Calendar cal = Calendar.getInstance();
283
            Calendar cal = Calendar.getInstance();
281
            cal.setTime(endDate);
284
            cal.setTime(endDate);
282
            cal.add(Calendar.DATE, 1);
285
            cal.add(Calendar.DATE, 1);
283
            endDate.setTime(cal.getTimeInMillis());
286
            endDate.setTime(cal.getTimeInMillis());
284
        } catch (ParseException pe) {
287
        } catch (ParseException pe) {