Subversion Repositories SmartDukaan

Rev

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