Subversion Repositories SmartDukaan

Rev

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

Rev 17501 Rev 18530
Line 23... Line 23...
23
import in.shop2020.model.v1.order.OrderType;
23
import in.shop2020.model.v1.order.OrderType;
24
import in.shop2020.model.v1.order.ProductCondition;
24
import in.shop2020.model.v1.order.ProductCondition;
25
import in.shop2020.model.v1.order.SnapdealOrder;
25
import in.shop2020.model.v1.order.SnapdealOrder;
26
import in.shop2020.model.v1.order.FlipkartOrder;
26
import in.shop2020.model.v1.order.FlipkartOrder;
27
import in.shop2020.model.v1.order.TaxType;
27
import in.shop2020.model.v1.order.TaxType;
-
 
28
import in.shop2020.model.v1.user.Address;
28
import in.shop2020.thrift.clients.CatalogClient;
29
import in.shop2020.thrift.clients.CatalogClient;
29
import in.shop2020.thrift.clients.LogisticsClient;
30
import in.shop2020.thrift.clients.LogisticsClient;
30
import in.shop2020.thrift.clients.TransactionClient;
31
import in.shop2020.thrift.clients.TransactionClient;
31
import in.shop2020.thrift.clients.config.ConfigClient;
32
import in.shop2020.thrift.clients.config.ConfigClient;
32
import in.shop2020.thrift.clients.InventoryClient;
33
import in.shop2020.thrift.clients.InventoryClient;
-
 
34
import in.shop2020.thrift.clients.UserClient;
33
 
35
 
34
import java.awt.image.BufferedImage;
36
import java.awt.image.BufferedImage;
35
import java.io.ByteArrayOutputStream;
37
import java.io.ByteArrayOutputStream;
36
import java.io.File;
38
import java.io.File;
37
import java.io.FileOutputStream;
39
import java.io.FileOutputStream;
Line 139... Line 141...
139
 
141
 
140
	private TransactionClient tsc = null;
142
	private TransactionClient tsc = null;
141
	private InventoryClient csc = null;
143
	private InventoryClient csc = null;
142
	private LogisticsClient lsc = null;
144
	private LogisticsClient lsc = null;
143
	private CatalogClient ctsc = null;
145
	private CatalogClient ctsc = null;
-
 
146
	private UserClient usc = null;
144
 
147
 
145
	private static Locale indianLocale = new Locale("en", "IN");
148
	private static Locale indianLocale = new Locale("en", "IN");
146
	private DecimalFormat amountFormat = new DecimalFormat("#,##0.00");
149
	private DecimalFormat amountFormat = new DecimalFormat("#,##0.00");
147
 
150
 
148
	//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
151
	//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
Line 166... Line 169...
166
		try {
169
		try {
167
			tsc = new TransactionClient();
170
			tsc = new TransactionClient();
168
			csc = new InventoryClient();
171
			csc = new InventoryClient();
169
			lsc = new LogisticsClient();
172
			lsc = new LogisticsClient();
170
			ctsc = new CatalogClient();
173
			ctsc = new CatalogClient();
-
 
174
			usc = new UserClient();
171
		} catch (Exception e) {
175
		} catch (Exception e) {
172
			logger.error("Error while instantiating thrift clients.", e);
176
			logger.error("Error while instantiating thrift clients.", e);
173
		}
177
		}
174
	}
178
	}
175
 
179
 
176
	public ByteArrayOutputStream generateInvoice(long orderId, boolean withBill, boolean printAll, long warehouseId) {
180
	public ByteArrayOutputStream generateInvoice(long orderId, boolean withBill, boolean printAll, long warehouseId) {
177
		ByteArrayOutputStream baosPDF = null;
181
		ByteArrayOutputStream baosPDF = null;
178
		in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
182
		in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
179
		in.shop2020.model.v1.inventory.InventoryService.Client iclient = csc.getClient();
183
		in.shop2020.model.v1.inventory.InventoryService.Client iclient = csc.getClient();
180
		in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
184
		in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
181
 
-
 
-
 
185
		in.shop2020.model.v1.user.UserContextService.Client userClient = usc.getClient();
182
 
186
 
183
		try {
187
		try {
184
			baosPDF = new ByteArrayOutputStream();
188
			baosPDF = new ByteArrayOutputStream();
185
 
189
 
186
			Document document = new Document();
190
			Document document = new Document();
Line 629... Line 633...
629
		
633
		
630
		PdfPTable logoTable = new PdfPTable(2);
634
		PdfPTable logoTable = new PdfPTable(2);
631
		addLogoTable(logoTable,order); 
635
		addLogoTable(logoTable,order); 
632
		
636
		
633
		PdfPCell titleCell = getTitleCell();
637
		PdfPCell titleCell = getTitleCell();
634
		PdfPTable customerTable = getCustomerAddressTable(order, destCode, false, helvetica12, false);
638
		PdfPTable customerTable = getCustomerAddressTable(order, destCode, false, helvetica12, false, false);
635
		PdfPTable providerInfoTable = getProviderTable(order, provider, barCodeFont, totalWeight);
639
		PdfPTable providerInfoTable = getProviderTable(order, provider, barCodeFont, totalWeight);
636
 
640
 
637
		PdfPTable dispatchTable = new PdfPTable(new float[]{0.5f, 0.1f, 0.4f});
641
		PdfPTable dispatchTable = new PdfPTable(new float[]{0.5f, 0.1f, 0.4f});
638
		dispatchTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
642
		dispatchTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
639
		dispatchTable.addCell(customerTable);
643
		dispatchTable.addCell(customerTable);
Line 1060... Line 1064...
1060
		Paragraph sorlAddress = new Paragraph(ourAddress + "\n Contact No.- +91-9811247808" + "\nTIN NO. " + tinNo, new Font(FontFamily.TIMES_ROMAN, 8f, Element.ALIGN_CENTER));
1064
		Paragraph sorlAddress = new Paragraph(ourAddress + "\n Contact No.- +91-9811247808" + "\nTIN NO. " + tinNo, new Font(FontFamily.TIMES_ROMAN, 8f, Element.ALIGN_CENTER));
1061
		PdfPCell sorlAddressCell = new PdfPCell(sorlAddress);
1065
		PdfPCell sorlAddressCell = new PdfPCell(sorlAddress);
1062
		sorlAddressCell.addElement(sorlAddress);
1066
		sorlAddressCell.addElement(sorlAddress);
1063
		sorlAddressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
1067
		sorlAddressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
1064
 
1068
 
1065
		PdfPTable customerAddress = getCustomerAddressTable(order, null, true, helvetica8, true);
1069
		PdfPTable customerAddress = getCustomerAddressTable(order, null, true, helvetica8, true, true);
1066
		PdfPTable orderDetails = getOrderDetails(order, provider);
1070
		PdfPTable orderDetails = getOrderDetails(order, provider);
1067
 
1071
 
1068
		PdfPTable addrAndOrderDetailsTable = new PdfPTable(new float[]{0.5f, 0.1f, 0.4f});
1072
		PdfPTable addrAndOrderDetailsTable = new PdfPTable(new float[]{0.5f, 0.1f, 0.4f});
1069
		addrAndOrderDetailsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
1073
		addrAndOrderDetailsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
1070
		addrAndOrderDetailsTable.addCell(customerAddress);
1074
		addrAndOrderDetailsTable.addCell(customerAddress);
Line 1199... Line 1203...
1199
		
1203
		
1200
		return flipkartTable;
1204
		return flipkartTable;
1201
		
1205
		
1202
	}
1206
	}
1203
 
1207
 
1204
	private PdfPTable getCustomerAddressTable(Order order, String destCode, boolean showPaymentMode, Font font, boolean forInvoce){
1208
	private PdfPTable getCustomerAddressTable(Order order, String destCode, boolean showPaymentMode, Font font, boolean forInvoce, boolean billingAdd){
1205
		PdfPTable customerTable = new PdfPTable(1);
1209
		PdfPTable customerTable = new PdfPTable(1);
1206
		customerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
1210
		customerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
1207
		if(forInvoce || order.getPickupStoreId() == 0){
1211
		if(forInvoce || order.getPickupStoreId() == 0){
-
 
1212
			in.shop2020.model.v1.user.UserContextService.Client userClient = usc.getClient();
-
 
1213
			try {
-
 
1214
				if(billingAdd && userClient.isPrivateDealUser(order.getCustomer_id())){
-
 
1215
					Address billingAddress = userClient.getBillingAddressForUser(order.getCustomer_id());
-
 
1216
					customerTable.addCell(new Phrase(billingAddress.getName(), font));
-
 
1217
					customerTable.addCell(new Phrase(billingAddress.getLine1(), font));
-
 
1218
					customerTable.addCell(new Phrase(billingAddress.getLine2(), font));
-
 
1219
					customerTable.addCell(new Phrase(billingAddress.getCity() + "," + billingAddress.getState(), font));
-
 
1220
					customerTable.addCell(new Phrase(billingAddress.getPin(), font));
-
 
1221
					customerTable.addCell(new Phrase("Phone : " + (billingAddress.getPhone()== null ? "" : billingAddress.getPhone()), font));
-
 
1222
				}else{
1208
			customerTable.addCell(new Phrase(order.getCustomer_name(), font));
1223
					customerTable.addCell(new Phrase(order.getCustomer_name(), font));
1209
			if(order.getSource() == OrderSource.HOMESHOP18.getValue()){
1224
					if(order.getSource() == OrderSource.HOMESHOP18.getValue()){
1210
				HsOrder hsOrder = null;
1225
						HsOrder hsOrder = null;
1211
				try {
1226
						try {
1212
					hsOrder = tsc.getClient().getHomeShopOrder(order.getId(), null, null).get(0);
1227
							hsOrder = tsc.getClient().getHomeShopOrder(order.getId(), null, null).get(0);
1213
				}catch (TException e) {
1228
						}catch (TException e) {
1214
					logger.error("Error while getting homeshop18 order", e);
1229
							logger.error("Error while getting homeshop18 order", e);
1215
				}
1230
						}
1216
				String hsShippingName = hsOrder.getShippingName();
1231
						String hsShippingName = hsOrder.getShippingName();
1217
				if(hsShippingName!=null && !hsShippingName.isEmpty()){
1232
						if(hsShippingName!=null && !hsShippingName.isEmpty()){
1218
					customerTable.addCell(new Phrase("Shipped To: "+hsShippingName, font));
1233
							customerTable.addCell(new Phrase("Shipped To: "+hsShippingName, font));
1219
				}
1234
						}
1220
			}
1235
					}
1221
			customerTable.addCell(new Phrase(order.getCustomer_address1(), font));
1236
					customerTable.addCell(new Phrase(order.getCustomer_address1(), font));
1222
			customerTable.addCell(new Phrase(order.getCustomer_address2(), font));
1237
					customerTable.addCell(new Phrase(order.getCustomer_address2(), font));
1223
			customerTable.addCell(new Phrase(order.getCustomer_city() + "," + order.getCustomer_state(), font));
1238
					customerTable.addCell(new Phrase(order.getCustomer_city() + "," + order.getCustomer_state(), font));
1224
			//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
1239
					//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
1225
			if(order.getLogistics_provider_id()!=7L){
1240
					if(order.getLogistics_provider_id()!=7L){
1226
				if(destCode != null)
1241
						if(destCode != null)
1227
					customerTable.addCell(new Phrase(order.getCustomer_pincode() + " - " + destCode, helvetica16));
1242
							customerTable.addCell(new Phrase(order.getCustomer_pincode() + " - " + destCode, helvetica16));
1228
				else
1243
						else
1229
					customerTable.addCell(new Phrase(order.getCustomer_pincode(), font));
1244
							customerTable.addCell(new Phrase(order.getCustomer_pincode(), font));
1230
				}
1245
						}
1231
			else{
1246
					else{
1232
				in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
1247
						in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
1233
				String fedexLocationcode = "";
1248
						String fedexLocationcode = "";
1234
				try {
1249
						try {
1235
					fedexLocationcode = tclient.getOrderAttributeValue(order.getId(), "FedEx_Location_Code");
1250
							fedexLocationcode = tclient.getOrderAttributeValue(order.getId(), "FedEx_Location_Code");
1236
				} catch (TException e1) {
1251
						} catch (TException e1) {
1237
					logger.error("Error while getting the provider information.", e1);
1252
							logger.error("Error while getting the provider information.", e1);
-
 
1253
						}
-
 
1254
						customerTable.addCell(new Phrase(order.getCustomer_pincode() + " - " + fedexLocationcode, helvetica16));
-
 
1255
					}
-
 
1256
					//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
-
 
1257
					if(order.getCustomer_mobilenumber()!=null && !order.getCustomer_mobilenumber().isEmpty()) {
-
 
1258
						customerTable.addCell(new Phrase("Phone : " + (order.getCustomer_mobilenumber()== null ? "" : order.getCustomer_mobilenumber()), font));
-
 
1259
					}
1238
				}
1260
				}
1239
				customerTable.addCell(new Phrase(order.getCustomer_pincode() + " - " + fedexLocationcode, helvetica16));
-
 
1240
			}
-
 
1241
			//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
1261
			} catch (TException e2) {
1242
			if(order.getCustomer_mobilenumber()!=null && !order.getCustomer_mobilenumber().isEmpty()) {
1262
				e2.printStackTrace();
1243
				customerTable.addCell(new Phrase("Phone : " + (order.getCustomer_mobilenumber()== null ? "" : order.getCustomer_mobilenumber()), font));
-
 
1244
			}
1263
			}
-
 
1264
			
1245
		}else{
1265
		}else{
1246
			try {
1266
			try {
1247
				in.shop2020.logistics.LogisticsService.Client lclient = (new LogisticsClient()).getClient();
1267
				in.shop2020.logistics.LogisticsService.Client lclient = (new LogisticsClient()).getClient();
1248
				PickupStore store = lclient.getPickupStore(order.getPickupStoreId());
1268
				PickupStore store = lclient.getPickupStore(order.getPickupStoreId());
1249
				customerTable.addCell(new Phrase(order.getCustomer_name() + " \nc/o " + store.getName(), font));
1269
				customerTable.addCell(new Phrase(order.getCustomer_name() + " \nc/o " + store.getName(), font));