Rev 21854 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on Jun 27, 2017@author: amit'''from elixir import *from shop2020.model.v1.order.impl.DataService import Seller, SellerWarehouse, \WarehouseAddressMaster, WarehouseAddressMapping, Organisationimport datetimefrom shop2020.model.v1.order.impl import DataServicefrom shop2020.clients.TransactionClient import TransactionClientfrom shop2020.clients.InventoryClient import InventoryClientdef create_delhi(company):# Create a seller for organisation which is specific to state - Delhiseller = Seller()#7537warehouseId = 7573# registered addressseller.address = 'Khasra No-322, Second Floor, Opp.Purani Tel Mil, Neb Sarai, New Delhi-110068'# keep one of , seller.gstn = '' orseller.tin = ''seller.gstin = '07AAFCM7436G1ZD'# short for seller e.g. NSSPL-STATEseller.label = 'SOPL-DL'seller.organisation_id = company.id# 0 for delhi, 1 MH, 2 karnataka, 3 Haryana, 4 Rajasthan, 5 Telangana, 6 Gujarat, 7 UP, 8, Punjabseller.state_id = 0session.merge(seller)# Create one warehouse for this sellersellerWarehouse = SellerWarehouse()sellerWarehouse.created_on = datetime.datetime.now()sellerWarehouse.is_active = True# 0-B2C, 1-B2B#This is no more valid as single invoice has to be generatedsellerWarehouse.orderType = 0# Prefix that will be used during invoice generation at the time of billing.sellerWarehouse.prefix = 'SOPL'# This has to be created in old system and to be set accordinglysellerWarehouse.warehouse_id = warehouseId# The sequence of invoice in system is controlled from here.sellerWarehouse.id = 0sellerWarehouse.seller_id = seller.idsession.merge(sellerWarehouse)# Lets Create one more warehouse for this seller for B2B purpose#sellerWarehouse1 = SellerWarehouse()#sellerWarehouse1.created_on = datetime.datetime.now()#sellerWarehouse1.is_active = True# 0-B2C, 1-B2B#sellerWarehouse1.orderType = 1# Prefix that will be used during invoice generation at the time of billing.#sellerWarehouse1.prefix = 'NSDLBB'# This has to be created in old system and to be set accordingly#sellerWarehouse1.warehouse_id = warehouseId# The sequence of invoice in system is controlled from here.#sellerWarehouse1.id = 0#sellerWarehouse1.seller_id = seller.id#session.merge(sellerWarehouse1)# Create warehouse addresses# whm1 = WarehouseAddressMaster()# # complete address without pin# whm1.address = 'Khasra No-322, Second Floor, Opp.Purani Tel Mil, Neb Sarai, New Delhi'# whm1.pin = 110068# whm1.created = datetime.datetime.now()# # number of person responsible for warehouse# whm1.contact_number = '9990381569'# whm1.state_id = 0# session.merge(whm1)warehouseAddressMapping = WarehouseAddressMapping()#warehouseAddressMapping.address_id = whm1.idwarehouseAddressMapping.address_id = 10warehouseAddressMapping.created = datetime.datetime.now()warehouseAddressMapping.updated = datetime.datetime.now()warehouseAddressMapping.warehouse_id = warehouseIdsession.merge(warehouseAddressMapping)def create_haryana(company):# Create a seller for organisation which is specific to state - DelhiwarehouseId = 7441seller = Seller()# registered addressseller.address = 'B/363-365, 2nd Floor, Opp Post Office, Part-2, Nehru Ground, NIT , Faridabad, Haryana-121001'# keep one of , seller.gstn = '' orseller.tin = ''seller.gstin = 'HRGSTIN'# short for seller e.g. NSSPL-STATEseller.label = 'NSSPL-HR'seller.organisation_id = company.id# 0 for delhi, 1 MH, 2 karnataka, 3 Haryana, 4 Rajasthan, 5 Telangana, 6 Gujarat, 7 UP, 8, Punjabseller.state_id = 3session.merge(seller)# Create one warehouse for this sellersellerWarehouse = SellerWarehouse()sellerWarehouse.created_on = datetime.datetime.now()sellerWarehouse.is_active = True# 0-B2C, 1-B2BsellerWarehouse.orderType = 0# Prefix that will be used during invoice generation at the time of billing.sellerWarehouse.prefix = 'NSHRBC'# This has to be created in old system and to be set accordinglysellerWarehouse.warehouse_id = warehouseId# The sequence of invoice in system is controlled from here.sellerWarehouse.id = 0sellerWarehouse.seller_id = seller.idsession.merge(sellerWarehouse)# Lets Create one one warehouse for this seller for B2B purposesellerWarehouse1 = SellerWarehouse()sellerWarehouse1.created_on = datetime.datetime.now()sellerWarehouse1.is_active = True# 0-B2C, 1-B2BsellerWarehouse1.orderType = 1# Prefix that will be used during invoice generation at the time of billing.sellerWarehouse1.prefix = 'NSHRBB'# This has to be created in old system and to be set accordinglysellerWarehouse1.warehouse_id = warehouseId# The sequence of invoice in system is controlled from here.sellerWarehouse1.id = 0sellerWarehouse1.seller_id = seller.idsession.merge(sellerWarehouse1)# Create warehouse addresseswhm1 = WarehouseAddressMaster()# complete address without pinwhm1.address = 'B/363-365, 2nd Floor, Opp Post Office, Part-2, Nehru Ground, NIT , Faridabad, Haryana'whm1.pin = 121001whm1.created = datetime.datetime.now()# number of person responsible for warehousewhm1.contact_number = '9990381569'whm1.state_id = 0session.merge(whm1)warehouseAddressMapping = WarehouseAddressMapping()warehouseAddressMapping.address_id = whm1.idwarehouseAddressMapping.created = datetime.datetime.now()warehouseAddressMapping.updated = datetime.datetime.now()warehouseAddressMapping.warehouse_id = warehouseIddef main():company = Organisation()company.name = 'SPICE ONLINE PRIVATE LIMITED'company.address = '512-B, Modi Tower, 98, Nehru Place, New Delhi-110019'company.type = 'company'company.registered_id = 'U74140DL2008PTC183856'session.merge(company)create_delhi(company)#create_haryana(company)session.commit()if __name__ == '__main__':DataService.initialize()main()tc = TransactionClient().get_client()#print tc.getSellerInfo(13)