Subversion Repositories SmartDukaan

Rev

Rev 6821 | Rev 6880 | 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
6821 amar.kumar 39
    15:i64 availableQuantity
40
    16:i64 reservedQuantity
41
    17:double avgSales
42
    18:i64 minStockLevel
43
    19:i64 numberOfDaysStock
44
    20:i64 suggestedQuantity
45
    21:i64 numberOfDaysInStock
6857 amar.kumar 46
    22:string lastXdaysSale
4496 mandeep.dh 47
}
48
 
49
enum POStatus {
50
    INIT = 0,                   //Just created.
51
    READY = 1,                  //Posted for fulfillment.
52
    PARTIALLY_FULFILLED = 2,    //Partially fulfullied. Possible to accept purchases against it.
53
    PRECLOSED = 3,              //PO was partially fulfilled and the supplier has clarified that he can't supply the remaining items. 
54
    CLOSED = 4                  //PO was completely fulfilled.
55
}
56
 
6821 amar.kumar 57
enum POType {
58
    REAL = 1,                   //PO created manually
59
    VIRTUAL = 2		            //Virtual PO generated automatically for Ours_External Billing
60
}
61
 
62
enum PurchaseReturnType {
63
    REAL = 1,                   //Purchase Returns where stock is returned to Vendor
64
    VIRTUAL = 2		            //Virtual Purchase Return associated with Sale Returns for OursExternal Billing
65
}
66
 
4496 mandeep.dh 67
struct PurchaseOrder {
68
    1:i64 id,
69
    2:string poNumber,
70
    3:list<LineItem> lineitems,
71
    4:i64 supplierId,
72
    5:i64 warehouseId,
73
    6:POStatus status,
74
    7:i64 createdAt,
75
    8:i64 updatedAt,
76
    9:double totalCost,
77
    10:double freightCharges,
78
    11:double realizedCost,
6821 amar.kumar 79
    12:double realizedFreightCharges,
80
    13:POType type
4496 mandeep.dh 81
}
82
 
83
struct Purchase {
84
    1:i64 id,
85
    2:i64 poId,
86
    3:string invoiceNumber,
87
    4:i64 receivedOn,
5530 mandeep.dh 88
    5:double freightCharges
4496 mandeep.dh 89
}
90
 
6467 amar.kumar 91
struct PurchaseReturn {
92
    1:i64 id,
93
    2:i64 vendorId,
94
    3:i64 amount,
95
    4:i64 returnTimestamp,
6821 amar.kumar 96
    5:bool isSettled,
97
    6:PurchaseReturnType type
6467 amar.kumar 98
}
99
 
5443 mandeep.dh 100
struct Invoice {
101
    1:i64 id,
102
    2:string invoiceNumber,
103
    3:i64 date,
104
    4:i64 numItems,
105
    5:string receivedFrom,
106
    6:i64 supplierId
107
}
108
 
4496 mandeep.dh 109
exception PurchaseServiceException {
110
    1:GenericService.ExceptionType exceptionType,
111
    2:string message
112
}
113
 
114
service PurchaseService extends GenericService.GenericService {
115
    /**
116
    Creates a purchase order based on the data in the given purchase order object.
117
    This method populates a nummber of missing fields 
118
    */
119
    i64 createPurchaseOrder(1:PurchaseOrder purchaseOrder) throws (1:PurchaseServiceException e),
120
 
121
    /**
122
    Returns the purchase order with the given id. Throws an exception if there is no such purchase order.
123
    */
124
    PurchaseOrder getPurchaseOrder(1:i64 id) throws (1:PurchaseServiceException e),
125
 
126
    /**
127
    Returns a list of all the purchase orders in the given state
128
    */
129
    list<PurchaseOrder> getAllPurchaseOrders(1:POStatus status) throws (1:PurchaseServiceException e),
130
 
131
    /**
132
    Returns the supplier with the given order id. Throws an exception if there is no such supplier.
133
    */
134
    Supplier getSupplier(1:i64 id) throws (1:PurchaseServiceException e),
135
 
136
    /**
137
    Creates a purchase for the given purchase order.
138
    Throws an exception if no more purchases are allowed against the given purchase order.
139
    */
140
    i64 startPurchase(1:i64 purchaseOrderId, 2:string invoiceNumber, 3:double freightCharges) throws (1:PurchaseServiceException e),
141
 
142
    /**
143
    Marks a purchase as complete and updates the receivedOn time.
144
    Throws an exception if no such purchase exists.
145
    */
146
    i64 closePurchase(1:i64 purchaseId) throws (1:PurchaseServiceException e),
147
 
148
    /**
149
    Returns all open or closed purchases for the given purchase order. Throws an exception if no such purchase order exists
150
    */
151
    list<Purchase> getAllPurchases(1:i64 purchaseOrderId, 2:bool open) throws (1:PurchaseServiceException e),
6385 amar.kumar 152
 
153
    /**
154
    Returns all purchases for the given purchase order. Throws an exception if no such purchase order exists
155
    */
156
    list<Purchase> getPurchasesForPO(1:i64 purchaseOrderId) throws (1:PurchaseServiceException e),
4555 mandeep.dh 157
 
4496 mandeep.dh 158
    /**
4555 mandeep.dh 159
     * Returns the purchase order object for a given purchase
4496 mandeep.dh 160
     */
4555 mandeep.dh 161
    PurchaseOrder getPurchaseOrderForPurchase(1:i64 purchaseId);
4754 mandeep.dh 162
 
163
    /**
164
     * Creates purchase order objects from pending orders
165
     */
166
    list<PurchaseOrder> getPendingPurchaseOrders(1:i64 warehouseId) throws (1:PurchaseServiceException e);
167
 
168
    /**
169
     * Returns all the valid suppliers
170
     */
171
    list<Supplier> getSuppliers() throws (1:PurchaseServiceException e);
172
 
173
    /**
174
     * Fulfills a given purchase order with an item.
175
     */
176
    void fulfillPO(1:i64 purchaseOrderId, 2:i64 itemId, 3:i64 quantity) throws (1:PurchaseServiceException e);
177
 
178
    /**
179
     * Amends a PO as per the new lineitems passed 
180
     */
181
    void updatePurchaseOrder(1:PurchaseOrder purchaseOrder) throws (1:PurchaseServiceException e),
5185 mandeep.dh 182
 
183
    /**
184
     * Fulfills a given purchase id with an item and its quantity.
185
     */
186
    void unFulfillPO(1:i64 purchaseId, 2:i64 itemId, 3:i64 quantity) throws (1:PurchaseServiceException e);
5443 mandeep.dh 187
 
188
    /**
5530 mandeep.dh 189
     * Fetches all invoices after a given date
5443 mandeep.dh 190
     */
191
    list<Invoice> getInvoices(1:i64 date);
192
 
193
    /**
194
     * Creates an invoice object
195
     */
196
    void createInvoice(1:Invoice invoice) throws (1:PurchaseServiceException e);
5591 mandeep.dh 197
 
198
    /**
199
     * Creates a supplier 
200
     */
201
    Supplier addSupplier(1:Supplier supplier);
202
 
203
    /**
204
     * Updates a supplier 
205
     */
206
    void updateSupplier(1:Supplier supplier);
6467 amar.kumar 207
 
208
    /**
209
     * Create a new Purchase Return
210
    */
211
   	i64 createPurchaseReturn(1:PurchaseReturn purchaseReturn);
212
 
213
    /**
214
     * Create a new Purchase Return
215
    */
216
    void settlePurchaseReturn(1:i64 id);
217
 
218
    /**
219
     * Create a new Purchase Return
220
    */
221
    list<PurchaseReturn> getUnsettledPurchaseReturns();
6630 amar.kumar 222
 
223
    /**
224
     * Get invoice with given supplierId and invoiceNumber
225
    */
226
    list<PurchaseReturn> getInvoice(1:string invoiceNumber, 2:i64 supplierId);
227
 
6762 amar.kumar 228
    /**
229
     * Inserts new Invoice/LineItem/Purchase Entries for Billed Product done through Our External Billing
230
    **/
231
    i64 createPurchaseForOurExtBilling(1:string invoiceNumber, 2:double unitPrice, 3:i64 itemId);
232
 
233
    void fulfillPOForExtBilling(1:i64 itemId, 2:i64 quantity);
234
 
235
 
236
 
4496 mandeep.dh 237
}