Subversion Repositories SmartDukaan

Rev

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