Subversion Repositories SmartDukaan

Rev

Rev 21847 | Go to most recent revision | 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 = ''
25
    seller.gstin = 'DELGSTIN'
26
    # short for seller e.g. NSSPL-STATE
27
    seller.label = 'NSSPL-DL'
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
37
    sellerWarehouse.orderType = 0
38
    # Prefix that will be used during invoice generation at the time of billing.
39
    sellerWarehouse.prefix = 'NSDL'
40
    # This has to be created in old system and to be set accordingly
41
    sellerWarehouse.warehouse_id = warehouseId
42
    # The sequence of invoice in system is controlled from here.
43
    sellerWarehouse.id = 0
44
    sellerWarehouse.seller_id = seller.id
45
    session.merge(sellerWarehouse)
46
    # Lets Create one more warehouse for this seller for B2B purpose 
47
    #sellerWarehouse1 = SellerWarehouse()
48
    #sellerWarehouse1.created_on = datetime.datetime.now()
49
    #sellerWarehouse1.is_active = True
50
    # 0-B2C, 1-B2B
51
    #sellerWarehouse1.orderType = 1
52
    # Prefix that will be used during invoice generation at the time of billing.
53
    #sellerWarehouse1.prefix = 'NSDLBB'
54
    # This has to be created in old system and to be set accordingly
55
    #sellerWarehouse1.warehouse_id = warehouseId
56
    # The sequence of invoice in system is controlled from here.
57
    #sellerWarehouse1.id = 0
58
    #sellerWarehouse1.seller_id = seller.id
59
    #session.merge(sellerWarehouse1)
60
    # Create warehouse addresses
61
    whm1 = WarehouseAddressMaster()
62
    # complete address without pin
63
    whm1.address = 'Khasra No-322, Second Floor, Opp.Purani Tel Mil, Neb Sarai, New Delhi'
64
    whm1.pin = 110068
65
    whm1.created = datetime.datetime.now()
66
    # number of person responsible for warehouse
67
    whm1.contact_number = '9990381569'
68
    whm1.state_id = 0
69
    session.merge(whm1)
70
 
71
    warehouseAddressMapping = WarehouseAddressMapping()
72
    warehouseAddressMapping.address_id = whm1.id
73
    warehouseAddressMapping.created = datetime.datetime.now()
74
    warehouseAddressMapping.updated = datetime.datetime.now()
75
    warehouseAddressMapping.warehouse_id = warehouseId
76
    session.merge(warehouseAddressMapping)
77
 
78
def create_haryana(company):
79
    # Create a seller for organisation which is specific to state - Delhi
80
    warehouseId = 7441
81
    seller = Seller()
82
    # registered address
83
    seller.address = 'B/363-365, 2nd Floor, Opp Post Office, Part-2, Nehru Ground, NIT , Faridabad, Haryana-121001'
84
    # keep one of , seller.gstn = '' or
85
    seller.tin = ''
86
    seller.gstin = 'HRGSTIN'
87
    # short for seller e.g. NSSPL-STATE
88
    seller.label = 'NSSPL-HR'
89
    seller.organisation_id = company.id
90
    # 0 for delhi, 1 MH, 2 karnataka, 3 Haryana, 4 Rajasthan, 5 Telangana, 6 Gujarat, 7 UP, 8, Punjab
91
    seller.state_id = 3
92
    session.merge(seller)
93
    # Create one warehouse for this seller 
94
    sellerWarehouse = SellerWarehouse()
95
    sellerWarehouse.created_on = datetime.datetime.now()
96
    sellerWarehouse.is_active = True
97
    # 0-B2C, 1-B2B
98
    sellerWarehouse.orderType = 0
99
    # Prefix that will be used during invoice generation at the time of billing.
100
    sellerWarehouse.prefix = 'NSHRBC'
101
    # This has to be created in old system and to be set accordingly
102
    sellerWarehouse.warehouse_id = warehouseId
103
    # The sequence of invoice in system is controlled from here.
104
    sellerWarehouse.id = 0
105
    sellerWarehouse.seller_id = seller.id
106
    session.merge(sellerWarehouse)
107
    # Lets Create one one warehouse for this seller for B2B purpose 
108
    sellerWarehouse1 = SellerWarehouse()
109
    sellerWarehouse1.created_on = datetime.datetime.now()
110
    sellerWarehouse1.is_active = True
111
    # 0-B2C, 1-B2B
112
    sellerWarehouse1.orderType = 1
113
    # Prefix that will be used during invoice generation at the time of billing.
114
    sellerWarehouse1.prefix = 'NSHRBB'
115
    # This has to be created in old system and to be set accordingly
116
    sellerWarehouse1.warehouse_id = warehouseId
117
    # The sequence of invoice in system is controlled from here.
118
    sellerWarehouse1.id = 0
119
    sellerWarehouse1.seller_id = seller.id
120
    session.merge(sellerWarehouse1)
121
    # Create warehouse addresses
122
    whm1 = WarehouseAddressMaster()
123
    # complete address without pin
124
    whm1.address = 'B/363-365, 2nd Floor, Opp Post Office, Part-2, Nehru Ground, NIT , Faridabad, Haryana'
125
    whm1.pin = 121001
126
    whm1.created = datetime.datetime.now()
127
    # number of person responsible for warehouse
128
    whm1.contact_number = '9990381569'
129
    whm1.state_id = 0
130
    session.merge(whm1)
131
 
132
    warehouseAddressMapping = WarehouseAddressMapping()
133
    warehouseAddressMapping.address_id = whm1.id
134
    warehouseAddressMapping.created = datetime.datetime.now()
135
    warehouseAddressMapping.updated = datetime.datetime.now()
136
    warehouseAddressMapping.warehouse_id = warehouseId
137
 
138
 
139
 
140
def main():
141
    company = Organisation()
142
    company.name = 'New Spice Solutions Private Limited'
143
    company.address = 'Global Knowledge Park, 19A & 19B, 6th Floor, Sector 125, Noida, Uttar Pradesh - 201301'
144
    company.type = 'company'
145
    company.registered_id = 'U2222UP2009PTC036977'
146
    session.merge(company)
147
    create_delhi(company)
148
    #create_haryana(company)
149
    session.commit()
150
 
151
 
152
 
153
 
154
 
155
if __name__ == '__main__':
156
    #DataService.initialize()
157
    #main()
158
    tc = TransactionClient().get_client()
159
    print tc.getSellerInfo(12)