| Line 6... |
Line 6... |
| 6 |
from elixir import *
|
6 |
from elixir import *
|
| 7 |
from functools import partial
|
7 |
from functools import partial
|
| 8 |
from shop2020.clients.CatalogClient import CatalogClient
|
8 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 9 |
from shop2020.clients.HelperClient import HelperClient
|
9 |
from shop2020.clients.HelperClient import HelperClient
|
| 10 |
from shop2020.clients.InventoryClient import InventoryClient
|
10 |
from shop2020.clients.InventoryClient import InventoryClient
|
| - |
|
11 |
from shop2020.clients.UserClient import UserClient
|
| 11 |
from shop2020.config.client.ConfigClient import ConfigClient
|
12 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 12 |
from shop2020.model.v1.catalog.impl import DataService
|
13 |
from shop2020.model.v1.catalog.impl import DataService
|
| 13 |
from shop2020.model.v1.catalog.impl.CategoryManager import CategoryManager
|
14 |
from shop2020.model.v1.catalog.impl.CategoryManager import CategoryManager
|
| 14 |
from shop2020.model.v1.catalog.impl.Convertors import to_t_item, to_t_source, \
|
15 |
from shop2020.model.v1.catalog.impl.Convertors import to_t_item, to_t_source, \
|
| 15 |
to_t_brand_info, to_t_private_deal, to_t_exclusive_affiliate_item_info, to_t_bulk_pricing
|
16 |
to_t_brand_info, to_t_private_deal, to_t_exclusive_affiliate_item_info, \
|
| - |
|
17 |
to_t_bulk_pricing
|
| 16 |
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
|
18 |
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
|
| 17 |
Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
|
19 |
Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
|
| 18 |
SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster, \
|
20 |
SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster, \
|
| 19 |
OOSTracker, EntityTag, ItemInsurerMapping, Insurer, Banner, BannerMap, \
|
21 |
OOSTracker, EntityTag, ItemInsurerMapping, Insurer, Banner, BannerMap, \
|
| 20 |
FreebieItem, BrandInfo, Amazonlisted, StorePricing, ItemVatMaster, \
|
22 |
FreebieItem, BrandInfo, Amazonlisted, StorePricing, ItemVatMaster, \
|
| Line 22... |
Line 24... |
| 22 |
ProductFeedSubmit, MarketplaceItems, MarketPlaceItemPrice, \
|
24 |
ProductFeedSubmit, MarketplaceItems, MarketPlaceItemPrice, \
|
| 23 |
SourcePercentageMaster, SourceItemPercentage, FlipkartItem, \
|
25 |
SourcePercentageMaster, SourceItemPercentage, FlipkartItem, \
|
| 24 |
MarketPlaceUpdateHistory, SourceCategoryPercentage, MarketPlaceHistory, \
|
26 |
MarketPlaceUpdateHistory, SourceCategoryPercentage, MarketPlaceHistory, \
|
| 25 |
PrivateDeals, AmazonOutOfSync, PrivateDealsPriceComparison, \
|
27 |
PrivateDeals, AmazonOutOfSync, PrivateDealsPriceComparison, \
|
| 26 |
SourceReturnPercentage, CompetitorPricing, CompetitorPricingRequest, \
|
28 |
SourceReturnPercentage, CompetitorPricing, CompetitorPricingRequest, \
|
| 27 |
AmazonPromotion, ExclusiveAffiliateItemInfo, OutboundAffiliateMaster, HsItem, BulkItemPricing, \
|
29 |
AmazonPromotion, ExclusiveAffiliateItemInfo, OutboundAffiliateMaster, HsItem, \
|
| 28 |
ItemWarrantyInfo, CategoryWarrantyInfo
|
30 |
BulkItemPricing, ItemWarrantyInfo, CategoryWarrantyInfo, StateGstMaster, \
|
| - |
|
31 |
CentralGstMaster, CategoryHsnCodes
|
| 29 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
32 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
| 30 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, \
|
33 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, \
|
| 31 |
StorePricing as tStorePricing, CatalogServiceException, BannerType, InsurerType, \
|
34 |
StorePricing as tStorePricing, CatalogServiceException, BannerType, InsurerType, \
|
| 32 |
Banner as t_banner, CompetitorPricing as TCompetitorPricing, AmazonPromotionType, ItemCondition
|
35 |
Banner as t_banner, CompetitorPricing as TCompetitorPricing, AmazonPromotionType, \
|
| - |
|
36 |
ItemCondition, StateGstRates, GstRate
|
| 33 |
from shop2020.thriftpy.model.v1.inventory.ttypes import VatType, \
|
37 |
from shop2020.thriftpy.model.v1.inventory.ttypes import VatType, \
|
| 34 |
InventoryServiceException, IgnoredInventoryUpdateItems, SnapdealInventoryItem
|
38 |
InventoryServiceException, IgnoredInventoryUpdateItems, SnapdealInventoryItem
|
| 35 |
from shop2020.thriftpy.utils.ttypes import UserSmsInfo, SmsType
|
- |
|
| 36 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
39 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
| - |
|
40 |
from shop2020.thriftpy.utils.ttypes import UserSmsInfo, SmsType
|
| 37 |
from shop2020.utils import EmailAttachmentSender
|
41 |
from shop2020.utils import EmailAttachmentSender
|
| 38 |
from shop2020.utils.EmailAttachmentSender import mail
|
42 |
from shop2020.utils.EmailAttachmentSender import mail
|
| 39 |
from shop2020.utils.Utils import to_py_date, log_risky_flag, to_java_date
|
43 |
from shop2020.utils.Utils import to_py_date, log_risky_flag, to_java_date
|
| 40 |
from sqlalchemy import desc, asc
|
44 |
from sqlalchemy import desc, asc
|
| - |
|
45 |
from sqlalchemy.orm import aliased
|
| 41 |
from sqlalchemy.sql.expression import or_, distinct, func, and_
|
46 |
from sqlalchemy.sql.expression import or_, distinct, func, and_, exists
|
| 42 |
from sqlalchemy.sql.functions import now
|
47 |
from sqlalchemy.sql.functions import now
|
| 43 |
from string import Template
|
48 |
from string import Template
|
| 44 |
import datetime
|
49 |
import datetime
|
| 45 |
import math
|
50 |
import math
|
| - |
|
51 |
import operator
|
| 46 |
import sys
|
52 |
import sys
|
| 47 |
import threading
|
53 |
import threading
|
| 48 |
import urllib2
|
54 |
import urllib2
|
| 49 |
from shop2020.clients.UserClient import UserClient
|
- |
|
| 50 |
import operator
|
- |
|
| 51 |
from sqlalchemy.orm import aliased
|
- |
|
| 52 |
|
55 |
|
| 53 |
sourceId = int(ConfigClient().get_property("sourceid"))
|
56 |
sourceId = int(ConfigClient().get_property("sourceid"))
|
| 54 |
to_addresses = ["khushal.bhatia@shop2020.in", "chandan.kumar@shop2020.in", "chaitnaya.vats@shop2020.in",'manoj.kumar@shop2020.in']
|
57 |
to_addresses = ["khushal.bhatia@shop2020.in", "chandan.kumar@shop2020.in", "chaitnaya.vats@shop2020.in",'manoj.kumar@shop2020.in']
|
| 55 |
to_store_addresses = ["rajveer.singh@shop2020.in"]
|
58 |
to_store_addresses = ["rajveer.singh@shop2020.in"]
|
| 56 |
mail_user = "cnc.center@shop2020.in"
|
59 |
mail_user = "cnc.center@shop2020.in"
|
| Line 64... |
Line 67... |
| 64 |
global stateIdMap
|
67 |
global stateIdMap
|
| 65 |
if stateIdMap:
|
68 |
if stateIdMap:
|
| 66 |
return stateIdMap
|
69 |
return stateIdMap
|
| 67 |
else:
|
70 |
else:
|
| 68 |
try:
|
71 |
try:
|
| 69 |
glob_inventory_client = InventoryClient().get_client()
|
72 |
ic = InventoryClient().get_client()
|
| 70 |
stateIdMap = glob_inventory_client.getStateMaster()
|
73 |
stateIdMap = ic.getStateMaster()
|
| 71 |
return stateIdMap
|
74 |
return stateIdMap
|
| 72 |
except:
|
75 |
except:
|
| 73 |
print "Could not fetch"
|
76 |
print "Could not fetch"
|
| 74 |
|
77 |
|
| 75 |
def initialize(dbname='catalog', db_hostname="localhost"):
|
78 |
def initialize(dbname='catalog', db_hostname="localhost"):
|
| Line 3415... |
Line 3418... |
| 3415 |
for i in items:
|
3418 |
for i in items:
|
| 3416 |
i.brand = data.brand
|
3419 |
i.brand = data.brand
|
| 3417 |
i.model_name = data.model_name
|
3420 |
i.model_name = data.model_name
|
| 3418 |
i.model_number = data.model_number
|
3421 |
i.model_number = data.model_number
|
| 3419 |
session.commit()
|
3422 |
session.commit()
|
| - |
|
3423 |
|
| - |
|
3424 |
def get_gst_rates_by_state(stateId):
|
| - |
|
3425 |
#CategoryState.query.filter_by(stateId=stateId)
|
| - |
|
3426 |
scGst = StateGstRates()
|
| - |
|
3427 |
|
| - |
|
3428 |
stateinfo = fetchStateMaster().get(stateId)
|
| - |
|
3429 |
|
| - |
|
3430 |
if stateinfo:
|
| - |
|
3431 |
scGst.stateCode = stateinfo.stateCode
|
| - |
|
3432 |
scGst.gstRatesMap = {}
|
| - |
|
3433 |
|
| - |
|
3434 |
alias1 = aliased(StateGstMaster)
|
| - |
|
3435 |
q = session.query(StateGstMaster).outerjoin((alias1, and_(alias1.hsnCode==StateGstMaster.hsnCode, StateGstMaster.startDate < alias1.startDate, StateGstMaster.stateId==alias1.stateId))).filter(StateGstMaster.stateId==stateId).filter(alias1.hsnCode==None)
|
| - |
|
3436 |
|
| - |
|
3437 |
for stateGst in q.all():
|
| - |
|
3438 |
gstRate = GstRate()
|
| - |
|
3439 |
gstRate.cgstRate = stateGst.cgstPercent
|
| - |
|
3440 |
gstRate.sgstRate = stateGst.sgstPercent
|
| - |
|
3441 |
gstRate.igstRate = 0.0
|
| - |
|
3442 |
gstRate.hsnCode = stateGst.hsnCode
|
| - |
|
3443 |
scGst.gstRatesMap[stateGst.hsnCode] = gstRate
|
| - |
|
3444 |
|
| - |
|
3445 |
else:
|
| - |
|
3446 |
raise CatalogServiceException(stateId, "Could not found this state id")
|
| - |
|
3447 |
|
| - |
|
3448 |
return scGst
|
| - |
|
3449 |
|
| - |
|
3450 |
def get_interstate_gst_rates():
|
| - |
|
3451 |
#CategoryState.query.filter_by(stateId=stateId)
|
| - |
|
3452 |
centralGstMap = {}
|
| - |
|
3453 |
alias1 = aliased(CentralGstMaster)
|
| - |
|
3454 |
q = session.query(CentralGstMaster).outerjoin((alias1, and_(alias1.hsnCode==CentralGstMaster.hsnCode, CentralGstMaster.startDate < alias1.startDate))).filter(alias1.hsnCode==None)
|
| - |
|
3455 |
|
| - |
|
3456 |
for centralGst in q.all():
|
| - |
|
3457 |
gstRate = GstRate()
|
| - |
|
3458 |
gstRate.cgstRate = 0.0
|
| - |
|
3459 |
gstRate.sgstRate = 0.0
|
| - |
|
3460 |
gstRate.igstRate = centralGst.gstPercent
|
| - |
|
3461 |
gstRate.hsnCode = centralGst.hsnCode
|
| - |
|
3462 |
centralGstMap[centralGst.hsnCode] = gstRate
|
| - |
|
3463 |
|
| - |
|
3464 |
return centralGstMap
|
| - |
|
3465 |
|
| - |
|
3466 |
|
| - |
|
3467 |
def get_hsn_codes_by_category(categoryId):
|
| - |
|
3468 |
return [hsnCode for (hsnCode,) in session.query(CategoryHsnCodes.hsnCode).filter(CategoryHsnCodes.categoryId==categoryId).all()]
|
| 3420 |
|
3469 |
|
| 3421 |
def get_warranty_info_for_item(itemId, itemCondition):
|
3470 |
def get_warranty_info_for_item(itemId, itemCondition):
|
| 3422 |
itemWarrantyInfo = ItemWarrantyInfo.query.filter(and_(ItemWarrantyInfo.catalogItemId ==itemId, ItemWarrantyInfo.itemCondition==itemCondition)).first()
|
3471 |
itemWarrantyInfo = ItemWarrantyInfo.query.filter(and_(ItemWarrantyInfo.catalogItemId ==itemId, ItemWarrantyInfo.itemCondition==itemCondition)).first()
|
| 3423 |
itemwarrantyinfoMap = {}
|
3472 |
itemwarrantyinfoMap = {}
|
| 3424 |
if itemWarrantyInfo is None:
|
3473 |
if itemWarrantyInfo is None:
|