Rev 22119 | Rev 22123 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on Apr 12, 2016@author: amit'''from datetime import datetimefrom elixir import *from random import randintfrom shop2020.clients.CatalogClient import CatalogClientfrom shop2020.clients.InventoryClient import InventoryClientfrom shop2020.clients.PurchaseClient import PurchaseClientfrom shop2020.clients.TransactionClient import TransactionClientfrom shop2020.clients.UserClient import UserClientfrom shop2020.model.v1.catalog.impl import DataServicefrom shop2020.model.v1.catalog.impl.DataService import CentralGstMaster, \StateGstMaster, Category, CategoryHsnCodesfrom shop2020.thriftpy.model.v1.order.ttypes import TransactionStatusfrom sqlalchemy import desc, ascfrom sqlalchemy.orm import aliasedfrom sqlalchemy.sql.expression import or_, distinct, func, and_, existsfrom sqlalchemy.sql.functions import nowdef getCategories():categories = session.query(Category).all()rootCategory = 10000l1 = []for category in categories:if category.parent_category_id == rootCategory:l1.append(category.id)leaves = []for category in categories:if category.parent_category_id in l1:leaves.append(category)for leaf in leaves:print "({}, '{}')".format(leaf.id, leaf.label)def getChildCategories(rootCategory, categories):childCategories = []def addHsnCodes():gstTuple = [(10027, 'Power Bank', '85076000', 28),(10030, 'Cables', '85183000', 28),(10024, 'Ear Buds', '85444220', 18),(12101, 'Fitness Band', '90318000', 18)]for (categoryId, description, hsnCode, rate) in gstTuple:categoryHsnCode = session.query(CategoryHsnCodes).filter(CategoryHsnCodes.hsnCode==hsnCode).first()if categoryHsnCode:categoryHsnCode.categoryId = categoryIdcategoryHsnCode.description = descriptionelse:categoryHsnCode = CategoryHsnCodes()categoryHsnCode.hsnCode = hsnCodecategoryHsnCode.categoryId = categoryIdcategoryHsnCode.description = descriptioncgs = session.query(CentralGstMaster).filter(CentralGstMaster.hsnCode==hsnCode).filter(CentralGstMaster.gstPercent==rate).first()if cgs is None:cgs = CentralGstMaster()cgs.hsnCode = hsnCodecgs.gstPercent = ratecgs.startDate = datetime.now()for i in range(37):sgst = rate/2cgst = rate/2sgs = session.query(StateGstMaster).filter(StateGstMaster.hsnCode==hsnCode).filter(StateGstMaster.sgstPercent==sgst).filter(StateGstMaster.cgstPercent==cgst).filter(StateGstMaster.stateId==i).first()if sgs is None:sgs = StateGstMaster()sgs.sgstPercent = sgstsgs.cgstPercent = cgstsgs.hsnCode = hsnCodesgs.stateId = isgs.startDate = datetime.now()session.commit()session.close()#c = CatalogClient().get_client()#print c.getGstRatesByState(0)#print c.getInterStateGstRates()#print c.getHsnCodesByCategory(10006)##ic = InventoryClient().get_client()#print ic.getStateMaster()###pc = PurchaseClient().get_client()#print pc.getPurchaseOrder(22141)#uc = UserClient().get_client()#print uc.getCounterByUserId(120398953)def main():passDataService.initialize('catalog', 'localhost', False)addHsnCodes()#getCategories()#tc = TransactionClient().get_client()#tc.changeTransactionStatus(699979, TransactionStatus.COD_IN_PROCESS, "COD in Process", 0, 0, 1)#tc.verifyOrderForTransaction(699983)#tc.acceptOrder(748108)#tc.addBillingDetailsForGrouppedOrders([748108], 'AMIT2', {748108:'1'}, {748108:['443423432431', '443423432432']}, {}, 'dl-ad-adonis', 1, 0, False, 'BulkInvoice')#order_ids, invoice_number, itemNumbersMap, serialNumbersMap, {}, 'mp-mmx-admin', 1, 0, False, 'Individual'#tc = TransactionClient().get_client()#print tc.getLatestUserWalletHistory(483649, 0, 20)#tupleList = [#(10006, 'Mobile Phone')#(10008, 'Codless Phones')#(10010, 'Tablets')#(10012, 'Bluetooth Headset')#(10013, 'Memory Card')#(10014, 'Battery')#(10015, 'Headset')#(10016, 'Charger')#(10017, 'Pen Drive')#(10018, 'Carrying Case')#(10019, 'Car Charger')#(10020, 'Screen Guard')#(10021, 'Face Plate')#(10022, 'Decal')#(10023, 'Data Cable')#(10024, 'Ear Buds')#(10025, 'Cleaning Kit')#(10026, 'Speaker')#(10027, 'Power Bank')#(10028, 'AUX Cable')#(10029, 'Vehiclle Mounts')#(10030, 'Cables')#(10032, 'LED Lights')#(10050, 'Laptops')#(10071, 'RAM')#(10072, 'Cooling Stands')#(10073, 'External Hard Disks')#(10074, 'USB Hubs')#(10075, 'Solid State Drives')#(10076, 'Wi-Fi Routers')#(10077, 'Laptop Batteries')#(10078, 'Antivirus')#(10079, 'Office Packs')#(10080, 'Keyboards')#(10081, 'Mouse')#(10082, 'Headphones')#(10083, 'Data Card')#(10084, 'Mouse pads')#(10085, 'Laptop bags')#(10086, 'Laptop Chargers')#(10087, 'Printer cartridges')#(10088, 'TV Tuner')#(10089, 'USB Light')#(10090, 'Card Reader')#(10091, 'USB Devices')#(11002, 'Compact Cameras')#(11003, 'DSLR Cameras')#(12002, 'Portable Music Players')#(12101, 'Smart Watches')#(12102, 'Corded Phones')#(12103, 'Screen Magnifier')#(12104, 'Mobile Holder')#(12105, 'Selfie Stick')#(13101, 'Projectors')#(14101, 'Scanners')#(14201, 'DVD Player')#(14202, 'LED TV')#(14203, 'LCD TV')#(14204, 'Home Theater')#(14205, 'Karaoke')#(14206, 'Radio')#(14207, 'Lens')#(14208, 'Boom Box')#(14301, 'Watch Strap')#(14401, 'Gaming Consoles')#(14501, 'Power Sockets')#(14601, 'Remote')#(15001, 'Trimmers')#(15002, 'Shavers')#(15003, 'Hair Dryers')#(15004, 'Hair Stylers')#(15005, 'Epilators')#(15006, 'Hair Straightners')#(15007, 'Hair Curlers')#(15008, 'Grooming Kits')#(15009, 'Clippers')#(15101, 'Microwave Ovens and OTG')#(15102, 'Juicer, Mixer, Grinder')#(15103, 'Food Processors')#(15104, 'Choppers and Blenders')#(15105, 'Cookers and Steamers')#(15106, 'Induction Cooktops')#(15107, 'Toasters and Sandwich Makers')#(15108, 'Grills and Tandoors')#(15109, 'Coffee Maker and Kettles')#(15110, 'Air Fryers')#(15111, 'Chimney and Hoods')#(15112, 'Gas Stoves and Hobs')#(15113, 'Roti Maker and Snack Maker')#(15301, 'Irons')#(15302, 'Vacuum Cleaners')#(15303, 'Lighting')#(15304, 'Air Purifiers')#(15305, 'Water Purifiers')#(15306, 'Dish Washers')#(16001, 'Power and Hand Tool Kits')#(16002, 'Drills')#(16003, 'Power Planes')#(16004, 'Sanders and Polishers')#(16005, 'Soldering Irons')#(16006, 'Nailers and Staplers')#(16007, 'Blowers')#(16101, 'Hammers')#(16102, 'Axes')#(16103, 'Clamps')#(16104, 'Crimpers')#(16105, 'Chisels and Sets')#(16106, 'Socket Sets')#(16107, 'Cutters and Snips')#(16108, 'Power and Hand Tool Kits')#(16109, 'Wrenches and Sets')#(16110, 'Pliers')#(16111, 'Locks')#(16112, 'Screwdrivers and Allen Keys')#(16113, 'Handsaws and Sets')#(16201, 'Calipers')#(16202, 'Level Measuring Instruments')#]if __name__ == "__main__":main()