Subversion Repositories SmartDukaan

Rev

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