Subversion Repositories SmartDukaan

Rev

Rev 21854 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21847 amit.gupta 1
'''
2
Created on Jun 27, 2017
3
 
4
@author: amit
5
'''
6
from elixir import *
7
 
8
from shop2020.model.v1.order.impl.DataService import Seller, SellerWarehouse, \
9
    WarehouseAddressMaster, WarehouseAddressMapping, Organisation
10
import datetime
11
from shop2020.model.v1.order.impl import DataService
12
from shop2020.clients.TransactionClient import TransactionClient
13
from shop2020.clients.InventoryClient import InventoryClient
14
 
15
 
16
def create_delhi(company):
17
    # Create a seller for organisation which is specific to state - Delhi
18
    seller = Seller()
21854 amit.gupta 19
    #7537
21847 amit.gupta 20
    warehouseId = 7573
21
    # registered address
22
    seller.address = 'Khasra No-322, Second Floor, Opp.Purani Tel Mil, Neb Sarai, New Delhi-110068'
23
    # keep one of , seller.gstn = '' or
24
    seller.tin = ''
22519 amit.gupta 25
    seller.gstin = '07AAFCM7436G1ZD'
21847 amit.gupta 26
    # short for seller e.g. NSSPL-STATE
22519 amit.gupta 27
    seller.label = 'SOPL-DL'
21847 amit.gupta 28
    seller.organisation_id = company.id
29
    # 0 for delhi, 1 MH, 2 karnataka, 3 Haryana, 4 Rajasthan, 5 Telangana, 6 Gujarat, 7 UP, 8, Punjab
30
    seller.state_id = 0
31
    session.merge(seller)
32
    # Create one warehouse for this seller 
33
    sellerWarehouse = SellerWarehouse()
34
    sellerWarehouse.created_on = datetime.datetime.now()
35
    sellerWarehouse.is_active = True
36
    # 0-B2C, 1-B2B
22519 amit.gupta 37
    #This is no more valid as single invoice has to be generated
21847 amit.gupta 38
    sellerWarehouse.orderType = 0
39
    # Prefix that will be used during invoice generation at the time of billing.
22519 amit.gupta 40
    sellerWarehouse.prefix = 'SOPL'
21847 amit.gupta 41
    # This has to be created in old system and to be set accordingly
42
    sellerWarehouse.warehouse_id = warehouseId
43
    # The sequence of invoice in system is controlled from here.
44
    sellerWarehouse.id = 0
45
    sellerWarehouse.seller_id = seller.id
46
    session.merge(sellerWarehouse)
47
    # Lets Create one more warehouse for this seller for B2B purpose 
48
    #sellerWarehouse1 = SellerWarehouse()
49
    #sellerWarehouse1.created_on = datetime.datetime.now()
50
    #sellerWarehouse1.is_active = True
51
    # 0-B2C, 1-B2B
52
    #sellerWarehouse1.orderType = 1
53
    # Prefix that will be used during invoice generation at the time of billing.
54
    #sellerWarehouse1.prefix = 'NSDLBB'
55
    # This has to be created in old system and to be set accordingly
56
    #sellerWarehouse1.warehouse_id = warehouseId
57
    # The sequence of invoice in system is controlled from here.
58
    #sellerWarehouse1.id = 0
59
    #sellerWarehouse1.seller_id = seller.id
60
    #session.merge(sellerWarehouse1)
61
    # Create warehouse addresses
22519 amit.gupta 62
#    whm1 = WarehouseAddressMaster()
63
#    # complete address without pin
64
#    whm1.address = 'Khasra No-322, Second Floor, Opp.Purani Tel Mil, Neb Sarai, New Delhi'
65
#    whm1.pin = 110068
66
#    whm1.created = datetime.datetime.now()
67
#    # number of person responsible for warehouse
68
#    whm1.contact_number = '9990381569'
69
#    whm1.state_id = 0
70
#    session.merge(whm1)
21847 amit.gupta 71
 
72
    warehouseAddressMapping = WarehouseAddressMapping()
22519 amit.gupta 73
    #warehouseAddressMapping.address_id = whm1.id
74
    warehouseAddressMapping.address_id = 10
21847 amit.gupta 75
    warehouseAddressMapping.created = datetime.datetime.now()
76
    warehouseAddressMapping.updated = datetime.datetime.now()
77
    warehouseAddressMapping.warehouse_id = warehouseId
78
    session.merge(warehouseAddressMapping)
79
 
80
def create_haryana(company):
81
    # Create a seller for organisation which is specific to state - Delhi
82
    warehouseId = 7441
83
    seller = Seller()
84
    # registered address
85
    seller.address = 'B/363-365, 2nd Floor, Opp Post Office, Part-2, Nehru Ground, NIT , Faridabad, Haryana-121001'
86
    # keep one of , seller.gstn = '' or
87
    seller.tin = ''
88
    seller.gstin = 'HRGSTIN'
89
    # short for seller e.g. NSSPL-STATE
90
    seller.label = 'NSSPL-HR'
91
    seller.organisation_id = company.id
92
    # 0 for delhi, 1 MH, 2 karnataka, 3 Haryana, 4 Rajasthan, 5 Telangana, 6 Gujarat, 7 UP, 8, Punjab
93
    seller.state_id = 3
94
    session.merge(seller)
95
    # Create one warehouse for this seller 
96
    sellerWarehouse = SellerWarehouse()
97
    sellerWarehouse.created_on = datetime.datetime.now()
98
    sellerWarehouse.is_active = True
99
    # 0-B2C, 1-B2B
100
    sellerWarehouse.orderType = 0
101
    # Prefix that will be used during invoice generation at the time of billing.
102
    sellerWarehouse.prefix = 'NSHRBC'
103
    # This has to be created in old system and to be set accordingly
104
    sellerWarehouse.warehouse_id = warehouseId
105
    # The sequence of invoice in system is controlled from here.
106
    sellerWarehouse.id = 0
107
    sellerWarehouse.seller_id = seller.id
108
    session.merge(sellerWarehouse)
109
    # Lets Create one one warehouse for this seller for B2B purpose 
110
    sellerWarehouse1 = SellerWarehouse()
111
    sellerWarehouse1.created_on = datetime.datetime.now()
112
    sellerWarehouse1.is_active = True
113
    # 0-B2C, 1-B2B
114
    sellerWarehouse1.orderType = 1
115
    # Prefix that will be used during invoice generation at the time of billing.
116
    sellerWarehouse1.prefix = 'NSHRBB'
117
    # This has to be created in old system and to be set accordingly
118
    sellerWarehouse1.warehouse_id = warehouseId
119
    # The sequence of invoice in system is controlled from here.
120
    sellerWarehouse1.id = 0
121
    sellerWarehouse1.seller_id = seller.id
122
    session.merge(sellerWarehouse1)
123
    # Create warehouse addresses
124
    whm1 = WarehouseAddressMaster()
125
    # complete address without pin
126
    whm1.address = 'B/363-365, 2nd Floor, Opp Post Office, Part-2, Nehru Ground, NIT , Faridabad, Haryana'
127
    whm1.pin = 121001
128
    whm1.created = datetime.datetime.now()
129
    # number of person responsible for warehouse
130
    whm1.contact_number = '9990381569'
131
    whm1.state_id = 0
132
    session.merge(whm1)
133
 
134
    warehouseAddressMapping = WarehouseAddressMapping()
135
    warehouseAddressMapping.address_id = whm1.id
136
    warehouseAddressMapping.created = datetime.datetime.now()
137
    warehouseAddressMapping.updated = datetime.datetime.now()
138
    warehouseAddressMapping.warehouse_id = warehouseId
139
 
140
 
141
 
142
def main():
143
    company = Organisation()
22519 amit.gupta 144
    company.name = 'SPICE ONLINE PRIVATE LIMITED'
145
    company.address = '512-B, Modi Tower, 98, Nehru Place, New Delhi-110019'
21847 amit.gupta 146
    company.type = 'company'
22519 amit.gupta 147
    company.registered_id = 'U74140DL2008PTC183856'
21847 amit.gupta 148
    session.merge(company)
149
    create_delhi(company)
150
    #create_haryana(company)
151
    session.commit()
152
 
153
 
154
 
155
 
156
 
157
if __name__ == '__main__':
22519 amit.gupta 158
    DataService.initialize()
159
    main()
21847 amit.gupta 160
    tc = TransactionClient().get_client()
22519 amit.gupta 161
    #print tc.getSellerInfo(13)