Subversion Repositories SmartDukaan

Rev

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

Rev 19723 Rev 19950
Line 40... Line 40...
40
import java.io.FileOutputStream;
40
import java.io.FileOutputStream;
41
import java.io.IOException;
41
import java.io.IOException;
42
import java.io.OutputStream;
42
import java.io.OutputStream;
43
import java.text.DateFormat;
43
import java.text.DateFormat;
44
import java.text.DecimalFormat;
44
import java.text.DecimalFormat;
-
 
45
import java.text.SimpleDateFormat;
45
import java.util.ArrayList;
46
import java.util.ArrayList;
46
import java.util.Date;
47
import java.util.Date;
47
import java.util.HashMap;
48
import java.util.HashMap;
48
import java.util.List;
49
import java.util.List;
49
import java.util.Locale;
50
import java.util.Locale;
Line 87... Line 88...
87
 
88
 
88
@SuppressWarnings("serial")
89
@SuppressWarnings("serial")
89
public class InvoiceServlet extends HttpServlet {
90
public class InvoiceServlet extends HttpServlet {
90
 
91
 
91
	private static Logger logger = LoggerFactory.getLogger(InvoiceServlet.class);
92
	private static Logger logger = LoggerFactory.getLogger(InvoiceServlet.class);
-
 
93
	private static long cutoffTime = 0;
92
 
94
	
-
 
95
	static {
-
 
96
		try {
-
 
97
		String cutOffDate = ConfigClient.getClient().get("warehouse_company_cutoff_date");
-
 
98
		DateFormat df = new SimpleDateFormat("yyyy-mm-dd");
-
 
99
		cutoffTime = df.parse(cutOffDate).getTime();
-
 
100
		} catch(Exception e) {
-
 
101
			logger.info("Could not read cutoff time");
-
 
102
		}
-
 
103
	}
93
	@Override
104
	@Override
94
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
105
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
95
		long orderId = Long.parseLong(request.getParameter("id"));
106
		long orderId = Long.parseLong(request.getParameter("id"));
96
		String logisticsTxnId  = request.getParameter("logisticsTxnId");
107
		String logisticsTxnId  = request.getParameter("logisticsTxnId");
97
		long warehouseId = Long.parseLong(request.getParameter("warehouse"));
108
		long warehouseId = Long.parseLong(request.getParameter("warehouse"));
Line 146... Line 157...
146
	private LogisticsClient lsc = null;
157
	private LogisticsClient lsc = null;
147
	private CatalogClient ctsc = null;
158
	private CatalogClient ctsc = null;
148
	private UserClient usc = null;
159
	private UserClient usc = null;
149
 
160
 
150
	private static Locale indianLocale = new Locale("en", "IN");
161
	private static Locale indianLocale = new Locale("en", "IN");
-
 
162
	private static String SORPL = "Spice Online Retail Pvt Ltd";
-
 
163
	private static String NEWCOMP = "New Spice Online Retail Pvt Ltd";
151
	private DecimalFormat amountFormat = new DecimalFormat("#,##0.00");
164
	private DecimalFormat amountFormat = new DecimalFormat("#,##0.00");
152
	private DecimalFormat weightFormat = new DecimalFormat("#0.000");
165
	private DecimalFormat weightFormat = new DecimalFormat("#0.000");
153
 
166
 
154
	//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
167
	//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
155
	private static final Font helvetica6 = FontFactory.getFont(FontFactory.HELVETICA, 6);
168
	private static final Font helvetica6 = FontFactory.getFont(FontFactory.HELVETICA, 6);
Line 166... Line 179...
166
	private static final String delhiPincodePrefix = "11";
179
	private static final String delhiPincodePrefix = "11";
167
	private static final String[] maharashtraPincodePrefix = {"40", "41", "42", "43", "44"};
180
	private static final String[] maharashtraPincodePrefix = {"40", "41", "42", "43", "44"};
168
	private static final String[] karnatakaPincodePrefix = {"56", "57", "58", "59"};
181
	private static final String[] karnatakaPincodePrefix = {"56", "57", "58", "59"};
169
	private static final String[] telanganaPincodes = {"500001","500002","500003","500004","500005","500006","500007","500008","500009","500010","500011","500012","500013","500014","500015","500016","500017","500018","500019","500020","500021","500022","500023","500024","500025","500026","500027","500028","500029","500030","500031","500032","500033","500034","500035","500036","500037","500038","500039","500040","500041","500042","500043","500044","500045","500046","500047","500048","500049","500050","500051","500052","500053","500054","500055","500056","500057","500058","500059","500060","500061","500062","500063","500064","500065","500066","500067","500068","500069","500070","500071","500072","500073","500074","500075","500076","500077","500078","500079","500080","500081","500082","500083","500084","500085","500086","500087","500088","500089","500090","500091","500092","500093","500094","500095","500096","500097","500098","500178","500409","501218","501301","501401","501510","501511","501512","502307","502319","517501","517502","517503","517505","517507","520001","520002","520003","520004","520005","520006","520007","520008","520009","520010","520011","520012","520013","520014","520015","521108","521225","522001","522002","522003","522004","522005","522006","522007","522019","522509","530001","530002","530003","530004","530005","530007","530008","530009","530010","530010","530011","530012","530013","530014","530015","530016","530017","530018","530020","530021","530022","530023","530024","530026","530027","530028","530029","530032","530035","530040","530041","530043","530044","530045","530046","531001","533101","533103","533104","533105"};
182
	private static final String[] telanganaPincodes = {"500001","500002","500003","500004","500005","500006","500007","500008","500009","500010","500011","500012","500013","500014","500015","500016","500017","500018","500019","500020","500021","500022","500023","500024","500025","500026","500027","500028","500029","500030","500031","500032","500033","500034","500035","500036","500037","500038","500039","500040","500041","500042","500043","500044","500045","500046","500047","500048","500049","500050","500051","500052","500053","500054","500055","500056","500057","500058","500059","500060","500061","500062","500063","500064","500065","500066","500067","500068","500069","500070","500071","500072","500073","500074","500075","500076","500077","500078","500079","500080","500081","500082","500083","500084","500085","500086","500087","500088","500089","500090","500091","500092","500093","500094","500095","500096","500097","500098","500178","500409","501218","501301","501401","501510","501511","501512","502307","502319","517501","517502","517503","517505","517507","520001","520002","520003","520004","520005","520006","520007","520008","520009","520010","520011","520012","520013","520014","520015","521108","521225","522001","522002","522003","522004","522005","522006","522007","522019","522509","530001","530002","530003","530004","530005","530007","530008","530009","530010","530010","530011","530012","530013","530014","530015","530016","530017","530018","530020","530021","530022","530023","530024","530026","530027","530028","530029","530032","530035","530040","530041","530043","530044","530045","530046","531001","533101","533103","533104","533105"};
170
	private Address billingAddress;
183
	private Address billingAddress;
-
 
184
	private String companyName=NEWCOMP;
171
 
185
 
172
	public InvoiceGenerationService() {
186
	public InvoiceGenerationService() {
173
		try {
187
		try {
174
			tsc = new TransactionClient();
188
			tsc = new TransactionClient();
175
			csc = new InventoryClient();
189
			csc = new InventoryClient();
Line 273... Line 287...
273
					}
287
					}
274
					
288
					
275
					if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
289
					if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
276
						for(Order order : ordersList){
290
						for(Order order : ordersList){
277
							if(isFirst){
291
							if(isFirst){
278
								document.add(getFixedTextTable(16, "Spice Online Retail Pvt Ltd"));
292
								document.add(getFixedTextTable(16, companyName));
279
								isFirst = false;
293
								isFirst = false;
280
							}
294
							}
281
							document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
295
							document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
282
							continue;
296
							continue;
283
						}
297
						}
Line 460... Line 474...
460
					}
474
					}
461
					
475
					
462
					if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
476
					if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
463
						for(Order order : ordersList){
477
						for(Order order : ordersList){
464
							if(isFirst){
478
							if(isFirst){
465
								document.add(getFixedTextTable(16, "Spice Online Retail Pvt Ltd"));
479
								document.add(getFixedTextTable(16, companyName));
466
								isFirst = false;
480
								isFirst = false;
467
							}
481
							}
468
							document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
482
							document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
469
							continue;
483
							continue;
470
						}
484
						}