| Line 25... |
Line 25... |
| 25 |
CompetitorPricing, CompetitorPricingRequest, AmazonPromotion
|
25 |
CompetitorPricing, CompetitorPricingRequest, AmazonPromotion
|
| 26 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
26 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
| 27 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, \
|
27 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, \
|
| 28 |
StorePricing as tStorePricing, CatalogServiceException, \
|
28 |
StorePricing as tStorePricing, CatalogServiceException, \
|
| 29 |
BannerType, InsurerType, Banner as t_banner, CompetitorPricing as TCompetitorPricing
|
29 |
BannerType, InsurerType, Banner as t_banner, CompetitorPricing as TCompetitorPricing
|
| 30 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
30 |
from shop2020.thriftpy.model.v1.inventory.ttypes import VatType, \
|
| 31 |
InventoryServiceException, IgnoredInventoryUpdateItems,SnapdealInventoryItem
|
31 |
InventoryServiceException, IgnoredInventoryUpdateItems,SnapdealInventoryItem
|
| 32 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
32 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
| 33 |
from shop2020.utils import EmailAttachmentSender
|
33 |
from shop2020.utils import EmailAttachmentSender
|
| 34 |
from shop2020.utils.EmailAttachmentSender import mail
|
34 |
from shop2020.utils.EmailAttachmentSender import mail
|
| 35 |
from shop2020.utils.Utils import to_py_date, log_risky_flag
|
35 |
from shop2020.utils.Utils import to_py_date, log_risky_flag
|
| Line 50... |
Line 50... |
| 50 |
mail_password = "5h0p2o2o"
|
50 |
mail_password = "5h0p2o2o"
|
| 51 |
source_name = "Saholic"
|
51 |
source_name = "Saholic"
|
| 52 |
source_url = "www.saholic.com"
|
52 |
source_url = "www.saholic.com"
|
| 53 |
skippedItems = { 175 : [27, 2160, 2175, 2163, 2158, 7128, 26, 2154],
|
53 |
skippedItems = { 175 : [27, 2160, 2175, 2163, 2158, 7128, 26, 2154],
|
| 54 |
193 : [5839] }
|
54 |
193 : [5839] }
|
| - |
|
55 |
stateIdMap = {}
|
| - |
|
56 |
def fetchStateMaster():
|
| - |
|
57 |
global stateIdMap
|
| - |
|
58 |
if stateIdMap:
|
| - |
|
59 |
return stateIdMap
|
| 55 |
|
60 |
else:
|
| - |
|
61 |
try:
|
| - |
|
62 |
glob_inventory_client = InventoryClient().get_client()
|
| - |
|
63 |
stateIdMap = glob_inventory_client.getStateMaster()
|
| - |
|
64 |
return stateIdMap
|
| - |
|
65 |
except:
|
| - |
|
66 |
print "Could not fetch"
|
| - |
|
67 |
|
| 56 |
def initialize(dbname='catalog', db_hostname="localhost"):
|
68 |
def initialize(dbname='catalog', db_hostname="localhost"):
|
| 57 |
DataService.initialize(dbname, db_hostname)
|
69 |
DataService.initialize(dbname, db_hostname)
|
| 58 |
|
70 |
|
| 59 |
def get_all_items_by_status(status, offset=0, limit=None):
|
71 |
def get_all_items_by_status(status, offset=0, limit=None):
|
| 60 |
query = Item.query
|
72 |
query = Item.query
|
| Line 349... |
Line 361... |
| 349 |
raise InventoryServiceException(101, "Item already exists")
|
361 |
raise InventoryServiceException(101, "Item already exists")
|
| 350 |
|
362 |
|
| 351 |
validate_item_prices(item)
|
363 |
validate_item_prices(item)
|
| 352 |
|
364 |
|
| 353 |
ds_item = Item()
|
365 |
ds_item = Item()
|
| - |
|
366 |
|
| - |
|
367 |
if item.id:
|
| - |
|
368 |
ds_item.id = item.id
|
| 354 |
if item.productGroup:
|
369 |
if item.productGroup:
|
| 355 |
ds_item.product_group = item.productGroup
|
370 |
ds_item.product_group = item.productGroup
|
| 356 |
if item.brand:
|
371 |
if item.brand:
|
| 357 |
ds_item.brand = item.brand
|
372 |
ds_item.brand = item.brand
|
| 358 |
if item.modelName:
|
373 |
if item.modelName:
|
| Line 1413... |
Line 1428... |
| 1413 |
raise CatalogServiceException(stateId, "Could not find vat rate for this state." + str(stateId) + " for " + str(itemId))
|
1428 |
raise CatalogServiceException(stateId, "Could not find vat rate for this state." + str(stateId) + " for " + str(itemId))
|
| 1414 |
return vatMaster.vatPercent
|
1429 |
return vatMaster.vatPercent
|
| 1415 |
else:
|
1430 |
else:
|
| 1416 |
return itemVatMaster.vatPercentage
|
1431 |
return itemVatMaster.vatPercentage
|
| 1417 |
|
1432 |
|
| - |
|
1433 |
def get_vat_percentage_for_item_category(itemId, stateId, price, categoryId):
|
| - |
|
1434 |
itemVatMaster = ItemVatMaster.query.filter(and_(ItemVatMaster.itemId==itemId, ItemVatMaster.stateId==stateId)).first()
|
| - |
|
1435 |
if itemVatMaster is None:
|
| - |
|
1436 |
vatMaster = CategoryVatMaster.query.filter(and_(CategoryVatMaster.categoryId==categoryId, CategoryVatMaster.minVal<=price, CategoryVatMaster.maxVal>=price, CategoryVatMaster.stateId == stateId)).first()
|
| - |
|
1437 |
if vatMaster is None:
|
| - |
|
1438 |
return -1
|
| - |
|
1439 |
return vatMaster.vatPercent
|
| - |
|
1440 |
else:
|
| - |
|
1441 |
return itemVatMaster.vatPercentage
|
| - |
|
1442 |
|
| 1418 |
def get_all_ignored_inventoryupdate_items_list(offset,limit):
|
1443 |
def get_all_ignored_inventoryupdate_items_list(offset,limit):
|
| 1419 |
client = InventoryClient().get_client()
|
1444 |
client = InventoryClient().get_client()
|
| 1420 |
itemids = client.getIgnoredInventoryUpdateItemids(offset,limit)
|
1445 |
itemids = client.getIgnoredInventoryUpdateItemids(offset,limit)
|
| 1421 |
result = []
|
1446 |
result = []
|
| 1422 |
if itemids is not None and len(itemids)>0:
|
1447 |
if itemids is not None and len(itemids)>0:
|
| Line 2817... |
Line 2842... |
| 2817 |
d_amazonPromotion.promotionType = amazonPromotion.promotionType
|
2842 |
d_amazonPromotion.promotionType = amazonPromotion.promotionType
|
| 2818 |
session.commit()
|
2843 |
session.commit()
|
| 2819 |
return True
|
2844 |
return True
|
| 2820 |
|
2845 |
|
| 2821 |
|
2846 |
|
| - |
|
2847 |
def get_vat_rates(itemId, categoryId):
|
| - |
|
2848 |
vatRates = {}
|
| - |
|
2849 |
item = get_item(itemId)
|
| - |
|
2850 |
for stateinfo in fetchStateMaster().values():
|
| - |
|
2851 |
price = item.sellingPrice
|
| - |
|
2852 |
if VatType.MRP == stateinfo.vatType:
|
| - |
|
2853 |
price = item.mrp
|
| - |
|
2854 |
vatRates[stateinfo.id] = get_vat_percentage_for_item_category(itemId, stateinfo.id, price, categoryId)
|
| - |
|
2855 |
return vatRates
|
| - |
|
2856 |
|
| - |
|
2857 |
def update_item_state_vat(itemId, stateVat):
|
| - |
|
2858 |
for k,v in stateVat.iteritems():
|
| - |
|
2859 |
itemVat = ItemVatMaster.query.filter(and_(ItemVatMaster.itemId==itemId, ItemVatMaster.stateId==k)).first()
|
| - |
|
2860 |
if itemVat:
|
| - |
|
2861 |
itemVat.vatPercentage = v
|
| - |
|
2862 |
else:
|
| - |
|
2863 |
itemVat = ItemVatMaster()
|
| - |
|
2864 |
itemVat.itemId = itemId
|
| - |
|
2865 |
itemVat.stateId = k
|
| - |
|
2866 |
itemVat.vatPercentage = v
|
| - |
|
2867 |
session.commit()
|
| - |
|
2868 |
return True
|
| - |
|
2869 |
|
| - |
|
2870 |
def mark_partially_active(itemId, categoryId):
|
| - |
|
2871 |
item = get_item(itemId)
|
| - |
|
2872 |
item.category = categoryId
|
| - |
|
2873 |
item.status = 8
|
| - |
|
2874 |
item.status_description = 'Partially Active'
|
| - |
|
2875 |
session.commit()
|
| - |
|
2876 |
return True
|
| - |
|
2877 |
|
| 2822 |
def get_amazon_promotion(startDate,endDate):
|
2878 |
def get_amazon_promotion(startDate,endDate):
|
| 2823 |
return AmazonPromotion.query.filter(AmazonPromotion.startDate>=(to_py_date(startDate))).filter(AmazonPromotion.endDate<=(to_py_date(endDate))).all()
|
2879 |
return AmazonPromotion.query.filter(AmazonPromotion.startDate>=(to_py_date(startDate))).filter(AmazonPromotion.endDate<=(to_py_date(endDate))).all()
|
| 2824 |
|
2880 |
|
| 2825 |
def update_amazon_promotion(amazonPromotions):
|
2881 |
def update_amazon_promotion(amazonPromotions):
|
| 2826 |
for amazonPromotion in amazonPromotions:
|
2882 |
for amazonPromotion in amazonPromotions:
|