| Line 168... |
Line 168... |
| 168 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
168 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
| 169 |
filename = "/tmp/insurance-return-" + datestr + ".xls"
|
169 |
filename = "/tmp/insurance-return-" + datestr + ".xls"
|
| 170 |
wbk.save(filename)
|
170 |
wbk.save(filename)
|
| 171 |
EmailAttachmentSender.mail("cnc.center@shop2020.in", "5h0p2o2o", ["ab@universalinsurance.co.in", "urmila.phadke@universalinsurace.co.in"], "Cancelled Insurance Policy Details for date " + datestr, "Please find attached orders which insurance need to be cancelled for today.", [get_attachment_part(filename)], ["pramit.singh@shop2020.in","rbuniversal@gmail.com","rajveer.singh@shop2020.in","anupam.singh@shop2020.in","rajneesh.arora@shop2020.in"], [])
|
171 |
EmailAttachmentSender.mail("cnc.center@shop2020.in", "5h0p2o2o", ["ab@universalinsurance.co.in", "urmila.phadke@universalinsurace.co.in"], "Cancelled Insurance Policy Details for date " + datestr, "Please find attached orders which insurance need to be cancelled for today.", [get_attachment_part(filename)], ["pramit.singh@shop2020.in","rbuniversal@gmail.com","rajveer.singh@shop2020.in","anupam.singh@shop2020.in","rajneesh.arora@shop2020.in"], [])
|
| 172 |
|
172 |
|
| 173 |
def submitDeliveredOrdersDetails():
|
173 |
def submitDeliveredOrdersDetails(args):
|
| 174 |
DataService.initialize(db_hostname="192.168.190.114")
|
174 |
DataService.initialize(db_hostname="192.168.190.114")
|
| 175 |
todate = datetime.now()
|
175 |
todate = datetime.now()
|
| 176 |
todate = todate-timedelta(days = 10)
|
176 |
todate = todate-timedelta(days = 10)
|
| 177 |
xstr = lambda s: s or ""
|
177 |
xstr = lambda s: s or ""
|
| 178 |
|
178 |
|
| 179 |
declaredAmount= 0.0
|
- |
|
| 180 |
successful= []
|
179 |
successful= []
|
| 181 |
duplicateRecord = []
|
180 |
duplicateRecord = []
|
| 182 |
serverSide = []
|
181 |
serverSide = []
|
| 183 |
dataFormat = []
|
182 |
dataFormat = []
|
| 184 |
client = Client('http://www.insuregadget.ae/SSSWebService/SSSWebService.asmx?wsdl')
|
183 |
client = Client('http://www.insuregadget.ae/SSSWebService/SSSWebService.asmx?wsdl')
|
| 185 |
header=client.factory.create('AuthHeader')
|
184 |
header=client.factory.create('AuthHeader')
|
| 186 |
header.Username = 'saholic'
|
185 |
header.Username = 'saholic'
|
| 187 |
header.Password = '1Dfgh4@#'
|
186 |
header.Password = '1Dfgh4@#'
|
| 188 |
client.set_options(soapheaders=header)
|
187 |
client.set_options(soapheaders=header)
|
| - |
|
188 |
|
| 189 |
|
189 |
|
| - |
|
190 |
if (len(args)>1):
|
| - |
|
191 |
insurances = InsuranceDetailForOrder.query.filter(InsuranceDetailForOrder.order_id.in_(args[1:])).all()
|
| - |
|
192 |
else:
|
| 190 |
insurances = InsuranceDetailForOrder.query.filter(InsuranceDetailForOrder.isDeclared == False).filter(InsuranceDetailForOrder.startDate >= todate).all()
|
193 |
insurances = InsuranceDetailForOrder.query.filter(InsuranceDetailForOrder.isDeclared == False).filter(InsuranceDetailForOrder.startDate >= todate).all()
|
| 191 |
if not insurances:
|
194 |
if not insurances:
|
| 192 |
return
|
195 |
return
|
| 193 |
for insurance in insurances:
|
196 |
for insurance in insurances:
|
| 194 |
order = insurance.order
|
197 |
order = insurance.order
|
| 195 |
if order.status != OrderStatus.DELIVERY_SUCCESS:
|
198 |
if order.status != OrderStatus.DELIVERY_SUCCESS:
|
| Line 214... |
Line 217... |
| 214 |
print ('SAHOLIC',line.serial_number,getValidDateFormat(order.billing_timestamp.date()),order.invoice_number,\
|
217 |
print ('SAHOLIC',line.serial_number,getValidDateFormat(order.billing_timestamp.date()),order.invoice_number,\
|
| 215 |
'Mobile Phones',line.brand,xstr(line.model_name) + " " + xstr(line.model_number),line.unit_price,\
|
218 |
'Mobile Phones',line.brand,xstr(line.model_name) + " " + xstr(line.model_number),line.unit_price,\
|
| 216 |
0.0,line.total_price,order.customer_name,insurance.guardianName,dateOfBirth,str(order.id),\
|
219 |
0.0,line.total_price,order.customer_name,insurance.guardianName,dateOfBirth,str(order.id),\
|
| 217 |
order.customer_mobilenumber,'')
|
220 |
order.customer_mobilenumber,'')
|
| 218 |
print "Response : ",response
|
221 |
print "Response : ",response
|
| - |
|
222 |
if response is None:
|
| - |
|
223 |
print "Unable to insert sale record.Empty Response came.Attempting again...."
|
| - |
|
224 |
if Attempt == 3:
|
| - |
|
225 |
break
|
| - |
|
226 |
Attempt+=1
|
| - |
|
227 |
continue
|
| 219 |
Connected=True
|
228 |
Connected=True
|
| 220 |
except:
|
229 |
except:
|
| 221 |
print "Unable to insert sale record.Attempting again...."
|
230 |
print "Unable to insert sale record.Attempting again...."
|
| 222 |
Attempt = Attempt+1
|
231 |
Attempt = Attempt+1
|
| 223 |
if Attempt ==3:
|
232 |
if Attempt == 3:
|
| 224 |
break
|
233 |
break
|
| 225 |
if not Connected:
|
234 |
if not Connected:
|
| 226 |
serverSide.append(order.id)
|
235 |
serverSide.append(order.id)
|
| 227 |
continue
|
236 |
continue
|
| 228 |
|
237 |
|
| Line 250... |
Line 259... |
| 250 |
today = date.today()
|
259 |
today = date.today()
|
| 251 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
260 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
| 252 |
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))
|
261 |
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))
|
| 253 |
print mail_body
|
262 |
print mail_body
|
| 254 |
EmailAttachmentSender.mail("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in","kshitij.sood@shop2020.in"], "Insurance submission result for date " + datestr, mail_body, [], [], [])
|
263 |
EmailAttachmentSender.mail("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in","kshitij.sood@shop2020.in"], "Insurance submission result for date " + datestr, mail_body, [], [], [])
|
| 255 |
|
264 |
|
| - |
|
265 |
if(len(args)>1):
|
| - |
|
266 |
print "Exiting.Dont want to run delivered_orders() and returned_orders() again."
|
| - |
|
267 |
sys.exit(0)
|
| 256 |
|
268 |
|
| 257 |
|
269 |
|
| 258 |
def getValidDateFormat(dateToFormat):
|
270 |
def getValidDateFormat(dateToFormat):
|
| 259 |
return str(dateToFormat).replace('-','')
|
271 |
return str(dateToFormat).replace('-','')
|
| 260 |
|
272 |
|
| Line 265... |
Line 277... |
| 265 |
|
277 |
|
| 266 |
def getDateFormatForDob2(dateToFormat):
|
278 |
def getDateFormatForDob2(dateToFormat):
|
| 267 |
return str(datetime.strptime(dateToFormat,"%d %b %Y").date()).replace('-','')
|
279 |
return str(datetime.strptime(dateToFormat,"%d %b %Y").date()).replace('-','')
|
| 268 |
|
280 |
|
| 269 |
def main():
|
281 |
def main():
|
| 270 |
submitDeliveredOrdersDetails()
|
282 |
submitDeliveredOrdersDetails(sys.argv)
|
| 271 |
delivered_orders()
|
283 |
delivered_orders()
|
| 272 |
returned_orders()
|
284 |
returned_orders()
|
| 273 |
|
285 |
|
| 274 |
if __name__ == '__main__':
|
286 |
if __name__ == '__main__':
|
| 275 |
main()
|
287 |
main()
|