-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.py
More file actions
156 lines (127 loc) · 5.05 KB
/
test.py
File metadata and controls
156 lines (127 loc) · 5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
username = ''
password = ''
vat = '' #VAT company
franchise = '' # Franchise code
seurid = '' #Description ID Seur
ci = '' #Customer Code Seur
ccc = '' #Account Code Seur
username_expedicion = '' # list and info services
password_expedicion = '' # list and info services
context = {}
context['printer'] = 'ZEBRA'
context['printer_model'] = 'LP2844-Z'
context['ecb_code'] = '2C'
from seur.picking import *
from seur.utils import services
from base64 import decodestring
print "Seur services"
services = services()
print services
with API(username, password, vat, franchise, seurid, ci, ccc, context=context) as seur_api:
print "Test connection"
print seur_api.test_connection()
with Picking(username, password, vat, franchise, seurid, ci, ccc, context=context) as picking_api:
print "Send a new shipment - Label ECB"
data = {}
data['servicio'] = '1'
data['product'] = '2'
data['total_bultos'] = 1
#~ data['total_kilos'] =
data['observaciones'] = 'Testing Seur API - Create shipments'
data['referencia_expedicion'] = 'S/OUT/0001'
data['ref_bulto'] = 'S/OUT/0001'
#~ data['clave_portes'] = '' # Add F to invoice
#~ data['clave_reembolso'] = '' # Add F to invoice
#~ data['valor_reembolso'] = ''
data['cliente_nombre'] = 'Zikzakmedia SL'
data['cliente_direccion'] = 'Doctor Fleming, 28. Baixos'
#~ data['cliente_tipovia'] = 'CL'
#~ data['cliente_tnumvia'] = 'N'
#~ data['cliente_numvia'] = '93'
#~ data['cliente_escalera'] = 'A'
#~ data['cliente_piso'] = '3'
#~ data['cliente_puerta'] = '2'
data['cliente_poblacion'] = 'Vilafranca del Penedes' # Important city exist in Seur. Get Seur values from zip method
data['cliente_cpostal'] = '08720'
data['cliente_pais'] = 'ES'
data['cliente_email'] = 'zikzak@zikzakmedia.com'
data['cliente_telefono'] = '938902108'
data['cliente_atencion'] = 'Raimon Esteve'
reference, label, error = picking_api.create(data)
if error:
print error
print reference
with open("/tmp/seur-label.txt","wb") as f:
f.write(label)
print "Generated label in /tmp/seur-label.txt"
context['pdf'] = True
with Picking(username, password, vat, franchise, seurid, ci, ccc, context=context) as picking_api:
print "Send a new shipment - Label PDF"
reference, label, error = picking_api.create(data)
if error:
print error
print reference
with open("/tmp/seur-label.pdf","wb") as f:
f.write(decodestring(label))
print "Generated PDF label in /tmp/seur-label.pdf"
with Picking(username_expedicion, password_expedicion, vat, franchise, seurid, ci, ccc, context=context) as picking_api:
print "Get info picking"
data = {}
data['expedicion'] = 'S'
data['reference'] = reference
data['service'] = '0'
data['public'] = 'N'
info = picking_api.info(data)
print info
with Picking(username_expedicion, password_expedicion, vat, franchise, seurid, ci, ccc, context=context) as picking_api:
print "Get list picking"
data = {}
data['expedicion'] = 'S'
data['public'] = 'N'
info = picking_api.list(data)
print info
context['pdf'] = True
with Picking(username, password, vat, franchise, seurid, ci, ccc, context=context) as picking_api:
print "Get Label PDF"
data = {}
data['servicio'] = '1'
data['product'] = '2'
data['total_bultos'] = 2
#~ data['total_kilos'] =
data['observaciones'] = 'Testing Seur API - Get Label'
data['referencia_expedicion'] = 'S/OUT/0001'
data['ref_bulto'] = 'S/OUT/0001'
#~ data['clave_portes'] = '' # Add F to invoice
#~ data['clave_reembolso'] = '' # Add F to invoice
#~ data['valor_reembolso'] = ''
data['cliente_nombre'] = 'Zikzakmedia SL'
data['cliente_direccion'] = 'Sant Jaume, 9. Baixos 2'
#~ data['cliente_tipovia'] = 'CL'
#~ data['cliente_tnumvia'] = 'N'
#~ data['cliente_numvia'] = '93'
#~ data['cliente_escalera'] = 'A'
#~ data['cliente_piso'] = '3'
#~ data['cliente_puerta'] = '2'
data['cliente_poblacion'] = 'Vilafranca del Penedes' # Important city exist in Seur. Get Seur values from zip method
data['cliente_cpostal'] = '08720'
data['cliente_pais'] = 'ES'
data['cliente_email'] = 'zikzak@zikzakmedia.com'
data['cliente_telefono'] = '938902108'
data['cliente_atencion'] = 'Raimon Esteve'
label = picking_api.label(data)
with open("/tmp/seur-label.pdf","wb") as f:
f.write(decodestring(label))
print "Generated PDF label in /tmp/seur-label.pdf"
with Picking(username, password, vat, franchise, seurid, ci, ccc, context=context) as picking_api:
print "Get Manifiesto"
data = {}
manifiesto = picking_api.manifiesto(data)
with open("/tmp/seur-manifiesto.pdf","wb") as f:
f.write(decodestring(manifiesto))
print "Generated PDF label in /tmp/seur-manifiesto.pdf"
with Picking(username, password, vat, franchise, seurid, ci, ccc, context=context) as picking_api:
print "Get values from Seur about city or zip"
city = 'Granollers'
print picking_api.city(city)
zip = '08720'
print picking_api.zip(zip)