Subversion Repositories SmartDukaan

Rev

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