| Line 295... |
Line 295... |
| 295 |
isGv = pc.isGiftVoucher(cart.coupon_code)
|
295 |
isGv = pc.isGiftVoucher(cart.coupon_code)
|
| 296 |
except:
|
296 |
except:
|
| 297 |
isGv = False
|
297 |
isGv = False
|
| 298 |
|
298 |
|
| 299 |
insuranceDetails = InsuranceDetails.get_by(addressId = cart.address_id)
|
299 |
insuranceDetails = InsuranceDetails.get_by(addressId = cart.address_id)
|
| 300 |
|
300 |
itemIds = []
|
| - |
|
301 |
for line in cart_lines:
|
| - |
|
302 |
itemIds.append(line.item_id)
|
| - |
|
303 |
inventory_client = CatalogClient().get_client()
|
| - |
|
304 |
items = inventory_client.getItems(itemIds)
|
| - |
|
305 |
itemsMap = {}
|
| - |
|
306 |
for item in items:
|
| - |
|
307 |
itemsMap[item.id] = item
|
| 301 |
for line in cart_lines:
|
308 |
for line in cart_lines:
|
| 302 |
if line.line_status == LineStatus.LINE_ACTIVE:
|
309 |
if line.line_status == LineStatus.LINE_ACTIVE:
|
| 303 |
quantity_remaining_for_order = line.quantity
|
310 |
quantity_remaining_for_order = line.quantity
|
| 304 |
|
311 |
|
| 305 |
for discount in line.discounts:
|
312 |
for discount in line.discounts:
|
| 306 |
#i = 0
|
313 |
#i = 0
|
| 307 |
#while i < discount.quantity:
|
314 |
#while i < discount.quantity:
|
| 308 |
t_line_item = create_line_item(line, line.actual_price if isGv else (line.actual_price - discount.discount), line.quantity)
|
315 |
t_line_item = create_line_item(line, line.actual_price if isGv else (line.actual_price - discount.discount), line.quantity, itemsMap.get(line.item_id))
|
| 309 |
t_order = create_order(userId, cart.address_id, t_line_item, cart.pickupStoreId, discount.discount if isGv else 0, line.insurer, (line.insuranceAmount/line.quantity), insuranceDetails,line.dataProtectionInsurer,(line.dataProtectionAmount)/line.quantity, orderSource, line.freebieId, totalshippingCost, totalCartVal)
|
316 |
t_order = create_order(userId, cart.address_id, t_line_item, cart.pickupStoreId, discount.discount if isGv else 0, line.insurer, (line.insuranceAmount/line.quantity), insuranceDetails,line.dataProtectionInsurer,(line.dataProtectionAmount)/line.quantity, orderSource, line.freebieId, totalshippingCost, totalCartVal)
|
| 310 |
orders.append(t_order)
|
317 |
orders.append(t_order)
|
| 311 |
#i += 1
|
318 |
#i += 1
|
| 312 |
quantity_remaining_for_order -= discount.quantity
|
319 |
quantity_remaining_for_order -= discount.quantity
|
| 313 |
|
320 |
|
| 314 |
if quantity_remaining_for_order > 0:
|
321 |
if quantity_remaining_for_order > 0:
|
| 315 |
t_line_item = create_line_item(line, line.actual_price, quantity_remaining_for_order)
|
322 |
t_line_item = create_line_item(line, line.actual_price, quantity_remaining_for_order, itemsMap.get(line.item_id))
|
| 316 |
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, line.freebieId, totalshippingCost, totalCartVal)
|
323 |
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, line.freebieId, totalshippingCost, totalCartVal)
|
| 317 |
orders.append(t_order)
|
324 |
orders.append(t_order)
|
| 318 |
'''
|
325 |
'''
|
| 319 |
i = 0
|
326 |
i = 0
|
| 320 |
while i < quantity_remaining_for_order:
|
327 |
while i < quantity_remaining_for_order:
|
| Line 370... |
Line 377... |
| 370 |
t_order.dataProtectionInsurer = dataProtectionInsurer
|
377 |
t_order.dataProtectionInsurer = dataProtectionInsurer
|
| 371 |
t_order.dataProtectionAmount = dataProtectionAmount
|
378 |
t_order.dataProtectionAmount = dataProtectionAmount
|
| 372 |
t_order.shippingCost = round((t_line_item.total_price*totalshippingCost)/totalCartVal, 0)
|
379 |
t_order.shippingCost = round((t_line_item.total_price*totalshippingCost)/totalCartVal, 0)
|
| 373 |
return t_order
|
380 |
return t_order
|
| 374 |
|
381 |
|
| 375 |
def create_line_item(line, final_price, quantity=1):
|
382 |
def create_line_item(line, final_price, quantity=1, item=None):
|
| - |
|
383 |
if item is None:
|
| 376 |
inventory_client = CatalogClient().get_client()
|
384 |
inventory_client = CatalogClient().get_client()
|
| 377 |
item = inventory_client.getItem(line.item_id)
|
385 |
item = inventory_client.getItem(line.item_id)
|
| 378 |
t_line_item = TLineItem()
|
386 |
t_line_item = TLineItem()
|
| 379 |
t_line_item.productGroup = item.productGroup
|
387 |
t_line_item.productGroup = item.productGroup
|
| 380 |
t_line_item.brand = item.brand
|
388 |
t_line_item.brand = item.brand
|
| 381 |
t_line_item.model_number = item.modelNumber
|
389 |
t_line_item.model_number = item.modelNumber
|
| 382 |
if item.color is None or item.color == "NA":
|
390 |
if item.color is None or item.color == "NA":
|