Subversion Repositories SmartDukaan

Rev

Rev 4541 | Rev 4618 | 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"

struct Warehouse {
    1:i64 id,
    2:string displayName,
    3:string location
}

struct InventoryItem {
    // fields in db
    1:i64 id,
    2:i64 itemId,
    3:string itemNumber,
    4:string serialNumber,
    5:i64 initialQuantity,
    6:i64 currentQuantity,
    7:i64 purchaseId,

    // derived fields for  efficient lookups
    8:i64 supplierId,
    9:double unitPrice
}

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)
}

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
}

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

service WarehouseService extends GenericService.GenericService {
    /**
     * Creating inventory for a serialized item
     */
    InventoryItem createSerializedInventoryItem(1:i64 itemId, 2:string serialNumber, 3:i64 purchaseId) throws (1:WarehouseServiceException wex);

    /**
     * Creating inventory for a serialized item using item number
     */
    InventoryItem createSerializedInventoryItemFromItemNumber(1:string itemNumber, 2:string serialNumber, 3:i64 purchaseId) throws (1:WarehouseServiceException wex);

    /**
     * Creates inventory for an unserailized item
     */
    InventoryItem createInventoryItem(1:i64 itemId, 2:i64 quantity, 3:i64 purchaseId) throws (1:WarehouseServiceException wex);

    /**
     * Retrieves serialized inventory item given a serial number
     */
    InventoryItem getInventoryItem(1:string serialNumber) throws (1:WarehouseServiceException wex);

    /**
     * Retrieves non-serialized inventory items from a given supplier
     */
    list<InventoryItem> getNonSeralizedInventoryItems(1:i64 itemId, 2:i64 quantity, 3:i64 supplierId);

    /**
     * Retrieves inventory items for a given item
     */
    list<InventoryItem> getInventoryItems(1:i64 itemId);

    /**
     * Retrieves scans for a given order
     */
    list<Scan> getScanForOrder(1:i64 orderId);

    /**
     * Retrieves scans for a given inventory item
     */
    list<Scan> getScan(1:i64 inventoryItemId);

    /**
     * Scan serialized items.
     */
    void scanSerializedItem(1:i64 inventoryItemId, 2:ScanType type, 3:i64 warehouseId) throws (1:WarehouseServiceException wex);

    /**
     * Scan non-serialized items.
     */
    void scan(1:i64 inventoryItemId, 2:ScanType type, 3:i64 quantity, 4:i64 warehouseId) 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 warehouseId) throws (1:WarehouseServiceException wex);

    /**
     * Scan non-serialized items linked with an order.
     */
    void scanForOrder(1:i64 inventoryItemId, 2:ScanType type, 3:i64 quantity, 4:i64 orderId, 5:i64 warehouseId) throws (1:WarehouseServiceException wex);

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