Subversion Repositories SmartDukaan

Rev

Rev 23310 | Rev 23323 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23310 Rev 23313
Line 1... Line 1...
1
'''
1
'''
2
Created on 23-Mar-2010
2
Created on 23-Mar-2010
3
 
3
 
4
@author: ashish
4
@author: ashish
5
'''
5
'''
6
import datetime
-
 
7
from functools import partial
-
 
8
import math
-
 
9
import operator
-
 
10
from string import Template
-
 
11
import sys
-
 
12
import threading
-
 
13
import traceback
-
 
14
import urllib2
-
 
15
 
-
 
16
from elixir import *
6
from elixir import *
17
from sqlalchemy import desc, asc
-
 
18
from sqlalchemy.orm import aliased
7
from functools import partial
19
from sqlalchemy.sql.expression import or_, distinct, func, and_, exists
-
 
20
from sqlalchemy.sql.functions import now
-
 
21
 
-
 
22
from shop2020.clients.CatalogClient import CatalogClient
8
from shop2020.clients.CatalogClient import CatalogClient
23
from shop2020.clients.HelperClient import HelperClient
9
from shop2020.clients.HelperClient import HelperClient
24
from shop2020.clients.InventoryClient import InventoryClient
10
from shop2020.clients.InventoryClient import InventoryClient
25
from shop2020.clients.UserClient import UserClient
11
from shop2020.clients.UserClient import UserClient
26
from shop2020.config.client.ConfigClient import ConfigClient
12
from shop2020.config.client.ConfigClient import ConfigClient
Line 45... Line 31...
45
    CentralGstMaster, CategoryHsnCodes, Tag_Listing, StateGstRate
31
    CentralGstMaster, CategoryHsnCodes, Tag_Listing, StateGstRate
46
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
32
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
47
    ItemType, PremiumType, FreebieItem as t_FreebieItem, \
33
    ItemType, PremiumType, FreebieItem as t_FreebieItem, \
48
    StorePricing as tStorePricing, CatalogServiceException, BannerType, InsurerType, \
34
    StorePricing as tStorePricing, CatalogServiceException, BannerType, InsurerType, \
49
    Banner as t_banner, CompetitorPricing as TCompetitorPricing, AmazonPromotionType, \
35
    Banner as t_banner, CompetitorPricing as TCompetitorPricing, AmazonPromotionType, \
50
    ItemCondition, StateGstRates, GstRate
36
    ItemCondition, StateGstRates, GstRate, StateGstRate as TStateGstRate
51
from shop2020.thriftpy.model.v1.inventory.ttypes import VatType, \
37
from shop2020.thriftpy.model.v1.inventory.ttypes import VatType, \
52
    InventoryServiceException, IgnoredInventoryUpdateItems, SnapdealInventoryItem
38
    InventoryServiceException, IgnoredInventoryUpdateItems, SnapdealInventoryItem
53
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
39
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
54
from shop2020.thriftpy.utils.ttypes import UserSmsInfo, SmsType
40
from shop2020.thriftpy.utils.ttypes import UserSmsInfo, SmsType
55
from shop2020.utils import EmailAttachmentSender
41
from shop2020.utils import EmailAttachmentSender
56
from shop2020.utils.EmailAttachmentSender import mail
42
from shop2020.utils.EmailAttachmentSender import mail
57
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
-
 
44
from sqlalchemy import desc, asc
-
 
45
from sqlalchemy.orm import aliased
-
 
46
from sqlalchemy.sql.expression import or_, distinct, func, and_, exists
-
 
47
from sqlalchemy.sql.functions import now
-
 
48
from string import Template
-
 
49
import datetime
-
 
50
import math
-
 
51
import operator
-
 
52
import sys
-
 
53
import threading
-
 
54
import traceback
-
 
55
import urllib2
-
 
56
 
-
 
57
 
58
 
58
 
59
 
59
 
60
sourceId = int(ConfigClient().get_property("sourceid"))
60
sourceId = int(ConfigClient().get_property("sourceid"))
61
to_addresses = ["khushal.bhatia@shop2020.in", "chandan.kumar@shop2020.in",  "chaitnaya.vats@shop2020.in",'manoj.kumar@shop2020.in']
61
to_addresses = ["khushal.bhatia@shop2020.in", "chandan.kumar@shop2020.in",  "chaitnaya.vats@shop2020.in",'manoj.kumar@shop2020.in']
62
to_store_addresses = ["rajveer.singh@shop2020.in"]
62
to_store_addresses = ["rajveer.singh@shop2020.in"]
Line 3509... Line 3509...
3509
        if itemIdIgstTaxRateMap.get(k) is None and itemIdItemMap[k].category==10006:
3509
        if itemIdIgstTaxRateMap.get(k) is None and itemIdItemMap[k].category==10006:
3510
            itemIdIgstTaxRateMap[k] = 12
3510
            itemIdIgstTaxRateMap[k] = 12
3511
    return itemIdIgstTaxRateMap
3511
    return itemIdIgstTaxRateMap
3512
 
3512
 
3513
 
3513
 
3514
def add_state_gst_rate(stateGstRate):
3514
def add_state_gst_rates(stateGstRates):
-
 
3515
    #lets keep rates only for haryana and delhi i.e. 0 and 3
-
 
3516
    stateIds = [-1, 0, 3]
-
 
3517
    s = StateGstRate()
3515
    if stateGstRate is not None:
3518
    for stateGstRate in stateGstRates:
-
 
3519
        session.query(StateGstRate).filter(StateGstRate.item_id==stateGstRate.itemId).delete()
-
 
3520
        for sid in stateIds:
3516
        sgr = StateGstRate()
3521
            sgr = StateGstRate()
3517
        sgr.item_id = stateGstRate.item_id;
3522
            sgr.item_id = stateGstRate.itemId
-
 
3523
            sgr.state_id = sid
-
 
3524
            if sid==-1:
3518
        sgr.state_id = stateGstRate.state_id;
3525
                sgr.igst_rate = stateGstRate.igstRate
3519
        sgr.igst_rate = stateGstRate.igst_rate;
3526
                sgr.cgst_rate = stateGstRate.igstRate
3520
        sgr.igst_rate = stateGstRate.igst_rate;
3527
                sgr.sgst_rate = stateGstRate.igstRate
-
 
3528
            else:
-
 
3529
                sgr.igst_rate = 0
-
 
3530
                sgr.cgst_rate = stateGstRate.igstRate/2
3521
        sgr.igst_rate = stateGstRate.igst_rate;
3531
                sgr.sgst_rate = stateGstRate.igstRate/2
3522
        session.commit()
3532
    session.commit()
3523
         
3533
         
3524
def get_interstate_gst_rates():
3534
def get_interstate_gst_rates():
3525
    #CategoryState.query.filter_by(stateId=stateId)
3535
    #CategoryState.query.filter_by(stateId=stateId)
3526
    centralGstMap = {} 
3536
    centralGstMap = {} 
3527
    alias1 = aliased(CentralGstMaster)
3537
    alias1 = aliased(CentralGstMaster)
Line 3586... Line 3596...
3586
    return returnMap
3596
    return returnMap
3587
             
3597
             
3588
 
3598
 
3589
if __name__=='__main__':
3599
if __name__=='__main__':
3590
    DataService.initialize()
3600
    DataService.initialize()
3591
    itemIds = [26821]
3601
#    itemIds = [26821]
3592
    tagIds = [4,7]
3602
#    tagIds = [4,7]
3593
    tagListings = session.query(Tag_Listing).join((Item, Item.id==Tag_Listing.item_id)).filter(Item.status.in_([status.ACTIVE, status.PAUSED_BY_RISK])).filter(Tag_Listing.active==True).filter(Item.id.in_(itemIds)).filter(Tag_Listing.tag_id.in_(tagIds))
3603
#    tagListings = session.query(Tag_Listing).join((Item, Item.id==Tag_Listing.item_id)).filter(Item.status.in_([status.ACTIVE, status.PAUSED_BY_RISK])).filter(Tag_Listing.active==True).filter(Item.id.in_(itemIds)).filter(Tag_Listing.tag_id.in_(tagIds))
3594
    for tagListing in tagListings.all():
3604
#    for tagListing in tagListings.all():
3595
        print tagListing
3605
#        print tagListing
3596
    #update_bulk_prices_on_production(21053,[])
3606
    #update_bulk_prices_on_production(21053,[])
3597
    #search_terms = ["12206"]
3607
    #search_terms = ["12206"]
3598
    #print search_items(search_terms, 0, 20)
3608
    #print search_items(search_terms, 0, 20)
3599
    #print get_search_result_count(search_terms)
3609
    #print get_search_result_count(search_terms)
-
 
3610
    rate = TStateGstRate()
-
 
3611
    rate.igstRate = 12
-
 
3612
    rate.itemId = 27702
-
 
3613
    add_state_gst_rates([rate])
3600
    
3614
    
3601
3615