Subversion Repositories SmartDukaan

Rev

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