Subversion Repositories SmartDukaan

Rev

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