Subversion Repositories SmartDukaan

Rev

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

Rev 22714 Rev 23142
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
from elixir import *
6
import datetime
7
from functools import partial
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 *
-
 
17
from sqlalchemy import desc, asc
-
 
18
from sqlalchemy.orm import aliased
-
 
19
from sqlalchemy.sql.expression import or_, distinct, func, and_, exists
-
 
20
from sqlalchemy.sql.functions import now
-
 
21
 
8
from shop2020.clients.CatalogClient import CatalogClient
22
from shop2020.clients.CatalogClient import CatalogClient
9
from shop2020.clients.HelperClient import HelperClient
23
from shop2020.clients.HelperClient import HelperClient
10
from shop2020.clients.InventoryClient import InventoryClient
24
from shop2020.clients.InventoryClient import InventoryClient
11
from shop2020.clients.UserClient import UserClient
25
from shop2020.clients.UserClient import UserClient
12
from shop2020.config.client.ConfigClient import ConfigClient
26
from shop2020.config.client.ConfigClient import ConfigClient
Line 26... Line 40...
26
    MarketPlaceUpdateHistory, SourceCategoryPercentage, MarketPlaceHistory, \
40
    MarketPlaceUpdateHistory, SourceCategoryPercentage, MarketPlaceHistory, \
27
    PrivateDeals, AmazonOutOfSync, PrivateDealsPriceComparison, \
41
    PrivateDeals, AmazonOutOfSync, PrivateDealsPriceComparison, \
28
    SourceReturnPercentage, CompetitorPricing, CompetitorPricingRequest, \
42
    SourceReturnPercentage, CompetitorPricing, CompetitorPricingRequest, \
29
    AmazonPromotion, ExclusiveAffiliateItemInfo, OutboundAffiliateMaster, HsItem, \
43
    AmazonPromotion, ExclusiveAffiliateItemInfo, OutboundAffiliateMaster, HsItem, \
30
    BulkItemPricing, ItemWarrantyInfo, CategoryWarrantyInfo, StateGstMaster, \
44
    BulkItemPricing, ItemWarrantyInfo, CategoryWarrantyInfo, StateGstMaster, \
31
    CentralGstMaster, CategoryHsnCodes, Tag_Listing
45
    CentralGstMaster, CategoryHsnCodes, Tag_Listing, StateGstRate
32
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
46
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
33
    ItemType, PremiumType, FreebieItem as t_FreebieItem, \
47
    ItemType, PremiumType, FreebieItem as t_FreebieItem, \
34
    StorePricing as tStorePricing, CatalogServiceException, BannerType, InsurerType, \
48
    StorePricing as tStorePricing, CatalogServiceException, BannerType, InsurerType, \
35
    Banner as t_banner, CompetitorPricing as TCompetitorPricing, AmazonPromotionType, \
49
    Banner as t_banner, CompetitorPricing as TCompetitorPricing, AmazonPromotionType, \
36
    ItemCondition, StateGstRates, GstRate
50
    ItemCondition, StateGstRates, GstRate
Line 39... Line 53...
39
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
53
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
40
from shop2020.thriftpy.utils.ttypes import UserSmsInfo, SmsType
54
from shop2020.thriftpy.utils.ttypes import UserSmsInfo, SmsType
41
from shop2020.utils import EmailAttachmentSender
55
from shop2020.utils import EmailAttachmentSender
42
from shop2020.utils.EmailAttachmentSender import mail
56
from shop2020.utils.EmailAttachmentSender import mail
43
from shop2020.utils.Utils import to_py_date, log_risky_flag, to_java_date
57
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
58
 
53
import threading
-
 
54
import urllib2
-
 
55
 
59
 
56
sourceId = int(ConfigClient().get_property("sourceid"))
60
sourceId = int(ConfigClient().get_property("sourceid"))
57
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']
58
to_store_addresses = ["rajveer.singh@shop2020.in"]
62
to_store_addresses = ["rajveer.singh@shop2020.in"]
59
mail_user = "cnc.center@shop2020.in"
63
mail_user = "cnc.center@shop2020.in"
Line 3445... Line 3449...
3445
                
3449
                
3446
    else:
3450
    else:
3447
        raise CatalogServiceException(stateId, "Could not found this state id")
3451
        raise CatalogServiceException(stateId, "Could not found this state id")
3448
    
3452
    
3449
    return scGst
3453
    return scGst
-
 
3454
 
-
 
3455
#def get_sgst_tax_rate(itemIds, stateId):
-
 
3456
#    query = session.query(StateGstRate).filter(StateGstRate.item_id==itemIds).filter(StateGstRate.state_id==stateId)
-
 
3457
#    itemIdSgstTaxRateMap = {};
-
 
3458
#    for stateGstRate in query.all():
-
 
3459
#        itemIdSgstTaxRateMap[stateGstRate.item_id] = stateGstRate.tax_rate;
-
 
3460
#    return itemIdSgstTaxRateMap;
-
 
3461
 
-
 
3462
def get_total_tax_rate(itemIds, stateId):
-
 
3463
    queryItem = session.query(Item).filter(Item.id.in_(itemIds))
-
 
3464
    itemIdItemMap = {}
-
 
3465
    for item in queryItem.all():
-
 
3466
        itemIdItemMap[item.id] = item
-
 
3467
    
-
 
3468
    queryStateGstRate = session.query(StateGstRate).filter(StateGstRate.item_id.in_(itemIds)).filter(StateGstRate.state_id==stateId)
-
 
3469
    itemIdTotalTaxRateMap = {}
-
 
3470
    for stateGstRate in queryStateGstRate.all():
-
 
3471
        igstTaxRate = itemIdItemMap[stateGstRate.item_id].tax_rate
-
 
3472
        sgstTaxRate = stateGstRate.tax_rate
-
 
3473
        cgstTaxRate = igstTaxRate - sgstTaxRate
-
 
3474
        gstRate = GstRate()
-
 
3475
        gstRate.cgstRate = cgstTaxRate
-
 
3476
        gstRate.sgstRate = sgstTaxRate
-
 
3477
        gstRate.igstRate = igstTaxRate
-
 
3478
        gstRate.hsnCode = itemIdItemMap[stateGstRate.item_id].hsnCode
-
 
3479
        itemIdTotalTaxRateMap[stateGstRate.item_id] = gstRate
-
 
3480
    return itemIdTotalTaxRateMap
3450
             
3481
             
3451
def get_interstate_gst_rates():
3482
def get_interstate_gst_rates():
3452
    #CategoryState.query.filter_by(stateId=stateId)
3483
    #CategoryState.query.filter_by(stateId=stateId)
3453
    centralGstMap = {} 
3484
    centralGstMap = {} 
3454
    alias1 = aliased(CentralGstMaster)
3485
    alias1 = aliased(CentralGstMaster)