| Line 267... |
Line 267... |
| 267 |
|
267 |
|
| 268 |
|
268 |
|
| 269 |
txn.totalShippingCost = perUnitShippingCost * totalQty
|
269 |
txn.totalShippingCost = perUnitShippingCost * totalQty
|
| 270 |
|
270 |
|
| 271 |
txnOrders = create_orders(cart, userId, orderSource, perUnitShippingCost, totalCartVal)
|
271 |
txnOrders = create_orders(cart, userId, orderSource, perUnitShippingCost, totalCartVal)
|
| 272 |
shippingCostInOrders = 0
|
272 |
# shippingCostInOrders = 0
|
| 273 |
for order in txnOrders:
|
273 |
# for order in txnOrders:
|
| 274 |
shippingCostInOrders = shippingCostInOrders + order.shippingCost
|
274 |
# shippingCostInOrders = shippingCostInOrders + order.shippingCost
|
| 275 |
|
275 |
|
| 276 |
#diff = totalshippingCost - shippingCostInOrders
|
276 |
#diff = totalshippingCost - shippingCostInOrders
|
| 277 |
#txnOrders[0].shippingCost = txnOrders[0].shippingCost + diff
|
277 |
#txnOrders[0].shippingCost = txnOrders[0].shippingCost + diff
|
| 278 |
|
278 |
|
| 279 |
|
279 |
|
| 280 |
txn.orders = txnOrders
|
280 |
txn.orders = txnOrders
|
| 281 |
|
281 |
|
| 282 |
transaction_client = TransactionClient().get_client()
|
282 |
transaction_client = TransactionClient().get_client()
|
| 283 |
txn_id = transaction_client.createTransaction(txn)
|
283 |
txn_id = transaction_client.createTransaction(txn)
|
| 284 |
|
284 |
|
| - |
|
285 |
"""Update amount in wallet"""
|
| - |
|
286 |
|
| 285 |
privateDealUser = PrivateDealUser.query.filter(PrivateDealUser.id == userId).filter(PrivateDealUser.isActive==True).first()
|
287 |
privateDealUser = PrivateDealUser.query.filter(PrivateDealUser.id == userId).filter(PrivateDealUser.isActive==True).first()
|
| 286 |
if privateDealUser is not None and privateDealUser.counter is not None:
|
288 |
if privateDealUser is not None and privateDealUser.counter is not None:
|
| 287 |
privateDealUser.counter.lastPurchasedOn = datetime.datetime.now()
|
289 |
privateDealUser.counter.lastPurchasedOn = datetime.datetime.now()
|
| 288 |
session.commit()
|
290 |
session.commit()
|
| 289 |
|
291 |
|
| Line 329... |
Line 331... |
| 329 |
t_line_item = create_line_item(line, line.actual_price)
|
331 |
t_line_item = create_line_item(line, line.actual_price)
|
| 330 |
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)
|
332 |
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)
|
| 331 |
orders.append(t_order)
|
333 |
orders.append(t_order)
|
| 332 |
i += 1
|
334 |
i += 1
|
| 333 |
'''
|
335 |
'''
|
| - |
|
336 |
|
| - |
|
337 |
wallet_amount = cart.wallet_amount
|
| - |
|
338 |
|
| - |
|
339 |
for order in orders:
|
| - |
|
340 |
if ((order.total_amount+ order.totalShippingCost - order.gvAmount) >= wallet_amount):
|
| - |
|
341 |
order.wallet_amount = wallet_amount
|
| - |
|
342 |
else:
|
| - |
|
343 |
order.wallet_amount = order.total_amount+ order.totalShippingCost - order.gvAmount
|
| - |
|
344 |
|
| - |
|
345 |
order.net_payable_amount = order.total_amount+ order.totalShippingCost - order.gvAmount - order.wallet_amount
|
| - |
|
346 |
wallet_amount = wallet_amount - order.wallet_amount
|
| 334 |
return orders
|
347 |
return orders
|
| 335 |
|
348 |
|
| 336 |
def create_order(userId, address_id, t_line_item, pickupStoreId, gvAmount, insurer, insuranceAmount, insuranceDetails, dataProtectionInsurer, dataProtectionAmount, orderSource, freebieId, perUnitShippingCost, totalCartVal):
|
349 |
def create_order(userId, address_id, t_line_item, pickupStoreId, gvAmount, insurer, insuranceAmount, insuranceDetails, dataProtectionInsurer, dataProtectionAmount, orderSource, freebieId, perUnitShippingCost, totalCartVal):
|
| 337 |
user = User.get_by(id=userId)
|
350 |
user = User.get_by(id=userId)
|
| 338 |
address = Address.get_by(id=address_id)
|
351 |
address = Address.get_by(id=address_id)
|
| Line 673... |
Line 686... |
| 673 |
|
686 |
|
| 674 |
# Removing Coupon
|
687 |
# Removing Coupon
|
| 675 |
cart.total_price = None
|
688 |
cart.total_price = None
|
| 676 |
cart.discounted_price = None
|
689 |
cart.discounted_price = None
|
| 677 |
cart.coupon_code = None
|
690 |
cart.coupon_code = None
|
| - |
|
691 |
cart.wallet_amount = 0.0
|
| 678 |
|
692 |
|
| 679 |
session.commit()
|
693 |
session.commit()
|
| 680 |
return True
|
694 |
return True
|
| 681 |
|
695 |
|
| 682 |
def get_carts_with_coupon_count(coupon_code):
|
696 |
def get_carts_with_coupon_count(coupon_code):
|
| Line 1125... |
Line 1139... |
| 1125 |
def close_session():
|
1139 |
def close_session():
|
| 1126 |
if session.is_active:
|
1140 |
if session.is_active:
|
| 1127 |
print "session is active. closing it."
|
1141 |
print "session is active. closing it."
|
| 1128 |
session.close()
|
1142 |
session.close()
|
| 1129 |
|
1143 |
|
| - |
|
1144 |
|
| - |
|
1145 |
def set_wallet_amount_in_cart(cartId, wallet_amount):
|
| - |
|
1146 |
cart = Cart.get_by(id = cartId)
|
| - |
|
1147 |
if cart is None:
|
| - |
|
1148 |
raise ShoppingCartException(102, "The specified cart couldn't be found")
|
| - |
|
1149 |
if wallet_amount < 0:
|
| - |
|
1150 |
raise ShoppingCartException(103, "Wallet amount is negative")
|
| - |
|
1151 |
cart.wallet_amount = wallet_amount
|
| - |
|
1152 |
session.commit()
|
| - |
|
1153 |
return True
|
| 1130 |
|
1154 |
|