| Line 226... |
Line 226... |
| 226 |
delete_discounts_from_cart(cart.id, cart=cart)
|
226 |
delete_discounts_from_cart(cart.id, cart=cart)
|
| 227 |
cart.discounted_price = None
|
227 |
cart.discounted_price = None
|
| 228 |
cart.coupon_code = None
|
228 |
cart.coupon_code = None
|
| 229 |
session.commit()
|
229 |
session.commit()
|
| 230 |
|
230 |
|
| 231 |
def commit_cart(cart_id, sessionSource, sessionTime, firstSource, firstSourceTime, userId, schemeId):
|
231 |
def commit_cart(cart_id, sessionSource, sessionTime, firstSource, firstSourceTime, userId, schemeId, orderSource):
|
| 232 |
cart = get_cart_by_id(cart_id)
|
232 |
cart = get_cart_by_id(cart_id)
|
| 233 |
#now we have a cart. Need to create a transaction with it
|
233 |
#now we have a cart. Need to create a transaction with it
|
| 234 |
txn = TTransaction()
|
234 |
txn = TTransaction()
|
| 235 |
txn.shoppingCartid = cart_id
|
235 |
txn.shoppingCartid = cart_id
|
| 236 |
txn.customer_id = userId
|
236 |
txn.customer_id = userId
|
| Line 241... |
Line 241... |
| 241 |
txn.sessionSource = sessionSource
|
241 |
txn.sessionSource = sessionSource
|
| 242 |
txn.sessionStartTime = sessionTime
|
242 |
txn.sessionStartTime = sessionTime
|
| 243 |
txn.firstSource = firstSource
|
243 |
txn.firstSource = firstSource
|
| 244 |
txn.firstSourceTime = firstSourceTime
|
244 |
txn.firstSourceTime = firstSourceTime
|
| 245 |
txn.emiSchemeId = schemeId
|
245 |
txn.emiSchemeId = schemeId
|
| 246 |
txn.orders = create_orders(cart, userId)
|
246 |
txn.orders = create_orders(cart, userId, orderSource)
|
| 247 |
|
247 |
|
| 248 |
transaction_client = TransactionClient().get_client()
|
248 |
transaction_client = TransactionClient().get_client()
|
| 249 |
txn_id = transaction_client.createTransaction(txn)
|
249 |
txn_id = transaction_client.createTransaction(txn)
|
| 250 |
session.commit()
|
250 |
session.commit()
|
| 251 |
|
251 |
|
| 252 |
return txn_id
|
252 |
return txn_id
|
| 253 |
|
253 |
|
| 254 |
def create_orders(cart, userId):
|
254 |
def create_orders(cart, userId, orderSource):
|
| 255 |
cart_lines = cart.lines
|
255 |
cart_lines = cart.lines
|
| 256 |
orders = []
|
256 |
orders = []
|
| 257 |
isGv = False
|
257 |
isGv = False
|
| 258 |
if cart.coupon_code:
|
258 |
if cart.coupon_code:
|
| 259 |
try:
|
259 |
try:
|
| Line 278... |
Line 278... |
| 278 |
quantity_remaining_for_order -= discount.quantity
|
278 |
quantity_remaining_for_order -= discount.quantity
|
| 279 |
|
279 |
|
| 280 |
i = 0
|
280 |
i = 0
|
| 281 |
while i < quantity_remaining_for_order:
|
281 |
while i < quantity_remaining_for_order:
|
| 282 |
t_line_item = create_line_item(line.item_id, line.actual_price)
|
282 |
t_line_item = create_line_item(line.item_id, line.actual_price)
|
| 283 |
t_order = create_order(userId, cart.address_id, t_line_item, cart.pickupStoreId, 0, line.insurer, (line.insuranceAmount/line.quantity), insuranceDetails, line.dataProtectionInsurer,(line.dataProtectionAmount)/line.quantity)
|
283 |
t_order = create_order(userId, cart.address_id, t_line_item, cart.pickupStoreId, 0, line.insurer, (line.insuranceAmount/line.quantity), insuranceDetails, line.dataProtectionInsurer,(line.dataProtectionAmount)/line.quantity, orderSource)
|
| 284 |
orders.append(t_order)
|
284 |
orders.append(t_order)
|
| 285 |
i += 1
|
285 |
i += 1
|
| 286 |
return orders
|
286 |
return orders
|
| 287 |
|
287 |
|
| 288 |
def create_order(userId, address_id, t_line_item, pickupStoreId, gvAmount, insurer, insuranceAmount, insuranceDetails, dataProtectionInsurer, dataProtectionAmount):
|
288 |
def create_order(userId, address_id, t_line_item, pickupStoreId, gvAmount, insurer, insuranceAmount, insuranceDetails, dataProtectionInsurer, dataProtectionAmount, orderSource):
|
| 289 |
user = User.get_by(id=userId)
|
289 |
user = User.get_by(id=userId)
|
| 290 |
address = Address.get_by(id=address_id)
|
290 |
address = Address.get_by(id=address_id)
|
| 291 |
t_order = TOrder()
|
291 |
t_order = TOrder()
|
| 292 |
|
292 |
|
| 293 |
t_order.customer_id = user.id
|
293 |
t_order.customer_id = user.id
|
| Line 320... |
Line 320... |
| 320 |
|
320 |
|
| 321 |
catalog_client = CatalogClient().get_client()
|
321 |
catalog_client = CatalogClient().get_client()
|
| 322 |
freebie_item_id = catalog_client.getFreebieForItem(t_line_item.item_id)
|
322 |
freebie_item_id = catalog_client.getFreebieForItem(t_line_item.item_id)
|
| 323 |
if freebie_item_id:
|
323 |
if freebie_item_id:
|
| 324 |
t_order.freebieItemId = freebie_item_id
|
324 |
t_order.freebieItemId = freebie_item_id
|
| 325 |
t_order.source = OrderSource.WEBSITE
|
325 |
t_order.source = orderSource
|
| 326 |
t_order.dataProtectionInsurer = dataProtectionInsurer
|
326 |
t_order.dataProtectionInsurer = dataProtectionInsurer
|
| 327 |
t_order.dataProtectionAmount = dataProtectionAmount
|
327 |
t_order.dataProtectionAmount = dataProtectionAmount
|
| 328 |
return t_order
|
328 |
return t_order
|
| 329 |
|
329 |
|
| 330 |
def create_line_item(item_id, final_price, quantity=1):
|
330 |
def create_line_item(item_id, final_price, quantity=1):
|