Subversion Repositories SmartDukaan

Rev

Rev 3374 | Rev 3424 | 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 Supplier{
        1:i64 id,
        2:string name,
        3:string phone,
        4:string fax,
        5:string tin,
        6:string pan,
        7:string headName,
        8:string headDesignation,
        9:string headEmail,
        10:string contactName,
        11:string contactPhone,
        12:string contactFax,
        13:string contactEmail,
        14:string registeredAddress,
        15:string communicationAddress
}

//struct WarehouseDashboardUser{
//      1:i64 id,
//      2:string name,
//      3:string password,
//      4:Role role
//}

struct LineItem{
        1:i64 orderId,
        2:i64 itemId,
        3:string productGroup,
        4:string brand,
        5:string modelNumber,
        6:string modelName,
        7:string color,
        8:string itemNumber,
        9:double quantity,
        10:double unfulfilledQuantity,
        11:i64 createdAt,
        12:double unitPrice,
        13:bool fulfilled
}

enum POStatus{
        INIT = 0,                                       //Just created.
        READY = 1,                                      //Posted for fulfillment.
        PARTIALLY_FULFILLED = 2,        //Partially fulfullied. Possible to accept purchases against it.
        PRECLOSED = 3,                          //PO was partially fulfilled and the supplier has clarified that he can't supply the remaining items. 
        CLOSED = 4                                      //PO was completely fulfilled.
}

struct PurchaseOrder{
        1:i64 id,
        2:string poNumber,
        3:list<LineItem> lineitems,
        4:i64 supplierId,
        5:i64 warehouseId,
        6:POStatus status,
        7:i64 createdAt,
        8:i64 updatedAt,
        9:double totalCost,
        10:double freightCharges,
        11:double realizedCost,
        12:double realizedFreightCharges
}

struct Purchase{
        1:i64 id,
        2:i64 poId,
        3:string invoiceNumber,
        4:i64 receivedOn,
        5:double freightCharges
}

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

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
}

struct Scan{
        1:i64 id,
        2:i64 itemId,
        3:i64 warehouseId,
        4:i64 purchaseId,
        5:string itemNumber,
        6:string imeiNumber,
        7:ScanType type,
        8:i64 scannedAt
}

exception WarehouseServiceException{
        1:i64 id,
        2:string message
}

service WarehouseService extends GenericService.GenericService{
        /**
        Creates a purchase order based on the data in the given purchase order object.
        This method populates a nummber of missing fields 
        */
        i64 createPurchaseOrder(1:PurchaseOrder purchaseOrder) throws (1:WarehouseServiceException wex),
        
        /**
        Returns the purchase order with the given id. Throws an exception if there is no such purchase order.
        */
        PurchaseOrder getPurchaseOrder(1:i64 id) throws (1:WarehouseServiceException wex),

        /**
        Returns a list of all the purchase orders in the given state
        */
        list<PurchaseOrder> getAllPurchaseOrders(1:POStatus status) throws(1:WarehouseServiceException wex),
        
        /**
        Returns the supplier with the given order id. Throws an exception if there is no such supplier.
        */
        Supplier getSupplier(1:i64 id) throws (1:WarehouseServiceException wex),
        
        /**
        Creates a purchase for the given purchase order.
        Throws an exception if no more purchases are allowed against the given purchase order.
        */
        i64 startPurchase(1:i64 purchaseOrderId, 2:string invoiceNumber, 3:double freightCharges) throws (1:WarehouseServiceException wex), 
        
        /**
        Marks a purchase as complete and updates the receivedOn time.
        Throws an exception if no such purchase exists.
        */
        i64 closePurchase(1:i64 purchaseId) throws (1:WarehouseServiceException wex),
        
        /**
        Returns all open or closed purchases for the given purchase order. Throws an exception if no such purchase order exists
        */
        list<Purchase> getAllPurchases(1:i64 purchaseOrderId, 2:bool open) throws(1:WarehouseServiceException wex),
        
        /**
        Creates a Scan object using the given details.
        Raises an exception if no more of the given item can be scanned in against the purchase order of the given purchase.
        */
        void scanIn(1:i64 purchaseId, 2:string itemNumber, 3:string imeiNumber, 4:ScanType type) throws (1:WarehouseServiceException wex),
        
        /**
        Marks the Scan object with the given details as scanned out. In case, the imeiNumber is not given,
        marks the oldest ItemInventory object as being scanned out.
        Raises an exception if:
        1. There is no stock present corresponding to the given item details.
        2. An older stock is present corresponding to the itemNumber which has not been scanned out.
        */
        void scanOut(1:i64 itemNumber, 2:i64 imeiNumber, 3:ScanType type) throws (1:WarehouseServiceException wex)
}