| 22059 |
amit.gupta |
1 |
'''
|
|
|
2 |
Created on Apr 12, 2016
|
|
|
3 |
|
|
|
4 |
@author: amit
|
|
|
5 |
'''
|
|
|
6 |
from datetime import datetime
|
|
|
7 |
from elixir import *
|
|
|
8 |
from random import randint
|
|
|
9 |
from shop2020.clients.CatalogClient import CatalogClient
|
|
|
10 |
from shop2020.clients.InventoryClient import InventoryClient
|
|
|
11 |
from shop2020.clients.PurchaseClient import PurchaseClient
|
|
|
12 |
from shop2020.clients.TransactionClient import TransactionClient
|
|
|
13 |
from shop2020.clients.UserClient import UserClient
|
|
|
14 |
from shop2020.model.v1.catalog.impl import DataService
|
|
|
15 |
from shop2020.model.v1.catalog.impl.DataService import CentralGstMaster, \
|
| 22394 |
amit.gupta |
16 |
StateGstMaster, Category, CategoryHsnCodes#, Tag_Listing
|
| 22059 |
amit.gupta |
17 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionStatus
|
|
|
18 |
from sqlalchemy import desc, asc
|
|
|
19 |
from sqlalchemy.orm import aliased
|
|
|
20 |
from sqlalchemy.sql.expression import or_, distinct, func, and_, exists
|
|
|
21 |
from sqlalchemy.sql.functions import now
|
|
|
22 |
|
|
|
23 |
|
| 22119 |
amit.gupta |
24 |
def getCategories():
|
|
|
25 |
|
|
|
26 |
categories = session.query(Category).all()
|
|
|
27 |
rootCategory = 10000
|
|
|
28 |
l1 = []
|
|
|
29 |
for category in categories:
|
|
|
30 |
if category.parent_category_id == rootCategory:
|
|
|
31 |
l1.append(category.id)
|
|
|
32 |
|
|
|
33 |
leaves = []
|
|
|
34 |
for category in categories:
|
|
|
35 |
if category.parent_category_id in l1:
|
|
|
36 |
leaves.append(category)
|
| 22059 |
amit.gupta |
37 |
|
| 22119 |
amit.gupta |
38 |
for leaf in leaves:
|
|
|
39 |
print "({}, '{}')".format(leaf.id, leaf.label)
|
|
|
40 |
|
|
|
41 |
def getChildCategories(rootCategory, categories):
|
|
|
42 |
childCategories = []
|
|
|
43 |
|
|
|
44 |
|
| 22059 |
amit.gupta |
45 |
def addHsnCodes():
|
| 22119 |
amit.gupta |
46 |
gstTuple = [
|
| 22393 |
amit.gupta |
47 |
(10026, 'Bluetooth Speaker', '8519', 28),
|
|
|
48 |
(10090, 'Card Reader', '8471', 18)
|
|
|
49 |
#,
|
|
|
50 |
#(10030, 'USB Cables', '85444220', 28),
|
|
|
51 |
#(10024, 'Ear Buds', '85183000', 18),
|
|
|
52 |
#(12101, 'Fitness Band', '90318000', 18)
|
| 22119 |
amit.gupta |
53 |
]
|
| 22059 |
amit.gupta |
54 |
|
| 22119 |
amit.gupta |
55 |
|
|
|
56 |
|
|
|
57 |
for (categoryId, description, hsnCode, rate) in gstTuple:
|
| 22123 |
amit.gupta |
58 |
categoryHsnCode = session.query(CategoryHsnCodes).filter(CategoryHsnCodes.hsnCode==hsnCode).filter(CategoryHsnCodes.categoryId==categoryId).first()
|
| 22119 |
amit.gupta |
59 |
if categoryHsnCode:
|
| 22123 |
amit.gupta |
60 |
if categoryHsnCode.description !=description:
|
|
|
61 |
categoryHsnCode.description = description
|
| 22119 |
amit.gupta |
62 |
else:
|
|
|
63 |
categoryHsnCode = CategoryHsnCodes()
|
|
|
64 |
categoryHsnCode.hsnCode = hsnCode
|
|
|
65 |
categoryHsnCode.categoryId = categoryId
|
|
|
66 |
categoryHsnCode.description = description
|
|
|
67 |
|
| 22059 |
amit.gupta |
68 |
cgs = session.query(CentralGstMaster).filter(CentralGstMaster.hsnCode==hsnCode).filter(CentralGstMaster.gstPercent==rate).first()
|
|
|
69 |
if cgs is None:
|
|
|
70 |
cgs = CentralGstMaster()
|
|
|
71 |
cgs.hsnCode = hsnCode
|
|
|
72 |
cgs.gstPercent = rate
|
|
|
73 |
cgs.startDate = datetime.now()
|
|
|
74 |
for i in range(37):
|
|
|
75 |
sgst = rate/2
|
|
|
76 |
cgst = rate/2
|
|
|
77 |
sgs = session.query(StateGstMaster).filter(StateGstMaster.hsnCode==hsnCode).filter(StateGstMaster.sgstPercent==sgst).filter(StateGstMaster.cgstPercent==cgst).filter(StateGstMaster.stateId==i).first()
|
|
|
78 |
if sgs is None:
|
|
|
79 |
sgs = StateGstMaster()
|
|
|
80 |
sgs.sgstPercent = sgst
|
|
|
81 |
sgs.cgstPercent = cgst
|
|
|
82 |
sgs.hsnCode = hsnCode
|
|
|
83 |
sgs.stateId = i
|
|
|
84 |
sgs.startDate = datetime.now()
|
|
|
85 |
|
|
|
86 |
session.commit()
|
|
|
87 |
session.close()
|
|
|
88 |
#c = CatalogClient().get_client()
|
|
|
89 |
#print c.getGstRatesByState(0)
|
|
|
90 |
#print c.getInterStateGstRates()
|
|
|
91 |
#print c.getHsnCodesByCategory(10006)
|
|
|
92 |
#
|
|
|
93 |
#ic = InventoryClient().get_client()
|
|
|
94 |
#print ic.getStateMaster()
|
|
|
95 |
#
|
|
|
96 |
#
|
|
|
97 |
#pc = PurchaseClient().get_client()
|
|
|
98 |
#print pc.getPurchaseOrder(22141)
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
#uc = UserClient().get_client()
|
|
|
102 |
#print uc.getCounterByUserId(120398953)
|
|
|
103 |
|
|
|
104 |
def main():
|
| 22393 |
amit.gupta |
105 |
#pass
|
|
|
106 |
print "initialising"
|
|
|
107 |
DataService.initialize('catalog', '173.255.254.24', False)
|
|
|
108 |
print "initiailised"
|
| 22119 |
amit.gupta |
109 |
addHsnCodes()
|
| 22393 |
amit.gupta |
110 |
|
|
|
111 |
#DataService.initialize('catalog', 'localhost', False)
|
|
|
112 |
#session.query(Tag_Listing).all()
|
| 22059 |
amit.gupta |
113 |
|
|
|
114 |
#tc = TransactionClient().get_client()
|
|
|
115 |
#tc.changeTransactionStatus(699979, TransactionStatus.COD_IN_PROCESS, "COD in Process", 0, 0, 1)
|
|
|
116 |
#tc.verifyOrderForTransaction(699983)
|
|
|
117 |
#tc.acceptOrder(748108)
|
|
|
118 |
#tc.addBillingDetailsForGrouppedOrders([748108], 'AMIT2', {748108:'1'}, {748108:['443423432431', '443423432432']}, {}, 'dl-ad-adonis', 1, 0, False, 'BulkInvoice')
|
|
|
119 |
#order_ids, invoice_number, itemNumbersMap, serialNumbersMap, {}, 'mp-mmx-admin', 1, 0, False, 'Individual'
|
|
|
120 |
|
| 22119 |
amit.gupta |
121 |
#tc = TransactionClient().get_client()
|
|
|
122 |
#print tc.getLatestUserWalletHistory(483649, 0, 20)
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
#tupleList = [
|
|
|
126 |
#(10006, 'Mobile Phone')
|
|
|
127 |
#(10008, 'Codless Phones')
|
|
|
128 |
#(10010, 'Tablets')
|
|
|
129 |
#(10012, 'Bluetooth Headset')
|
|
|
130 |
#(10013, 'Memory Card')
|
|
|
131 |
#(10014, 'Battery')
|
|
|
132 |
#(10015, 'Headset')
|
|
|
133 |
#(10016, 'Charger')
|
|
|
134 |
#(10017, 'Pen Drive')
|
|
|
135 |
#(10018, 'Carrying Case')
|
|
|
136 |
#(10019, 'Car Charger')
|
|
|
137 |
#(10020, 'Screen Guard')
|
|
|
138 |
#(10021, 'Face Plate')
|
|
|
139 |
#(10022, 'Decal')
|
|
|
140 |
#(10023, 'Data Cable')
|
|
|
141 |
#(10024, 'Ear Buds')
|
|
|
142 |
#(10025, 'Cleaning Kit')
|
|
|
143 |
#(10026, 'Speaker')
|
|
|
144 |
#(10027, 'Power Bank')
|
|
|
145 |
#(10028, 'AUX Cable')
|
|
|
146 |
#(10029, 'Vehiclle Mounts')
|
|
|
147 |
#(10030, 'Cables')
|
|
|
148 |
#(10032, 'LED Lights')
|
|
|
149 |
#(10050, 'Laptops')
|
|
|
150 |
#(10071, 'RAM')
|
|
|
151 |
#(10072, 'Cooling Stands')
|
|
|
152 |
#(10073, 'External Hard Disks')
|
|
|
153 |
#(10074, 'USB Hubs')
|
|
|
154 |
#(10075, 'Solid State Drives')
|
|
|
155 |
#(10076, 'Wi-Fi Routers')
|
|
|
156 |
#(10077, 'Laptop Batteries')
|
|
|
157 |
#(10078, 'Antivirus')
|
|
|
158 |
#(10079, 'Office Packs')
|
|
|
159 |
#(10080, 'Keyboards')
|
|
|
160 |
#(10081, 'Mouse')
|
|
|
161 |
#(10082, 'Headphones')
|
|
|
162 |
#(10083, 'Data Card')
|
|
|
163 |
#(10084, 'Mouse pads')
|
|
|
164 |
#(10085, 'Laptop bags')
|
|
|
165 |
#(10086, 'Laptop Chargers')
|
|
|
166 |
#(10087, 'Printer cartridges')
|
|
|
167 |
#(10088, 'TV Tuner')
|
|
|
168 |
#(10089, 'USB Light')
|
|
|
169 |
#(10090, 'Card Reader')
|
|
|
170 |
#(10091, 'USB Devices')
|
|
|
171 |
#(11002, 'Compact Cameras')
|
|
|
172 |
#(11003, 'DSLR Cameras')
|
|
|
173 |
#(12002, 'Portable Music Players')
|
|
|
174 |
#(12101, 'Smart Watches')
|
|
|
175 |
#(12102, 'Corded Phones')
|
|
|
176 |
#(12103, 'Screen Magnifier')
|
|
|
177 |
#(12104, 'Mobile Holder')
|
|
|
178 |
#(12105, 'Selfie Stick')
|
|
|
179 |
#(13101, 'Projectors')
|
|
|
180 |
#(14101, 'Scanners')
|
|
|
181 |
#(14201, 'DVD Player')
|
|
|
182 |
#(14202, 'LED TV')
|
|
|
183 |
#(14203, 'LCD TV')
|
|
|
184 |
#(14204, 'Home Theater')
|
|
|
185 |
#(14205, 'Karaoke')
|
|
|
186 |
#(14206, 'Radio')
|
|
|
187 |
#(14207, 'Lens')
|
|
|
188 |
#(14208, 'Boom Box')
|
|
|
189 |
#(14301, 'Watch Strap')
|
|
|
190 |
#(14401, 'Gaming Consoles')
|
|
|
191 |
#(14501, 'Power Sockets')
|
|
|
192 |
#(14601, 'Remote')
|
|
|
193 |
#(15001, 'Trimmers')
|
|
|
194 |
#(15002, 'Shavers')
|
|
|
195 |
#(15003, 'Hair Dryers')
|
|
|
196 |
#(15004, 'Hair Stylers')
|
|
|
197 |
#(15005, 'Epilators')
|
|
|
198 |
#(15006, 'Hair Straightners')
|
|
|
199 |
#(15007, 'Hair Curlers')
|
|
|
200 |
#(15008, 'Grooming Kits')
|
|
|
201 |
#(15009, 'Clippers')
|
|
|
202 |
#(15101, 'Microwave Ovens and OTG')
|
|
|
203 |
#(15102, 'Juicer, Mixer, Grinder')
|
|
|
204 |
#(15103, 'Food Processors')
|
|
|
205 |
#(15104, 'Choppers and Blenders')
|
|
|
206 |
#(15105, 'Cookers and Steamers')
|
|
|
207 |
#(15106, 'Induction Cooktops')
|
|
|
208 |
#(15107, 'Toasters and Sandwich Makers')
|
|
|
209 |
#(15108, 'Grills and Tandoors')
|
|
|
210 |
#(15109, 'Coffee Maker and Kettles')
|
|
|
211 |
#(15110, 'Air Fryers')
|
|
|
212 |
#(15111, 'Chimney and Hoods')
|
|
|
213 |
#(15112, 'Gas Stoves and Hobs')
|
|
|
214 |
#(15113, 'Roti Maker and Snack Maker')
|
|
|
215 |
#(15301, 'Irons')
|
|
|
216 |
#(15302, 'Vacuum Cleaners')
|
|
|
217 |
#(15303, 'Lighting')
|
|
|
218 |
#(15304, 'Air Purifiers')
|
|
|
219 |
#(15305, 'Water Purifiers')
|
|
|
220 |
#(15306, 'Dish Washers')
|
|
|
221 |
#(16001, 'Power and Hand Tool Kits')
|
|
|
222 |
#(16002, 'Drills')
|
|
|
223 |
#(16003, 'Power Planes')
|
|
|
224 |
#(16004, 'Sanders and Polishers')
|
|
|
225 |
#(16005, 'Soldering Irons')
|
|
|
226 |
#(16006, 'Nailers and Staplers')
|
|
|
227 |
#(16007, 'Blowers')
|
|
|
228 |
#(16101, 'Hammers')
|
|
|
229 |
#(16102, 'Axes')
|
|
|
230 |
#(16103, 'Clamps')
|
|
|
231 |
#(16104, 'Crimpers')
|
|
|
232 |
#(16105, 'Chisels and Sets')
|
|
|
233 |
#(16106, 'Socket Sets')
|
|
|
234 |
#(16107, 'Cutters and Snips')
|
|
|
235 |
#(16108, 'Power and Hand Tool Kits')
|
|
|
236 |
#(16109, 'Wrenches and Sets')
|
|
|
237 |
#(16110, 'Pliers')
|
|
|
238 |
#(16111, 'Locks')
|
|
|
239 |
#(16112, 'Screwdrivers and Allen Keys')
|
|
|
240 |
#(16113, 'Handsaws and Sets')
|
|
|
241 |
#(16201, 'Calipers')
|
|
|
242 |
#(16202, 'Level Measuring Instruments')
|
|
|
243 |
#]
|
|
|
244 |
|
|
|
245 |
|
| 22059 |
amit.gupta |
246 |
|
|
|
247 |
|
|
|
248 |
if __name__ == "__main__":
|
| 22393 |
amit.gupta |
249 |
print "in main"
|
| 22119 |
amit.gupta |
250 |
main()
|
|
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
|
254 |
|