Subversion Repositories SmartDukaan

Rev

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