Subversion Repositories SmartDukaan

Rev

Rev 13691 | Rev 20025 | 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,
9925 amar.kumar 113
    15:TaxType taxType
4496 mandeep.dh 114
}
115
 
116
struct Purchase {
117
    1:i64 id,
118
    2:i64 poId,
119
    3:string invoiceNumber,
120
    4:i64 receivedOn,
11801 manish.sha 121
    5:double freightCharges,
122
    6:string purchaseComments
4496 mandeep.dh 123
}
124
 
6467 amar.kumar 125
struct PurchaseReturn {
126
    1:i64 id,
127
    2:i64 vendorId,
128
    3:i64 amount,
129
    4:i64 returnTimestamp,
6821 amar.kumar 130
    5:bool isSettled,
10864 manish.sha 131
    6:PurchaseReturnType type,
13691 manish.sha 132
    7:PurchaseReturnInventoryType returnInventoryType,
133
    8:SettlementType currentSettlementType,
134
    9:i64 latestSettlementDate,
135
    10:PrReasonType purchaseReturnType,
136
    11:string reasonText,
137
    12:string documentNumber,
138
    13:string createdBy,
139
    14:i64 unsettledAmount  
6467 amar.kumar 140
}
141
 
13691 manish.sha 142
struct PurchaseReturnSettlement {
143
	1:i64 purchaseReturnId,
144
	2:SettlementType settlementType,
145
	3:i64 settlementAmount,
146
	4:i64 settlementDate,
147
	5:string settlementBy
148
	6:string documentNumber
149
}
150
 
151
 
5443 mandeep.dh 152
struct Invoice {
153
    1:i64 id,
154
    2:string invoiceNumber,
155
    3:i64 date,
156
    4:i64 numItems,
157
    5:string receivedFrom,
7410 amar.kumar 158
    6:i64 supplierId,
11219 manish.sha 159
    7:i64 warehouseId,
160
    8:i64 invoiceDate
5443 mandeep.dh 161
}
162
 
4496 mandeep.dh 163
exception PurchaseServiceException {
164
    1:GenericService.ExceptionType exceptionType,
165
    2:string message
166
}
167
 
168
service PurchaseService extends GenericService.GenericService {
169
    /**
170
    Creates a purchase order based on the data in the given purchase order object.
171
    This method populates a nummber of missing fields 
172
    */
173
    i64 createPurchaseOrder(1:PurchaseOrder purchaseOrder) throws (1:PurchaseServiceException e),
174
 
175
    /**
176
    Returns the purchase order with the given id. Throws an exception if there is no such purchase order.
177
    */
178
    PurchaseOrder getPurchaseOrder(1:i64 id) throws (1:PurchaseServiceException e),
179
 
180
    /**
181
    Returns a list of all the purchase orders in the given state
182
    */
183
    list<PurchaseOrder> getAllPurchaseOrders(1:POStatus status) throws (1:PurchaseServiceException e),
184
 
185
    /**
186
    Returns the supplier with the given order id. Throws an exception if there is no such supplier.
187
    */
188
    Supplier getSupplier(1:i64 id) throws (1:PurchaseServiceException e),
189
 
190
    /**
191
    Creates a purchase for the given purchase order.
192
    Throws an exception if no more purchases are allowed against the given purchase order.
193
    */
11801 manish.sha 194
    i64 startPurchase(1:i64 purchaseOrderId, 2:string invoiceNumber, 3:double freightCharges, 4:string purchaseComments) throws (1:PurchaseServiceException e),
4496 mandeep.dh 195
 
196
    /**
197
    Marks a purchase as complete and updates the receivedOn time.
198
    Throws an exception if no such purchase exists.
199
    */
200
    i64 closePurchase(1:i64 purchaseId) throws (1:PurchaseServiceException e),
201
 
202
    /**
203
    Returns all open or closed purchases for the given purchase order. Throws an exception if no such purchase order exists
204
    */
205
    list<Purchase> getAllPurchases(1:i64 purchaseOrderId, 2:bool open) throws (1:PurchaseServiceException e),
6385 amar.kumar 206
 
207
    /**
208
    Returns all purchases for the given purchase order. Throws an exception if no such purchase order exists
209
    */
210
    list<Purchase> getPurchasesForPO(1:i64 purchaseOrderId) throws (1:PurchaseServiceException e),
4555 mandeep.dh 211
 
4496 mandeep.dh 212
    /**
4555 mandeep.dh 213
     * Returns the purchase order object for a given purchase
4496 mandeep.dh 214
     */
4555 mandeep.dh 215
    PurchaseOrder getPurchaseOrderForPurchase(1:i64 purchaseId);
4754 mandeep.dh 216
 
217
    /**
218
     * Creates purchase order objects from pending orders
219
     */
220
    list<PurchaseOrder> getPendingPurchaseOrders(1:i64 warehouseId) throws (1:PurchaseServiceException e);
221
 
222
    /**
223
     * Returns all the valid suppliers
224
     */
225
    list<Supplier> getSuppliers() throws (1:PurchaseServiceException e);
226
 
227
    /**
228
     * Fulfills a given purchase order with an item.
229
     */
230
    void fulfillPO(1:i64 purchaseOrderId, 2:i64 itemId, 3:i64 quantity) throws (1:PurchaseServiceException e);
231
 
232
    /**
233
     * Amends a PO as per the new lineitems passed 
234
     */
235
    void updatePurchaseOrder(1:PurchaseOrder purchaseOrder) throws (1:PurchaseServiceException e),
5185 mandeep.dh 236
 
237
    /**
238
     * Fulfills a given purchase id with an item and its quantity.
239
     */
240
    void unFulfillPO(1:i64 purchaseId, 2:i64 itemId, 3:i64 quantity) throws (1:PurchaseServiceException e);
5443 mandeep.dh 241
 
242
    /**
5530 mandeep.dh 243
     * Fetches all invoices after a given date
5443 mandeep.dh 244
     */
245
    list<Invoice> getInvoices(1:i64 date);
246
 
7410 amar.kumar 247
	/**
248
     * Fetches all invoices after a given date
249
     */
250
    list<Invoice> getInvoicesForWarehouse(1:i64 warehouseId, 2:i64 supplierId, 3:i64 date);
251
 
5443 mandeep.dh 252
    /**
253
     * Creates an invoice object
254
     */
255
    void createInvoice(1:Invoice invoice) throws (1:PurchaseServiceException e);
5591 mandeep.dh 256
 
257
    /**
258
     * Creates a supplier 
259
     */
260
    Supplier addSupplier(1:Supplier supplier);
261
 
262
    /**
263
     * Updates a supplier 
264
     */
265
    void updateSupplier(1:Supplier supplier);
6467 amar.kumar 266
 
267
    /**
268
     * Create a new Purchase Return
269
    */
270
   	i64 createPurchaseReturn(1:PurchaseReturn purchaseReturn);
271
 
272
    /**
273
     * Create a new Purchase Return
274
    */
275
    void settlePurchaseReturn(1:i64 id);
276
 
277
    /**
278
     * Create a new Purchase Return
279
    */
280
    list<PurchaseReturn> getUnsettledPurchaseReturns();
6630 amar.kumar 281
 
282
    /**
283
     * Get invoice with given supplierId and invoiceNumber
284
    */
285
    list<PurchaseReturn> getInvoice(1:string invoiceNumber, 2:i64 supplierId);
286
 
6762 amar.kumar 287
    /**
288
     * Inserts new Invoice/LineItem/Purchase Entries for Billed Product done through Our External Billing
289
    **/
7672 rajveer 290
    i64 createPurchaseForOurExtBilling(1:string invoiceNumber, 2:double unitPrice, 3:double nlc, 4:i64 itemId);
6762 amar.kumar 291
 
292
    void fulfillPOForExtBilling(1:i64 itemId, 2:i64 quantity);
293
 
7410 amar.kumar 294
    /**
295
     * Marks a purchase order as closedcomplete and updates the receivedOn time.
296
    */
297
    void closePO(1:i64 poId) throws (1:PurchaseServiceException e),
298
 
299
    /**
300
     * Check if invoice is already received with given supplierId and invoiceNumber
301
    */
302
    bool isInvoiceReceived(1:string invoiceNumber, 2:i64 supplierId);
9829 amar.kumar 303
 
304
    /**
305
     * Change warehouseId of PO if no items have been received yet for the PO
306
    */
307
    void changeWarehouseForPO(1:i64 id, 2:i64 warehouseId) throws (1:PurchaseServiceException e);
9925 amar.kumar 308
 
309
    /**
310
     * Change status of PO 
311
    */
312
    void changePOStatus(1:i64 id, 2:POStatus poStatus)throws (1:PurchaseServiceException e);
11751 manish.sha 313
 
314
    /**
315
     * Get Purchase Return from Id
316
    */
317
    PurchaseReturn getPurchaseReturn(1:i64 id)throws (1:PurchaseServiceException e);
13691 manish.sha 318
 
319
    bool markPurchasereturnSettled(1:i64 id, 2:SettlementType settlementType, 3:string documentNumber, 4:string settlementBy, 5:i64 settledAmount) throws (1:PurchaseServiceException e);
320
 
321
    list<PurchaseReturnSettlement> getPrSettlementsForPurchaseReturn(1:i64 purchaseReturnId) throws (1:PurchaseServiceException e);
322
 
323
    void updatePurchaseReturn(1:PurchaseReturn purchaseReturn) throws (1:PurchaseServiceException e);
4496 mandeep.dh 324
}