Subversion Repositories SmartDukaan

Rev

Rev 23400 | Blame | Compare with Previous | Last modification | View Log | RSS feed

namespace java in.shop2020.warehouse
namespace py shop2020.thriftpy.warehouse

include "GenericService.thrift"

enum ScanType {
    PURCHASE = 0,   // Scan-in at the time of purchase
    SALE = 1,       // Scan-out for sale
    SALE_RET = 2,   // Scan-in when an item is returned undelivered
    DOA_IN = 3,     // Scan-in when an item is returned by the customer with the DOA certificate
    DOA_OUT = 4,     // Scan-out to return an item to the supplier
    PURCHASE_RETURN = 5, // Scan-out to return an item to the supplier (a Non-DOA case)
    SALE_RET_UNUSABLE = 6,
    LOST_IN_TRANSIT = 7,
    DOA_REPLACED = 8,
    LOST_IN_WAREHOUSE = 9,
    MARKED_USED = 10,
        MARKED_BAD = 11,
        MARKED_GOOD = 12;
        WAREHOUSE_TRANSFER_IN = 13;
        WAREHOUSE_TRANSFER_OUT = 14;
        BAD_SALE = 15;
        DOA_REJECTED = 16;
        DOA_CLOSED_BY_CREDIT_NOTE = 17;
        BAD_PURCHASE_RETURN = 18;
        LOST_IN_WAREHOUSE_BAD = 19;
        EMPTY_PRODUCT_RECEIVED = 20;
        WRONG_PRODUCT_RECEIVED = 21;
}

enum TransferLotStatus {
        IN_TRANSIT = 1,
        PARTIAL_TRANSFER = 2,
        TRANSFER_COMPLETE = 3
}

enum TransferType {
        OURS_OURS = 1,
        OURS_THIRDPARTY = 2
}

struct InventoryItem {
    // primary fields
    1:i64 id,
    2:i64 itemId,
    3:string itemNumber,
    4:string serialNumber,
    5:i64 initialQuantity,
    6:i64 currentQuantity,
    7:i64 purchaseId,
    8:i64 purchaseReturnId,
    9:i64 physicalWarehouseId,
    10:TransferLotStatus transferStatus,
    // derived fields for  efficient lookups
    11:i64 supplierId,
    12:double unitPrice,
    13:i64 currentWarehouseId,
    14:ScanType lastScanType,
    15:double nlc,
    16:string serialNumber2,
    17:i64 firstScanned,
    18:i64 activated,
    19:i64 created
}

struct Scan {
    1:i64 id,
    2:i64 inventoryItemId,
    3:optional i64 quantity, // ignored in case of serialized items
    4:optional i64 orderId, // The order that was fulfilled with this scan!
    5:i64 warehouseId,
    6:ScanType type,
    7:i64 scannedAt,
    8:i64 transferLotId,
    9:string remarks
}

struct DetailedPurchaseScan {
    1:i64 purchaseOrderId,
    2:i64 poCreatedAt,
    3:string supplierName,
    4:string invoiceNumbers,
    5:string receivedBy,
    6:i64 itemId,
    7:string brand,
    8:string modelName,
    9:string modelNumber,
   10:string color,
   11:double unitPrice,
   12:i64 quantity,
   13:i64 purchaseId,
   14:i64 purchasedAt,
   15:double nlc,
   16:i64 warehouseId,
   17:i64 taxType,
   18:i64 invoiceDate,
   19:double mrp,
   20:string purchaseComments,
   21:double sgstRate,
   22:double cgstRate,
   23:double igstRate,
   24:double invoicePrice
}

struct InvoiceScan {
    1:string invoiceNumber,
    2:i64 numItems,
    3:string supplierName,
    4:i64 date,
    5:i64 scannedQuantity
}

struct InTransitInventory {
        1:i64 itemId,
        2:string brand,
        3:string modelName,
        4:string modelNumber,
        5:string color,
        6:i64 originWarehouseId,
        7:i64 destinationWarehouseId,
        8:i64 quantity,
        9:i64 transferDate,
}

struct InventoryAvailability{
        1:i64 itemId,
        2:string brand,
        3:string modelName,
        4:string modelNumber,
        5:string color,
        6:i64 quantity
}

struct InventoryMovement{
        1:i64 itemId,
        2:string brand,
        3:string modelName,
        4:string modelNumber,
        5:string color,
        6:ScanType type
        7:i64 quantity
}

struct InventoryAge {
    1:i64 itemId,
    2:string brand,
    3:string modelName,
    4:string modelNumber,
    5:string color,
    6:i64 freshCount,
    7:i64 oneToTwoCount,
    8:i64 TwoToThreeCount,
    9:i64 ThreeToFourCount,
   10:i64 FourPlusCount,
   11:i64 threeMonthPlusCount,
   12:i64 sixMonthPlusCount,
   13:i64 zeroToThreeMonthCount,
   14:i64 threeToSixMonthCount,
   15:i64 sixToTwelveMonthCount,
   16:i64 twelveMonthsPlusCount,
   17:i64 ZeroPlusCount,
   18:i64 OnePlusCount,
   19:i64 ZeroPlusCost,
   20:i64 OnePlusCost,
   21:string category
}

struct AmazonTransferredSkuDetail{
        1:i64 itemId,
        2:i64 purchaseId,
        3:i64 purchaseDate,
        4:i64 quantity,
        5:double unitPrice
        6:double nlc
        7:string brand,
    8:string modelName,
    9:string modelNumber,
    10:string category,
    11:string color,
    12:string taxType
}

struct PossibleWarehouseMovement {
        1:i64 fromWarehouseId,
        2:i64 toWarehouseId
}

struct TransferLot {
        1:i64 id,
        2:i64 originWarehouseId,
        3:i64 destinationWarehouseId,
        4:TransferLotStatus status,
        5:i64 transferDate,
        6:TransferType type,
        7:string transitCompletionReferenceNumber,
        8:i64 referenceUpdationDate
        9:string remarks,
        10:i64 shipmentReference
}

struct RemovalStockShipmentReference {
        1:i64 id,
        2:string shipmentReference,
        3:i64 createdOn,
        4:string source,
        5:i64 inventoryType,
        6:i64 quantity,
        7:i64 unfulfilQuantity,
        8:bool completed
}

struct InvAgeConsiderItems {
    1:i64 id,
    2:i64 itemId,
    3:i64 currentQuantity,
    4:i64 purchaseId,
    5:double age,
    6:string category,
    7:i64 cost
}

struct DoaOutInventoryItem {
        1:i64 id
        2:i64 warehouseId,
        3:string warehouseName,
        4:i64 itemId,
        5:string product,
        6:string serialNumber,
        7:string itemNumber,
        8:string purchaseOrder
        9:i64 doaOutTimeStamp,
        10:double transferPrice,
        11:double nlcPrice
}

struct TransferInvoiceScan {
    1:string shipmentReference,
    2:i64 transferLotId,
    3:string source,
    4:i64 quantity,
    5:string inventoryType,
    6:i64 date,
    7:i64 scannedQuantity
}

exception WarehouseServiceException {
    1:GenericService.ExceptionType exceptionType,
    2:string message
}


service WarehouseService extends GenericService.GenericService {
    /**
     * Retrieves serialized inventory item given a serial number
     */
    InventoryItem getInventoryItem(1:string serialNumber) throws (1:WarehouseServiceException wex);

    /**
     * Retrieves non-serialized inventory item from a given supplier
     */
    InventoryItem getNonSeralizedInventoryItem(1:string itemNumber, 2:i64 itemId, 3:i64 fulfilmentWarehouseId, 4:i64 billingWarehouseId) throws (1:WarehouseServiceException wex);

    /**
     * Scan non-serialized items.
     */
    void scan(1:InventoryItem inventoryItem, 2:ScanType type, 3:i64 quantity, 4:i64 billingWarehouseId, 5:i64 transferLotId) throws (1:WarehouseServiceException wex);
    
    /**
     * Scan non-serialized items.
     */
    void genericScan(1:InventoryItem inventoryItem, 2:Scan scan) throws (1:WarehouseServiceException wex);

    /**
     * Scan serialized items linked with an order. Returns its price.
     */
    InventoryItem scanSerializedItemForOrder(1:string serialNumber, 2:ScanType type, 3:i64 orderId, 4:i64 fulfilmentWarehouseId, 5:double quantity, 6:i64 billingWarehouseId) throws (1:WarehouseServiceException wex);

    /**
     * Scan non-serialized items linked with an order.
     */
    InventoryItem scanForOrder(1:InventoryItem inventoryItem, 2:ScanType type, 3:i64 quantity, 4:i64 orderId, 5:i64 fulfilmentWarehouseId, 6:i64 billingWarehouseId) throws (1:WarehouseServiceException wex);

    /**
     * Created item number to item id mapping
     */
    void createItemNumberMapping(1:string itemNumber, 2:i64 itemId);

    /**
     * Get itemNumber mappings for itemId 
     */
    list<string> getItemNumbers(1:i64 itemId);

    /**
     * Gets item ids for a given item number
     */
    list<i64> getItemIds(1:string itemNumber);
    
    /**
     * Retrieves all inventory items given a last scan type
     */
    list<InventoryItem> getInventoryItemsFromLastScanType(1:ScanType lastScanType) throws (1:WarehouseServiceException wex);
    
    /**
     * Retrieves inventory item given a inventoryItem id
     */
    InventoryItem getInventoryItemFromId(1:i64 inventoryItemId) throws (1:WarehouseServiceException wex);

    /**
     * Returns the purchase scans grouped by items for Purchase register reconciliation
     */
    list<DetailedPurchaseScan> getPurchaseScans(1:i64 startDate, 2:i64 endDate);

    /**
     * Returns the purchase scans between grn dates grouped by items for Purchase register reconciliation 
     */
    list<DetailedPurchaseScan> getPurchaseScansByGrnDate(1:i64 startDate, 2:i64 endDate);
    
    /**
     * Returns the empty grn-ids between grn dates 
     */
    list<i64> getEmptyGrnsByDate(1:i64 startDate, 2:i64 endDate);

    /**
     * Returns the invoices and the count of scans against on a given day.
     */
     list<InvoiceScan> fetchScansPerInvoiceNumber(1:i64 date);
     
     /**
      * Returns inventory item for a given order
      */
     InventoryItem getInventoryItemFromOrder(1:i64 orderId) throws (1:WarehouseServiceException we);

     /**
      * Fetches the stock inventory age week-wise
      */
     list<InventoryAge> getInventoryAge();
     
         /**
      * Fetches the scanRecords for a given item for a given time interval 
      */
     list<Scan> getInventoryScansForItem(1:i64 itemId, 2:i64 fromDate, 3:i64 toDate);
     
     /**
      * Fetches the scanRecords for a given serialNumber for a given time interval 
      */
     list<Scan> getScanRecordsForSerialNumber(1:string serialNumber);
     
     /**
      * Inserts outgoing scans for Returned Items and updates returnId in InventoryItems
      */
     i64 scanForPurchaseReturn(1:list<InventoryItem> saleReturnItems, 2:i64 vendorId, 3:i64 billingWarehouseId) throws (1:WarehouseServiceException ex);
     
     /**
      * Inserts scans for lost Items and updates lastScanType in InventoryItems
      */
     void scanForLostItem(1:list<InventoryItem> lostItems, 2:i64 vendorId, 3:i64 billingWarehouseId) throws (1:WarehouseServiceException ex);
     
     /**
      * Get inventory count for available Serialized items in our warehouses using entries in ScanNew table
      */
     list<InventoryAvailability> getCurrentSerializedInventoryByScans(1:i64 physicalWarehouseId);
     
      /**
      * Get inventory count for available Serialized items in our warehouses using entries in ScanNew table
      */
     list<InventoryAvailability> getCurrentNonSerializedInventoryByScans(1:i64 physicalWarehouseId);
     
     /**
      * Get inventory for Serialized items in our warehouses at a given date using entries in ScanNew table
      */
     list<InventoryAvailability> getHistoricSerializedInventoryByScans(1:i64 date);
     
      /**
      * Get inventory for Non Serialized items in our warehouses at a given date using entries in ScanNew table
      */
     list<InventoryAvailability> getHistoricNonSerializedInventoryByScans(1:i64 date);

     /**
      * Get inventory for Serialized items in our warehouses at a given date using entries in ScanNew table
      */
     list<InventoryAvailability> getOurHistoricSerializedInventoryByScans(1:i64 date);
     
     /**
      * Get inventory for Non Serialized items in our warehouses at a given date using entries in ScanNew table
      */
     list<InventoryAvailability> getOurHistoricNonSerializedInventoryByScans(1:i64 date);
     
     /**
      * Insert Purchase/Sale Entries for product billed by Hotspot using OURS_EXTERNAL Billing
      */
     InventoryItem scanForOursExternalSale(1:i64 itemId, 2:string serialNumber, 3:string itemNumber, 4:string invoiceNumber, 5:i64 warehouseId, 6:double unitPrice, 7:double nlc, 8:i64 orderId)throws (1:WarehouseServiceException ex);
     
     /**
      * Insert Purchase_Ret/Sale_Ret Entries for product billed by Hotspot using OURS_EXTERNAL Billing
      */
     void scanForOursExternalSaleReturn(1:i64 orderId, 2:double unitPrice) throws (1:WarehouseServiceException ex);
     
     /**
      * This returns movement for each non serialized item in the specified window.(Doesn't include Hotspot and Amazon w/h)     
      */
     list<InventoryMovement> getMovementNonSerializedInventoryByScans(1:i64 startDate, 2:i64 endDate);
     
     /**
      * This returns movement for each serialized item in the specified window.(Doesn't include Hotspot and Amazon w/h) 
      */
     list<InventoryMovement> getMovementSerializedInventoryByScans(1:i64 startDate, 2:i64 endDate);
     
     /**
      * This returns movement for each serialized item in the specified window.(Doesn't include Amazon w/h)     
      */
     list<InventoryMovement> getCompleteMovementSerializedInventoryByScans(1:i64 startDate, 2:i64 endDate);
     
     /**
      * This returns movement for each non serialized item in the specified window.(Doesn't include Amazon w/h) 
      */
     list<InventoryMovement> getCompleteMovementNonSerializedInventoryByScans(1:i64 startDate, 2:i64 endDate);
     
     InventoryItem scanfreebie(1:i64 orderId, 2:i64 freebieItemId, 3:i64 freebieWarehouseId, 4:ScanType scanType) throws (1:WarehouseServiceException wex);
     
     void reshipfreebie(1:i64 oldOrderId, 2:i64 newOrderId, 3:i64 freebieItemId, 4:ScanType scanType) throws (1:WarehouseServiceException wex);
     
     bool isItemTransferAllowed(1:i64 warehouseId, 2:i64 transferWarehouseId);
     
     i64 createTransferLot(1:i64 originWarehouseId, 2:i64 destWarehouseId) throws (1:WarehouseServiceException wex);
     
     TransferLot getTransferLot(1:i64 transferLotId) throws (1:WarehouseServiceException wex);

         void markTransferLotAsReceived(1:i64 id, 2:string remoteTransferRefNumber) throws (1:WarehouseServiceException wex);
         
         list<TransferLot> getTransferLotsByDate(1:i64 fromDate, 2:i64 toDate) throws (1:WarehouseServiceException wex);
         
         list<i64> getAllowedDestinationWarehousesForTransfer(1:i64 warehouseId);
         
         map<i64, i64> getItemsInTransferLot(1:i64 transferLotId);
         
         void markItemsAsReceivedForTransferLot(1:i64 id) throws (1:WarehouseServiceException wex);
         
         TransferLotStatus updateTransferLotAfterItemReceive(1:i64 id) throws (1:WarehouseServiceException wex);
         
         void scanForTransferOut(1:list<InventoryItem> inventoryItems, 2:ScanType type, 3:i64 transferLotId) throws (1:WarehouseServiceException wex);
         
         void scanForTransferIn(1:list<InventoryItem> inventoryItems, 2:ScanType type, 3:i64 transferLotId) throws (1:WarehouseServiceException wex);
         
         void scanForOursThirdPartyReceive(1:list<InventoryItem>inventoryItems, 2:i64 id) throws (1:WarehouseServiceException wex);

         i64 getCurrentQuantityForNonSerializedInTransitItemInPhysicalWarehouse(1:i64 itemId, 2:i64 physicalWarehouseId) throws (1:WarehouseServiceException wex);
         
         list<InTransitInventory> getInTransitInventory(1:i64 originWarehouseId);
         
         bool isItemAvailableForSale(1:i64 itemId, 2:string serialNumber, 3:i64 warehouseId) throws (1:WarehouseServiceException wex);
         
         /**
         * Get inventory for Non Serialized items in our warehouses at a given date using entries in ScanNew table
         */
     list<InventoryAvailability> getHistoricBadInventoryByScans(1:i64 date) throws (1:WarehouseServiceException wex);
     
     InventoryItem scanForBadSale(1:string serialNumber, 2:string itemNumber, 3:i64 itemId, 4:i64 orderId, 5:i64 fulfilmentWarehouseId, 6:i64 quantity, 7:i64 billingWarehouseId) throws (1:WarehouseServiceException wex);
        
         list<InventoryItem> getTransferLotItemsForMarkReceive(1:i64 transferLotId, 2:ScanType scanType) throws (1:WarehouseServiceException wex);
         
         void markItemsAsReceivedForTransferLotPartial(1:list<InventoryItem> inventoryItems, 2:i64 transferLotId) throws (1:WarehouseServiceException wex);
         
         void markTransferLotAsReceivedPartial(1:i64 id, 2:string remoteTransferRefNumber) throws (1:WarehouseServiceException wex);
         
         list<InventoryItem> getInventoryItemScannedInForPO(1:i64 itemId, 2:list<i64> purchaseIds) throws (1:WarehouseServiceException wex);
         
         list<AmazonTransferredSkuDetail> getAmazonTransferredSkuDetails(1:list<i64> itemIds) throws (1:WarehouseServiceException wex);
         
         list<Scan> getScansforPurchase(1:i64 purchaseId, 2:ScanType scanType) throws (1:WarehouseServiceException wex);
         
         i64 getCurrentBadQuantityForItem(1:i64 itemId, 2:i64 currentWarehouseId, 3:i64 physicalWarehouseId) throws (1:WarehouseServiceException wex);
         
         i64 scanForBadPurchaseReturn(1:list<InventoryItem> saleReturnItems, 2:i64 vendorId, 3:i64 billingWarehouseId) throws (1:WarehouseServiceException ex);
         
         map<i64, i64> getItemsInPurchaseReturn(1:i64 purchaseReturnId, 2:ScanType type, 3:string returnTime) throws (1:WarehouseServiceException ex);
         
         list<Scan> getScansForInventoryItem(1:i64 inventoryItemId, 2:ScanType type) throws (1:WarehouseServiceException ex);
         
         //string scanWithResponse(1:InventoryItem inventoryItem, 2:ScanType type, 3:i64 quantity, 4:i64 billingWarehouseId, 5:i64 transferLotId) throws (1:WarehouseServiceException wex);
         
         list<string> checkGrnImeiStatus(1:list<string> imeiNos) throws (1:WarehouseServiceException ex);
         
         list<InvAgeConsiderItems> getInventoryAgeConsideredItems(1:i64 itemId) throws (1:WarehouseServiceException ex);
         
         list<InventoryMovement> getCompleteMovementForThirdPartyWarehouse(1:i64 startDate, 2:i64 endDate);
         /* 
         list<InventoryItem> getDoaOutInventoryItems(1:i64 offset,2:i64 limit) throws (1:WarehouseServiceException ex);
         
         list<InventoryItem> getDoaOutSearchedItems(1:list<string> searchTerm,2:i64 offset,3:i64 limit) throws (1:WarehouseServiceException ex);
         
         i64 getCountForDoaOutInventoryItems() throws (1:WarehouseServiceException ex);
        
         i64 getDoaOutInventoryItemsResultCount(1:list<string> searchTerm) throws (1:WarehouseServiceException ex); */
         
         list<DoaOutInventoryItem> getAllDoaOutInventoryItems() throws (1:WarehouseServiceException ex);
         
         list<RemovalStockShipmentReference> getAllUnCompletedStockShipments(1:string source) throws (1:WarehouseServiceException ex);
         
         RemovalStockShipmentReference getRemovalStockShipmentReferenceById(1:i64 id) throws (1:WarehouseServiceException ex);
         
         i64 createRemovalStockShipmentReference(1:RemovalStockShipmentReference removalStockShipmentReference) throws (1:WarehouseServiceException ex);
         
         void updateShipmentReferenceTransferLot(1:i64 transferLotId, 2:i64 shipmentReferenceId) throws (1:WarehouseServiceException ex); 
         
         /**
     * Returns the shipment references and the count of scans against on a given day.
     */
     list<TransferInvoiceScan> fetchScansPerTransferInvoiceNumber(1:i64 date);
     
     list<InventoryItem> getInventoryItems(1:list<string> serialNumbers) throws (1:WarehouseServiceException wex);

     list<InventoryItem> getInventoryItemsBySerailNumbers(1:list<string> serialNumbers) throws (1:WarehouseServiceException wex);
     
     void scanPurchaseBulk(1:list<InventoryItem> inventoryItems) throws (1:WarehouseServiceException wex);
     
     
     
     
     
}