| Line 13... |
Line 13... |
| 13 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderStatus
|
13 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderStatus
|
| 14 |
from shop2020.clients.CatalogClient import CatalogClient
|
14 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 15 |
from suds.client import Client
|
15 |
from suds.client import Client
|
| 16 |
from xml.dom.minidom import parseString
|
16 |
from xml.dom.minidom import parseString
|
| 17 |
import logging
|
17 |
import logging
|
| - |
|
18 |
import re
|
| 18 |
|
19 |
|
| 19 |
def delivered_orders():
|
20 |
def delivered_orders():
|
| 20 |
DataService.initialize(db_hostname="192.168.190.114")
|
21 |
DataService.initialize(db_hostname="192.168.190.114")
|
| 21 |
todate = datetime.now()
|
22 |
todate = datetime.now()
|
| 22 |
todate = todate-timedelta(days = 10)
|
23 |
todate = todate-timedelta(days = 10)
|
| Line 210... |
Line 211... |
| 210 |
Attempt = 1
|
211 |
Attempt = 1
|
| 211 |
while not Connected:
|
212 |
while not Connected:
|
| 212 |
try:
|
213 |
try:
|
| 213 |
response = client.service.InsertSalesRecord('SAHOLIC',line.serial_number,getValidDateFormat(order.billing_timestamp.date()),order.invoice_number,\
|
214 |
response = client.service.InsertSalesRecord('SAHOLIC',line.serial_number,getValidDateFormat(order.billing_timestamp.date()),order.invoice_number,\
|
| 214 |
'Mobile Phones',line.brand,xstr(line.model_name) + " " + xstr(line.model_number),line.unit_price,\
|
215 |
'Mobile Phones',line.brand,xstr(line.model_name) + " " + xstr(line.model_number),line.unit_price,\
|
| 215 |
0.0,line.total_price,order.customer_name,insurance.guardianName,dateOfBirth,str(order.id),\
|
216 |
0.0,line.total_price,getValidName(order.customer_name),getValidName(insurance.guardianName),dateOfBirth,str(order.id),\
|
| 216 |
order.customer_mobilenumber,'')
|
217 |
order.customer_mobilenumber,'')
|
| 217 |
print ('SAHOLIC',line.serial_number,getValidDateFormat(order.billing_timestamp.date()),order.invoice_number,\
|
218 |
print ('SAHOLIC',line.serial_number,getValidDateFormat(order.billing_timestamp.date()),order.invoice_number,\
|
| 218 |
'Mobile Phones',line.brand,xstr(line.model_name) + " " + xstr(line.model_number),line.unit_price,\
|
219 |
'Mobile Phones',line.brand,xstr(line.model_name) + " " + xstr(line.model_number),line.unit_price,\
|
| 219 |
0.0,line.total_price,order.customer_name,insurance.guardianName,dateOfBirth,str(order.id),\
|
220 |
0.0,line.total_price,getValidName(order.customer_name),getValidName(insurance.guardianName),dateOfBirth,str(order.id),\
|
| 220 |
order.customer_mobilenumber,'')
|
221 |
order.customer_mobilenumber,'')
|
| 221 |
print "Response : ",response
|
222 |
print "Response : ",response
|
| 222 |
if response is None:
|
223 |
if response is None:
|
| 223 |
print "Unable to insert sale record.Empty Response came.Attempting again...."
|
224 |
print "Unable to insert sale record.Empty Response came.Attempting again...."
|
| 224 |
if Attempt == 3:
|
225 |
if Attempt == 3:
|
| Line 275... |
Line 276... |
| 275 |
return '19700101'
|
276 |
return '19700101'
|
| 276 |
return str(datetime.strptime(dateToFormat,"%b %d %Y").date()).replace('-','')
|
277 |
return str(datetime.strptime(dateToFormat,"%b %d %Y").date()).replace('-','')
|
| 277 |
|
278 |
|
| 278 |
def getDateFormatForDob2(dateToFormat):
|
279 |
def getDateFormatForDob2(dateToFormat):
|
| 279 |
return str(datetime.strptime(dateToFormat,"%d %b %Y").date()).replace('-','')
|
280 |
return str(datetime.strptime(dateToFormat,"%d %b %Y").date()).replace('-','')
|
| - |
|
281 |
|
| - |
|
282 |
def getValidName(nameToFormat):
|
| - |
|
283 |
pattern = r'[^\.a-zA-Z\ \']'
|
| - |
|
284 |
return re.sub(pattern,"",nameToFormat)
|
| 280 |
|
285 |
|
| 281 |
def main():
|
286 |
def main():
|
| 282 |
submitDeliveredOrdersDetails(sys.argv)
|
287 |
submitDeliveredOrdersDetails(sys.argv)
|
| 283 |
delivered_orders()
|
288 |
delivered_orders()
|
| 284 |
returned_orders()
|
289 |
returned_orders()
|