| Line 8... |
Line 8... |
| 8 |
from shop2020.model.v1.order.impl.DataService import InsuranceDetailForOrder
|
8 |
from shop2020.model.v1.order.impl.DataService import InsuranceDetailForOrder
|
| 9 |
import xlwt
|
9 |
import xlwt
|
| 10 |
from shop2020.utils import EmailAttachmentSender
|
10 |
from shop2020.utils import EmailAttachmentSender
|
| 11 |
from shop2020.utils.EmailAttachmentSender import get_attachment_part
|
11 |
from shop2020.utils.EmailAttachmentSender import get_attachment_part
|
| 12 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderStatus
|
12 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderStatus
|
| 13 |
|
- |
|
| - |
|
13 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 14 |
|
14 |
|
| 15 |
def main():
|
15 |
def main():
|
| 16 |
DataService.initialize()
|
16 |
DataService.initialize()
|
| 17 |
todate = datetime.now()
|
17 |
todate = datetime.now()
|
| 18 |
todate = todate-timedelta(days = 10)
|
18 |
todate = todate-timedelta(days = 10)
|
| Line 53... |
Line 53... |
| 53 |
sheet.write(0, 15, "OrderId", heading_xf)
|
53 |
sheet.write(0, 15, "OrderId", heading_xf)
|
| 54 |
sheet.write(0, 16, "OtherDetails3", heading_xf)
|
54 |
sheet.write(0, 16, "OtherDetails3", heading_xf)
|
| 55 |
|
55 |
|
| 56 |
xstr = lambda s: s or ""
|
56 |
xstr = lambda s: s or ""
|
| 57 |
|
57 |
|
| - |
|
58 |
declaredAmount= 0.0
|
| 58 |
i = 1
|
59 |
i = 1
|
| 59 |
for insurance in insurances:
|
60 |
for insurance in insurances:
|
| 60 |
order = insurance.order
|
61 |
order = insurance.order
|
| 61 |
if order.status != OrderStatus.DELIVERY_SUCCESS:
|
62 |
if order.status != OrderStatus.DELIVERY_SUCCESS:
|
| 62 |
continue
|
63 |
continue
|
| 63 |
line = order.lineitems[0]
|
64 |
line = order.lineitems[0]
|
| 64 |
insurance.isDeclared = True
|
65 |
insurance.isDeclared = True
|
| - |
|
66 |
declaredAmount += line.total_price
|
| 65 |
|
67 |
|
| 66 |
sheet.write(i, 0, insurance.startDate, date_style)
|
68 |
sheet.write(i, 0, insurance.startDate, date_style)
|
| 67 |
sheet.write(i, 1, '')
|
69 |
sheet.write(i, 1, '')
|
| 68 |
sheet.write(i, 2, order.invoice_number)
|
70 |
sheet.write(i, 2, order.invoice_number)
|
| 69 |
sheet.write(i, 3, order.customer_name)
|
71 |
sheet.write(i, 3, order.customer_name)
|
| Line 80... |
Line 82... |
| 80 |
sheet.write(i, 14, order.billing_timestamp, date_style)
|
82 |
sheet.write(i, 14, order.billing_timestamp, date_style)
|
| 81 |
sheet.write(i, 15, order.id)
|
83 |
sheet.write(i, 15, order.id)
|
| 82 |
sheet.write(i, 16, '')
|
84 |
sheet.write(i, 16, '')
|
| 83 |
i = i + 1
|
85 |
i = i + 1
|
| 84 |
|
86 |
|
| 85 |
|
- |
|
| 86 |
session.commit()
|
87 |
session.commit()
|
| - |
|
88 |
client = CatalogClient().get_client()
|
| - |
|
89 |
client.updateInsuranceDeclaredAmount(1, declaredAmount)
|
| 87 |
|
90 |
|
| 88 |
today = date.today()
|
91 |
today = date.today()
|
| 89 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
92 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
| 90 |
filename = "/tmp/insurance-" + datestr + ".xls"
|
93 |
filename = "/tmp/insurance-" + datestr + ".xls"
|
| 91 |
wbk.save(filename)
|
94 |
wbk.save(filename)
|
| 92 |
EmailAttachmentSender.mail("cnc.center@shop2020.in", "5h0p2o2o", ["ab@universalinsurance.co.in", "urmila.phadke@universalinsurace.co.in"], "Insurance Details for date ", "Please find attached insurance details 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"], [])
|
95 |
EmailAttachmentSender.mail("cnc.center@shop2020.in", "5h0p2o2o", ["ab@universalinsurance.co.in", "urmila.phadke@universalinsurace.co.in"], "Insurance Details for date ", "Please find attached insurance details 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"], [])
|