Subversion Repositories SmartDukaan

Rev

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, Organisation
import datetime
from shop2020.model.v1.order.impl import DataService
from shop2020.clients.TransactionClient import TransactionClient
from shop2020.clients.InventoryClient import InventoryClient


def create_delhi(company):
    # Create a seller for organisation which is specific to state - Delhi
    seller = Seller()
    #7537
    warehouseId = 7573
    # registered address
    seller.address = 'Khasra No-322, Second Floor, Opp.Purani Tel Mil, Neb Sarai, New Delhi-110068'
    # keep one of , seller.gstn = '' or
    seller.tin = ''
    seller.gstin = '07AAFCM7436G1ZD'
    # short for seller e.g. NSSPL-STATE
    seller.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, Punjab
    seller.state_id = 0
    session.merge(seller)
    # Create one warehouse for this seller 
    sellerWarehouse = 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 generated
    sellerWarehouse.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 accordingly
    sellerWarehouse.warehouse_id = warehouseId
    # The sequence of invoice in system is controlled from here.
    sellerWarehouse.id = 0
    sellerWarehouse.seller_id = seller.id
    session.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.id
    warehouseAddressMapping.address_id = 10
    warehouseAddressMapping.created = datetime.datetime.now()
    warehouseAddressMapping.updated = datetime.datetime.now()
    warehouseAddressMapping.warehouse_id = warehouseId
    session.merge(warehouseAddressMapping)
    
def create_haryana(company):
    # Create a seller for organisation which is specific to state - Delhi
    warehouseId = 7441
    seller = Seller()
    # registered address
    seller.address = 'B/363-365, 2nd Floor, Opp Post Office, Part-2, Nehru Ground, NIT , Faridabad, Haryana-121001'
    # keep one of , seller.gstn = '' or
    seller.tin = ''
    seller.gstin = 'HRGSTIN'
    # short for seller e.g. NSSPL-STATE
    seller.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, Punjab
    seller.state_id = 3
    session.merge(seller)
    # Create one warehouse for this seller 
    sellerWarehouse = SellerWarehouse()
    sellerWarehouse.created_on = datetime.datetime.now()
    sellerWarehouse.is_active = True
    # 0-B2C, 1-B2B
    sellerWarehouse.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 accordingly
    sellerWarehouse.warehouse_id = warehouseId
    # The sequence of invoice in system is controlled from here.
    sellerWarehouse.id = 0
    sellerWarehouse.seller_id = seller.id
    session.merge(sellerWarehouse)
    # Lets Create one one 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 = 'NSHRBB'
    # 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 = 'B/363-365, 2nd Floor, Opp Post Office, Part-2, Nehru Ground, NIT , Faridabad, Haryana'
    whm1.pin = 121001
    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.id
    warehouseAddressMapping.created = datetime.datetime.now()
    warehouseAddressMapping.updated = datetime.datetime.now()
    warehouseAddressMapping.warehouse_id = warehouseId
    
    

def 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)