Subversion Repositories SmartDukaan

Rev

Rev 7199 | Rev 7216 | Go to most recent revision | 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;
}

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,
    // derived fields for  efficient lookups
    9:i64 supplierId,
    10:double unitPrice,
    11:i64 currentWarehouseId,
    12:ScanType lastScanType
}

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 thin scan!
    5:i64 warehouseId,
    6:ScanType type,
    7:i64 scannedAt,
    //8: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
}

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

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 ZeroPlusCount,
   12:i64 OnePlusCount,
   13:i64 ZeroPlusCost,
   14:i64 OnePlusCost,
   15:string category
}

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) throws (1:WarehouseServiceException wex);

    /**
     * Scan non-serialized items.
     */
    void scan(1:InventoryItem inventoryItem, 2:ScanType type, 3:i64 quantity, 4:i64 billingWarehouseId) 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 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:i64 serialNumber);
     
     /**
      * Inserts outgoing scans for Returned Items and updates returnId in InventoryItems
      */
     void scanForPurchaseReturn(1:list<InventoryItem> saleReturnItems, 2:i64 vendorId) throws (1:WarehouseServiceException ex);
     
     /**
      * Inserts scans for lost Items and updates lastScanType in InventoryItems
      */
     void scanForLostItem(1:list<InventoryItem> lostItems, 2:i64 vendorId) throws (1:WarehouseServiceException ex);
     
     /**
      * Get inventory count for available Serialized items in our warehouses using entries in ScanNew table
      */
     list<InventoryAvailability> getCurrentSerializedInventoryByScans();
     
      /**
      * Get inventory count for available Serialized items in our warehouses using entries in ScanNew table
      */
     list<InventoryAvailability> getCurrentNonSerializedInventoryByScans();
     
     /**
      * 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);
     
     /**
      * 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: 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);
     
     list<InventoryMovement> getMovementNonSerializedInventoryByScans(1:i64 startDate, 2:i64 endDate);
     
     list<InventoryMovement> getMovementSerializedInventoryByScans(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);
     
}