| Line 1... |
Line 1... |
| 1 |
from elixir import *
|
1 |
from elixir import *
|
| 2 |
from sqlalchemy.sql import or_ ,func, asc, desc
|
2 |
from sqlalchemy.sql import or_ ,func, asc, desc, and_
|
| 3 |
from shop2020.config.client.ConfigClient import ConfigClient
|
3 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 4 |
from shop2020.model.v1.catalog.impl import DataService
|
4 |
from shop2020.model.v1.catalog.impl import DataService
|
| 5 |
from shop2020.model.v1.catalog.impl.DataService import Amazonlisted, Item, \
|
5 |
from shop2020.model.v1.catalog.impl.DataService import Amazonlisted, Item, \
|
| 6 |
Category, SourcePercentageMaster,SourceCategoryPercentage, SourceItemPercentage, AmazonPromotion, AmazonScrapingHistory
|
6 |
Category, SourcePercentageMaster,SourceCategoryPercentage, SourceItemPercentage, AmazonPromotion, AmazonScrapingHistory, \
|
| - |
|
7 |
ItemVatMaster, CategoryVatMaster
|
| 7 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
8 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
| 8 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, SalesPotential,\
|
9 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, SalesPotential,\
|
| 9 |
Decision, RunType, AmazonPromotionType
|
10 |
Decision, RunType, AmazonPromotionType
|
| 10 |
from shop2020.model.v1.catalog.script import SellerCentralInventoryReport, AmazonAsyncScraper
|
11 |
from shop2020.model.v1.catalog.script import SellerCentralInventoryReport, AmazonAsyncScraper
|
| 11 |
from shop2020.clients.CatalogClient import CatalogClient
|
12 |
from shop2020.clients.CatalogClient import CatalogClient
|
| Line 389... |
Line 390... |
| 389 |
exceptionList.append(temp)
|
390 |
exceptionList.append(temp)
|
| 390 |
continue
|
391 |
continue
|
| 391 |
skuUrls.append('http://www.amazon.in/gp/offer-listing/'+item.asin+'/ref=olp_sort_ps')
|
392 |
skuUrls.append('http://www.amazon.in/gp/offer-listing/'+item.asin+'/ref=olp_sort_ps')
|
| 392 |
aggResponse = amScraper.read(skuUrls, True)
|
393 |
aggResponse = amScraper.read(skuUrls, True)
|
| 393 |
|
394 |
|
| 394 |
catalog_client = CatalogClient().get_client()
|
- |
|
| 395 |
for val in itemInfo:
|
395 |
for val in itemInfo:
|
| 396 |
print "Trying to get details of ",val.sku
|
396 |
print "Trying to get details of ",val.sku
|
| 397 |
if val.asin is None or len(val.asin)==0:
|
397 |
if val.asin is None or len(val.asin)==0:
|
| 398 |
continue
|
398 |
continue
|
| 399 |
scrapInfo = aggResponse.get(val.asin)
|
399 |
scrapInfo = aggResponse.get(val.asin)
|
| Line 506... |
Line 506... |
| 506 |
print "Creating object am details",val.sku
|
506 |
print "Creating object am details",val.sku
|
| 507 |
amDetails = __AmazonDetails(sku, ourSp, ourRank, lowestSellerName,lowestSellerSp,secondLowestSellerName, secondLowestSellerSp, thirdLowestSellerName, thirdLowestSellerSp,len(scrapInfo),multipleListings)
|
507 |
amDetails = __AmazonDetails(sku, ourSp, ourRank, lowestSellerName,lowestSellerSp,secondLowestSellerName, secondLowestSellerSp, thirdLowestSellerName, thirdLowestSellerSp,len(scrapInfo),multipleListings)
|
| 508 |
print "am details obj created"
|
508 |
print "am details obj created"
|
| 509 |
try:
|
509 |
try:
|
| 510 |
print "inside val getter"
|
510 |
print "inside val getter"
|
| - |
|
511 |
itemVatMaster = ItemVatMaster.query.filter(and_(ItemVatMaster.itemId==int(val.sku[3:]), ItemVatMaster.stateId==val.state_id)).first()
|
| 511 |
print catalog_client
|
512 |
if itemVatMaster is None:
|
| - |
|
513 |
item = Item.query.filter_by(id=int(val.sku[3:]).first()
|
| - |
|
514 |
if item is None:
|
| - |
|
515 |
raise
|
| - |
|
516 |
vatMaster = CategoryVatMaster.query.filter(and_(CategoryVatMaster.categoryId==item.category, CategoryVatMaster.minVal<=amDetails.ourSp, CategoryVatMaster.maxVal>=amDetails.ourSp, CategoryVatMaster.stateId == val.state_id)).first()
|
| 512 |
print catalog_client.isAlive()
|
517 |
if vatMaster is None:
|
| - |
|
518 |
raise
|
| - |
|
519 |
val.vatRate = vatMaster.vatPercent
|
| - |
|
520 |
else:
|
| 513 |
val.vatRate = catalog_client.getVatPercentageForItem(int(val.sku[3:]), val.state_id, amDetails.ourSp)
|
521 |
val.vatRate = itemVatMaster.vatPercentage
|
| 514 |
print "vat fetched"
|
522 |
print "vat fetched"
|
| 515 |
except:
|
523 |
except:
|
| 516 |
print "vat exception"
|
524 |
print "vat exception"
|
| 517 |
temp = []
|
525 |
temp = []
|
| 518 |
temp.append(val)
|
526 |
temp.append(val)
|