Subversion Repositories SmartDukaan

Rev

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