Subversion Repositories SmartDukaan

Rev

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