| Line 36... |
Line 36... |
| 36 |
for rownum in range(1, num_rows):
|
36 |
for rownum in range(1, num_rows):
|
| 37 |
#print sheet.row_values(rownum)
|
37 |
#print sheet.row_values(rownum)
|
| 38 |
catalog_item_id, category_id = [None, None]
|
38 |
catalog_item_id, category_id = [None, None]
|
| 39 |
|
39 |
|
| 40 |
#hotspot_category, brand, model_number, color, model_name, mrp, mop, dp, xfer_price, weight, start_date, deal_text, deal_value, comments, catalog_item_id, category_id = sheet.row_values(rownum)[0:17]
|
40 |
#hotspot_category, brand, model_number, color, model_name, mrp, mop, dp, xfer_price, weight, start_date, deal_text, deal_value, comments, catalog_item_id, category_id = sheet.row_values(rownum)[0:17]
|
| 41 |
brand, model_number, model_name, color, dp, mrp, mop, comments, hotspot_category, unused_feature, xfer_price, weight, start_date, deal_text, deal_value = sheet.row_values(rownum)[0:15]
|
41 |
our_brand, our_model_number, our_color, brand, model_number, model_name, color, dp, mrp, mop, sp, comments, hotspot_category, unused_feature, xfer_price, weight, start_date, deal_text, deal_value = sheet.row_values(rownum)[0:19]
|
| 42 |
#product_group, brand, model_number, color, xfer_price, mop, mrp, catalog_item_id, category_id = sheet.row_values(rownum)[0:9]
|
42 |
#product_group, brand, model_number, color, xfer_price, mop, mrp, catalog_item_id, category_id = sheet.row_values(rownum)[0:9]
|
| 43 |
if isinstance(model_number, float):
|
43 |
if isinstance(model_number, float):
|
| 44 |
model_number = str(int(model_number))
|
44 |
model_number = str(int(model_number))
|
| 45 |
|
45 |
if sp == '':
|
| - |
|
46 |
sp = mop
|
| 46 |
item = None
|
47 |
item = None
|
| 47 |
vendor_item_pricing = None
|
48 |
vendor_item_pricing = None
|
| 48 |
|
49 |
|
| 49 |
key = product_group.strip().lower() + '|' + brand.strip().lower() + '|' + model_number.strip().lower() + '|' + color.strip().lower()
|
50 |
key = product_group.strip().lower() + '|' + brand.strip().lower() + '|' + model_number.strip().lower() + '|' + color.strip().lower()
|
| 50 |
if key in existing_vendor_item_mappings_set:
|
51 |
if key in existing_vendor_item_mappings_set:
|
| Line 102... |
Line 103... |
| 102 |
vendor_item_pricing = VendorItemPricing.get_by(vendor=vendor, item=item)
|
103 |
vendor_item_pricing = VendorItemPricing.get_by(vendor=vendor, item=item)
|
| 103 |
if vendor_item_pricing is None:
|
104 |
if vendor_item_pricing is None:
|
| 104 |
vendor_item_pricing = VendorItemPricing(vendor=vendor, item=item)
|
105 |
vendor_item_pricing = VendorItemPricing(vendor=vendor, item=item)
|
| 105 |
session.add(vendor_item_pricing)
|
106 |
session.add(vendor_item_pricing)
|
| 106 |
|
107 |
|
| 107 |
if item.mrp != mrp or vendor_item_pricing.dealerPrice != dp or vendor_item_pricing.transfer_price != xfer_price:
|
108 |
if item.mrp != mrp or vendor_item_pricing.dealerPrice != dp or vendor_item_pricing.transfer_price != xfer_price or item.sellingPrice != sp:
|
| 108 |
updated_items.append(sheet.row_values(rownum)[0:15] + [item.mrp, item.dealerPrice, item.transfer_price])
|
109 |
updated_items.append(sheet.row_values(rownum)[0:19] + [item.mrp, item.dealerPrice, item.transfer_price])
|
| 109 |
|
110 |
|
| 110 |
if category_id !=None and category_id != "":
|
111 |
if category_id !=None and category_id != "":
|
| 111 |
item.category = int(category_id)
|
112 |
item.category = int(category_id)
|
| 112 |
|
113 |
|
| 113 |
if dp != "":
|
114 |
if dp != "":
|
| Line 116... |
Line 117... |
| 116 |
vendor_item_pricing.dealerPrice = dp
|
117 |
vendor_item_pricing.dealerPrice = dp
|
| 117 |
|
118 |
|
| 118 |
if mrp != "" and mop != "" and mrp < mop:
|
119 |
if mrp != "" and mop != "" and mrp < mop:
|
| 119 |
raise Exception("[BAD MRP and MOP:] for {0} {1} {2} {3}. MRP={4}. MOP={5}".format(product_group, brand, model_number, color, mrp, mop))
|
120 |
raise Exception("[BAD MRP and MOP:] for {0} {1} {2} {3}. MRP={4}. MOP={5}".format(product_group, brand, model_number, color, mrp, mop))
|
| 120 |
|
121 |
|
| - |
|
122 |
if mrp != "" and sp != "" and mrp < sp:
|
| - |
|
123 |
raise Exception("[BAD MRP and SP:] for {0} {1} {2} {3}. MRP={4}. SP={5}".format(product_group, brand, model_number, color, mrp, sp))
|
| - |
|
124 |
|
| 121 |
if mop != "" and xfer_price != "" and xfer_price > mop:
|
125 |
if mop != "" and xfer_price != "" and xfer_price > mop:
|
| 122 |
raise Exception("[BAD MOP and TP:] for {0} {1} {2} {3}. TP={4}. MOP={5}".format(product_group, brand, model_number, color, xfer_price, mop))
|
126 |
raise Exception("[BAD MOP and TP:] for {0} {1} {2} {3}. TP={4}. MOP={5}".format(product_group, brand, model_number, color, xfer_price, mop))
|
| 123 |
# if mrp != "":
|
127 |
# if mrp != "":
|
| 124 |
# if item.mrp == None or item.mrp >= mrp:
|
128 |
# if item.mrp == None or item.mrp >= mrp:
|
| 125 |
# item.mrp = mrp
|
129 |
# item.mrp = mrp
|
| Line 130... |
Line 134... |
| 130 |
item.mrp = mrp
|
134 |
item.mrp = mrp
|
| 131 |
|
135 |
|
| 132 |
if mop != "":
|
136 |
if mop != "":
|
| 133 |
item.mop = mop
|
137 |
item.mop = mop
|
| 134 |
vendor_item_pricing.mop = mop
|
138 |
vendor_item_pricing.mop = mop
|
| 135 |
item.sellingPrice = mop
|
- |
|
| 136 |
|
139 |
|
| 137 |
if xfer_price !="":
|
140 |
if xfer_price !="":
|
| 138 |
item.transfer_price = xfer_price
|
141 |
item.transfer_price = xfer_price
|
| 139 |
vendor_item_pricing.transfer_price = xfer_price
|
142 |
vendor_item_pricing.transfer_price = xfer_price
|
| 140 |
|
143 |
|
| 141 |
if item.startDate == None or item.startDate == '':
|
144 |
if item.startDate == None or item.startDate == '':
|
| 142 |
item.startDate = datetime.datetime.now()
|
145 |
item.startDate = datetime.datetime.now()
|
| 143 |
|
146 |
|
| - |
|
147 |
item.sellingPrice = sp
|
| 144 |
item.model_name = model_name
|
148 |
item.model_name = model_name
|
| 145 |
|
149 |
|
| 146 |
if weight != "":
|
150 |
if weight != "":
|
| 147 |
item.weight = weight
|
151 |
item.weight = weight
|
| 148 |
# if start_date != "":
|
152 |
# if start_date != "":
|