Subversion Repositories SmartDukaan

Rev

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

Rev 7198 Rev 7199
Line 1210... Line 1210...
1210
            if freebieWarehouseId:
1210
            if freebieWarehouseId:
1211
                try:
1211
                try:
1212
                    inventory_client = InventoryClient().get_client()
1212
                    inventory_client = InventoryClient().get_client()
1213
                    warehouse = inventory_client.getWarehouse(freebieWarehouseId)
1213
                    warehouse = inventory_client.getWarehouse(freebieWarehouseId)
1214
                    
1214
                    
1215
                    if warehouse.warehouseType!= 'OURS'or warehouse.inventoryType != 'GOOD':
1215
                    if warehouse.warehouseType!= WarehouseType.OURS or warehouse.inventoryType != InventoryType.GOOD:
1216
                        raise TransactionServiceException(110,'Billing of Freebie is only allowed from OURS_GOOD warehouses ')
1216
                        raise TransactionServiceException(110,'Billing of Freebie is only allowed from OURS_GOOD warehouses ')
1217
                    
1217
                    
1218
                    warehouse_client = WarehouseClient().get_client()
1218
                    warehouse_client = WarehouseClient().get_client()
1219
                    inventoryItem = warehouse_client.scanfreebie(orderId, order.freebieItemId, freebieWarehouseId, ScanType.SALE);
1219
                    inventoryItem = warehouse_client.scanfreebie(orderId, order.freebieItemId, freebieWarehouseId, ScanType.SALE);
1220
                    
1220
                    
Line 2161... Line 2161...
2161
    orders_not_picked_up = Order.query.filter_by(doa_logistics_provider_id = provider_id).filter_by(status=OrderStatus.RET_PICKUP_CONFIRMED).filter(Order.doa_auth_timestamp <= to_datetime).all()
2161
    orders_not_picked_up = Order.query.filter_by(doa_logistics_provider_id = provider_id).filter_by(status=OrderStatus.RET_PICKUP_CONFIRMED).filter(Order.doa_auth_timestamp <= to_datetime).all()
2162
    return orders_not_picked_up
2162
    return orders_not_picked_up
2163
 
2163
 
2164
def receive_return(order_id, receiveCondition):
2164
def receive_return(order_id, receiveCondition):
2165
    order = get_order(order_id)
2165
    order = get_order(order_id)
-
 
2166
    scanFreebie = False
2166
 
2167
 
2167
    if order.status in [OrderStatus.DOA_PICKUP_CONFIRMED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
2168
    if order.status in [OrderStatus.DOA_PICKUP_CONFIRMED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
2168
        if receiveCondition == 0:
2169
        if receiveCondition == 0:
2169
            order.status = OrderStatus.DOA_RECEIVED_PRESTINE
2170
            order.status = OrderStatus.DOA_RECEIVED_PRESTINE
2170
            order.statusDescription = "DOA package received"
2171
            order.statusDescription = "DOA package received"
Line 2195... Line 2196...
2195
            order.statusDescription = "RTO received damaged"
2196
            order.statusDescription = "RTO received damaged"
2196
        elif receiveCondition == 2:
2197
        elif receiveCondition == 2:
2197
            order.status = OrderStatus.RTO_LOST_IN_TRANSIT
2198
            order.status = OrderStatus.RTO_LOST_IN_TRANSIT
2198
            order.statusDescription = "RTO lost in transit"
2199
            order.statusDescription = "RTO lost in transit"
2199
        order.received_return_timestamp = datetime.datetime.now()
2200
        order.received_return_timestamp = datetime.datetime.now()
-
 
2201
        if order.freebieItemId:
-
 
2202
            scanFreebie = True
2200
    else:
2203
    else:
2201
        return False
2204
        return False
2202
 
2205
 
2203
    # For OUR warehouses, we need to scan in items for every return
2206
    # For OUR warehouses, we need to scan in items for every return
2204
    inventoryClient = InventoryClient().get_client()
2207
    inventoryClient = InventoryClient().get_client()
Line 2224... Line 2227...
2224
                    warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, scanType, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
2227
                    warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, scanType, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
2225
                else:
2228
                else:
2226
                    warehouseClient.scanForOrder(None, scanType, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
2229
                    warehouseClient.scanForOrder(None, scanType, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
2227
            if warehouse.billingType == BillingType.OURS_EXTERNAL and scanType == ScanType.SALE_RET:
2230
            if warehouse.billingType == BillingType.OURS_EXTERNAL and scanType == ScanType.SALE_RET:
2228
                warehouseClient.scanForOursExternalSaleReturn(order.id, lineitem.transfer_price)
2231
                warehouseClient.scanForOursExternalSaleReturn(order.id, lineitem.transfer_price)
2229
 
-
 
-
 
2232
            if scanFreebie:
-
 
2233
                warehouseClient.scanFreebie(order.id, order.freebieItemId, 0, scanType)
2230
    session.commit()
2234
    session.commit()
2231
    return True
2235
    return True
2232
 
2236
 
2233
def validate_doa(order_id, is_valid):
2237
def validate_doa(order_id, is_valid):
2234
    order = get_order(order_id)
2238
    order = get_order(order_id)
Line 2378... Line 2382...
2378
    warehouse = inventoryClient.getWarehouse(new_order.warehouse_id)
2382
    warehouse = inventoryClient.getWarehouse(new_order.warehouse_id)
2379
    if warehouse.billingType == BillingType.OURS:
2383
    if warehouse.billingType == BillingType.OURS:
2380
        warehouseClient = WarehouseClient().get_client()
2384
        warehouseClient = WarehouseClient().get_client()
2381
        inventoryItem = warehouseClient.getInventoryItemFromOrder(order_id)
2385
        inventoryItem = warehouseClient.getInventoryItemFromOrder(order_id)
2382
        warehouseClient.scanForOrder(inventoryItem, ScanType.SALE, new_order.lineitems[0].quantity, new_order.id, new_order.fulfilmentWarehouseId, new_order.warehouse_id)
2386
        warehouseClient.scanForOrder(inventoryItem, ScanType.SALE, new_order.lineitems[0].quantity, new_order.id, new_order.fulfilmentWarehouseId, new_order.warehouse_id)
-
 
2387
    if order.freebieItemId:
-
 
2388
        warehouseClient = WarehouseClient().get_client()
-
 
2389
        inventoryItem = warehouseClient.reshipfreebie(order_id, new_order.id, new_order.freebieItemId, ScanType.SALE)
2383
    
2390
    
2384
def refund_order(order_id, refunded_by, reason):
2391
def refund_order(order_id, refunded_by, reason):
2385
    """
2392
    """
2386
    If the order is in RTO_RECEIVED_PRESTINE, DOA_CERT_VALID or DOA_CERT_INVALID state, it does the following:
2393
    If the order is in RTO_RECEIVED_PRESTINE, DOA_CERT_VALID or DOA_CERT_INVALID state, it does the following:
2387
        1. Creates a refund request for batch processing.
2394
        1. Creates a refund request for batch processing.
Line 2590... Line 2597...
2590
    new_order.originalOrderId = order.originalOrderId if order.originalOrderId is not None else order.id 
2597
    new_order.originalOrderId = order.originalOrderId if order.originalOrderId is not None else order.id 
2591
    
2598
    
2592
    new_order.transaction = order.transaction
2599
    new_order.transaction = order.transaction
2593
    new_order.cod = is_cod
2600
    new_order.cod = is_cod
2594
    new_order.orderType = order.orderType
2601
    new_order.orderType = order.orderType
2595
     
2602
    new_order.freebieItemId = order.freebieItemId
2596
    for line_item in order.lineitems:
2603
    for line_item in order.lineitems:
2597
        litem = LineItem()
2604
        litem = LineItem()
2598
        litem.item_id = line_item.item_id
2605
        litem.item_id = line_item.item_id
2599
        litem.productGroup = line_item.productGroup
2606
        litem.productGroup = line_item.productGroup
2600
        litem.brand = line_item.brand
2607
        litem.brand = line_item.brand