Subversion Repositories SmartDukaan

Rev

Rev 8378 | Rev 12619 | 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 {
8413 vikram.rag 60
			salessnapshots = transactionClient.getAmazonFbaSalesSnapshotForDays(5);
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()){
8378 vikram.rag 265
					if(percent_diff >= 0 && latest_snapshot.getSalePrice()<=asp_total ){
8363 vikram.rag 266
						days_of_stock = 15;
267
						days_of_stock_rule = "Cheapest 15 days";
268
						style.setFillForegroundColor(HSSFColor.GREEN.index);
269
						///GREEN
270
					}
8378 vikram.rag 271
					else if(percent_diff >= 0 && latest_snapshot.getSalePrice()>asp_total && asp_total!=0){
8363 vikram.rag 272
						days_of_stock = 7;
273
						days_of_stock_rule = "Cheapest Price Increased 7 days";
274
						style.setFillForegroundColor(HSSFColor.GREEN.index);
275
						///GREEN
276
					}
8378 vikram.rag 277
					else if(percent_diff >= 0 && latest_snapshot.getSalePrice()>asp_total){
278
						days_of_stock = 0;
279
					days_of_stock_rule = "Cheapest but no Sale";
280
					style.setFillForegroundColor(HSSFColor.RED.index);
281
					///RED
282
					}
8293 kshitij.so 283
				}
8363 vikram.rag 284
				else if(latest_snapshot.getSalePrice() > latest_snapshot.getMinFbaPrice() &&  latest_snapshot.getSalePrice() > latest_snapshot.getMinMfnPrice()){
285
					if(percent_diff > -1 && percent_diff < 0){
286
						days_of_stock = 4;
287
						days_of_stock_rule = "Slightly Expensive (diff 0% to 1 %) 4 days";
288
						style.setFillForegroundColor(HSSFColor.YELLOW.index);
289
						///YELLOW
290
					}
291
					else{
292
						days_of_stock = 0;
293
						days_of_stock_rule = "Non Competitive 0 days";
294
						style.setFillForegroundColor(HSSFColor.RED.index);
295
						////RED
296
					}
297
				}else if(latest_snapshot.getSalePrice() < latest_snapshot.getMinFbaPrice() &&  latest_snapshot.getSalePrice() > latest_snapshot.getMinMfnPrice()){
298
					if(((latest_snapshot.getMinFbaPrice() - latest_snapshot.getSalePrice())/latest_snapshot.getSalePrice())*100 >=0 && ((latest_snapshot.getMinMfnPrice() - latest_snapshot.getSalePrice())/latest_snapshot.getSalePrice())*100 <=-2){
299
						days_of_stock = 4;
300
						days_of_stock_rule = "Cheapest  AFN but not MFN 4 days";
301
						style.setFillForegroundColor(HSSFColor.YELLOW.index);
302
						////YELLOW
303
					}
304
					else{
305
						days_of_stock = 0;
306
						days_of_stock_rule = "Non Competitive 0 days";
307
						style.setFillForegroundColor(HSSFColor.RED.index);
308
						///RED
309
					}
8293 kshitij.so 310
				}
8363 vikram.rag 311
			}
312
 
313
 
314
			rowhead.createCell((short) 23).setCellValue("VARIANCE-FROM-CHEAPEST");
315
			rowhead.createCell((short) 24).setCellValue("DAYS-OF-STOCK-RULE");
316
			row.createCell((short) 1).setCellValue(item.getBrand());
317
			row.createCell((short) 2).setCellValue(category.getLabel());
318
			row.createCell((short) 3).setCellValue(item.getProductGroup());
319
			row.createCell((short) 4).setCellValue(item.getModelName()+" " + item.getModelNumber() + " " +item.getColor());
320
			if(item.isIsWarehousePreferenceSticky()){
321
				row.createCell((short) 5).setCellValue("YES");
322
			}
323
			else{
324
				row.createCell((short) 5).setCellValue("NO");
325
			}
326
			if(vendor!=null){
327
				row.createCell((short) 6).setCellValue(vendor.getName());
328
			}
329
			else{
330
				row.createCell((short) 6).setCellValue("Preferred Vendor Not Set");
331
			}
332
			if(vip!=null){
333
				row.createCell((short) 7).setCellValue(vip.getTransferPrice());
334
				row.createCell((short) 8).setCellValue(vip.getNlc());
8293 kshitij.so 335
				}
8363 vikram.rag 336
				else{
337
					row.createCell((short) 7).setCellValue("Preferred Vendor Not Set");
338
					row.createCell((short) 8).setCellValue("Preferred Vendor Not Set");
339
			}
340
			row.createCell((short) 9).setCellValue(total_days_sale.toString());
341
			if(avg_total_sale!=0){
342
 
343
				row.createCell((short) 10).setCellValue(String.format("%.2f", asp_total));
344
			}
345
			else{
346
				row.createCell((short) 10).setCellValue(0);	
347
			}
348
			row.createCell((short) 11).setCellValue(promotion_days_sale.toString());
349
			if(avg_promotion_sale!=0){
350
			double asp_promotion = promotion_sale/avg_promotion_sale;
351
			row.createCell((short) 12).setCellValue(String.format("%.2f",asp_promotion));
352
			}
353
			else{
354
				row.createCell((short) 12).setCellValue(0);
355
			}
356
			if(latest_snapshot.getMinFbaPrice()!=0){
357
				row.createCell((short) 13).setCellValue(latest_snapshot.getMinFbaPrice());
358
			}
359
			else{
360
				row.createCell((short) 13).setCellValue("Not Available");
361
			}
362
			if(latest_snapshot.getMinFbaPrice()!=0){
363
				row.createCell((short) 14).setCellValue(latest_snapshot.getMinMfnPrice());	
364
			}
365
			else{
366
				row.createCell((short) 14).setCellValue("Not Available");
367
			}
368
 
369
			row.createCell((short) 15).setCellValue(latest_snapshot.getSalePrice());
370
			long inv_mum=0;
371
			if(allItemsAvailability.containsKey(entry.getKey())){
372
				ItemInventory itemInventory = allItemsAvailability.get(entry.getKey());
373
				Map<Long, Long> itemAvailability = itemInventory.getAvailability();
374
				Map<Long, Long> itemReserved = itemInventory.getReserved();
375
				Map<Long, Long> itemHeld = itemInventory.getHeld();
376
				for (Map.Entry<Long,Long> itementry : itemAvailability.entrySet()) {
377
					if(WarehouseIdsForMumbaiLocation.contains(itementry.getKey())){
378
						System.out.println(itemAvailability.get(itementry.getKey()) - itemReserved.get(itementry.getKey()) - itemHeld.get(itementry.getKey()));
379
						inv_mum =  inv_mum + itemAvailability.get(itementry.getKey()) - itemReserved.get(itementry.getKey()) - itemHeld.get(itementry.getKey());    	
380
					}
8293 kshitij.so 381
				}
8363 vikram.rag 382
				if(inv_mum!=0){
383
					row.createCell((short) 16).setCellValue(inv_mum);
384
				}
8293 kshitij.so 385
				else{
8363 vikram.rag 386
					row.createCell((short) 16).setCellValue(0);
8293 kshitij.so 387
				}
388
			}
8363 vikram.rag 389
			else{
390
				row.createCell((short) 16).setCellValue(0);
391
			}
392
 
393
			row.createCell((short) 17).setCellValue(String.format("%.2f",total_sale_avg));
394
 
395
			row.createCell((short) 18).setCellValue(days_of_stock);
396
 
397
			int total_stock = (int) (total_sale_avg*days_of_stock);
398
 
399
			row.createCell((short) 19).setCellValue(total_stock);
400
 
401
			row.createCell((short) 20).setCellValue(availability);
402
 
403
			long po = total_stock - availability;
404
 
405
			row.createCell((short) 21).setCellValue(po);
406
 
407
			if(item.getPreferredVendor()!=0){
408
				double amount = total_sale_avg*days_of_stock*vip.getNlc();
409
				row.createCell((short) 22).setCellValue(amount);
410
			}
411
			else{
412
				row.createCell((short) 22).setCellValue(0.0);
413
			}
414
			row.createCell((short) 23).setCellValue(String.format("%.2f", percent_diff)+"%");
415
 
416
			row.createCell((short) 24).setCellValue(days_of_stock_rule);
8285 kshitij.so 417
 
8293 kshitij.so 418
			iterator++;
419
 
8285 kshitij.so 420
		}
8293 kshitij.so 421
 
422
		FileOutputStream fileOut = null;
423
		try {
424
			fileOut = new FileOutputStream(AMAZON_FBA_SHEET);
425
		} catch (FileNotFoundException e) {
426
			// TODO Auto-generated catch block
427
			e.printStackTrace();
428
		}
429
		try {
430
			hwb.write(fileOut);
431
		} catch (IOException e) {
432
			// TODO Auto-generated catch block
433
			e.printStackTrace();
434
		}
435
		try {
436
			fileOut.close();
437
		} catch (IOException e) {
438
			// TODO Auto-generated catch block
439
			e.printStackTrace();
440
		}
441
 
8285 kshitij.so 442
		String emailFromAddress = "build@shop2020.in";
443
		String password = "cafe@nes";
8363 vikram.rag 444
		String[] sendTo = new String[]{ "vikram.raghav@shop2020.in", "rajveer.singh@shop2020.in","rajneesh.arora@shop2020.in" };
445
		//String[] sendTo = new String[]{ "vikram.raghav@shop2020.in"};
8293 kshitij.so 446
		String emailSubjectTxt = "FBA Stock Estimation Sheet";
447
 
8285 kshitij.so 448
		try {
8293 kshitij.so 449
			GmailUtils mailer = new GmailUtils();
8378 vikram.rag 450
			mailer.sendSSLMessage(sendTo, emailSubjectTxt, "", emailFromAddress, password, AMAZON_FBA_SHEET);
8285 kshitij.so 451
		}
452
		catch (Exception ex) {
453
			ex.printStackTrace();
454
		}
455
 
456
	}
8293 kshitij.so 457
 
8285 kshitij.so 458
	public static Double getPercentageDifferenceFromMinimumPrice(AmazonFbaSalesSnapshot snapshot){
459
		Double minPrice = getMinimumSalePriceOnAmazonFBA(snapshot);
8293 kshitij.so 460
		return (((minPrice - snapshot.getSalePrice())/snapshot.getSalePrice())*100);
461
 
8285 kshitij.so 462
	}
8293 kshitij.so 463
 
8285 kshitij.so 464
	public static Double getMinimumSalePriceOnAmazonFBA(AmazonFbaSalesSnapshot snapshot){
465
		if(snapshot.getMinFbaPrice() > snapshot.getMinMfnPrice()){
466
			return snapshot.getMinMfnPrice();
467
		}
468
		else{
469
			return snapshot.getMinFbaPrice();
470
		}
471
	}
472
 
473
}