Subversion Repositories SmartDukaan

Rev

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

Rev 7967 Rev 7968
Line 1322... Line 1322...
1322
        if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
1322
        if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
1323
            if freebieWarehouseId:
1323
            if freebieWarehouseId:
1324
                try:
1324
                try:
1325
                    inventory_client = InventoryClient().get_client()
1325
                    inventory_client = InventoryClient().get_client()
1326
                    warehouse = inventory_client.getWarehouse(freebieWarehouseId)
1326
                    warehouse = inventory_client.getWarehouse(freebieWarehouseId)
1327
                    
-
 
1328
                    if warehouse.warehouseType!= WarehouseType.OURS or warehouse.inventoryType != InventoryType.GOOD:
1327
                    if warehouse.warehouseType!= WarehouseType.OURS or warehouse.inventoryType != InventoryType.GOOD:
1329
                        raise TransactionServiceException(110,'Billing of Freebie is only allowed from OURS_GOOD warehouses ')
1328
                        raise TransactionServiceException(110,'Billing of Freebie is only allowed from OURS_GOOD warehouses ')
1330
                    
-
 
1331
                    warehouse_client = WarehouseClient().get_client()
1329
                    warehouse_client = WarehouseClient().get_client()
1332
                    inventoryItem = warehouse_client.scanfreebie(orderId, order.freebieItemId, freebieWarehouseId, ScanType.SALE);
1330
                    isItemAvailable = warehouse_client.isItemAvailableForSale(order.freebieItemId, "", freebieWarehouseId)
1333
                    
-
 
1334
                    attr = Attribute()
-
 
1335
                    attr.orderId = orderId
-
 
1336
                    attr.name = "freebie_tp"
-
 
1337
                    attr.value = str(inventoryItem.unitPrice)
-
 
1338
                    
-
 
1339
                    attr1 = Attribute()
-
 
1340
                    attr1.orderId = orderId
1331
                    if isItemAvailable == False:
1341
                    attr1.name = "freebie_vendor"
-
 
1342
                    attr1.value = str(inventoryItem.supplierId)
1332
                        raise TransactionServiceException(110,'No Freebie Item available ')
1343
    
-
 
1344
                    attr2 = Attribute()
-
 
1345
                    attr2.orderId = orderId
-
 
1346
                    attr2.name = "freebie_nlc"
-
 
1347
                    attr2.value = str(inventoryItem.nlc)
-
 
1348
                except Exception as e:
1333
                except Exception as e:
1349
                    print sys.exc_info()[0]
-
 
1350
                    print e.message
1334
                    print e.message
1351
                    raise TransactionServiceException(110,'Error in billing freebie for warehouseId ' + str(freebieWarehouseId))
1335
                    raise TransactionServiceException(110,'Error in billing freebie for warehouseId ' + str(freebieWarehouseId))
1352
            else:
1336
            else:
1353
                raise TransactionServiceException(110,'No warehouseId provided for billing of freebie ')
1337
                raise TransactionServiceException(110,'No warehouseId provided for billing of freebie ')
1354
        else:
1338
        else:
Line 1470... Line 1454...
1470
                raise TransactionServiceException(110, e.message)
1454
                raise TransactionServiceException(110, e.message)
1471
        else:
1455
        else:
1472
            if not warehouse.isAvailabilityMonitored:
1456
            if not warehouse.isAvailabilityMonitored:
1473
                inventory_client = InventoryClient().get_client()
1457
                inventory_client = InventoryClient().get_client()
1474
                inventory_client.addInventory(item.id, warehouse.id, -1 * lineitem.quantity)
1458
                inventory_client.addInventory(item.id, warehouse.id, -1 * lineitem.quantity)
-
 
1459
        
-
 
1460
        if order.freebieItemId:
-
 
1461
            try:
-
 
1462
                inventory_client = InventoryClient().get_client()
-
 
1463
                warehouse = inventory_client.getWarehouse(freebieWarehouseId)
-
 
1464
                
-
 
1465
                if warehouse.warehouseType!= WarehouseType.OURS or warehouse.inventoryType != InventoryType.GOOD:
-
 
1466
                    raise TransactionServiceException(110,'Billing of Freebie is only allowed from OURS_GOOD warehouses ')
-
 
1467
                
-
 
1468
                warehouse_client = WarehouseClient().get_client()
-
 
1469
                inventoryItem = warehouse_client.scanfreebie(orderId, order.freebieItemId, freebieWarehouseId, ScanType.SALE);
-
 
1470
                
-
 
1471
                attr = Attribute()
-
 
1472
                attr.orderId = orderId
-
 
1473
                attr.name = "freebie_tp"
-
 
1474
                attr.value = str(inventoryItem.unitPrice)
-
 
1475
                
-
 
1476
                attr1 = Attribute()
-
 
1477
                attr1.orderId = orderId
-
 
1478
                attr1.name = "freebie_vendor"
-
 
1479
                attr1.value = str(inventoryItem.supplierId)
-
 
1480
 
-
 
1481
                attr2 = Attribute()
-
 
1482
                attr2.orderId = orderId
-
 
1483
                attr2.name = "freebie_nlc"
-
 
1484
                attr2.value = str(inventoryItem.nlc)
-
 
1485
            except Exception as e:
-
 
1486
                print e.message
-
 
1487
                raise TransactionServiceException(110,'Error in billing freebie for warehouseId ' + str(freebieWarehouseId))
1475
 
1488
 
1476
        __update_inventory_reservation(order)
1489
        __update_inventory_reservation(order)
1477
        order.fulfilmentWarehouseId = warehouse.id
1490
        order.fulfilmentWarehouseId = warehouse.id
1478
        if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
1491
        if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
1479
            order.invoice_number = get_next_invoice_number(order.orderType)
1492
            order.invoice_number = get_next_invoice_number(order.orderType)
Line 3226... Line 3239...
3226
            print "Allowing item change for split Freebie Order"
3239
            print "Allowing item change for split Freebie Order"
3227
        else:    
3240
        else:    
3228
            raise TransactionServiceException(121, "You can't ship a different item. You can only ship the same item in a different color.")
3241
            raise TransactionServiceException(121, "You can't ship a different item. You can only ship the same item in a different color.")
3229
    
3242
    
3230
    inventoryClient = InventoryClient().get_client()
3243
    inventoryClient = InventoryClient().get_client()
-
 
3244
    inventoryClient.updateReservationForOrder(item_id, order.fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
3231
    inventoryClient.reserveItemInWarehouse(item_id, order.fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
3245
    #inventoryClient.reserveItemInWarehouse(item_id, order.fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
3232
    __update_inventory_reservation(order)
3246
    #__update_inventory_reservation(order)
3233
    #TODO: Check that this new item has the same price
3247
    #TODO: Check that this new item has the same price
3234
        
3248
        
3235
    lineitem.item_id = item_id
3249
    lineitem.item_id = item_id
3236
    lineitem.brand = item.brand
3250
    lineitem.brand = item.brand
3237
    lineitem.model_name = item.modelName
3251
    lineitem.model_name = item.modelName
Line 3286... Line 3300...
3286
                        if goodWarehouse.vendor.id == item.preferredVendor:
3300
                        if goodWarehouse.vendor.id == item.preferredVendor:
3287
                            warehouse = goodWarehouse
3301
                            warehouse = goodWarehouse
3288
        else:
3302
        else:
3289
            raise TransactionServiceException(119, "Shifting of warehouse allowed to GOOD inventory type warehouse with billing support")
3303
            raise TransactionServiceException(119, "Shifting of warehouse allowed to GOOD inventory type warehouse with billing support")
3290
 
3304
 
3291
    inventoryClient.reserveItemInWarehouse(lineitem.item_id, warehouse.id, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), lineitem.quantity)
3305
    #inventoryClient.reserveItemInWarehouse(lineitem.item_id, warehouse.id, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), lineitem.quantity)
-
 
3306
    inventoryClient.updateReservationForOrder(lineitem.item_id, warehouse.id, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), lineitem.quantity)
3292
    __update_inventory_reservation(order)
3307
    #__update_inventory_reservation(order)
3293
    if order.status == OrderStatus.ACCEPTED:
3308
    if order.status == OrderStatus.ACCEPTED:
3294
        __update_transfer_price(order, warehouse.id)
3309
        __update_transfer_price(order, warehouse.id)
3295
    order.warehouse_id = warehouse.billingWarehouseId
3310
    order.warehouse_id = warehouse.billingWarehouseId
3296
    order.fulfilmentWarehouseId = warehouse.id
3311
    order.fulfilmentWarehouseId = warehouse.id
3297
    session.commit()
3312
    session.commit()