Subversion Repositories SmartDukaan

Rev

Rev 5545 | Rev 5711 | 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
}

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,

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

struct DetailedPurchaseScan {
    1:i64 purchaseOrderId,
    2:i64 poCreatedAt,
    3:string supplierName,
    4:string invoiceNumbers,
    5:i64 itemId,
    6:string brand,
    7:string modelName,
    8:string modelNumber,
    9:string color,
   10:double unitPrice,
   11:i64 quantity
}

struct InvoiceScan {
    1:string invoiceNumber,
    2:i64 numItems,
    3:string supplierName,
    4:i64 date,
    5: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) 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 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);
}