Subversion Repositories SmartDukaan

Rev

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

Rev 8688 Rev 8717
Line 69... Line 69...
69
    InventoryServiceException, WarehouseType, InventoryType
69
    InventoryServiceException, WarehouseType, InventoryType
70
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
70
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
71
    TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
71
    TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
72
    HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType, RechargeOrderStatus, \
72
    HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType, RechargeOrderStatus, \
73
    RechargeType, RechargeStatistics, DeviceNumberInfo, EmiChargeType, PayMethod, OrderSource,\
73
    RechargeType, RechargeStatistics, DeviceNumberInfo, EmiChargeType, PayMethod, OrderSource,\
74
    StorePaymentStatus
74
    StorePaymentStatus, ProductCondition
75
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
75
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
76
from shop2020.thriftpy.payments.ttypes import PaymentException
76
from shop2020.thriftpy.payments.ttypes import PaymentException
77
#Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
77
#Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
78
from shop2020.thriftpy.crm.ttypes import *
78
from shop2020.thriftpy.crm.ttypes import *
79
#End:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
79
#End:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
Line 1418... Line 1418...
1418
                if ourColor and etpColor != ourColor and not authorize:
1418
                if ourColor and etpColor != ourColor and not authorize:
1419
                    raise TransactionServiceException(777, "ETP color: " + etpColor + " and Order color: " + ourColor)
1419
                    raise TransactionServiceException(777, "ETP color: " + etpColor + " and Order color: " + ourColor)
1420
                else:
1420
                else:
1421
                    billedOrdersColorMap.pop(orderId)
1421
                    billedOrdersColorMap.pop(orderId)
1422
        '''
1422
        '''
1423
 
1423
            
-
 
1424
        if order.productCondition == ProductCondition.BAD:
-
 
1425
            if billingType != BillingType.OURS:
-
 
1426
                raise TransactionServiceException(110, 'Bad inventory is not allowed to be sold from current warehouse')
1424
        if billingType == BillingType.EXTERNAL:            
1427
        if billingType == BillingType.EXTERNAL:            
1425
            order.invoice_number = invoice_number
1428
            order.invoice_number = invoice_number
1426
 
1429
 
1427
        if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
1430
        if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
1428
            if ItemType.SERIALIZED == item.type and not (serialNumbers and serialNumbers[0]):
1431
            if ItemType.SERIALIZED == item.type and not (serialNumbers and serialNumbers[0]):
Line 1451... Line 1454...
1451
            print e.message
1454
            print e.message
1452
            raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
1455
            raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
1453
 
1456
 
1454
        # For OUR warehouse, we need to scan out items for every billed order
1457
        # For OUR warehouse, we need to scan out items for every billed order
1455
        if billingType == BillingType.OURS:
1458
        if billingType == BillingType.OURS:
-
 
1459
            if order.productCondition == ProductCondition.GOOD: 
1456
            for index, serialNumber in enumerate(serialNumbers):
1460
                for index, serialNumber in enumerate(serialNumbers):
1457
                try:
1461
                    try:
1458
                    warehouse_client = WarehouseClient().get_client()
1462
                        warehouse_client = WarehouseClient().get_client()
1459
                    # Fetching GOOD w/h corresponding to the virtual one here
1463
                        # Fetching GOOD w/h corresponding to the virtual one here
1460
                    if not warehouse.billingWarehouseId:
1464
                        if not warehouse.billingWarehouseId:
1461
                        warehouse = inventory_client.getWarehouses(None, InventoryType.GOOD, warehouse.vendor.id, order.warehouse_id, 0)[0]
1465
                            warehouse = inventory_client.getWarehouses(None, InventoryType.GOOD, warehouse.vendor.id, order.warehouse_id, 0)[0]
1462
 
1466
    
1463
                    if ItemType.SERIALIZED == item.type:
1467
                        if ItemType.SERIALIZED == item.type:
1464
                        inventoryItem = warehouse_client.getInventoryItem(serialNumber)
1468
                            inventoryItem = warehouse_client.getInventoryItem(serialNumber)
1465
                    else:
1469
                        else:
1466
                        inventoryItem = warehouse_client.getNonSeralizedInventoryItem(itemNumbers[index], item_id, warehouse.id, warehouse.billingWarehouseId)
1470
                            inventoryItem = warehouse_client.getNonSeralizedInventoryItem(itemNumbers[index], item_id, warehouse.id, warehouse.billingWarehouseId)
1467
    
1471
        
1468
                    if (inventoryItem.itemId != item_id):
1472
                        if (inventoryItem.itemId != item_id):
-
 
1473
                            catalog_client = CatalogClient().get_client()
-
 
1474
                            item = catalog_client.getItem(inventoryItem.itemId)
-
 
1475
                            scanItemString = " ".join([str(item.brand), str(item.modelName), str(item.modelNumber), str(item.color)])
-
 
1476
                            lineItemString = " ".join([str(lineitem.brand), str(lineitem.model_name), str(lineitem.model_number), str(lineitem.color)])
-
 
1477
                            raise TransactionServiceException(110, 'Trying to scan ' + scanItemString + ' instead of ' + lineItemString)
-
 
1478
        
-
 
1479
                        if ItemType.SERIALIZED == item.type:
-
 
1480
                            inventoryItem = warehouse_client.scanSerializedItemForOrder(serialNumber, ScanType.SALE, orderId, warehouse.id, 1, order.warehouse_id)
-
 
1481
                        else:
-
 
1482
                            inventoryItem = warehouse_client.scanForOrder(inventoryItem, ScanType.SALE, 1, order.id, warehouse.id, order.warehouse_id)
-
 
1483
        
-
 
1484
                        lineitem.transfer_price = inventoryItem.unitPrice
-
 
1485
                        lineitem.nlc = inventoryItem.nlc
-
 
1486
                        order.vendorId = inventoryItem.supplierId
1469
                        catalog_client = CatalogClient().get_client()
1487
                        catalog_client = CatalogClient().get_client()
1470
                        item = catalog_client.getItem(inventoryItem.itemId)
1488
                    except WarehouseServiceException as e:
1471
                        scanItemString = " ".join([str(item.brand), str(item.modelName), str(item.modelNumber), str(item.color)])
1489
                        print sys.exc_info()[0]
1472
                        lineItemString = " ".join([str(lineitem.brand), str(lineitem.model_name), str(lineitem.model_number), str(lineitem.color)])
1490
                        print 'Could not scan out orders due to: ' + e.message
1473
                        raise TransactionServiceException(110, 'Trying to scan ' + scanItemString + ' instead of ' + lineItemString)
1491
                        raise TransactionServiceException(110, e.message)
1474
    
1492
            else:
-
 
1493
                for index, serialNumber in enumerate(serialNumbers):
-
 
1494
                    try:
-
 
1495
                        warehouse_client = WarehouseClient().get_client()
-
 
1496
                        
1475
                    if ItemType.SERIALIZED == item.type:
1497
                        if ItemType.SERIALIZED == item.type:
1476
                        inventoryItem = warehouse_client.scanSerializedItemForOrder(serialNumber, ScanType.SALE, orderId, warehouse.id, 1, order.warehouse_id)
1498
                            inventoryItem = warehouse_client.scanForBadSale(serialNumber, itemNumbers[index], item_id, orderId, warehouse.id, 1, order.warehouse_id)
1477
                    else:
1499
                        else:
1478
                        inventoryItem = warehouse_client.scanForOrder(inventoryItem, ScanType.SALE, 1, order.id, warehouse.id, order.warehouse_id)
1500
                            raise TransactionServiceException(110, "Bad sale for Non Serialized inventory is not allowed as of now")
1479
    
1501
                        
1480
                    lineitem.transfer_price = inventoryItem.unitPrice
1502
                        lineitem.transfer_price = inventoryItem.unitPrice
1481
                    lineitem.nlc = inventoryItem.nlc
1503
                        lineitem.nlc = inventoryItem.nlc
1482
                    order.vendorId = inventoryItem.supplierId
1504
                        order.vendorId = inventoryItem.supplierId
1483
                    catalog_client = CatalogClient().get_client()
1505
                        catalog_client = CatalogClient().get_client()
1484
                except WarehouseServiceException as e:
1506
                    except WarehouseServiceException as e:
1485
                    print sys.exc_info()[0]
1507
                        print sys.exc_info()[0]
1486
                    print 'Could not scan out orders due to: ' + e.message
1508
                        print 'Could not scan out orders due to: ' + e.message
1487
                    raise TransactionServiceException(110, e.message)
1509
                        raise TransactionServiceException(110, e.message)
-
 
1510
            
1488
        elif billingType == BillingType.OURS_EXTERNAL:
1511
        elif billingType == BillingType.OURS_EXTERNAL:
1489
            try:
1512
            try:
1490
                if ItemType.SERIALIZED == item.type:
1513
                if ItemType.SERIALIZED == item.type:
1491
                    serialNumber = serialNumbers[0]
1514
                    serialNumber = serialNumbers[0]
1492
                else:
1515
                else: