Subversion Repositories SmartDukaan

Rev

Rev 11877 | Rev 11980 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11877 Rev 11915
Line 273... Line 273...
273
            quantity_remaining_for_order = line.quantity
273
            quantity_remaining_for_order = line.quantity
274
        
274
        
275
            for discount in line.discounts:
275
            for discount in line.discounts:
276
                i = 0
276
                i = 0
277
                while i < discount.quantity:
277
                while i < discount.quantity:
278
                    t_line_item = create_line_item(line.item_id, line.actual_price if isGv else (line.actual_price - discount.discount))
278
                    t_line_item = create_line_item(line, line.actual_price if isGv else (line.actual_price - discount.discount))
279
                    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)
279
                    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)
280
                    orders.append(t_order)
280
                    orders.append(t_order)
281
                    i += 1
281
                    i += 1
282
                quantity_remaining_for_order -= discount.quantity
282
                quantity_remaining_for_order -= discount.quantity
283
            
283
            
284
            i = 0
284
            i = 0
285
            while i < quantity_remaining_for_order:
285
            while i < quantity_remaining_for_order:
286
                t_line_item = create_line_item(line.item_id, line.actual_price)
286
                t_line_item = create_line_item(line, line.actual_price)
287
                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)
287
                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)
288
                orders.append(t_order)
288
                orders.append(t_order)
289
                i += 1
289
                i += 1
290
    return orders
290
    return orders
291
 
291
 
Line 333... Line 333...
333
    t_order.source = orderSource
333
    t_order.source = orderSource
334
    t_order.dataProtectionInsurer = dataProtectionInsurer
334
    t_order.dataProtectionInsurer = dataProtectionInsurer
335
    t_order.dataProtectionAmount = dataProtectionAmount
335
    t_order.dataProtectionAmount = dataProtectionAmount
336
    return t_order
336
    return t_order
337
        
337
        
338
def create_line_item(item_id, final_price, quantity=1):
338
def create_line_item(line, final_price, quantity=1):
339
    inventory_client = CatalogClient().get_client()
339
    inventory_client = CatalogClient().get_client()
340
    item = inventory_client.getItem(item_id)
340
    item = inventory_client.getItem(line.item_id)
341
    t_line_item = TLineItem()
341
    t_line_item = TLineItem()
342
    t_line_item.productGroup = item.productGroup
342
    t_line_item.productGroup = item.productGroup
343
    t_line_item.brand = item.brand
343
    t_line_item.brand = item.brand
344
    t_line_item.model_number = item.modelNumber
344
    t_line_item.model_number = item.modelNumber
345
    if item.color is None or item.color == "NA":
345
    if item.color is None or item.color == "NA":
Line 354... Line 354...
354
    t_line_item.unit_price = final_price
354
    t_line_item.unit_price = final_price
355
    t_line_item.total_price = final_price * quantity
355
    t_line_item.total_price = final_price * quantity
356
    
356
    
357
    t_line_item.unit_weight = item.weight
357
    t_line_item.unit_weight = item.weight
358
    t_line_item.total_weight = item.weight if item.weight is None else item.weight * quantity
358
    t_line_item.total_weight = item.weight if item.weight is None else item.weight * quantity
-
 
359
    if line.dealText is None:
359
    t_line_item.dealText = item.bestDealText
360
        t_line_item.dealText = item.bestDealText
-
 
361
    elif line.dealText == '':
-
 
362
        t_line_item.dealText = None
-
 
363
    else:
-
 
364
        t_line_item.dealText = line.dealText
360
    
365
        
361
    if item.warrantyPeriod:
366
    if item.warrantyPeriod:
362
        #Computing Manufacturer Warranty expiry date
367
        #Computing Manufacturer Warranty expiry date
363
        today = datetime.date.today()
368
        today = datetime.date.today()
364
        expiry_year = today.year + int((today.month + item.warrantyPeriod) / 12)
369
        expiry_year = today.year + int((today.month + item.warrantyPeriod) / 12)
365
        expiry_month = (today.month + item.warrantyPeriod) % 12
370
        expiry_month = (today.month + item.warrantyPeriod) % 12