Subversion Repositories SmartDukaan

Rev

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