Subversion Repositories SmartDukaan

Rev

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

Rev 12318 Rev 12337
Line 2083... Line 2083...
2083
    inactiveAutoPricing = session.query(MarketPlaceHistory,Item,MarketplaceItems).join((Item,MarketPlaceHistory.item_id==Item.id)).join((MarketplaceItems,MarketPlaceHistory.item_id==MarketplaceItems.itemId)).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(or_(MarketplaceItems.autoDecrement==0,MarketplaceItems.autoIncrement==0)).filter(MarketPlaceHistory.competitiveCategory.in_([CompetitionCategory.BUY_BOX,CompetitionCategory.COMPETITIVE])).all()
2083
    inactiveAutoPricing = session.query(MarketPlaceHistory,Item,MarketplaceItems).join((Item,MarketPlaceHistory.item_id==Item.id)).join((MarketplaceItems,MarketPlaceHistory.item_id==MarketplaceItems.itemId)).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(or_(MarketplaceItems.autoDecrement==0,MarketplaceItems.autoIncrement==0)).filter(MarketPlaceHistory.competitiveCategory.in_([CompetitionCategory.BUY_BOX,CompetitionCategory.COMPETITIVE])).all()
2084
    if len(inactiveAutoPricing) == 0:
2084
    if len(inactiveAutoPricing) == 0:
2085
        return
2085
        return
2086
    message="""<html>
2086
    message="""<html>
2087
            <body>
2087
            <body>
2088
            <h3 style="color:red;font-weight:bold;">Snapdeal Competitive But No Inventory</h3>
2088
            <h3 style="color:red;font-weight:bold;">Snapdeal Inactive Auto Pricing</h3>
2089
            <table border="1" style="width:100%;">
2089
            <table border="1" style="width:100%;">
2090
            <thead>
2090
            <thead>
2091
            <tr><th>Item Id</th>
2091
            <tr><th>Item Id</th>
2092
            <th>Product Name</th>
2092
            <th>Product Name</th>
2093
            <th>Selling Price</th>
2093
            <th>Selling Price</th>
Line 2097... Line 2097...
2097
            <th>Commission %</th>
2097
            <th>Commission %</th>
2098
            <th>Return Provision %</th>
2098
            <th>Return Provision %</th>
2099
            <th>Snapdeal Inventory</th>
2099
            <th>Snapdeal Inventory</th>
2100
            <th>Total Inventory</th>
2100
            <th>Total Inventory</th>
2101
            <th>Sales History</th>
2101
            <th>Sales History</th>
-
 
2102
            <th>Action</th>
2102
            </tr></thead>
2103
            </tr></thead>
2103
            <tbody>"""
2104
            <tbody>"""
2104
    for item in inactiveAutoPricing:
2105
    for item in inactiveAutoPricing:
2105
        mpHistory = item[0]
2106
        mpHistory = item[0]
2106
        catItem = item[1]
2107
        catItem = item[1]
Line 2108... Line 2109...
2108
        netInventory=''
2109
        netInventory=''
2109
        if not inventoryMap.has_key(mpHistory.item_id):
2110
        if not inventoryMap.has_key(mpHistory.item_id):
2110
            netInventory='Info Not Available'
2111
            netInventory='Info Not Available'
2111
        else:
2112
        else:
2112
            netInventory = str(getNetAvailability(inventoryMap.get(mpHistory.item_id)))
2113
            netInventory = str(getNetAvailability(inventoryMap.get(mpHistory.item_id)))
-
 
2114
        if (mpHistory.competitiveCategory==2):
-
 
2115
            decision="Auto Increment"
-
 
2116
        elif (mpHistory.competitiveCategory in (3)):
-
 
2117
            decision="Auto Decrement"
-
 
2118
        else:
-
 
2119
            decision=""
2113
        message+="""<tr>
2120
        message+="""<tr>
2114
            <td style="text-align:center">"""+str(mpHistory.item_id)+"""</td>
2121
            <td style="text-align:center">"""+str(mpHistory.item_id)+"""</td>
2115
            <td style="text-align:center">"""+xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)+"""</td>
2122
            <td style="text-align:center">"""+xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)+"""</td>
2116
            <td style="text-align:center">"""+str(mpHistory.ourSellingPrice)+"""</td>
2123
            <td style="text-align:center">"""+str(mpHistory.ourSellingPrice)+"""</td>
2117
            <td style="text-align:center">"""+str(CompetitionCategory._VALUES_TO_NAMES.get(mpHistory.competitiveCategory))+"""</td>
2124
            <td style="text-align:center">"""+str(CompetitionCategory._VALUES_TO_NAMES.get(mpHistory.competitiveCategory))+"""</td>
Line 2120... Line 2127...
2120
            <td style="text-align:center">"""+str(mpItem.commission)+"""</td>
2127
            <td style="text-align:center">"""+str(mpItem.commission)+"""</td>
2121
            <td style="text-align:center">"""+str(mpItem.returnProvision)+" %"+"""</td>
2128
            <td style="text-align:center">"""+str(mpItem.returnProvision)+" %"+"""</td>
2122
            <td style="text-align:center">"""+str(mpHistory.ourInventory)+"""</td>
2129
            <td style="text-align:center">"""+str(mpHistory.ourInventory)+"""</td>
2123
            <td style="text-align:center">"""+netInventory+"""</td>
2130
            <td style="text-align:center">"""+netInventory+"""</td>
2124
            <td style="text-align:center">"""+getOosString((itemSaleMap.get(mpHistory.item_id))[1])+"""</td>
2131
            <td style="text-align:center">"""+getOosString((itemSaleMap.get(mpHistory.item_id))[1])+"""</td>
-
 
2132
            <td style="text-align:center">"""+decision+"""</td>
2125
            </tr>"""
2133
            </tr>"""
2126
    message+="""</tbody></table></body></html>"""
2134
    message+="""</tbody></table></body></html>"""
2127
    print message
2135
    print message
2128
    mailServer = smtplib.SMTP("smtp.gmail.com", 587)
2136
    mailServer = smtplib.SMTP("smtp.gmail.com", 587)
2129
    mailServer.ehlo()
2137
    mailServer.ehlo()