| Line 7... |
Line 7... |
| 7 |
AdditionalInfo, Payment, Shipment, TransactionTrail, Billing, ItemInfo
|
7 |
AdditionalInfo, Payment, Shipment, TransactionTrail, Billing, ItemInfo
|
| 8 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction,\
|
8 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction,\
|
| 9 |
TransactionServiceException
|
9 |
TransactionServiceException
|
| 10 |
import datetime
|
10 |
import datetime
|
| 11 |
from shop2020.utils.OrderStatus import status_transaction_init,\
|
11 |
from shop2020.utils.OrderStatus import status_transaction_init,\
|
| 12 |
status_shipment_shipped, status_shipment_delivered
|
12 |
status_shipment_shipped, status_shipment_delivered, get_c_status
|
| 13 |
from elixir import *
|
13 |
from elixir import *
|
| 14 |
from shop2020.utils.Utils import to_py_date
|
14 |
from shop2020.utils.Utils import to_py_date
|
| 15 |
from sqlalchemy.sql.expression import and_
|
15 |
from sqlalchemy.sql.expression import and_
|
| 16 |
|
16 |
|
| 17 |
|
17 |
|
| Line 47... |
Line 47... |
| 47 |
litem.additional_info.append(additional_info)
|
47 |
litem.additional_info.append(additional_info)
|
| 48 |
if t_transaction.shoppingCartid:
|
48 |
if t_transaction.shoppingCartid:
|
| 49 |
transaction.shopping_cart_id = t_transaction.shoppingCartid
|
49 |
transaction.shopping_cart_id = t_transaction.shoppingCartid
|
| 50 |
transaction.customer_id = t_transaction.customer_id
|
50 |
transaction.customer_id = t_transaction.customer_id
|
| 51 |
transaction.expected_delivery_time = to_py_date(t_transaction.expectedDeliveryTime)
|
51 |
transaction.expected_delivery_time = to_py_date(t_transaction.expectedDeliveryTime)
|
| - |
|
52 |
#no need to set status. It is already set.
|
| 52 |
transaction.status = t_transaction.transactionStatus
|
53 |
#transaction.status = t_transaction.transactionStatus
|
| 53 |
transaction.status_message = t_transaction.statusDescription
|
54 |
transaction.status_message = t_transaction.statusDescription
|
| 54 |
transaction.createdOn = to_py_date(t_transaction.createdOn)
|
55 |
transaction.createdOn = to_py_date(t_transaction.createdOn)
|
| 55 |
|
56 |
|
| 56 |
#add payment info
|
57 |
#add payment info
|
| 57 |
#transaction.payments=[]
|
58 |
#transaction.payments=[]
|
| Line 69... |
Line 70... |
| 69 |
payment.status = v.status
|
70 |
payment.status = v.status
|
| 70 |
payment.status_message = v.description
|
71 |
payment.status_message = v.description
|
| 71 |
payment.start_time = to_py_date(v.submissionTimestamp)
|
72 |
payment.start_time = to_py_date(v.submissionTimestamp)
|
| 72 |
payment.finish_time = to_py_date(v.completionTimestamp)
|
73 |
payment.finish_time = to_py_date(v.completionTimestamp)
|
| 73 |
transaction.payments.append(payment)
|
74 |
transaction.payments.append(payment)
|
| - |
|
75 |
if not t_transaction.shipmentInfo:
|
| - |
|
76 |
raise TransactionServiceException(109, "no shipping info attached with this")
|
| - |
|
77 |
transaction.shipments = []
|
| - |
|
78 |
for v in t_transaction.shipmentInfo.shipments:
|
| - |
|
79 |
shipment = Shipment()
|
| - |
|
80 |
shipment.weight = v.weight
|
| - |
|
81 |
shipment.insurance_value = v.insurance
|
| - |
|
82 |
shipment.status = get_c_status(v.status);
|
| - |
|
83 |
transaction.shipments.append(shipment)
|
| 74 |
session.commit()
|
84 |
session.commit()
|
| 75 |
return transaction.id
|
85 |
return transaction.id
|
| 76 |
|
86 |
|
| 77 |
|
87 |
|
| 78 |
def get_transaction(transaction_id):
|
88 |
def get_transaction(transaction_id):
|
| Line 266... |
Line 276... |
| 266 |
session.commit()
|
276 |
session.commit()
|
| 267 |
return True
|
277 |
return True
|
| 268 |
|
278 |
|
| 269 |
def set_billing(transaction_id, t_billing):
|
279 |
def set_billing(transaction_id, t_billing):
|
| 270 |
transaction = get_transaction(transaction_id)
|
280 |
transaction = get_transaction(transaction_id)
|
| - |
|
281 |
line_item = LineItem.query.filter_by(transaction_id=transaction_id).all()
|
| 271 |
line_item = LineItem.get_by(id = t_billing.lineItem.id)
|
282 |
#line_item = LineItem.get_by(id = t_billing.lineItem.id)
|
| 272 |
if not line_item:
|
283 |
if not line_item:
|
| 273 |
raise TransactionServiceException(101, "unable to get this line item for id %d" % (t_billing.lineItem.id))
|
284 |
raise TransactionServiceException(101, "unable to get this line item for id %d" % (t_billing.lineItem.id))
|
| 274 |
billing = Billing()
|
285 |
billing = Billing()
|
| 275 |
billing.line_item = line_item
|
286 |
billing.line_item = line_item
|
| 276 |
billing.bill_number = t_billing.billNumber
|
287 |
billing.bill_number = t_billing.billNumber
|
| 277 |
try:
|
288 |
try:
|
| 278 |
billing.created_on = to_py_date(t_billing.generatedTimestamp)
|
289 |
billing.created_on = to_py_date(t_billing.generatedTimestamp)
|
| 279 |
except:
|
290 |
except:
|
| 280 |
raise TransactionServiceException(108, "bad time stamp found while adding billing for transaction id %d" %(transaction.id))
|
291 |
raise TransactionServiceException(108, "bad time stamp found while adding billing for transaction id %d" %(transaction.id))
|
| 281 |
billing.generated_by = t_billing.generatedby
|
292 |
billing.generated_by = t_billing.generatedBy
|
| 282 |
session.commit()
|
293 |
session.commit()
|
| 283 |
return True
|
294 |
return True
|
| 284 |
|
295 |
|
| 285 |
def get_line_items(transaction_id):
|
296 |
def get_line_items(transaction_id):
|
| 286 |
transaction = get_transaction(transaction_id)
|
297 |
transaction = get_transaction(transaction_id)
|