Subversion Repositories SmartDukaan

Rev

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