Subversion Repositories SmartDukaan

Rev

Rev 21847 | 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,
10295 amar.kumar 21
    15:string communicationAddress,
14072 manish.sha 22
    16:i64 stateId,
21844 amit.gupta 23
    17:i64 poValidityLimit,
23081 amit.gupta 24
    18:string gstin,
25
    19:string tnc
4496 mandeep.dh 26
}
27
 
28
struct LineItem {
29
    1:i64 orderId,
30
    2:i64 itemId,
31
    3:string productGroup,
32
    4:string brand,
33
    5:string modelNumber,
34
    6:string modelName,
35
    7:string color,
36
    8:string itemNumber,
37
    9:double quantity,
38
    10:double unfulfilledQuantity,
39
    11:i64 createdAt,
40
    12:double unitPrice,
4754 mandeep.dh 41
    13:bool fulfilled,
9416 amar.kumar 42
    14:i64 codCount,
43
    15:i64 availableQuantity,
44
    16:i64 reservedQuantity,
45
    17:double avgSales,
46
    18:i64 minStockLevel,
47
    19:i64 numberOfDaysStock,
48
    20:i64 suggestedQuantity,
49
    21:i64 numberOfDaysInStock,
50
    22:i64 rtoOrders,
51
    23:string lastXdaysSale,
52
    24:i64 previouslyOrderedQty,
53
    25:double nlc,
54
    26:double mrp
12357 manish.sha 55
    27:double nlcP,
21844 amit.gupta 56
    28:double vatDiff,
57
    29:double igstRate,
58
	30:double cgstRate,
59
	31:double sgstRate,
60
	32:string hsnCode
61
 
4496 mandeep.dh 62
}
63
 
64
enum POStatus {
65
    INIT = 0,                   //Just created.
66
    READY = 1,                  //Posted for fulfillment.
67
    PARTIALLY_FULFILLED = 2,    //Partially fulfullied. Possible to accept purchases against it.
68
    PRECLOSED = 3,              //PO was partially fulfilled and the supplier has clarified that he can't supply the remaining items. 
69
    CLOSED = 4                  //PO was completely fulfilled.
70
}
71
 
6821 amar.kumar 72
enum POType {
73
    REAL = 1,                   //PO created manually
74
    VIRTUAL = 2		            //Virtual PO generated automatically for Ours_External Billing
75
}
76
 
77
enum PurchaseReturnType {
78
    REAL = 1,                   //Purchase Returns where stock is returned to Vendor
79
    VIRTUAL = 2		            //Virtual Purchase Return associated with Sale Returns for OursExternal Billing
80
}
81
 
10864 manish.sha 82
enum PurchaseReturnInventoryType {
83
	GOOD = 1,
84
	BAD = 2
85
}
86
 
9416 amar.kumar 87
enum TaxType {
88
	VAT = 0,
89
	CST = 1,
21844 amit.gupta 90
	CFORM = 2,
91
	IGST = 3,
92
	SGST = 4
9416 amar.kumar 93
}
94
 
13691 manish.sha 95
enum PrReasonType {
96
	WRONG_GRN = 1,
97
	ACTUAL_PR = 2,
98
	REPLACEMENT = 3
99
}
100
 
101
enum SettlementType {
102
	CREDIT_NOTE = 1,
103
	REPLACEMENT = 2,
104
	AGAINST_GRN = 3
105
}
106
 
4496 mandeep.dh 107
struct PurchaseOrder {
108
    1:i64 id,
109
    2:string poNumber,
110
    3:list<LineItem> lineitems,
111
    4:i64 supplierId,
112
    5:i64 warehouseId,
9925 amar.kumar 113
    6:i64 shippingWarehouseId,
114
    7:POStatus status,
115
    8:i64 createdAt,
116
    9:i64 updatedAt,
117
    10:double totalCost,
118
    11:double freightCharges,
119
    12:double realizedCost,
120
    13:double realizedFreightCharges,
13691 manish.sha 121
    14:POType type,
20025 amit.gupta 122
    15:TaxType taxType,
123
    16:i64 warehouseAddressId
124
    17:i64 shippingWarehouseAddressId
125
    18:i64 buyerId
4496 mandeep.dh 126
}
127
 
128
struct Purchase {
129
    1:i64 id,
130
    2:i64 poId,
131
    3:string invoiceNumber,
132
    4:i64 receivedOn,
11801 manish.sha 133
    5:double freightCharges,
134
    6:string purchaseComments
4496 mandeep.dh 135
}
136
 
6467 amar.kumar 137
struct PurchaseReturn {
138
    1:i64 id,
139
    2:i64 vendorId,
140
    3:i64 amount,
141
    4:i64 returnTimestamp,
6821 amar.kumar 142
    5:bool isSettled,
10864 manish.sha 143
    6:PurchaseReturnType type,
13691 manish.sha 144
    7:PurchaseReturnInventoryType returnInventoryType,
145
    8:SettlementType currentSettlementType,
146
    9:i64 latestSettlementDate,
147
    10:PrReasonType purchaseReturnType,
148
    11:string reasonText,
149
    12:string documentNumber,
150
    13:string createdBy,
151
    14:i64 unsettledAmount  
6467 amar.kumar 152
}
153
 
13691 manish.sha 154
struct PurchaseReturnSettlement {
155
	1:i64 purchaseReturnId,
156
	2:SettlementType settlementType,
157
	3:i64 settlementAmount,
158
	4:i64 settlementDate,
159
	5:string settlementBy
160
	6:string documentNumber
161
}
162
 
163
 
5443 mandeep.dh 164
struct Invoice {
165
    1:i64 id,
166
    2:string invoiceNumber,
167
    3:i64 date,
168
    4:i64 numItems,
169
    5:string receivedFrom,
7410 amar.kumar 170
    6:i64 supplierId,
11219 manish.sha 171
    7:i64 warehouseId,
172
    8:i64 invoiceDate
5443 mandeep.dh 173
}
174
 
4496 mandeep.dh 175
exception PurchaseServiceException {
176
    1:GenericService.ExceptionType exceptionType,
177
    2:string message
178
}
179
 
180
service PurchaseService extends GenericService.GenericService {
181
    /**
182
    Creates a purchase order based on the data in the given purchase order object.
183
    This method populates a nummber of missing fields 
184
    */
185
    i64 createPurchaseOrder(1:PurchaseOrder purchaseOrder) throws (1:PurchaseServiceException e),
186
 
187
    /**
188
    Returns the purchase order with the given id. Throws an exception if there is no such purchase order.
189
    */
190
    PurchaseOrder getPurchaseOrder(1:i64 id) throws (1:PurchaseServiceException e),
191
 
192
    /**
193
    Returns a list of all the purchase orders in the given state
194
    */
195
    list<PurchaseOrder> getAllPurchaseOrders(1:POStatus status) throws (1:PurchaseServiceException e),
196
 
197
    /**
198
    Returns the supplier with the given order id. Throws an exception if there is no such supplier.
199
    */
200
    Supplier getSupplier(1:i64 id) throws (1:PurchaseServiceException e),
201
 
202
    /**
203
    Creates a purchase for the given purchase order.
204
    Throws an exception if no more purchases are allowed against the given purchase order.
205
    */
11801 manish.sha 206
    i64 startPurchase(1:i64 purchaseOrderId, 2:string invoiceNumber, 3:double freightCharges, 4:string purchaseComments) throws (1:PurchaseServiceException e),
4496 mandeep.dh 207
 
208
    /**
209
    Marks a purchase as complete and updates the receivedOn time.
210
    Throws an exception if no such purchase exists.
211
    */
212
    i64 closePurchase(1:i64 purchaseId) throws (1:PurchaseServiceException e),
213
 
214
    /**
215
    Returns all open or closed purchases for the given purchase order. Throws an exception if no such purchase order exists
216
    */
217
    list<Purchase> getAllPurchases(1:i64 purchaseOrderId, 2:bool open) throws (1:PurchaseServiceException e),
6385 amar.kumar 218
 
219
    /**
220
    Returns all purchases for the given purchase order. Throws an exception if no such purchase order exists
221
    */
222
    list<Purchase> getPurchasesForPO(1:i64 purchaseOrderId) throws (1:PurchaseServiceException e),
4555 mandeep.dh 223
 
4496 mandeep.dh 224
    /**
4555 mandeep.dh 225
     * Returns the purchase order object for a given purchase
4496 mandeep.dh 226
     */
4555 mandeep.dh 227
    PurchaseOrder getPurchaseOrderForPurchase(1:i64 purchaseId);
4754 mandeep.dh 228
 
229
    /**
230
     * Creates purchase order objects from pending orders
231
     */
232
    list<PurchaseOrder> getPendingPurchaseOrders(1:i64 warehouseId) throws (1:PurchaseServiceException e);
233
 
234
    /**
21847 amit.gupta 235
     * Returns all the valid suppliers with GST Codes
4754 mandeep.dh 236
     */
237
    list<Supplier> getSuppliers() throws (1:PurchaseServiceException e);
238
 
239
    /**
21847 amit.gupta 240
     * Returns all the valid suppliers
241
     */
242
    list<Supplier> getAllSuppliers() throws (1:PurchaseServiceException e);
243
 
244
    /**
4754 mandeep.dh 245
     * Fulfills a given purchase order with an item.
246
     */
247
    void fulfillPO(1:i64 purchaseOrderId, 2:i64 itemId, 3:i64 quantity) throws (1:PurchaseServiceException e);
248
 
249
    /**
250
     * Amends a PO as per the new lineitems passed 
251
     */
252
    void updatePurchaseOrder(1:PurchaseOrder purchaseOrder) throws (1:PurchaseServiceException e),
5185 mandeep.dh 253
 
254
    /**
255
     * Fulfills a given purchase id with an item and its quantity.
256
     */
257
    void unFulfillPO(1:i64 purchaseId, 2:i64 itemId, 3:i64 quantity) throws (1:PurchaseServiceException e);
5443 mandeep.dh 258
 
259
    /**
5530 mandeep.dh 260
     * Fetches all invoices after a given date
5443 mandeep.dh 261
     */
262
    list<Invoice> getInvoices(1:i64 date);
263
 
7410 amar.kumar 264
	/**
265
     * Fetches all invoices after a given date
266
     */
267
    list<Invoice> getInvoicesForWarehouse(1:i64 warehouseId, 2:i64 supplierId, 3:i64 date);
268
 
5443 mandeep.dh 269
    /**
270
     * Creates an invoice object
271
     */
272
    void createInvoice(1:Invoice invoice) throws (1:PurchaseServiceException e);
5591 mandeep.dh 273
 
274
    /**
275
     * Creates a supplier 
276
     */
277
    Supplier addSupplier(1:Supplier supplier);
278
 
279
    /**
280
     * Updates a supplier 
281
     */
282
    void updateSupplier(1:Supplier supplier);
6467 amar.kumar 283
 
284
    /**
285
     * Create a new Purchase Return
286
    */
287
   	i64 createPurchaseReturn(1:PurchaseReturn purchaseReturn);
288
 
289
    /**
290
     * Create a new Purchase Return
291
    */
292
    void settlePurchaseReturn(1:i64 id);
293
 
294
    /**
295
     * Create a new Purchase Return
296
    */
297
    list<PurchaseReturn> getUnsettledPurchaseReturns();
6630 amar.kumar 298
 
299
    /**
300
     * Get invoice with given supplierId and invoiceNumber
301
    */
302
    list<PurchaseReturn> getInvoice(1:string invoiceNumber, 2:i64 supplierId);
303
 
6762 amar.kumar 304
    /**
305
     * Inserts new Invoice/LineItem/Purchase Entries for Billed Product done through Our External Billing
306
    **/
7672 rajveer 307
    i64 createPurchaseForOurExtBilling(1:string invoiceNumber, 2:double unitPrice, 3:double nlc, 4:i64 itemId);
6762 amar.kumar 308
 
309
    void fulfillPOForExtBilling(1:i64 itemId, 2:i64 quantity);
310
 
7410 amar.kumar 311
    /**
312
     * Marks a purchase order as closedcomplete and updates the receivedOn time.
313
    */
314
    void closePO(1:i64 poId) throws (1:PurchaseServiceException e),
315
 
316
    /**
317
     * Check if invoice is already received with given supplierId and invoiceNumber
318
    */
319
    bool isInvoiceReceived(1:string invoiceNumber, 2:i64 supplierId);
9829 amar.kumar 320
 
321
    /**
322
     * Change warehouseId of PO if no items have been received yet for the PO
323
    */
324
    void changeWarehouseForPO(1:i64 id, 2:i64 warehouseId) throws (1:PurchaseServiceException e);
9925 amar.kumar 325
 
326
    /**
327
     * Change status of PO 
328
    */
329
    void changePOStatus(1:i64 id, 2:POStatus poStatus)throws (1:PurchaseServiceException e);
11751 manish.sha 330
 
331
    /**
332
     * Get Purchase Return from Id
333
    */
334
    PurchaseReturn getPurchaseReturn(1:i64 id)throws (1:PurchaseServiceException e);
13691 manish.sha 335
 
336
    bool markPurchasereturnSettled(1:i64 id, 2:SettlementType settlementType, 3:string documentNumber, 4:string settlementBy, 5:i64 settledAmount) throws (1:PurchaseServiceException e);
337
 
338
    list<PurchaseReturnSettlement> getPrSettlementsForPurchaseReturn(1:i64 purchaseReturnId) throws (1:PurchaseServiceException e);
339
 
340
    void updatePurchaseReturn(1:PurchaseReturn purchaseReturn) throws (1:PurchaseServiceException e);
4496 mandeep.dh 341
}