Subversion Repositories SmartDukaan

Rev

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

Rev 10292 Rev 10293
Line 1146... Line 1146...
1146
        sheet_iterator+=1
1146
        sheet_iterator+=1
1147
    
1147
    
1148
    filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
1148
    filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
1149
    wbk.save(filename)
1149
    wbk.save(filename)
1150
    try:
1150
    try:
1151
        EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
1151
        #EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
1152
        #EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["chandan.kumar@saholic.com","manoj.kumar@saholic.com","yukti.jain@saholic.com","ankush.dhingra@saholic.com","manoj.pal@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], ["rajneesh.arora@saholic.com","rajveer.singh@saholic.com","vikram.raghav@saholic.com","kshitij.sood@saholic.com","chaitnaya.vats@saholic.com","khushal.bhatia@saholic.com"], [])
1152
        EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["chandan.kumar@saholic.com","manoj.kumar@saholic.com","yukti.jain@saholic.com","ankush.dhingra@saholic.com","manoj.pal@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], ["rajneesh.arora@saholic.com","rajveer.singh@saholic.com","vikram.raghav@saholic.com","kshitij.sood@saholic.com","chaitnaya.vats@saholic.com","khushal.bhatia@saholic.com"], [])
1153
    except Exception as e:
1153
    except Exception as e:
1154
        print e
1154
        print e
1155
        print "Unable to send report.Trying with local SMTP"
1155
        print "Unable to send report.Trying with local SMTP"
1156
        smtpServer = smtplib.SMTP('localhost')
1156
        smtpServer = smtplib.SMTP('localhost')
1157
        smtpServer.set_debuglevel(1)
1157
        smtpServer.set_debuglevel(1)
1158
        sender = 'support@shop2020.in'
1158
        sender = 'support@shop2020.in'
1159
        recipients = ['kshitij.sood@saholic.com']
1159
        #recipients = ['kshitij.sood@saholic.com']
1160
        msg = MIMEMultipart()
1160
        msg = MIMEMultipart()
1161
        msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
1161
        msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
1162
        msg['From'] = sender
1162
        msg['From'] = sender
1163
        #recipients = ['rajneesh.arora@saholic.com','rajveer.singh@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
1163
        recipients = ['rajneesh.arora@saholic.com','rajveer.singh@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
1164
        msg['To'] = ",".join(recipients)
1164
        msg['To'] = ",".join(recipients)
1165
        fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
1165
        fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
1166
        fileMsg.set_payload(file(filename).read())
1166
        fileMsg.set_payload(file(filename).read())
1167
        email.encoders.encode_base64(fileMsg)
1167
        email.encoders.encode_base64(fileMsg)
1168
        fileMsg.add_header('Content-Disposition','attachment;filename=snapdeal.xls')
1168
        fileMsg.add_header('Content-Disposition','attachment;filename=snapdeal.xls')
Line 1482... Line 1482...
1482
    mailServer = smtplib.SMTP("smtp.gmail.com", 587)
1482
    mailServer = smtplib.SMTP("smtp.gmail.com", 587)
1483
    mailServer.ehlo()
1483
    mailServer.ehlo()
1484
    mailServer.starttls()
1484
    mailServer.starttls()
1485
    mailServer.ehlo()
1485
    mailServer.ehlo()
1486
 
1486
 
1487
    recipients = ['kshitij.sood@saholic.com']
1487
    #recipients = ['kshitij.sood@saholic.com']
1488
    #recipients = ['rajneesh.arora@saholic.com','rajveer.singh@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
1488
    recipients = ['rajneesh.arora@saholic.com','rajveer.singh@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
1489
    msg = MIMEMultipart()
1489
    msg = MIMEMultipart()
1490
    msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
1490
    msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
1491
    msg['From'] = ""
1491
    msg['From'] = ""
1492
    msg['To'] = ",".join(recipients)
1492
    msg['To'] = ",".join(recipients)
1493
    msg.preamble = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
1493
    msg.preamble = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
Line 1520... Line 1520...
1520
        warehouse = inventory_client.getWarehouse(sdItem.warehouseId)
1520
        warehouse = inventory_client.getWarehouse(sdItem.warehouseId)
1521
        vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, item.proposedSellingPrice)
1521
        vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, item.proposedSellingPrice)
1522
        addHistory(sdItem)
1522
        addHistory(sdItem)
1523
        sdItem.transferPrice = getNewOurTp(mpItem,item.proposedSellingPrice)
1523
        sdItem.transferPrice = getNewOurTp(mpItem,item.proposedSellingPrice)
1524
        sdItem.sellingPrice = math.ceil(item.proposedSellingPrice)
1524
        sdItem.sellingPrice = math.ceil(item.proposedSellingPrice)
-
 
1525
        if ((mpItem.pgFee/100)*sdItem.sellingPrice)>=20:
-
 
1526
            sdItem.commission = round((mpItem.commission/100+mpItem.pgFee/100)*(sdItem.sellingPrice),2)
-
 
1527
        else:
1525
        sdItem.commission = round((mpItem.commission/100)*(sdItem.sellingPrice),2)
1528
            sdItem.commission = round((mpItem.commission/100)*(sdItem.sellingPrice),2)+20
1526
        sdItem.serviceTax = round((mpItem.serviceTax/100)*(sdItem.commission+sdItem.courierCost),2)
1529
        sdItem.serviceTax = round((mpItem.serviceTax/100)*(sdItem.commission+sdItem.courierCost),2)
1527
        sdItem.updatedOn = timestamp
1530
        sdItem.updatedOn = timestamp
1528
        sdItem.priceUpdatedBy = 'SYSTEM'
1531
        sdItem.priceUpdatedBy = 'SYSTEM'
1529
        mpItem.currentSp = sdItem.sellingPrice
1532
        mpItem.currentSp = sdItem.sellingPrice
1530
        mpItem.currentTp = sdItem.transferPrice
1533
        mpItem.currentTp = sdItem.transferPrice
Line 1539... Line 1542...
1539
        warehouse = inventory_client.getWarehouse(sdItem.warehouseId)
1542
        warehouse = inventory_client.getWarehouse(sdItem.warehouseId)
1540
        vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))
1543
        vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))
1541
        addHistory(sdItem)
1544
        addHistory(sdItem)
1542
        sdItem.transferPrice = getNewOurTp(mpItem,item.ourSellingPrice+max(10,.01*item.ourSellingPrice))
1545
        sdItem.transferPrice = getNewOurTp(mpItem,item.ourSellingPrice+max(10,.01*item.ourSellingPrice))
1543
        sdItem.sellingPrice = math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice))
1546
        sdItem.sellingPrice = math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice))
-
 
1547
        if ((mpItem.pgFee/100)*sdItem.sellingPrice)>=20:
-
 
1548
            sdItem.commission = round((mpItem.commission/100+mpItem.pgFee/100)*(sdItem.sellingPrice),2)
-
 
1549
        else:
1544
        sdItem.commission = round((mpItem.commission/100)*(sdItem.sellingPrice),2)
1550
            sdItem.commission = round((mpItem.commission/100)*(sdItem.sellingPrice),2)+20
1545
        sdItem.serviceTax = round((mpItem.serviceTax/100)*(sdItem.commission+sdItem.courierCost),2)
1551
        sdItem.serviceTax = round((mpItem.serviceTax/100)*(sdItem.commission+sdItem.courierCost),2)
1546
        sdItem.updatedOn = timestamp
1552
        sdItem.updatedOn = timestamp
1547
        sdItem.priceUpdatedBy = 'SYSTEM'
1553
        sdItem.priceUpdatedBy = 'SYSTEM'
1548
        mpItem.currentSp = sdItem.sellingPrice
1554
        mpItem.currentSp = sdItem.sellingPrice
1549
        mpItem.currentTp = sdItem.transferPrice
1555
        mpItem.currentTp = sdItem.transferPrice
Line 1795... Line 1801...
1795
        previousAutoFav, nowAutoFav = markAutoFavourite()
1801
        previousAutoFav, nowAutoFav = markAutoFavourite()
1796
    if options.runType=='FULL':
1802
    if options.runType=='FULL':
1797
        writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
1803
        writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
1798
    else:
1804
    else:
1799
        writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
1805
        writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
1800
    #commitPricing(successfulAutoDecrease,successfulAutoIncrease,timestamp)
1806
    commitPricing(successfulAutoDecrease,successfulAutoIncrease,timestamp)
1801
    sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
1807
    sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
1802
    processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
1808
    processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
1803
    #updatePricesOnSnapdeal(successfulAutoDecrease,successfulAutoIncrease)
1809
    updatePricesOnSnapdeal(successfulAutoDecrease,successfulAutoIncrease)
1804
    
1810
    
1805
if __name__ == '__main__':
1811
if __name__ == '__main__':
1806
    main()
1812
    main()
1807
1813