Subversion Repositories SmartDukaan

Rev

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