| Line 740... |
Line 740... |
| 740 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
740 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 741 |
sheet.write(sheet_iterator, 25, round(proposed_tp,2))
|
741 |
sheet.write(sheet_iterator, 25, round(proposed_tp,2))
|
| 742 |
sheet.write(sheet_iterator, 26, round(proposed_sp,2))
|
742 |
sheet.write(sheet_iterator, 26, round(proposed_sp,2))
|
| 743 |
sheet.write(sheet_iterator, 27, round((proposed_tp - snapdealPricing.ourTp),2))
|
743 |
sheet.write(sheet_iterator, 27, round((proposed_tp - snapdealPricing.ourTp),2))
|
| 744 |
mp_history_item = session.query(MarketPlaceHistory).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.item_id==snapdealItemInfo.item_id).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).one()
|
744 |
mp_history_item = session.query(MarketPlaceHistory).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.item_id==snapdealItemInfo.item_id).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).one()
|
| - |
|
745 |
if mp_history_item is None:
|
| - |
|
746 |
sheet.write(sheet_iterator, 28, 'Auto Pricing Inactive')
|
| - |
|
747 |
sheet_iterator+=1
|
| - |
|
748 |
continue
|
| 745 |
sheet.write(sheet_iterator, 28, Decision._VALUES_TO_NAMES.get(mp_history_item.decision))
|
749 |
sheet.write(sheet_iterator, 28, Decision._VALUES_TO_NAMES.get(mp_history_item.decision))
|
| 746 |
sheet.write(sheet_iterator, 29, mp_history_item.reason)
|
750 |
sheet.write(sheet_iterator, 29, mp_history_item.reason)
|
| 747 |
if Decision._VALUES_TO_NAMES.get(mp_history_item.decision) == "AUTO_DECREMENT_SUCCESS":
|
751 |
if Decision._VALUES_TO_NAMES.get(mp_history_item.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 748 |
sheet.write(sheet_iterator, 30, math.ceil(mp_history_item.proposedSellingPrice))
|
752 |
sheet.write(sheet_iterator, 30, math.ceil(mp_history_item.proposedSellingPrice))
|
| 749 |
if Decision._VALUES_TO_NAMES.get(mp_history_item.decision) == "AUTO_INCREMENT_SUCCESS":
|
753 |
if Decision._VALUES_TO_NAMES.get(mp_history_item.decision) == "AUTO_INCREMENT_SUCCESS":
|
| Line 837... |
Line 841... |
| 837 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
841 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 838 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
842 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
| 839 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
843 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
| 840 |
sheet.write(sheet_iterator, 28, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
844 |
sheet.write(sheet_iterator, 28, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| 841 |
mp_history_item = session.query(MarketPlaceHistory).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.item_id==snapdealItemInfo.item_id).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).one()
|
845 |
mp_history_item = session.query(MarketPlaceHistory).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.item_id==snapdealItemInfo.item_id).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).one()
|
| - |
|
846 |
if mp_history_item is None:
|
| - |
|
847 |
sheet.write(sheet_iterator, 29, 'Auto pricing Inactive')
|
| - |
|
848 |
sheet_iterator+=1
|
| - |
|
849 |
continue
|
| 842 |
sheet.write(sheet_iterator, 29, Decision._VALUES_TO_NAMES.get(mp_history_item.decision))
|
850 |
sheet.write(sheet_iterator, 29, Decision._VALUES_TO_NAMES.get(mp_history_item.decision))
|
| 843 |
sheet.write(sheet_iterator, 30, mp_history_item.reason)
|
851 |
sheet.write(sheet_iterator, 30, mp_history_item.reason)
|
| 844 |
if Decision._VALUES_TO_NAMES.get(mp_history_item.decision) == "AUTO_DECREMENT_SUCCESS":
|
852 |
if Decision._VALUES_TO_NAMES.get(mp_history_item.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 845 |
sheet.write(sheet_iterator, 31, math.ceil(mp_history_item.proposedSellingPrice))
|
853 |
sheet.write(sheet_iterator, 31, math.ceil(mp_history_item.proposedSellingPrice))
|
| 846 |
if Decision._VALUES_TO_NAMES.get(mp_history_item.decision) == "AUTO_INCREMENT_SUCCESS":
|
854 |
if Decision._VALUES_TO_NAMES.get(mp_history_item.decision) == "AUTO_INCREMENT_SUCCESS":
|
| Line 1146... |
Line 1154... |
| 1146 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
1154 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
| 1147 |
sheet.write(sheet_iterator, 3, "False")
|
1155 |
sheet.write(sheet_iterator, 3, "False")
|
| 1148 |
sheet_iterator+=1
|
1156 |
sheet_iterator+=1
|
| 1149 |
|
1157 |
|
| 1150 |
|
1158 |
|
| 1151 |
autoPricingItems = session.query(MarketPlaceHistory,Item).join((Item,MarketPlaceHistory.item_id==Item.id)).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.decision.in_([1,2,3,4])).all()
|
1159 |
# autoPricingItems = session.query(MarketPlaceHistory,Item).join((Item,MarketPlaceHistory.item_id==Item.id)).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.decision.in_([1,2,3,4])).all()
|
| 1152 |
sheet = wbk.add_sheet('Auto Inc and Dec')
|
1160 |
# sheet = wbk.add_sheet('Auto Inc and Dec')
|
| 1153 |
|
1161 |
#
|
| 1154 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
1162 |
# heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| 1155 |
|
1163 |
#
|
| 1156 |
excel_integer_format = '0'
|
1164 |
# excel_integer_format = '0'
|
| 1157 |
integer_style = xlwt.XFStyle()
|
1165 |
# integer_style = xlwt.XFStyle()
|
| 1158 |
integer_style.num_format_str = excel_integer_format
|
1166 |
# integer_style.num_format_str = excel_integer_format
|
| 1159 |
xstr = lambda s: s or ""
|
1167 |
# xstr = lambda s: s or ""
|
| 1160 |
|
1168 |
#
|
| 1161 |
sheet.write(0, 0, "Item ID", heading_xf)
|
1169 |
# sheet.write(0, 0, "Item ID", heading_xf)
|
| 1162 |
sheet.write(0, 1, "Brand", heading_xf)
|
1170 |
# sheet.write(0, 1, "Brand", heading_xf)
|
| 1163 |
sheet.write(0, 2, "Product Name", heading_xf)
|
1171 |
# sheet.write(0, 2, "Product Name", heading_xf)
|
| 1164 |
sheet.write(0, 3, "Decision", heading_xf)
|
1172 |
# sheet.write(0, 3, "Decision", heading_xf)
|
| 1165 |
sheet.write(0, 4, "Reason", heading_xf)
|
1173 |
# sheet.write(0, 4, "Reason", heading_xf)
|
| 1166 |
sheet.write(0, 5, "Old Selling Price", heading_xf)
|
1174 |
# sheet.write(0, 5, "Old Selling Price", heading_xf)
|
| 1167 |
sheet.write(0, 6, "Selling Price Updated",heading_xf)
|
1175 |
# sheet.write(0, 6, "Selling Price Updated",heading_xf)
|
| 1168 |
|
1176 |
#
|
| 1169 |
sheet_iterator=1
|
1177 |
# sheet_iterator=1
|
| 1170 |
for autoPricingItem in autoPricingItems:
|
1178 |
# for autoPricingItem in autoPricingItems:
|
| 1171 |
mpHistory = autoPricingItem[0]
|
1179 |
# mpHistory = autoPricingItem[0]
|
| 1172 |
item = autoPricingItem[1]
|
1180 |
# item = autoPricingItem[1]
|
| 1173 |
it = Item.query.filter_by(id=item.id).one()
|
1181 |
# it = Item.query.filter_by(id=item.id).one()
|
| 1174 |
sheet.write(sheet_iterator, 0, item.id)
|
1182 |
# sheet.write(sheet_iterator, 0, item.id)
|
| 1175 |
sheet.write(sheet_iterator, 1, it.brand)
|
1183 |
# sheet.write(sheet_iterator, 1, it.brand)
|
| 1176 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
1184 |
# sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
| 1177 |
sheet.write(sheet_iterator, 3, Decision._VALUES_TO_NAMES.get(mpHistory.decision))
|
1185 |
# sheet.write(sheet_iterator, 3, Decision._VALUES_TO_NAMES.get(mpHistory.decision))
|
| 1178 |
sheet.write(sheet_iterator, 4, mpHistory.reason)
|
1186 |
# sheet.write(sheet_iterator, 4, mpHistory.reason)
|
| 1179 |
if Decision._VALUES_TO_NAMES.get(mpHistory.decision) == "AUTO_DECREMENT_SUCCESS":
|
1187 |
# if Decision._VALUES_TO_NAMES.get(mpHistory.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 1180 |
sheet.write(sheet_iterator, 5, mpHistory.ourSellingPrice)
|
1188 |
# sheet.write(sheet_iterator, 5, mpHistory.ourSellingPrice)
|
| 1181 |
sheet.write(sheet_iterator, 6, math.ceil(mpHistory.proposedSellingPrice))
|
1189 |
# sheet.write(sheet_iterator, 6, math.ceil(mpHistory.proposedSellingPrice))
|
| 1182 |
if Decision._VALUES_TO_NAMES.get(mpHistory.decision) == "AUTO_INCREMENT_SUCCESS":
|
1190 |
# if Decision._VALUES_TO_NAMES.get(mpHistory.decision) == "AUTO_INCREMENT_SUCCESS":
|
| 1183 |
sheet.write(sheet_iterator, 5, mpHistory.ourSellingPrice)
|
1191 |
# sheet.write(sheet_iterator, 5, mpHistory.ourSellingPrice)
|
| 1184 |
sheet.write(sheet_iterator, 6, math.ceil(mpHistory.ourSellingPrice+max(10,.01*mpHistory.ourSellingPrice)))
|
1192 |
# sheet.write(sheet_iterator, 6, math.ceil(mpHistory.ourSellingPrice+max(10,.01*mpHistory.ourSellingPrice)))
|
| 1185 |
sheet_iterator+=1
|
1193 |
# sheet_iterator+=1
|
| 1186 |
|
1194 |
|
| 1187 |
filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
|
1195 |
filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
|
| 1188 |
wbk.save(filename)
|
1196 |
wbk.save(filename)
|
| 1189 |
try:
|
1197 |
try:
|
| 1190 |
#EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
|
1198 |
#EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
|