Subversion Repositories SmartDukaan

Rev

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