Subversion Repositories SmartDukaan

Rev

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