Subversion Repositories SmartDukaan

Rev

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