| Line 209... |
Line 209... |
| 209 |
try:
|
209 |
try:
|
| 210 |
response = client.service.InsertSalesRecord('SAHOLIC',line.serial_number,getValidDateFormat(order.billing_timestamp.date()),order.invoice_number,\
|
210 |
response = client.service.InsertSalesRecord('SAHOLIC',line.serial_number,getValidDateFormat(order.billing_timestamp.date()),order.invoice_number,\
|
| 211 |
'Mobile Phones',line.brand,xstr(line.model_name) + " " + xstr(line.model_number),line.unit_price,\
|
211 |
'Mobile Phones',line.brand,xstr(line.model_name) + " " + xstr(line.model_number),line.unit_price,\
|
| 212 |
'0',line.total_price,order.customer_name,insurance.guardianName,dateOfBirth,str(order.id),\
|
212 |
'0',line.total_price,order.customer_name,insurance.guardianName,dateOfBirth,str(order.id),\
|
| 213 |
order.customer_mobilenumber,'')
|
213 |
order.customer_mobilenumber,'')
|
| 214 |
|
- |
|
| 215 |
Connected=True
|
214 |
Connected=True
|
| 216 |
except:
|
215 |
except:
|
| 217 |
print "Unable to insert sale record.Attempting again...."
|
216 |
print "Unable to insert sale record.Attempting again...."
|
| 218 |
Attempt = Attempt+1
|
217 |
Attempt = Attempt+1
|
| 219 |
if Attempt ==3:
|
218 |
if Attempt ==3:
|
| Line 235... |
Line 234... |
| 235 |
serverSide.append(order.id)
|
234 |
serverSide.append(order.id)
|
| 236 |
else:
|
235 |
else:
|
| 237 |
dataFormat.append(order.id)
|
236 |
dataFormat.append(order.id)
|
| 238 |
|
237 |
|
| 239 |
elif (statusStr == 'Success'):
|
238 |
elif (statusStr == 'Success'):
|
| 240 |
insurance.isDeclared = True
|
- |
|
| 241 |
declaredAmount += line.total_price
|
- |
|
| 242 |
successful.append(order.id)
|
239 |
successful.append(order.id)
|
| 243 |
print "Insurance details successfully inserted.Order Id ",order.id
|
240 |
print "Insurance details successfully inserted.Order Id ",order.id
|
| 244 |
|
241 |
|
| 245 |
else:
|
242 |
else:
|
| 246 |
serverSide.append(order.id)
|
243 |
serverSide.append(order.id)
|
| 247 |
|
244 |
|
| 248 |
session.commit()
|
- |
|
| 249 |
client = CatalogClient().get_client()
|
- |
|
| 250 |
client.updateInsuranceDeclaredAmount(1, declaredAmount)
|
- |
|
| 251 |
today = date.today()
|
245 |
today = date.today()
|
| 252 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
246 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
| 253 |
insurer = client.getInsurer(1)
|
- |
|
| 254 |
EmailAttachmentSender.mail("cnc.center@shop2020.in", "5h0p2o2o", ["pramit.singh@shop2020.in","rajveer.singh@shop2020.in","anupam.singh@shop2020.in","rajneesh.arora@shop2020.in", "amit.tyagi@spiceretail.co.in", "pardeep.panwar@spiceretail.co.in", "j.p.gupta@shop2020.in"], "Declaration Status for insurer " + insurer.name + " as on " + datestr + " : (Declared Amount - " + str(insurer.declaredAmount) + ") (Total Amount - " + str(insurer.creditedAmount), "", [], [], [])
|
- |
|
| 255 |
mail_body = "Number of records successfully inserted :"+str(len(successful))+"\nFollowing order id's were not processed because\nServer Side Error: "+', '.join(map(str, serverSide))+"\n"+"Data Format Error: "+', '.join(map(str, dataFormat))+"\n"+"Duplicate entry IMEI: "+', '.join(map(str, duplicateRecord))
|
247 |
mail_body = "Number of records successfully inserted :"+str(len(successful))+"\nFollowing order id's were not processed because\nServer Side Error: "+', '.join(map(str, serverSide))+"\n"+"Data Format Error: "+', '.join(map(str, dataFormat))+"\n"+"Duplicate entry IMEI: "+', '.join(map(str, duplicateRecord))
|
| 256 |
print mail_body
|
248 |
print mail_body
|
| 257 |
EmailAttachmentSender.mail("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in","kshitij.sood@shop2020.in"], "Insurance submission result for date " + datestr, mail_body, [], [], [])
|
249 |
EmailAttachmentSender.mail("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in","kshitij.sood@shop2020.in"], "Insurance submission result for date " + datestr, mail_body, [], [], [])
|
| 258 |
|
250 |
|
| 259 |
|
251 |
|
| 260 |
|
252 |
|
| 261 |
def getValidDateFormat(dateToFormat):
|
253 |
def getValidDateFormat(dateToFormat):
|
| 262 |
return str(dateToFormat).replace('-','')
|
254 |
return str(dateToFormat).replace('-','')
|
| 263 |
|
255 |
|
| 264 |
def getDateFormatForDob(dateToFormat):
|
256 |
def getDateFormatForDob(dateToFormat):
|
| - |
|
257 |
if (dateToFormat=='Organisation'):
|
| - |
|
258 |
return '19700101'
|
| 265 |
return str(datetime.strptime(dateToFormat,"%b %d %Y").date()).replace('-','')
|
259 |
return str(datetime.strptime(dateToFormat,"%b %d %Y").date()).replace('-','')
|
| 266 |
|
260 |
|
| 267 |
def getDateFormatForDob2(dateToFormat):
|
261 |
def getDateFormatForDob2(dateToFormat):
|
| 268 |
return str(datetime.strptime(dateToFormat,"%d %b %Y").date()).replace('-','')
|
262 |
return str(datetime.strptime(dateToFormat,"%d %b %Y").date()).replace('-','')
|
| 269 |
|
263 |
|
| 270 |
def main():
|
264 |
def main():
|
| 271 |
submitDeliveredOrdersDetails()
|
265 |
submitDeliveredOrdersDetails()
|
| 272 |
#delivered_orders()
|
266 |
delivered_orders()
|
| 273 |
returned_orders()
|
267 |
returned_orders()
|
| 274 |
|
268 |
|
| 275 |
if __name__ == '__main__':
|
269 |
if __name__ == '__main__':
|
| 276 |
main()
|
270 |
main()
|
| 277 |
|
271 |
|