Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package com.spice.profitmandi.service.transaction;

import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
import com.spice.profitmandi.dao.entity.transaction.ReturnTransaction;
import in.shop2020.model.v1.catalog.ItemCondition;
import org.springframework.stereotype.Service;

@Service
public interface ReturnService {
    ReturnTransaction createReturnTransaction(in.shop2020.model.v1.order.ReturnTransaction tReturnTransaction, ItemCondition itemCondition) throws ProfitMandiBusinessException;


    /*void receiveReturn(int orderId, receiveCondition, receiveFreebie, serialNumbers)
    order = get_order(order_id)
    scanFreebie = False
    grouppedOrdersList = []
            if order.logisticsTransactionId:
    grouppedOrdersList = get_group_orders_by_logistics_txn_id(order.logisticsTransactionId)
    else:
            grouppedOrdersList.append(order)
    orderCurrentStatus = order.status

    if order.status in [OrderStatus.DOA_PICKUP_CONFIRMED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
            if receiveCondition == 0:
    order.status = OrderStatus.DOA_RECEIVED_PRESTINE
    order.statusDescription = "DOA package received"
    scanFreebie = receiveFreebie
    elif receiveCondition == 1:
    order.status = OrderStatus.DOA_RECEIVED_DAMAGED
    order.statusDescription = "DOA received damaged"
    elif receiveCondition == 2:
    order.status = OrderStatus.DOA_LOST_IN_TRANSIT
    order.statusDescription = "DOA lost in transit"
    order.received_return_timestamp = datetime.datetime.now()
    elif order.status in [OrderStatus.RET_PICKUP_CONFIRMED, OrderStatus.RET_RETURN_IN_TRANSIT]:
            if receiveCondition == 0:
    order.status = OrderStatus.RET_RECEIVED_PRESTINE
    order.statusDescription = "RETURN package received"
    scanFreebie = receiveFreebie
    elif receiveCondition == 1:
    order.status = OrderStatus.RET_RECEIVED_DAMAGED
    order.statusDescription = "RETURN received damaged"
    elif receiveCondition == 2:
    order.status = OrderStatus.RET_LOST_IN_TRANSIT
    order.statusDescription = "RETURN lost in transit"
    order.received_return_timestamp = datetime.datetime.now()
    elif order.status == OrderStatus.RTO_IN_TRANSIT :
            for orderObj in grouppedOrdersList:
            if receiveCondition == 0:
    orderObj.status = OrderStatus.RTO_RECEIVED_PRESTINE
    orderObj.statusDescription = "Returned to origin"
            if orderObj.freebieItemId:
    scanFreebie = True
    elif receiveCondition == 1:
    orderObj.status = OrderStatus.RTO_RECEIVED_DAMAGED
    orderObj.statusDescription = "RTO received damaged"
    elif receiveCondition == 2:
    orderObj.status = OrderStatus.RTO_LOST_IN_TRANSIT
    orderObj.statusDescription = "RTO lost in transit"
    orderObj.received_return_timestamp = datetime.datetime.now()

            else:
            return False

    # For OUR warehouses, we need to scan in items for every return
    inventoryClient = InventoryClient().get_client()
    warehouse = inventoryClient.getWarehouse(order.warehouse_id)
            if warehouse.billingType == BillingType.OURS or warehouse.billingType == BillingType.OURS_EXTERNAL:
    scanMap = {
        OrderStatus.RTO_RECEIVED_PRESTINE : ScanType.SALE_RET,
                OrderStatus.RTO_RECEIVED_DAMAGED  : ScanType.SALE_RET_UNUSABLE,
                OrderStatus.RTO_LOST_IN_TRANSIT   : ScanType.LOST_IN_TRANSIT,
                OrderStatus.DOA_RECEIVED_PRESTINE : ScanType.DOA_IN,
                OrderStatus.DOA_RECEIVED_DAMAGED  : ScanType.DOA_IN,
                OrderStatus.DOA_LOST_IN_TRANSIT   : ScanType.LOST_IN_TRANSIT
    }
        if orderCurrentStatus == OrderStatus.RTO_IN_TRANSIT:
    order = grouppedOrdersList[0]

            if order.transaction.payment_option == capitalFloatPayMethod:
    total_amount = 0
            for ordObj in grouppedOrdersList:
    total_amount = total_amount + ordObj.total_amount + ordObj.shippingCost - ordObj.gvAmount

            creditObj = __creditHistoryObj(order.customer_id, 1, order.transaction.id, total_amount, CreditTxnType.BLOCKED_REVERSED, order.logisticsTransactionId)
    creditTxns = []
            creditTxns.append(creditObj)
            try:
    process_credit_transaction(order.transaction.id, order.customer_id, 1, creditTxns)
    except:
            traceback.print_exc()
            session.rollback()
            return False

            for orderObj in grouppedOrdersList:
            if scanMap.has_key(orderObj.status):
    scanType = scanMap[orderObj.status]
    lineitem = orderObj.lineitems[0]
    catalogClient = CatalogClient().get_client()
    item = catalogClient.getItem(lineitem.item_id)
    warehouseClient = WarehouseClient().get_client()
                    if warehouse.billingType == BillingType.OURS or scanType != ScanType.SALE_RET:
            if item.type == ItemType.SERIALIZED:
            if lineitem.quantity > 1:
    serialNoList = lineitem.serial_number.split(',')
            for serialNumber in serialNoList:
            warehouseClient.scanSerializedItemForOrder(serialNumber, scanType, orderObj.id, orderObj.fulfilmentWarehouseId, 1, orderObj.warehouse_id)
            else:
            warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, scanType, orderObj.id, orderObj.fulfilmentWarehouseId, lineitem.quantity, orderObj.warehouse_id)
            else:
            warehouseClient.scanForOrder(None, scanType, lineitem.quantity, orderObj.id, orderObj.fulfilmentWarehouseId, orderObj.warehouse_id)
            if warehouse.billingType == BillingType.OURS_EXTERNAL and scanType == ScanType.SALE_RET:
            warehouseClient.scanForOursExternalSaleReturn(orderObj.id, lineitem.transfer_price)
            if scanFreebie:
            warehouseClient.scanfreebie(orderObj.id, orderObj.freebieItemId, 0, scanType)
            else:
            if scanMap.has_key(order.status):
    scanType = scanMap[order.status]
    lineitem = order.lineitems[0]
    catalogClient = CatalogClient().get_client()
    item = catalogClient.getItem(lineitem.item_id)
    warehouseClient = WarehouseClient().get_client()
                if warehouse.billingType == BillingType.OURS or scanType != ScanType.SALE_RET:
            if item.type == ItemType.SERIALIZED:
            if lineitem.quantity > 1:
            if serialNumbers is None or len(serialNumbers)==0:
            return False
                            else:
    serialNoList = serialNumbers.split(',')
            for serialNumber in serialNoList:
            warehouseClient.scanSerializedItemForOrder(serialNumber, scanType, order.id, order.fulfilmentWarehouseId, 1, order.warehouse_id)
            else:
            warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, scanType, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
            else:
            warehouseClient.scanForOrder(None, scanType, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
            if warehouse.billingType == BillingType.OURS_EXTERNAL and scanType == ScanType.SALE_RET:
            warehouseClient.scanForOursExternalSaleReturn(order.id, lineitem.transfer_price)
            if scanFreebie:
            warehouseClient.scanfreebie(order.id, order.freebieItemId, 0, scanType)

            session.commit()
            return True*/
}