Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
8285 kshitij.so 1
package com.amazonaws.mws.samples;
2
 
3
import in.shop2020.model.v1.catalog.Amazonlisted;
4
import in.shop2020.model.v1.catalog.CatalogServiceException;
8363 vikram.rag 5
import in.shop2020.model.v1.catalog.Category;
8285 kshitij.so 6
import in.shop2020.model.v1.catalog.Item;
7
import in.shop2020.model.v1.inventory.AmazonFbaInventorySnapshot;
8363 vikram.rag 8
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
8285 kshitij.so 9
import in.shop2020.model.v1.inventory.InventoryServiceException;
8363 vikram.rag 10
import in.shop2020.model.v1.inventory.ItemInventory;
8285 kshitij.so 11
import in.shop2020.model.v1.inventory.Vendor;
12
import in.shop2020.model.v1.inventory.VendorItemPricing;
13
import in.shop2020.model.v1.order.AmazonFbaSalesSnapshot;
14
import in.shop2020.model.v1.order.TransactionService.Client;
15
import in.shop2020.thrift.clients.CatalogClient;
16
import in.shop2020.thrift.clients.InventoryClient;
17
import in.shop2020.thrift.clients.TransactionClient;
18
import in.shop2020.utils.GmailUtils;
19
import java.io.FileNotFoundException;
20
import java.io.FileOutputStream;
21
import java.io.FileReader;
22
import java.io.IOException;
23
import java.text.ParseException;
24
import java.text.SimpleDateFormat;
25
import java.util.ArrayList;
26
import java.util.Date;
27
import java.util.HashMap;
28
import java.util.List;
29
import java.util.Map;
30
import java.util.Map.Entry;
31
import java.util.TimeZone;
32
 
8363 vikram.rag 33
import org.apache.poi.hssf.usermodel.HSSFCell;
34
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
35
import org.apache.poi.hssf.usermodel.HSSFFont;
8285 kshitij.so 36
import org.apache.poi.hssf.usermodel.HSSFRow;
37
import org.apache.poi.hssf.usermodel.HSSFSheet;
38
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
8363 vikram.rag 39
import org.apache.poi.hssf.util.HSSFColor;
8285 kshitij.so 40
import org.apache.thrift.TException;
41
 
42
import au.com.bytecode.opencsv.CSVReader;
43
 
44
 
45
public class CreateSendFBAStockEstimation {
8288 kshitij.so 46
	final public static String AMAZON_FBA_SHEET = "/home/FBA-Stock-File.xls";
8293 kshitij.so 47
 
8288 kshitij.so 48
	public static void main(String... args){
8285 kshitij.so 49
		TransactionClient transactionServiceClient = null;
50
		try {
51
			transactionServiceClient = new TransactionClient();
52
		} catch (Exception e) {
53
			// TODO Auto-generated catch block
54
			e.printStackTrace();
55
		}	
8293 kshitij.so 56
 
8285 kshitij.so 57
		in.shop2020.model.v1.order.TransactionService.Client transactionClient   = transactionServiceClient.getClient();
58
		List<AmazonFbaSalesSnapshot> salessnapshots = null;
59
		try {
8363 vikram.rag 60
			salessnapshots = transactionClient.getAmazonFbaSalesSnapshotForDays(4);
8285 kshitij.so 61
		} catch (TException e) {
62
			// TODO Auto-generated catch block
63
			e.printStackTrace();
64
		}
8363 vikram.rag 65
		Map<Long,List<FbaSalesSnapshot>> itemId5daysSale = new HashMap<Long,List<FbaSalesSnapshot>>();
8285 kshitij.so 66
		AmazonFbaSalesSnapshot snapshot;
67
		for(AmazonFbaSalesSnapshot salessnapshot:salessnapshots){
68
			try {
8363 vikram.rag 69
				FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
8285 kshitij.so 70
				if(itemId5daysSale.containsKey(salessnapshot.getItem_id())){
8363 vikram.rag 71
					if(!salessnapshot.isIsOutOfStock()){
72
						fbaSalesSnapshot.setPromotionOrderCount(salessnapshot.getPromotionOrderCount());
73
						fbaSalesSnapshot.setTotalOrderCount(salessnapshot.getTotalOrderCount());
74
						fbaSalesSnapshot.setTotalPromotionSale((float) salessnapshot.getPromotionSale());
75
						fbaSalesSnapshot.setTotalSale((float) salessnapshot.getTotalSale());
76
					}
77
					else{
78
						fbaSalesSnapshot.setPromotionOrderCount(-1);
79
						fbaSalesSnapshot.setTotalOrderCount(-1);
80
						fbaSalesSnapshot.setTotalPromotionSale((float) 0);
81
						fbaSalesSnapshot.setTotalSale((float) 0);
82
					}
83
					itemId5daysSale.get(salessnapshot.getItem_id()).add(fbaSalesSnapshot);
8285 kshitij.so 84
				}
85
				else{
8363 vikram.rag 86
					List<FbaSalesSnapshot> last5daysSale = new ArrayList<FbaSalesSnapshot>();
87
					if(!salessnapshot.isIsOutOfStock()){
88
						fbaSalesSnapshot.setPromotionOrderCount(salessnapshot.getPromotionOrderCount());
89
						fbaSalesSnapshot.setTotalOrderCount(salessnapshot.getTotalOrderCount());
90
						fbaSalesSnapshot.setTotalPromotionSale((float) salessnapshot.getPromotionSale());
91
						fbaSalesSnapshot.setTotalSale((float) salessnapshot.getTotalSale());
8285 kshitij.so 92
					}
93
					else{ 
8363 vikram.rag 94
						fbaSalesSnapshot.setPromotionOrderCount(-1);
95
						fbaSalesSnapshot.setTotalOrderCount(-1);
96
						fbaSalesSnapshot.setTotalPromotionSale((float) 0);
97
						fbaSalesSnapshot.setTotalSale((float) 0);
8285 kshitij.so 98
					}
8363 vikram.rag 99
					last5daysSale.add(fbaSalesSnapshot);
8285 kshitij.so 100
					itemId5daysSale.put(salessnapshot.getItem_id(),last5daysSale);
101
				}
8293 kshitij.so 102
			} catch (Exception e) {
8285 kshitij.so 103
				// TODO Auto-generated catch block
104
				e.printStackTrace();
105
			}
8293 kshitij.so 106
		}	
107
 
108
		//System.out.println("ItemID , Last Five Days Sale , Product Name , TP , NLC , STICKY , Preferred Vendor , Qty , Min AFN , Min MFN , SP ,Total Amount");
109
		CatalogClient catalogServiceClient = null;
110
		InventoryClient inventoryServiceClient = null;
111
		try {
112
			inventoryServiceClient = new InventoryClient();
113
			//catalogServiceClient = new CatalogClient();
114
			catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port");
115
		} catch (Exception e) {
116
			// TODO Auto-generated catch block
117
			e.printStackTrace();
118
		}	
119
		in.shop2020.model.v1.catalog.CatalogService.Client catalogClient   = catalogServiceClient.getClient();
120
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
121
		HSSFWorkbook hwb=new HSSFWorkbook();
122
		HSSFSheet sheet =  hwb.createSheet("FBA-STOCK-SHEET");
123
		HSSFRow rowhead=   sheet.createRow((short)0);
124
		rowhead.createCell((short) 0).setCellValue("ITEM-ID");
8363 vikram.rag 125
		rowhead.createCell((short) 1).setCellValue("BRAND");
126
		rowhead.createCell((short) 2).setCellValue("CATEGORY");
127
		rowhead.createCell((short) 3).setCellValue("PRODUCT-GROUP");
128
		rowhead.createCell((short) 4).setCellValue("PRODUCT-NAME");
8293 kshitij.so 129
		rowhead.createCell((short) 5).setCellValue("IS-STICKY");
130
		rowhead.createCell((short) 6).setCellValue("PREFERRED-VENDOR");
8363 vikram.rag 131
		rowhead.createCell((short) 7).setCellValue("TRANSFER-PRICE");
132
		rowhead.createCell((short) 8).setCellValue("NLC");
133
		rowhead.createCell((short) 9).setCellValue("LAST 5 DAYS TOTAL SALE");
134
		rowhead.createCell((short) 10).setCellValue("TOTAL ASP");
135
		rowhead.createCell((short) 11).setCellValue("LAST 5 DAYS PROMOTION SALE");
136
		rowhead.createCell((short) 12).setCellValue("PROMOTION ASP");
137
		rowhead.createCell((short) 13).setCellValue("MIN-AFN-PRICE");
138
		rowhead.createCell((short) 14).setCellValue("MIN-MFN-PRICE");
139
		rowhead.createCell((short) 15).setCellValue("OUR-PRICE");
140
		rowhead.createCell((short) 16).setCellValue("STOCK-IN-MUMBAI");
141
		rowhead.createCell((short) 17).setCellValue("AVERAGE-SALE");
142
		rowhead.createCell((short) 18).setCellValue("DAYS-OF-STOCK");
143
		rowhead.createCell((short) 19).setCellValue("REQUIRED STOCK");
144
		rowhead.createCell((short) 20).setCellValue("CURRENT-STOCK (FBA)");
145
		rowhead.createCell((short) 21).setCellValue("P.O");
146
		rowhead.createCell((short) 22).setCellValue("P.O AMOUNT");
147
		rowhead.createCell((short) 23).setCellValue("VARIANCE-FROM-CHEAPEST");
148
		rowhead.createCell((short) 24).setCellValue("DAYS-OF-STOCK-RULE");
8293 kshitij.so 149
		int iterator=1;
8363 vikram.rag 150
		Map<Long,ItemInventory> allItemsAvailability = null;
151
		List<Long> WarehouseIdsForMumbaiLocation = null;
152
		try {
153
			WarehouseIdsForMumbaiLocation = inventoryClient.getOursGoodWarehouseIdsForLocation(1);
154
			allItemsAvailability =	inventoryClient.getInventorySnapshot(0);
155
		} catch (TException e1) {
156
			// TODO Auto-generated catch block
157
			e1.printStackTrace();
158
		}
159
		for(Entry<Long, List<FbaSalesSnapshot>> entry : itemId5daysSale.entrySet()){
8293 kshitij.so 160
			Item item = null;
161
			VendorItemPricing vip=null;
162
			Vendor vendor = null;
8363 vikram.rag 163
			Category category = null;
8285 kshitij.so 164
			try {
8363 vikram.rag 165
				System.out.println("Item ID is " + entry.getKey());
8293 kshitij.so 166
				item = catalogClient.getItem(entry.getKey());
8363 vikram.rag 167
				if(item.getId()==0){
168
					continue;
169
				}
170
				category = catalogClient.getCategory(item.getCategory());
171
				//System.out.println("Preferred Vendor is " + item.getPreferredVendor());
172
				if(item.getPreferredVendor()!=0){
173
					vip = inventoryClient.getItemPricing(item.getId(),item.getPreferredVendor());
174
					vendor = inventoryClient.getVendor(item.getPreferredVendor());
175
				}
8293 kshitij.so 176
			} catch (CatalogServiceException e) {
8285 kshitij.so 177
				// TODO Auto-generated catch block
178
				e.printStackTrace();
8293 kshitij.so 179
			} catch (TException e) {
8285 kshitij.so 180
				// TODO Auto-generated catch block
181
				e.printStackTrace();
8293 kshitij.so 182
			} catch (InventoryServiceException e) {
183
				// TODO Auto-generated catch block
184
				e.printStackTrace();
8285 kshitij.so 185
			}
8363 vikram.rag 186
 
187
			HSSFRow row=   sheet.createRow((short)iterator);
188
			HSSFCell cell = row.createCell((short) 0);
189
			cell.setCellValue(entry.getKey());
190
			HSSFCellStyle style = hwb.createCellStyle();
191
			style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
192
			HSSFFont font = hwb.createFont();
193
			style.setFillForegroundColor(HSSFColor.WHITE.index);
194
			font.setColor(HSSFColor.BLACK.index);
195
			style.setFont(font);
196
			cell.setCellStyle(style);
197
			cell.setCellValue(entry.getKey());
198
			int count =1;
199
			Double promotion_sale=0.0;
200
			Double total_sale=0.0;
201
			float avg_promotion_sale=0;
202
			float avg_total_sale=0;
203
			int total_sale_days=0;
204
			int promotion_sale_days=0;
205
			StringBuilder total_days_sale = new StringBuilder();
206
			StringBuilder promotion_days_sale = new StringBuilder();
207
			for(FbaSalesSnapshot sale:entry.getValue()){
208
				if(sale.getPromotionOrderCount()!=-1){
209
					promotion_days_sale.append(sale.getPromotionOrderCount());
210
					avg_promotion_sale=avg_promotion_sale+sale.getPromotionOrderCount();
211
					promotion_sale = promotion_sale+sale.getTotalPromotionSale();
212
						promotion_sale_days++;
213
				}
214
				else{
215
					promotion_days_sale.append("X");
216
				}
217
				if(count != entry.getValue().size()){
218
					promotion_days_sale.append("-");
219
				}
220
				if(sale.getTotalOrderCount()!=-1){
221
					total_days_sale.append(sale.getTotalOrderCount());
222
					avg_total_sale=avg_total_sale+sale.getTotalOrderCount();
223
					total_sale = total_sale+sale.getTotalSale();
224
					total_sale_days++;
225
				}
226
				else{
227
					total_days_sale.append("X");
228
				}
229
				if(count != entry.getValue().size()){
230
					total_days_sale.append("-");
231
				}
232
				count++;
233
			}
234
			float promotion_sale_avg=0;
235
			float total_sale_avg = 0;
236
			if(promotion_sale_days!=0){
237
				promotion_sale_avg = avg_promotion_sale/promotion_sale_days;
238
			}
239
			if(total_sale_days!=0){
240
				total_sale_avg=avg_total_sale/total_sale_days;
241
			}
8293 kshitij.so 242
			AmazonFbaSalesSnapshot latest_snapshot = null;
8363 vikram.rag 243
			long availability=0;
244
			double percent_diff=0;
8285 kshitij.so 245
			try {
8293 kshitij.so 246
				latest_snapshot = transactionClient.getAmazonFbaSalesLatestSnapshotForItem(entry.getKey());
8363 vikram.rag 247
				availability = inventoryClient.getAmazonFbaItemInventory(entry.getKey());
8293 kshitij.so 248
			} catch (TException e) {
8285 kshitij.so 249
				// TODO Auto-generated catch block
250
				e.printStackTrace();
251
			}
8363 vikram.rag 252
			double asp_total=0;
253
			if(avg_total_sale!=0){
254
				asp_total = total_sale/avg_total_sale;
255
			}
8293 kshitij.so 256
			int days_of_stock=0;
8363 vikram.rag 257
			String days_of_stock_rule= new String();
8293 kshitij.so 258
			if(latest_snapshot.getMinFbaPrice()==0 ||  latest_snapshot.getMinMfnPrice()==0){
259
				days_of_stock=0;
8363 vikram.rag 260
				days_of_stock_rule = "Min Prices not Available";
8293 kshitij.so 261
			}
262
			else{
8363 vikram.rag 263
				percent_diff = getPercentageDifferenceFromMinimumPrice(latest_snapshot);
264
				if(latest_snapshot.getSalePrice() <= latest_snapshot.getMinFbaPrice() &&  latest_snapshot.getSalePrice() <= latest_snapshot.getMinMfnPrice()){
265
					if(percent_diff >= 0 && latest_snapshot.getSalePrice()<=asp_total){
266
						days_of_stock = 15;
267
						days_of_stock_rule = "Cheapest 15 days";
268
						style.setFillForegroundColor(HSSFColor.GREEN.index);
269
						///GREEN
270
					}
271
					else if(percent_diff >= 0 && latest_snapshot.getSalePrice()>asp_total){
272
						days_of_stock = 7;
273
						days_of_stock_rule = "Cheapest Price Increased 7 days";
274
						style.setFillForegroundColor(HSSFColor.GREEN.index);
275
						///GREEN
276
					}
8293 kshitij.so 277
				}
8363 vikram.rag 278
				else if(latest_snapshot.getSalePrice() > latest_snapshot.getMinFbaPrice() &&  latest_snapshot.getSalePrice() > latest_snapshot.getMinMfnPrice()){
279
					if(percent_diff > -1 && percent_diff < 0){
280
						days_of_stock = 4;
281
						days_of_stock_rule = "Slightly Expensive (diff 0% to 1 %) 4 days";
282
						style.setFillForegroundColor(HSSFColor.YELLOW.index);
283
						///YELLOW
284
					}
285
					else{
286
						days_of_stock = 0;
287
						days_of_stock_rule = "Non Competitive 0 days";
288
						style.setFillForegroundColor(HSSFColor.RED.index);
289
						////RED
290
					}
291
				}else if(latest_snapshot.getSalePrice() < latest_snapshot.getMinFbaPrice() &&  latest_snapshot.getSalePrice() > latest_snapshot.getMinMfnPrice()){
292
					if(((latest_snapshot.getMinFbaPrice() - latest_snapshot.getSalePrice())/latest_snapshot.getSalePrice())*100 >=0 && ((latest_snapshot.getMinMfnPrice() - latest_snapshot.getSalePrice())/latest_snapshot.getSalePrice())*100 <=-2){
293
						days_of_stock = 4;
294
						days_of_stock_rule = "Cheapest  AFN but not MFN 4 days";
295
						style.setFillForegroundColor(HSSFColor.YELLOW.index);
296
						////YELLOW
297
					}
298
					else{
299
						days_of_stock = 0;
300
						days_of_stock_rule = "Non Competitive 0 days";
301
						style.setFillForegroundColor(HSSFColor.RED.index);
302
						///RED
303
					}
8293 kshitij.so 304
				}
8363 vikram.rag 305
			}
306
 
307
 
308
			rowhead.createCell((short) 23).setCellValue("VARIANCE-FROM-CHEAPEST");
309
			rowhead.createCell((short) 24).setCellValue("DAYS-OF-STOCK-RULE");
310
			row.createCell((short) 1).setCellValue(item.getBrand());
311
			row.createCell((short) 2).setCellValue(category.getLabel());
312
			row.createCell((short) 3).setCellValue(item.getProductGroup());
313
			row.createCell((short) 4).setCellValue(item.getModelName()+" " + item.getModelNumber() + " " +item.getColor());
314
			if(item.isIsWarehousePreferenceSticky()){
315
				row.createCell((short) 5).setCellValue("YES");
316
			}
317
			else{
318
				row.createCell((short) 5).setCellValue("NO");
319
			}
320
			if(vendor!=null){
321
				row.createCell((short) 6).setCellValue(vendor.getName());
322
			}
323
			else{
324
				row.createCell((short) 6).setCellValue("Preferred Vendor Not Set");
325
			}
326
			if(vip!=null){
327
				row.createCell((short) 7).setCellValue(vip.getTransferPrice());
328
				row.createCell((short) 8).setCellValue(vip.getNlc());
8293 kshitij.so 329
				}
8363 vikram.rag 330
				else{
331
					row.createCell((short) 7).setCellValue("Preferred Vendor Not Set");
332
					row.createCell((short) 8).setCellValue("Preferred Vendor Not Set");
333
			}
334
			row.createCell((short) 9).setCellValue(total_days_sale.toString());
335
			if(avg_total_sale!=0){
336
 
337
				row.createCell((short) 10).setCellValue(String.format("%.2f", asp_total));
338
			}
339
			else{
340
				row.createCell((short) 10).setCellValue(0);	
341
			}
342
			row.createCell((short) 11).setCellValue(promotion_days_sale.toString());
343
			if(avg_promotion_sale!=0){
344
			double asp_promotion = promotion_sale/avg_promotion_sale;
345
			row.createCell((short) 12).setCellValue(String.format("%.2f",asp_promotion));
346
			}
347
			else{
348
				row.createCell((short) 12).setCellValue(0);
349
			}
350
			if(latest_snapshot.getMinFbaPrice()!=0){
351
				row.createCell((short) 13).setCellValue(latest_snapshot.getMinFbaPrice());
352
			}
353
			else{
354
				row.createCell((short) 13).setCellValue("Not Available");
355
			}
356
			if(latest_snapshot.getMinFbaPrice()!=0){
357
				row.createCell((short) 14).setCellValue(latest_snapshot.getMinMfnPrice());	
358
			}
359
			else{
360
				row.createCell((short) 14).setCellValue("Not Available");
361
			}
362
 
363
			row.createCell((short) 15).setCellValue(latest_snapshot.getSalePrice());
364
			long inv_mum=0;
365
			if(allItemsAvailability.containsKey(entry.getKey())){
366
				ItemInventory itemInventory = allItemsAvailability.get(entry.getKey());
367
				Map<Long, Long> itemAvailability = itemInventory.getAvailability();
368
				Map<Long, Long> itemReserved = itemInventory.getReserved();
369
				Map<Long, Long> itemHeld = itemInventory.getHeld();
370
				for (Map.Entry<Long,Long> itementry : itemAvailability.entrySet()) {
371
					if(WarehouseIdsForMumbaiLocation.contains(itementry.getKey())){
372
						System.out.println(itemAvailability.get(itementry.getKey()) - itemReserved.get(itementry.getKey()) - itemHeld.get(itementry.getKey()));
373
						inv_mum =  inv_mum + itemAvailability.get(itementry.getKey()) - itemReserved.get(itementry.getKey()) - itemHeld.get(itementry.getKey());    	
374
					}
8293 kshitij.so 375
				}
8363 vikram.rag 376
				if(inv_mum!=0){
377
					row.createCell((short) 16).setCellValue(inv_mum);
378
				}
8293 kshitij.so 379
				else{
8363 vikram.rag 380
					row.createCell((short) 16).setCellValue(0);
8293 kshitij.so 381
				}
382
			}
8363 vikram.rag 383
			else{
384
				row.createCell((short) 16).setCellValue(0);
385
			}
386
 
387
			row.createCell((short) 17).setCellValue(String.format("%.2f",total_sale_avg));
388
 
389
			row.createCell((short) 18).setCellValue(days_of_stock);
390
 
391
			int total_stock = (int) (total_sale_avg*days_of_stock);
392
 
393
			row.createCell((short) 19).setCellValue(total_stock);
394
 
395
			row.createCell((short) 20).setCellValue(availability);
396
 
397
			long po = total_stock - availability;
398
 
399
			row.createCell((short) 21).setCellValue(po);
400
 
401
			if(item.getPreferredVendor()!=0){
402
				double amount = total_sale_avg*days_of_stock*vip.getNlc();
403
				row.createCell((short) 22).setCellValue(amount);
404
			}
405
			else{
406
				row.createCell((short) 22).setCellValue(0.0);
407
			}
408
			row.createCell((short) 23).setCellValue(String.format("%.2f", percent_diff)+"%");
409
 
410
			row.createCell((short) 24).setCellValue(days_of_stock_rule);
8285 kshitij.so 411
 
8293 kshitij.so 412
			iterator++;
413
 
8285 kshitij.so 414
		}
8293 kshitij.so 415
 
416
		FileOutputStream fileOut = null;
417
		try {
418
			fileOut = new FileOutputStream(AMAZON_FBA_SHEET);
419
		} catch (FileNotFoundException e) {
420
			// TODO Auto-generated catch block
421
			e.printStackTrace();
422
		}
423
		try {
424
			hwb.write(fileOut);
425
		} catch (IOException e) {
426
			// TODO Auto-generated catch block
427
			e.printStackTrace();
428
		}
429
		try {
430
			fileOut.close();
431
		} catch (IOException e) {
432
			// TODO Auto-generated catch block
433
			e.printStackTrace();
434
		}
435
 
8285 kshitij.so 436
		String emailFromAddress = "build@shop2020.in";
437
		String password = "cafe@nes";
8363 vikram.rag 438
		String[] sendTo = new String[]{ "vikram.raghav@shop2020.in", "rajveer.singh@shop2020.in","rajneesh.arora@shop2020.in" };
439
		//String[] sendTo = new String[]{ "vikram.raghav@shop2020.in"};
8293 kshitij.so 440
		String emailSubjectTxt = "FBA Stock Estimation Sheet";
441
 
8285 kshitij.so 442
		try {
8293 kshitij.so 443
			GmailUtils mailer = new GmailUtils();
8363 vikram.rag 444
			mailer.sendSSLMessage(sendTo, emailSubjectTxt, "", emailFromAddress, password, "/home/vikram/FBA-Stock-File.xls");
8285 kshitij.so 445
		}
446
		catch (Exception ex) {
447
			ex.printStackTrace();
448
		}
449
 
450
	}
8293 kshitij.so 451
 
8285 kshitij.so 452
	public static Double getPercentageDifferenceFromMinimumPrice(AmazonFbaSalesSnapshot snapshot){
453
		Double minPrice = getMinimumSalePriceOnAmazonFBA(snapshot);
8293 kshitij.so 454
		return (((minPrice - snapshot.getSalePrice())/snapshot.getSalePrice())*100);
455
 
8285 kshitij.so 456
	}
8293 kshitij.so 457
 
8285 kshitij.so 458
	public static Double getMinimumSalePriceOnAmazonFBA(AmazonFbaSalesSnapshot snapshot){
459
		if(snapshot.getMinFbaPrice() > snapshot.getMinMfnPrice()){
460
			return snapshot.getMinMfnPrice();
461
		}
462
		else{
463
			return snapshot.getMinFbaPrice();
464
		}
465
	}
466
 
467
}