Subversion Repositories SmartDukaan

Rev

Rev 9748 | Rev 9750 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8363 vikram.rag 1
package com.amazonaws.mws.samples;
2
 
3
import in.shop2020.model.v1.catalog.Amazonlisted;
4
import in.shop2020.model.v1.catalog.CatalogServiceException;
5
import in.shop2020.model.v1.catalog.Item;
6
import in.shop2020.model.v1.inventory.AmazonFbaInventorySnapshot;
7
import in.shop2020.model.v1.inventory.InventoryServiceException;
8
import in.shop2020.model.v1.inventory.Vendor;
9
import in.shop2020.model.v1.inventory.VendorItemPricing;
10
import in.shop2020.model.v1.order.AmazonFbaSalesSnapshot;
11
import in.shop2020.model.v1.order.TransactionService.Client;
12
import in.shop2020.thrift.clients.CatalogClient;
13
import in.shop2020.thrift.clients.InventoryClient;
14
import in.shop2020.thrift.clients.TransactionClient;
15
 
16
import java.io.FileNotFoundException;
17
import java.io.FileOutputStream;
18
import java.io.FileReader;
19
import java.io.IOException;
8825 vikram.rag 20
import java.io.OutputStream;
8363 vikram.rag 21
import java.text.ParseException;
22
import java.text.SimpleDateFormat;
23
import java.util.ArrayList;
8825 vikram.rag 24
import java.util.Calendar;
8363 vikram.rag 25
import java.util.Date;
26
import java.util.HashMap;
27
import java.util.List;
28
import java.util.Map;
29
import java.util.Map.Entry;
30
import java.util.TimeZone;
31
 
32
import org.apache.poi.hssf.usermodel.HSSFRow;
33
import org.apache.poi.hssf.usermodel.HSSFSheet;
34
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
35
import org.apache.thrift.TException;
36
 
37
import au.com.bytecode.opencsv.CSVReader;
38
 
39
public class FileParser {
40
	public static void main(String... args){
41
		CSVReader orderreportreader = null;
42
		CSVReader inventoryhealthreportreader = null;
43
		try {
8438 vikram.rag 44
			orderreportreader = new CSVReader(new FileReader("/home/amazonorderreport.csv"),'\t');
45
			inventoryhealthreportreader = new CSVReader(new FileReader("/home/inventoryhealthreport.csv"),'\t');
8363 vikram.rag 46
		} catch (FileNotFoundException e) {
47
			// TODO Auto-generated catch block
48
			e.printStackTrace();
49
		}
50
		String [] nextLine;
51
		try {
52
			int count =1;
53
			Map<Date,Map<Long,FbaSalesSnapshot>> orderDateItemIdFbaSaleSnapshotMap = new HashMap<Date,Map<Long,FbaSalesSnapshot>>();
54
			while ((nextLine = orderreportreader.readNext()) != null) {
8826 vikram.rag 55
				try{
56
					if(count!=1 && nextLine[5].equalsIgnoreCase("Amazon") && nextLine[6].equalsIgnoreCase("Amazon.in")){
57
						SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
58
						istFormatter .setLenient(false);
59
						TimeZone zone= TimeZone.getTimeZone("GMT");
60
						istFormatter.setTimeZone(zone);
61
						Date date = istFormatter.parse(nextLine[2]);
62
						SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
63
						Date date_key = dateFormat.parse(dateFormat.format(date));
9749 vikram.rag 64
						if(nextLine[11].equals("FBA13465")){
9742 vikram.rag 65
							System.out.println("Order Details " + nextLine[0]+" "+date_key+" "+ nextLine[11] +" " + nextLine[14] + " " + nextLine[4] + " " + nextLine[13] );
9740 vikram.rag 66
						}
8826 vikram.rag 67
						Long itemid = Long.parseLong(nextLine[11].replaceAll("FBA",""));
68
						Integer qty=0;
69
						if(nextLine[14].length()!=0){
70
							qty = new Integer(nextLine[14]);
71
						}
72
						Float itemSale = null;
73
						if(nextLine[16].length()!=0){
74
							itemSale = new Float(nextLine[16]);
75
						}
76
						else{
9742 vikram.rag 77
							itemSale = (float) 0;
8826 vikram.rag 78
						}
79
						Float itemDiscount; 
80
						if(nextLine[22].length()!=0){
81
							itemDiscount = new Float(nextLine[22]);
82
						}
83
						else{
84
							itemDiscount = new Float(0);
85
						}
9257 vikram.rag 86
						if(nextLine[4].equalsIgnoreCase("Cancelled") || nextLine[13].equalsIgnoreCase("Cancelled")){
8826 vikram.rag 87
							itemSale = (float) 0; 
88
							itemDiscount = (float) 0;
89
							qty = 0;
90
						}
9749 vikram.rag 91
						if(itemid==13465){
9741 vikram.rag 92
							System.out.println("Order Details after parsing " + nextLine[0]+" "+date_key+" "+ itemid +" " + qty);
9740 vikram.rag 93
						}
8826 vikram.rag 94
						if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date_key)){
9260 vikram.rag 95
							Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap;
8826 vikram.rag 96
							if(orderDateItemIdFbaSaleSnapshotMap.get(date_key).containsKey(itemid)){
97
								FbaSalesSnapshot fbaSalesSnapshot = orderDateItemIdFbaSaleSnapshotMap.get(date_key).get(itemid);
98
								if(itemDiscount!=0){
99
									fbaSalesSnapshot.setPromotionOrderCount(fbaSalesSnapshot.getPromotionOrderCount()+qty);
100
									fbaSalesSnapshot.setTotalPromotionSale(fbaSalesSnapshot.getTotalPromotionSale() + (itemSale - itemDiscount));
101
								}
102
								fbaSalesSnapshot.setTotalOrderCount(fbaSalesSnapshot.getTotalOrderCount() + qty);
103
								fbaSalesSnapshot.setTotalSale(fbaSalesSnapshot.getTotalSale() + itemSale - itemDiscount);
9260 vikram.rag 104
								ItemIdFbaSaleSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date_key);
105
								ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot); 
106
								orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
8363 vikram.rag 107
							}
8826 vikram.rag 108
							else{
109
								FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
110
								fbaSalesSnapshot.setTotalOrderCount(qty);
111
								fbaSalesSnapshot.setTotalSale(itemSale - itemDiscount);
112
								if(itemDiscount!=0){
113
									fbaSalesSnapshot.setPromotionOrderCount(qty);
114
									fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
115
								}
116
								else{
117
									fbaSalesSnapshot.setPromotionOrderCount(0);
118
									fbaSalesSnapshot.setTotalPromotionSale((float) 0);
119
								}
9260 vikram.rag 120
								ItemIdFbaSaleSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date_key);
121
								ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot); 
122
								orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
8826 vikram.rag 123
							}
8363 vikram.rag 124
						}
125
						else{
8826 vikram.rag 126
							Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
8363 vikram.rag 127
							FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
128
							fbaSalesSnapshot.setTotalOrderCount(qty);
8826 vikram.rag 129
							fbaSalesSnapshot.setTotalSale(itemSale);
8363 vikram.rag 130
							if(itemDiscount!=0){
8826 vikram.rag 131
								fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
8363 vikram.rag 132
								fbaSalesSnapshot.setPromotionOrderCount(qty);
133
							}
134
							else{
8826 vikram.rag 135
								fbaSalesSnapshot.setTotalPromotionSale((float) 0);
8363 vikram.rag 136
								fbaSalesSnapshot.setPromotionOrderCount(0);
137
							}
8826 vikram.rag 138
							ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
139
							orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
8363 vikram.rag 140
						}
141
					}
8826 vikram.rag 142
				}
143
				catch(Exception e){
144
					e.printStackTrace();
145
				}
8363 vikram.rag 146
				count++;
147
			}
148
			InventoryClient inventoryServiceClient = null;
149
			TransactionClient transactionServiceClient = null;
150
			CatalogClient catalogServiceClient = null;
151
			try {
152
				inventoryServiceClient = new InventoryClient();
153
				transactionServiceClient = new TransactionClient();
8825 vikram.rag 154
				catalogServiceClient = new CatalogClient();
155
				//catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port");
8363 vikram.rag 156
			} catch (Exception e) {
157
				// TODO Auto-generated catch block
158
				e.printStackTrace();
159
			}	
160
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
161
			in.shop2020.model.v1.order.TransactionService.Client transactionClient   = transactionServiceClient.getClient();
162
			in.shop2020.model.v1.catalog.CatalogService.Client catalogClient   = catalogServiceClient.getClient();
163
			SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
8825 vikram.rag 164
			//Date date_today = dateFormat.parse(dateFormat.format(new Date()));
165
			List<Date> dates = new ArrayList<Date>();
166
			Calendar cal = Calendar.getInstance();
167
			cal.add(Calendar.DATE, -1);
168
			Date date_end = dateFormat.parse(dateFormat.format(cal.getTime()));
169
			cal.add(Calendar.DATE, -5);
170
			Date date_start = dateFormat.parse(dateFormat.format(cal.getTime()));
9737 vikram.rag 171
			//System.out.println("Start Date = " + date_start);
172
			//System.out.println("End Date = " + date_end);
8825 vikram.rag 173
			Date d = date_start;
174
			while(!d.equals(date_end)){
8826 vikram.rag 175
				cal.setTime(d);
176
				cal.add(Calendar.DATE,1);
8825 vikram.rag 177
				d = cal.getTime();
178
				dates.add(d);
179
			}
8363 vikram.rag 180
			List<AmazonFbaInventorySnapshot> nonzeroFbaInventorySnapshotlist =  inventoryClient.getAllAmazonFbaItemInventory();
8825 vikram.rag 181
			for(Date date:dates){
182
				if(nonzeroFbaInventorySnapshotlist!=null){
183
					for(AmazonFbaInventorySnapshot amazonFbaInventory:nonzeroFbaInventorySnapshotlist){
184
						if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date) ){ 
185
							if(!orderDateItemIdFbaSaleSnapshotMap.get(date).containsKey(amazonFbaInventory.getItem_id())){
186
								Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
187
								FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
188
								fbaSalesSnapshot.setTotalOrderCount(0);
189
								fbaSalesSnapshot.setPromotionOrderCount(0);
190
								fbaSalesSnapshot.setTotalPromotionSale((float) 0);
191
								fbaSalesSnapshot.setTotalSale((float) 0);
192
								ItemIdFbaSaleSnapshotMap.put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
193
								orderDateItemIdFbaSaleSnapshotMap.get(date).put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
194
							}
195
 
196
						}
197
						else{
8363 vikram.rag 198
							Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
199
							FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
200
							fbaSalesSnapshot.setTotalOrderCount(0);
201
							fbaSalesSnapshot.setPromotionOrderCount(0);
202
							fbaSalesSnapshot.setTotalPromotionSale((float) 0);
203
							fbaSalesSnapshot.setTotalSale((float) 0);
204
							ItemIdFbaSaleSnapshotMap.put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
8825 vikram.rag 205
							orderDateItemIdFbaSaleSnapshotMap.put(date,ItemIdFbaSaleSnapshotMap);
8363 vikram.rag 206
						}
207
					}
208
				}
8825 vikram.rag 209
				else{
210
					System.out.println("No inventory in FBA");
211
				}
8363 vikram.rag 212
			}
8461 vikram.rag 213
			Map<Long,PriceAtDate> itemIdOurPriceMap = new HashMap<Long,PriceAtDate>();
214
			Map<Long,PriceAtDate> itemIdSalePriceMap = new HashMap<Long,PriceAtDate>();
215
			Map<Long,PriceAtDate> itemIdminFBAPriceMap = new HashMap<Long,PriceAtDate>();
216
			Map<Long,PriceAtDate> itemIdminMFNPriceMap = new HashMap<Long,PriceAtDate>();
8363 vikram.rag 217
			count=1;
218
			while ((nextLine = inventoryhealthreportreader.readNext()) != null ) {
8825 vikram.rag 219
				try{
220
					if(count!=1){
221
						//System.out.println(nextLine[1] +" "+ nextLine[31] +" " + nextLine[32] + " " + nextLine[34]);
222
						SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
223
						istFormatter .setLenient(false);
224
						TimeZone zone= TimeZone.getTimeZone("GMT");
225
						istFormatter.setTimeZone(zone);
226
						Date date = istFormatter.parse(nextLine[0]);
227
						Long item_id = Long.parseLong(nextLine[1].replaceAll("FBA",""));
228
						Double ourPrice = null;
229
						Double minFBAPrice= null;
230
						Double minMFNPrice= null;
231
						Double salePrice= null; 
232
						if(nextLine[30].length() >0){
233
							ourPrice = Double.parseDouble(nextLine[30]);
234
							if(itemIdOurPriceMap.containsKey(item_id)){
235
								if(itemIdOurPriceMap.get(item_id).getDate().getTime() < date.getTime()){
236
									PriceAtDate priceAtDate= new PriceAtDate();
237
									priceAtDate.setDate(date);
238
									priceAtDate.setPrice(ourPrice);
239
									itemIdOurPriceMap.put(item_id,priceAtDate);
240
								}
241
							}
242
							else{	
8532 vikram.rag 243
								PriceAtDate priceAtDate= new PriceAtDate();
244
								priceAtDate.setDate(date);
245
								priceAtDate.setPrice(ourPrice);
246
								itemIdOurPriceMap.put(item_id,priceAtDate);
247
							}
8461 vikram.rag 248
						}
8825 vikram.rag 249
						if(nextLine[31].length() >0){
250
							salePrice = Double.parseDouble(nextLine[31]);
251
							if(itemIdSalePriceMap.containsKey(item_id) ){
252
								if(itemIdSalePriceMap.get(item_id).getDate().getTime() < date.getTime()){
253
									PriceAtDate priceAtDate= new PriceAtDate();
254
									priceAtDate.setDate(date);
255
									priceAtDate.setPrice(salePrice);
256
									itemIdSalePriceMap.put(item_id,priceAtDate);
257
								}
258
							}
259
							else{	
8532 vikram.rag 260
								PriceAtDate priceAtDate= new PriceAtDate();
261
								priceAtDate.setDate(date);
262
								priceAtDate.setPrice(salePrice);
263
								itemIdSalePriceMap.put(item_id,priceAtDate);
264
							}
8461 vikram.rag 265
						}
8825 vikram.rag 266
						if(nextLine[32].length() >0){
267
							minFBAPrice = Double.parseDouble(nextLine[32]);
268
							if(itemIdminFBAPriceMap.containsKey(item_id)){
269
								if(itemIdminFBAPriceMap.get(item_id).getDate().getTime() < date.getTime()){
270
									PriceAtDate priceAtDate= new PriceAtDate();
271
									priceAtDate.setDate(date);
272
									priceAtDate.setPrice(minFBAPrice);
273
									itemIdminFBAPriceMap.put(item_id,priceAtDate);
274
								}
275
							}
276
							else{	
8532 vikram.rag 277
								PriceAtDate priceAtDate= new PriceAtDate();
278
								priceAtDate.setDate(date);
279
								priceAtDate.setPrice(minFBAPrice);
280
								itemIdminFBAPriceMap.put(item_id,priceAtDate);
281
							}
8461 vikram.rag 282
						}
8825 vikram.rag 283
						if(nextLine[34].length() >0){
284
							minMFNPrice = Double.parseDouble(nextLine[34]);
285
							if(itemIdminMFNPriceMap.containsKey(item_id)){
286
								if(itemIdminMFNPriceMap.get(item_id).getDate().getTime() < date.getTime()){
287
									PriceAtDate priceAtDate= new PriceAtDate();
288
									priceAtDate.setDate(date);
289
									priceAtDate.setPrice(minMFNPrice);
290
									itemIdminMFNPriceMap.put(item_id,priceAtDate);
291
								}
292
							}
293
							else{	
8532 vikram.rag 294
								PriceAtDate priceAtDate= new PriceAtDate();
295
								priceAtDate.setDate(date);
296
								priceAtDate.setPrice(minMFNPrice);
297
								itemIdminMFNPriceMap.put(item_id,priceAtDate);
298
							}
8461 vikram.rag 299
						}
8451 vikram.rag 300
					}
8363 vikram.rag 301
				}
8825 vikram.rag 302
				catch(Exception e){
303
					e.printStackTrace();
304
				}
8363 vikram.rag 305
				count++;
306
			}
307
			boolean oos;
308
			for (Entry<Date, Map<Long, FbaSalesSnapshot>> entry : orderDateItemIdFbaSaleSnapshotMap.entrySet()){
309
				Date orderDate = entry.getKey();
310
				for(Entry<Long, FbaSalesSnapshot> entry1 :entry.getValue().entrySet()){
9737 vikram.rag 311
					//System.out.println("Item ID is " + entry1.getKey());
8363 vikram.rag 312
					Long inventory = inventoryClient.getAmazonFbaItemInventory(entry1.getKey());
313
 
314
					if(inventory==0 && entry1.getValue().getTotalOrderCount()==0){
315
						oos=true;
316
					}
317
					else{
318
						oos=false;
319
					}
320
					Long item_id = entry1.getKey();
8534 vikram.rag 321
					Amazonlisted amazon_item=catalogClient.getAmazonItemDetails(item_id);
322
					if(amazon_item.getItemid()==0){
323
						continue;
324
					}
9737 vikram.rag 325
					//System.out.println(orderDate +","+entry1.getKey()+","+entry1.getValue()+","+ inventory +","+ oos+","+itemIdSalePriceMap.get(item_id)+","+itemIdminFBAPriceMap.get(item_id)+","+itemIdminMFNPriceMap.get(item_id));
8363 vikram.rag 326
					AmazonFbaSalesSnapshot amazonfbasalessnapshot = new AmazonFbaSalesSnapshot();
327
					amazonfbasalessnapshot.setDateOfSale(orderDate.getTime());
328
					amazonfbasalessnapshot.setItem_id(entry1.getKey());
329
					amazonfbasalessnapshot.setTotalOrderCount(entry1.getValue().getPromotionOrderCount());
330
					amazonfbasalessnapshot.setTotalOrderCount(entry1.getValue().getTotalOrderCount());
331
					amazonfbasalessnapshot.setTotalSale(entry1.getValue().getTotalSale());
332
					amazonfbasalessnapshot.setPromotionSale(entry1.getValue().getTotalPromotionSale());
333
					amazonfbasalessnapshot.setIsOutOfStock(oos);
8461 vikram.rag 334
					if(itemIdSalePriceMap.containsKey(item_id) && itemIdSalePriceMap.get(item_id).getPrice()!=0){
335
						amazonfbasalessnapshot.setSalePrice(itemIdSalePriceMap.get(item_id).getPrice());
8532 vikram.rag 336
						amazonfbasalessnapshot.setSalePriceSnapshotDate(itemIdSalePriceMap.get(item_id).getDate().getTime());
8363 vikram.rag 337
					}
338
					else{
8460 vikram.rag 339
						amazonfbasalessnapshot.setSalePrice(0.0);
8532 vikram.rag 340
						amazonfbasalessnapshot.setSalePriceSnapshotDate(0);
8363 vikram.rag 341
					}
8461 vikram.rag 342
					if(itemIdminMFNPriceMap.containsKey(item_id) && itemIdminMFNPriceMap.get(item_id).getPrice()!=0){
343
						amazonfbasalessnapshot.setMinMfnPrice(itemIdminMFNPriceMap.get(item_id).getPrice());
8532 vikram.rag 344
						amazonfbasalessnapshot.setMinMfnPriceSnapshotDate(itemIdminMFNPriceMap.get(item_id).getDate().getTime());
8363 vikram.rag 345
					}
346
					else{
8460 vikram.rag 347
						amazonfbasalessnapshot.setMinMfnPrice(0.0);
8532 vikram.rag 348
						amazonfbasalessnapshot.setMinMfnPriceSnapshotDate(0);
8363 vikram.rag 349
					}
8461 vikram.rag 350
					if(itemIdminFBAPriceMap.containsKey(item_id) && itemIdminFBAPriceMap.get(item_id).getPrice()!=0){
351
						amazonfbasalessnapshot.setMinFbaPrice(itemIdminFBAPriceMap.get(item_id).getPrice());
8532 vikram.rag 352
						amazonfbasalessnapshot.setMinFbaPriceSnapshotDate(itemIdminFBAPriceMap.get(item_id).getDate().getTime());
8363 vikram.rag 353
					}
354
					else{
8460 vikram.rag 355
						amazonfbasalessnapshot.setMinFbaPrice(0.0);
8532 vikram.rag 356
						amazonfbasalessnapshot.setMinFbaPriceSnapshotDate(0);
8363 vikram.rag 357
					}
8461 vikram.rag 358
					if(itemIdOurPriceMap.containsKey(item_id) && itemIdOurPriceMap.get(item_id).getPrice()!=0){
359
						amazonfbasalessnapshot.setOurPrice(itemIdOurPriceMap.get(item_id).getPrice());
8532 vikram.rag 360
						amazonfbasalessnapshot.setOurPriceSnapshotDate(itemIdOurPriceMap.get(item_id).getDate().getTime());
8447 vikram.rag 361
					}
362
					else{
8460 vikram.rag 363
						amazonfbasalessnapshot.setOurPrice(amazon_item.getFbaPrice());
8532 vikram.rag 364
						amazonfbasalessnapshot.setOurPriceSnapshotDate(0);
8447 vikram.rag 365
					}
9739 vikram.rag 366
					if(amazonfbasalessnapshot.getTotalOrderCount() > 0){
367
						Date date =  new Date(amazonfbasalessnapshot.getDateOfSale());
368
						SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); 
369
						System.out.println(" Item details are " + sdf.format(date) + " "+ amazonfbasalessnapshot.getItem_id() + " " + amazonfbasalessnapshot.getTotalOrderCount());
370
					}
8363 vikram.rag 371
					amazonfbasalessnapshot.setAmazonFbaInventory(inventory);
372
					transactionClient.addOrUpdateAmazonFbaSalesSnapshot(amazonfbasalessnapshot);
373
				}
374
			}
9256 vikram.rag 375
		} catch (IOException e) {
8363 vikram.rag 376
			// TODO Auto-generated catch block
377
			e.printStackTrace();
378
		} catch (ParseException e) {
379
			// TODO Auto-generated catch block
380
			e.printStackTrace();
381
		} catch (TException e) {
382
			// TODO Auto-generated catch block
383
			e.printStackTrace();
9256 vikram.rag 384
		}
385
		catch (Exception e) {
8825 vikram.rag 386
			// TODO Auto-generated catch block
387
			e.printStackTrace();
8363 vikram.rag 388
		}
8825 vikram.rag 389
 
8363 vikram.rag 390
	}
391
 
392
	public static Double getPercentageDifferenceFromMinimumPrice(AmazonFbaSalesSnapshot snapshot){
393
		Double minPrice = getMinimumSalePriceOnAmazonFBA(snapshot);
8468 vikram.rag 394
		return (((minPrice - snapshot.getOurPrice())/snapshot.getOurPrice())*100);
8363 vikram.rag 395
 
396
	}
397
 
398
	public static Double getMinimumSalePriceOnAmazonFBA(AmazonFbaSalesSnapshot snapshot){
399
		if(snapshot.getMinFbaPrice() > snapshot.getMinMfnPrice()){
400
			return snapshot.getMinMfnPrice();
401
		}
402
		else{
403
			return snapshot.getMinFbaPrice();
404
		}
405
	}
406
 
407
}