Subversion Repositories SmartDukaan

Rev

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