Subversion Repositories SmartDukaan

Rev

Rev 5185 | Rev 5530 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4496 mandeep.dh 1
namespace java in.shop2020.purchase
2
namespace py shop2020.thriftpy.purchase
3
 
4
include "GenericService.thrift"
5
 
6
struct Supplier {
7
    1:i64 id,
8
    2:string name,
9
    3:string phone,
10
    4:string fax,
11
    5:string tin,
12
    6:string pan,
13
    7:string headName,
14
    8:string headDesignation,
15
    9:string headEmail,
16
    10:string contactName,
17
    11:string contactPhone,
18
    12:string contactFax,
19
    13:string contactEmail,
20
    14:string registeredAddress,
21
    15:string communicationAddress
22
}
23
 
24
struct LineItem {
25
    1:i64 orderId,
26
    2:i64 itemId,
27
    3:string productGroup,
28
    4:string brand,
29
    5:string modelNumber,
30
    6:string modelName,
31
    7:string color,
32
    8:string itemNumber,
33
    9:double quantity,
34
    10:double unfulfilledQuantity,
35
    11:i64 createdAt,
36
    12:double unitPrice,
4754 mandeep.dh 37
    13:bool fulfilled,
38
    14:i64 codCount
4496 mandeep.dh 39
}
40
 
41
enum POStatus {
42
    INIT = 0,                   //Just created.
43
    READY = 1,                  //Posted for fulfillment.
44
    PARTIALLY_FULFILLED = 2,    //Partially fulfullied. Possible to accept purchases against it.
45
    PRECLOSED = 3,              //PO was partially fulfilled and the supplier has clarified that he can't supply the remaining items. 
46
    CLOSED = 4                  //PO was completely fulfilled.
47
}
48
 
49
struct PurchaseOrder {
50
    1:i64 id,
51
    2:string poNumber,
52
    3:list<LineItem> lineitems,
53
    4:i64 supplierId,
54
    5:i64 warehouseId,
55
    6:POStatus status,
56
    7:i64 createdAt,
57
    8:i64 updatedAt,
58
    9:double totalCost,
59
    10:double freightCharges,
60
    11:double realizedCost,
61
    12:double realizedFreightCharges
62
}
63
 
64
struct Purchase {
65
    1:i64 id,
66
    2:i64 poId,
67
    3:string invoiceNumber,
68
    4:i64 receivedOn,
4555 mandeep.dh 69
    5:double freightCharges,
4496 mandeep.dh 70
}
71
 
5443 mandeep.dh 72
struct Invoice {
73
    1:i64 id,
74
    2:string invoiceNumber,
75
    3:i64 date,
76
    4:i64 numItems,
77
    5:string receivedFrom,
78
    6:i64 supplierId
79
}
80
 
4496 mandeep.dh 81
exception PurchaseServiceException {
82
    1:GenericService.ExceptionType exceptionType,
83
    2:string message
84
}
85
 
86
service PurchaseService extends GenericService.GenericService {
87
    /**
88
    Creates a purchase order based on the data in the given purchase order object.
89
    This method populates a nummber of missing fields 
90
    */
91
    i64 createPurchaseOrder(1:PurchaseOrder purchaseOrder) throws (1:PurchaseServiceException e),
92
 
93
    /**
94
    Returns the purchase order with the given id. Throws an exception if there is no such purchase order.
95
    */
96
    PurchaseOrder getPurchaseOrder(1:i64 id) throws (1:PurchaseServiceException e),
97
 
98
    /**
99
    Returns a list of all the purchase orders in the given state
100
    */
101
    list<PurchaseOrder> getAllPurchaseOrders(1:POStatus status) throws (1:PurchaseServiceException e),
102
 
103
    /**
104
    Returns the supplier with the given order id. Throws an exception if there is no such supplier.
105
    */
106
    Supplier getSupplier(1:i64 id) throws (1:PurchaseServiceException e),
107
 
108
    /**
109
    Creates a purchase for the given purchase order.
110
    Throws an exception if no more purchases are allowed against the given purchase order.
111
    */
112
    i64 startPurchase(1:i64 purchaseOrderId, 2:string invoiceNumber, 3:double freightCharges) throws (1:PurchaseServiceException e),
113
 
114
    /**
115
    Marks a purchase as complete and updates the receivedOn time.
116
    Throws an exception if no such purchase exists.
117
    */
118
    i64 closePurchase(1:i64 purchaseId) throws (1:PurchaseServiceException e),
119
 
120
    /**
121
    Returns all open or closed purchases for the given purchase order. Throws an exception if no such purchase order exists
122
    */
123
    list<Purchase> getAllPurchases(1:i64 purchaseOrderId, 2:bool open) throws (1:PurchaseServiceException e),
4555 mandeep.dh 124
 
4496 mandeep.dh 125
    /**
4555 mandeep.dh 126
     * Returns the purchase order object for a given purchase
4496 mandeep.dh 127
     */
4555 mandeep.dh 128
    PurchaseOrder getPurchaseOrderForPurchase(1:i64 purchaseId);
4754 mandeep.dh 129
 
130
    /**
131
     * Creates purchase order objects from pending orders
132
     */
133
    list<PurchaseOrder> getPendingPurchaseOrders(1:i64 warehouseId) throws (1:PurchaseServiceException e);
134
 
135
    /**
136
     * Returns all the valid suppliers
137
     */
138
    list<Supplier> getSuppliers() throws (1:PurchaseServiceException e);
139
 
140
    /**
141
     * Fulfills a given purchase order with an item.
142
     */
143
    void fulfillPO(1:i64 purchaseOrderId, 2:i64 itemId, 3:i64 quantity) throws (1:PurchaseServiceException e);
144
 
145
    /**
146
     * Amends a PO as per the new lineitems passed 
147
     */
148
    void updatePurchaseOrder(1:PurchaseOrder purchaseOrder) throws (1:PurchaseServiceException e),
5185 mandeep.dh 149
 
150
    /**
151
     * Fulfills a given purchase id with an item and its quantity.
152
     */
153
    void unFulfillPO(1:i64 purchaseId, 2:i64 itemId, 3:i64 quantity) throws (1:PurchaseServiceException e);
5443 mandeep.dh 154
 
155
    /**
156
     * Fetches all invoices for a given date
157
     */
158
    list<Invoice> getInvoices(1:i64 date);
159
 
160
    /**
161
     * Creates an invoice object
162
     */
163
    void createInvoice(1:Invoice invoice) throws (1:PurchaseServiceException e);
4496 mandeep.dh 164
}