Subversion Repositories SmartDukaan

Rev

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