-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_client_using_dll.py
1300 lines (1048 loc) · 46.7 KB
/
app_client_using_dll.py
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ============================================================================
# By Ruben Pantaleon Miranda | rpm+ EPSON Argentina
# ============================================================================
# It requires pywin32: https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/
#
# Note: windll use by default the calling convention "StdCall"
import ctypes
from ctypes import byref, c_int, c_char, c_long, c_short, create_string_buffer
import binascii
import sys
# from ctypes import windll
# -----------------------------------------------------------------------------
# GLOBAL DEFINES AREA
# -----------------------------------------------------------------------------
ID_TIPO_COMPROBANTE_TIQUET = c_int( 1 ).value # "83" Tique
ID_TIPO_COMPROBANTE_TIQUE_FACTURA = c_int( 2 ).value # "81" Tique Factura A, "82" Tique Factura B, "111" Tique Factura C, "118" Tique Factura M
ID_TIPO_COMPROBANTE_TIQUE_NOTA_DE_CREDITO = c_int( 3 ).value # "110" Tique Nota de Credito, "112" Tique Nota de Credito A, "113" Tique Nota de Credito B, "114" Tique Nota de Credito C, "119" Tique Nota de Credito M
ID_TIPO_COMPROBANTE_TIQUE_NOTA_DE_DEBITO = c_int( 4 ).value # "115" Tique Nota de Debito A, "116" Tique Nota de Debito B, "117" Tique Nota de Debito C, "120" Tique Nota de Debito M
ID_TIPO_DOCUMENTO_NINGUNO = c_int( 0 ).value
ID_TIPO_DOCUMENTO_DNI = c_int( 1 ).value
ID_TIPO_DOCUMENTO_CUIL = c_int( 2 ).value
ID_TIPO_DOCUMENTO_CUIT = c_int( 3 ).value
ID_TIPO_DOCUMENTO_CEDULA_IDENTIDAD = c_int( 4 ).value
ID_TIPO_DOCUMENTO_PASAPORTE = c_int( 5 ).value
ID_TIPO_DOCUMENTO_LIB_CIVICA = c_int( 6 ).value
ID_TIPO_DOCUMENTO_LIB_ENROLAMIENTO = c_int( 7 ).value
ID_RESPONSABILIDAD_IVA_NINGUNO = c_int( 0 ).value
ID_RESPONSABILIDAD_IVA_RESPONSABLE_INSCRIPTO = c_int( 1 ).value
ID_RESPONSABILIDAD_IVA_NO_RESPONSABLE = c_int( 3 ).value
ID_RESPONSABILIDAD_IVA_MONOTRIBUTISTA = c_int( 4 ).value
ID_RESPONSABILIDAD_IVA_CONSUMIDOR_FINAL = c_int( 5 ).value
ID_RESPONSABILIDAD_IVA_EXENTO = c_int( 6 ).value
ID_RESPONSABILIDAD_IVA_NO_CATEGORIZADO = c_int( 7 ).value
ID_RESPONSABILIDAD_IVA_MONOTRIBUTISTA_SOCIAL = c_int( 8 ).value
ID_RESPONSABILIDAD_IVA_CONTRIBUYENTE_EVENTUAL = c_int( 9 ).value
ID_RESPONSABILIDAD_IVA_CONTRIBUYENTE_EVENTUAL_SOCIAL = c_int( 10 ).value
ID_RESPONSABILIDAD_IVA_MONOTRIBUTO_INDEPENDIENTE_PROMOVIDO = c_int( 11 ).value
ID_MODIFICADOR_AGREGAR_ITEM = c_int( 200 ).value
ID_MODIFICADOR_ANULAR_ITEM = c_int( 201 ).value
ID_MODIFICADOR_AGREGAR_ITEM_RETORNO_ENVASES = c_int( 202 ).value
ID_MODIFICADOR_ANULAR_ITEM_RETORNO_ENVASES = c_int( 203 ).value
ID_MODIFICADOR_AGREGAR_ITEM_BONIFICACION = c_int( 204 ).value
ID_MODIFICADOR_ANULAR_ITEM_BONIFICACION = c_int( 205 ).value
ID_MODIFICADOR_AGREGAR_ITEM_DESCUENTO = c_int( 206 ).value
ID_MODIFICADOR_ANULAR_ITEM_DESCUENTO = c_int( 207 ).value
ID_MODIFICADOR_AGREGAR_ITEM_ANTICIPO = c_int( 208 ).value
ID_MODIFICADOR_ANULAR_ITEM_ANTICIPO = c_int( 209 ).value
ID_MODIFICADOR_AGREGAR_ITEM_DESCUENTO_ANTICIPO = c_int( 210 ).value
ID_MODIFICADOR_ANULAR_ITEM_DESCUENTO_ANTICIPO = c_int( 211 ).value
ID_MODIFICADOR_DESCUENTO = c_int( 400 ).value
ID_MODIFICADOR_AJUSTE = c_int( 401 ).value
ID_MODIFICADOR_AJUSTE_NEGATIVO = c_int( 402 ).value
ID_MODIFICADOR_AUDITORIA_DETALLADA = c_int( 500 ).value
ID_MODIFICADOR_AUDITORIA_RESUMIDA = c_int( 501 ).value
ID_MODIFICADOR_AGREGAR = ID_MODIFICADOR_AGREGAR_ITEM
ID_MODIFICADOR_ANULAR = ID_MODIFICADOR_ANULAR_ITEM
ID_TASA_IVA_NINGUNO = c_int( 0 ).value
ID_TASA_IVA_EXENTO = c_int( 1 ).value
ID_TASA_IVA_10_50 = c_int( 4 ).value
ID_TASA_IVA_21_00 = c_int( 5 ).value
ID_TASA_IVA_27_00 = c_int( 6 ).value
ID_IMPUESTO_NINGUNO = c_int( 0 ).value
ID_IMPUESTO_INTERNO_FIJO = c_int( 1 ).value
ID_IMPUESTO_INTERNO_PORCENTUAL = c_int( 2 ).value
ID_CODIGO_INTERNO = c_int( 1 ).value
ID_CODIGO_MATRIX = c_int( 2 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_SIN_DESCRIPCION = c_int( 0 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_KILOGRAMO = c_int( 1 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_METROS = c_int( 2 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_METRO_CUADRADO = c_int( 3 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_METRO_CUBICO = c_int( 4 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_LITROS = c_int( 5 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_UNIDAD = c_int( 7 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_PAR = c_int( 8 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_DOCENA = c_int( 9 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_QUILATE = c_int( 10 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MILLAR = c_int( 11 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MEGA_U_INTER_ACT_ANTIB = c_int( 12 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_UNIDAD_INT_ACT_INMUNG = c_int( 13 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_GRAMO = c_int( 14 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MILIMETRO = c_int( 15 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MILIMETRO_CUBICO = c_int( 16 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_KILOMETRO = c_int( 17 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_HECTOLITRO = c_int( 18 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MEGA_UNIDAD_INT_ACT_INMUNG = c_int( 19 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_CENTIMETRO = c_int( 20 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_KILOGRAMO_ACTIVO = c_int( 21 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_GRAMO_ACTIVO = c_int( 22 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_GRAMO_BASE = c_int( 23 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_UIACTHOR = c_int( 24 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_JGO_PQT_MAZO_NAIPES = c_int( 25 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MUIACTHOR = c_int( 26 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_CENTIMETRO_CUBICO = c_int( 27 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_UIACTANT = c_int( 28 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_TONELADA = c_int( 29 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_DECAMETRO_CUBICO = c_int( 30 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_HECTOMETRO_CUBICO = c_int( 31 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_KILOMETRO_CUBICO = c_int( 32 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MICROGRAMO = c_int( 33 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_NANOGRAMO = c_int( 34 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_PICOGRAMO = c_int( 35 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MUIACTANT = c_int( 36 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_UIACTIG = c_int( 37 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MILIGRAMO = c_int( 41 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MILILITRO = c_int( 47 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_CURIE = c_int( 48 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MILICURIE = c_int( 49 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MICROCURIE = c_int( 50 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_U_INTER_ACT_HORMONAL = c_int( 51 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MEGA_U_INTER_ACT_HORMONAL = c_int( 52 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_KILOGRAMO_BASE = c_int( 53 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_GRUESA = c_int( 54 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_MUIACTIG = c_int( 55 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_KILOGRAMO_BRUTO = c_int( 61 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_PACK = c_int( 62 ).value
AFIP_CODIGO_UNIDAD_MEDIDA_HORMA = c_int( 63 ).value
AFIP_CODIGO_OTROS_TRIBUTOS_IMPUESTOS_NACIONALES = c_int( 1 ).value
AFIP_CODIGO_OTROS_TRIBUTOS_IMPUESTOS_PROVINCIAL = c_int( 2 ).value
AFIP_CODIGO_OTROS_TRIBUTOS_IMPUESTO_MUNICIPAL = c_int( 3 ).value
AFIP_CODIGO_OTROS_TRIBUTOS_IMPUESTO_INTERNOS = c_int( 4 ).value
AFIP_CODIGO_OTROS_TRIBUTOS_INGRESOS_BRUTOS = c_int( 5 ).value
AFIP_CODIGO_OTROS_TRIBUTOS_PERCEPCION_DE_IVA = c_int( 6 ).value
AFIP_CODIGO_OTROS_TRIBUTOS_PERCEPCION_DE_INGRESOS_BRUTOS = c_int( 7 ).value
AFIP_CODIGO_OTROS_TRIBUTOS_PERCEPCION_POR_IMPUESTOS_MUNICIPALES = c_int( 8 ).value
AFIP_CODIGO_OTROS_TRIBUTOS_OTRAS_PERCEPCIONES = c_int( 9 ).value
AFIP_CODIGO_OTROS_TRIBUTOS_OTROS = c_int( 99 ).value
AFIP_CODIGO_FORMA_DE_PAGO_CARTA_DE_CREDITO_DOCUMENTARIO = c_int( 1 ).value
AFIP_CODIGO_FORMA_DE_PAGO_CARTAS_DE_CREDITO_SIMPLE = c_int( 2 ).value
AFIP_CODIGO_FORMA_DE_PAGO_CHEQUE = c_int( 3 ).value
AFIP_CODIGO_FORMA_DE_PAGO_CHEQUES_CANCELATORIOS = c_int( 4 ).value
AFIP_CODIGO_FORMA_DE_PAGO_CREDITO_DOCUMENTARIO = c_int( 5 ).value
AFIP_CODIGO_FORMA_DE_PAGO_CUENTA_CORRIENTE = c_int( 6 ).value
AFIP_CODIGO_FORMA_DE_PAGO_DEPOSITO = c_int( 7 ).value
AFIP_CODIGO_FORMA_DE_PAGO_EFECTIVO = c_int( 8 ).value
AFIP_CODIGO_FORMA_DE_PAGO_ENDOSO_DE_CHEQUE = c_int( 9 ).value
AFIP_CODIGO_FORMA_DE_PAGO_FACTURA_DE_CREDITO = c_int( 10 ).value
AFIP_CODIGO_FORMA_DE_PAGO_GARANTIAS_BANCARIAS = c_int( 11 ).value
AFIP_CODIGO_FORMA_DE_PAGO_GIROS = c_int( 12 ).value
AFIP_CODIGO_FORMA_DE_PAGO_LETRAS_DE_CAMBIO = c_int( 13 ).value
AFIP_CODIGO_FORMA_DE_PAGO_MEDIOS_DE_PAGO_DE_COMERCIO_EXTERIOR = c_int( 14 ).value
AFIP_CODIGO_FORMA_DE_PAGO_ORDEN_DE_PAGO_DOCUMENTARIA = c_int( 15 ).value
AFIP_CODIGO_FORMA_DE_PAGO_ORDEN_DE_PAGO_SIMPLE = c_int( 16 ).value
AFIP_CODIGO_FORMA_DE_PAGO_PAGO_CONTRA_REEMBOLSO = c_int( 17 ).value
AFIP_CODIGO_FORMA_DE_PAGO_REMESA_DOCUMENTARIA = c_int( 18 ).value
AFIP_CODIGO_FORMA_DE_PAGO_REMESA_SIMPLE = c_int( 19 ).value
AFIP_CODIGO_FORMA_DE_PAGO_TARJETA_DE_CREDITO = c_int( 20 ).value
AFIP_CODIGO_FORMA_DE_PAGO_TARJETA_DE_DEBITO = c_int( 21 ).value
AFIP_CODIGO_FORMA_DE_PAGO_TICKET = c_int( 22 ).value
AFIP_CODIGO_FORMA_DE_PAGO_TRANSFERENCIA_BANCARIA = c_int( 23 ).value
AFIP_CODIGO_FORMA_DE_PAGO_TRANSFERENCIA_NO_BANCARIA = c_int( 24 ).value
AFIP_CODIGO_FORMA_DE_PAGO_OTROS_MEDIOS_DE_PAGO = c_int( 99 ).value
# -----------------------------------------------------------------------------
# Function: dll_version()
# -----------------------------------------------------------------------------
def dll_version():
#title
print "*** DLL VERSION ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# get dll version
str_version_max_len = 500
str_version = create_string_buffer( b'\000' * str_version_max_len )
int_major = c_int()
int_minor = c_int()
error = Handle_HL.ConsultarVersionDll( str_version, c_int(str_version_max_len).value, byref(int_major), byref(int_minor) )
print "DllVersion : ",
print error
print "String Dll Version : ",
print str_version.value
print "Major Dll Version : ",
print int_major.value
print "Minor Dll Version : ",
print int_minor.value
# -----------------------------------------------------------------------------
# Function: dll_version()
# -----------------------------------------------------------------------------
def dll_ll_test_comm():
#title
print "*** DLL LOW LEVEL ***"
print " "
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
print "OpenPort()"
Handle_HL.setComPort(0) # usb
Handle_HL.setBaudRate( 115200 )
Handle_HL.setProtocolType( c_int(1) ) # protocol extended
Handle_HL.OpenPort() # open
error = Handle_HL.getLastError()
print "OpenPort() Error : ",
print error
# getState
print "getState()"
error = Handle_HL.getState()
print "getState() Error: ",
print error
# -----------------------------------------------------------------------------
# Function: equipment_machine_version()
# -----------------------------------------------------------------------------
def equipment_machine_version():
#title
print "*** EQUIPMENT MACHINE VERSION ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# get dll version
str_version_max_len = 500
str_version = create_string_buffer( b'\000' * str_version_max_len )
int_major = c_int()
int_minor = c_int()
error = Handle_HL.ConsultarVersionEquipo( str_version, c_int(str_version_max_len).value, byref(int_major), byref(int_minor) )
print "Machinne Version : ",
print error
print "String Machinne Version : ",
print str_version.value
print "Major Machinne Version : ",
print int_major.value
print "Minor Machine Version : ",
print int_minor.value
# status
error = Handle_HL.ConsultarEstadoDeConexion()
print "Conexion Status : ",
print error
# close port
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: set_and_get_header_trailer()
# -----------------------------------------------------------------------------
def set_and_get_header_trailer():
#title
print "*** HEADER & TRAILER ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# set header #1
error = Handle_HL.EstablecerEncabezado( c_int(1).value, "Nuevo Encabezado #1" )
print "Config Header Error : ",
print error
# get header #1
str_header1_max_len = 100
str_header1 = create_string_buffer( b'\000' * str_header1_max_len )
error = Handle_HL.ConsultarEncabezado( c_int(1).value, str_header1, c_int(str_header1_max_len).value )
print "Get Header Error : ",
print error
print "Header #1 String : ",
print str_header1.value
# set trailer #1
error = Handle_HL.EstablecerCola( c_int(1).value, "Nueva Cola #1" )
print "Config Trailer Error : ",
print error
# get trailer #1
str_trailer1_max_len = 100
str_trailer1 = create_string_buffer( b'\000' * str_trailer1_max_len )
error = Handle_HL.ConsultarCola( c_int(1).value, str_trailer1, c_int(str_trailer1_max_len).value )
print "Get Trailer Error : ",
print error
print "Trailer #1 String : ",
print str_trailer1.value
# close port
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: set_and_get_header()
# -----------------------------------------------------------------------------
def set_and_get_datetime():
#title
print "*** DATE & TIME ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# get datetime
str_datetime_max_len = 100
str_datetime = create_string_buffer( b'\000' * str_datetime_max_len )
error = Handle_HL.ConsultarFechaHora( str_datetime, c_int(str_datetime_max_len).value )
print "Get Date & Time Error : ",
print error
print "Date & Time : ",
print str_datetime.value
# set datetime (use the same value)
error = Handle_HL.EstablecerFechaHora( str_datetime.value )
print "Set Date & Time Error : ",
print error
# close port
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: set_and_get_header()
# -----------------------------------------------------------------------------
def cancel_all():
#title
print "*** CANCEL ALL ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# get document number
str_doc_number_max_len = 20
str_doc_number = create_string_buffer( b'\000' * str_doc_number_max_len )
error = Handle_HL.ConsultarNumeroComprobanteActual( str_doc_number, c_int(str_doc_number_max_len).value )
print "Get Doc. Number Error : ",
print error
print "Doc Number : ",
print str_doc_number.value
# get document type
str_doc_type_max_len = 20
str_doc_type = create_string_buffer( b'\000' * str_doc_type_max_len )
error = Handle_HL.ConsultarTipoComprobanteActual( str_doc_type, c_int(str_doc_type_max_len).value )
print "Get Type Doc. Error : ",
print error
print "Doc Type : ",
print str_doc_type.value
# try cancel
error = Handle_HL.Cancelar()
print "Cancel : ",
print error
# get last error
error = Handle_HL.ConsultarUltimoError()
print "Last Error : ",
print error
# close port
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: print_X_and_Z()
# -----------------------------------------------------------------------------
def print_X_and_Z():
# get handle from DLL
Handle_HL= ctypes.cdll.LoadLibrary("so/64/libEpsonFiscalInterface.so")
# Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "serial:/dev/ttyUSB0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# print X
error = Handle_HL.ImprimirCierreX()
print "Closure Cashier : ",
print error
# print Z
error = Handle_HL.ImprimirCierreZ()
print "Closure Day : ",
print error
# close port
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: ticket
# -----------------------------------------------------------------------------
def ticket():
#title
print "*** TICKET ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# try cancel all
error = Handle_HL.Cancelar()
print "Cancel : ",
print error
# open
error = Handle_HL.AbrirComprobante( ID_TIPO_COMPROBANTE_TIQUET )
print "Open : ",
print error
# get document number
str_doc_number_max_len = 20
str_doc_number = create_string_buffer( b'\000' * str_doc_number_max_len )
error = Handle_HL.ConsultarNumeroComprobanteActual( str_doc_number, c_int(str_doc_number_max_len).value )
print "Get Doc. Number Error : ",
print error
print "Doc Number : ",
print str_doc_number.value
# get document type
str_doc_type_max_len = 20
str_doc_type = create_string_buffer( b'\000' * str_doc_type_max_len )
error = Handle_HL.ConsultarTipoComprobanteActual( str_doc_type, c_int(str_doc_type_max_len).value )
print "Get Type Doc. Error : ",
print error
print "Doc Type : ",
print str_doc_type.value
# load extra text descripcion
error = Handle_HL.CargarTextoExtra( "Descrip. Extra #1" )
print "Extra Descript. #1 : ",
print error
error = Handle_HL.CargarTextoExtra( "Descrip. Extra #2" )
print "Extra Descript. #2 : ",
print error
error = Handle_HL.CargarTextoExtra( "Descrip. Extra #3" )
print "Extra Descript. #3 : ",
print error
error = Handle_HL.CargarTextoExtra( "Descrip. Extra #4" )
print "Extra Descript. #4 : ",
print error
# item
error = Handle_HL.ImprimirItem( ID_MODIFICADOR_AGREGAR, "Sardinas", "1.1234", "100.1234", ID_TASA_IVA_21_00, ID_IMPUESTO_INTERNO_FIJO, "7.1234", ID_CODIGO_INTERNO, "CodigoInterno4567890123456789012345678901234567890", "", AFIP_CODIGO_UNIDAD_MEDIDA_KILOGRAMO )
print "Item : ",
print error
# subtotal
error = Handle_HL.ImprimirSubtotal()
print "Subtotal : ",
print error
# get subtotal gross amount
str_subtotal_max_len = 20
str_subtotal = create_string_buffer( b'\000' * str_subtotal_max_len )
error = Handle_HL.ConsultarSubTotalBrutoComprobanteActual( str_subtotal, c_int(str_subtotal_max_len).value )
print "Get Subtotal Gross : ",
print error
print "Subtotal Gross Amount : ",
print str_subtotal.value
# get subtotal gross amount
str_subtotal_max_len = 20
str_subtotal = create_string_buffer( b'\000' * str_subtotal_max_len )
error = Handle_HL.ConsultarSubTotalNetoComprobanteActual( str_subtotal, c_int(str_subtotal_max_len).value )
print "Get Subtotal Net : ",
print error
print "Subtotal Net Amount : ",
print str_subtotal.value
# global discount
error = Handle_HL.CargarAjuste( ID_MODIFICADOR_DESCUENTO, "Descuento global", "10.1", c_int(0).value, "CodigoInterno4567890123456789012345678901234567890" )
print "Discount : ",
print error
# global uplift
error = Handle_HL.CargarAjuste( ID_MODIFICADOR_AJUSTE, "Recargo global", "90.03", c_int(0).value, "CodigoInterno4567891123456789012345678901234567891" )
print "Uplift : ",
print error
# close
error = Handle_HL.CerrarComprobante()
print "Close : ",
print error
# disconect
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: ticket_from_ticket_invoice
# -----------------------------------------------------------------------------
def ticket_from_ticket_invoice():
#title
print "*** TICKET FROM INVOICE ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# try cancel
error = Handle_HL.Cancelar()
print "Cancel : ",
print error
# open - without customer data previously loaded
error = Handle_HL.AbrirComprobante( ID_TIPO_COMPROBANTE_TIQUE_FACTURA )
print "Open : ",
print error
# get document number
str_doc_number_max_len = 20
str_doc_number = create_string_buffer( b'\000' * str_doc_number_max_len )
error = Handle_HL.ConsultarNumeroComprobanteActual( str_doc_number, c_int(str_doc_number_max_len).value )
print "Get Doc. Number Error : ",
print error
print "Doc Number : ",
print str_doc_number.value
# get document type
str_doc_type_max_len = 20
str_doc_type = create_string_buffer( b'\000' * str_doc_type_max_len )
error = Handle_HL.ConsultarTipoComprobanteActual( str_doc_type, c_int(str_doc_type_max_len).value )
print "Get Type Doc. Error : ",
print error
print "Doc Type : ",
print str_doc_type.value
# load extra text descripcion
error = Handle_HL.CargarTextoExtra( "Descrip. Extra #1" )
print "Extra Descript. #1 : ",
print error
error = Handle_HL.CargarTextoExtra( "Descrip. Extra #2" )
print "Extra Descript. #2 : ",
print error
error = Handle_HL.CargarTextoExtra( "Descrip. Extra #3" )
print "Extra Descript. #3 : ",
print error
error = Handle_HL.CargarTextoExtra( "Descrip. Extra #4" )
print "Extra Descript. #4 : ",
print error
# item
error = Handle_HL.ImprimirItem( ID_MODIFICADOR_AGREGAR, "Sardinas", "1", ".12", ID_TASA_IVA_21_00, ID_IMPUESTO_NINGUNO, "", ID_CODIGO_INTERNO, "CodigoInterno4567890123456789012345678901234567890", "", AFIP_CODIGO_UNIDAD_MEDIDA_KILOGRAMO )
print "Item : ",
print error
# item 2
error = Handle_HL.ImprimirItem( ID_MODIFICADOR_AGREGAR, "Banana (item2)", "10", "132.087", ID_TASA_IVA_21_00, ID_IMPUESTO_NINGUNO, "", ID_CODIGO_INTERNO, "CodigoInterno5555588999922255999999600000000000001", "", AFIP_CODIGO_UNIDAD_MEDIDA_KILOGRAMO )
print "Item 2 : ",
print error
# subtotal
error = Handle_HL.ImprimirSubtotal()
print "Subtotal : ",
print error
# get subtotal gross amount
str_subtotal_max_len = 20
str_subtotal = create_string_buffer( b'\000' * str_subtotal_max_len )
error = Handle_HL.ConsultarSubTotalBrutoComprobanteActual( str_subtotal, c_int(str_subtotal_max_len).value )
print "Get Subtotal Gross : ",
print error
print "Subtotal Gross Amount : ",
print str_subtotal.value
# get subtotal gross amount
str_subtotal_max_len = 20
str_subtotal = create_string_buffer( b'\000' * str_subtotal_max_len )
error = Handle_HL.ConsultarSubTotalNetoComprobanteActual( str_subtotal, c_int(str_subtotal_max_len).value )
print "Get Subtotal Net : ",
print error
print "Subtotal Net Amount : ",
print str_subtotal.value
# global discount
error = Handle_HL.CargarAjuste( ID_MODIFICADOR_DESCUENTO, "Descuento global", "10.00", c_int(0).value, "CodigoInterno4567890123456789012345678901234567890" )
print "Discount : ",
print error
# global uplift
error = Handle_HL.CargarAjuste( ID_MODIFICADOR_AJUSTE, "Recargo global", "90.00", c_int(0).value, "CodigoInterno4567890122222222222225678901234567892" )
print "Uplift : ",
print error
# close
error = Handle_HL.CerrarComprobante()
print "Close : ",
print error
# disconect
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: ticket_invoice
# -----------------------------------------------------------------------------
def ticket_invoice():
#title
print "*** TICKET INVOICE ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# cancel
error = Handle_HL.Cancelar()
print "Cancel : ",
print error
# load customer data
error = Handle_HL.CargarDatosCliente( "Nombre Comprador #1", "Nombre Comprador #2", "Domicilio Comprador #1", "Domicilio Comprador #2", "Domicilio Comprador #3", ID_TIPO_DOCUMENTO_CUIT, "24272242549", ID_RESPONSABILIDAD_IVA_RESPONSABLE_INSCRIPTO )
print "Customer Data : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "083-00001-00000027" )
print "Customer Remit #1 : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "082-00003-01003020" )
print "Customer Remit #2 : ",
print error
# open
error = Handle_HL.AbrirComprobante( ID_TIPO_COMPROBANTE_TIQUE_FACTURA )
print "Open : ",
print error
# fixed info
send_fixed_invoice_body( Handle_HL )
# close
error = Handle_HL.CerrarComprobante()
print "Close : ",
print error
# disconect
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: ticket_invoice_B
# -----------------------------------------------------------------------------
def ticket_invoice_B():
#title
print "*** TICKET INVOICE 'B' ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# cancel
error = Handle_HL.Cancelar()
print "Cancel : ",
print error
# load customer data
error = Handle_HL.CargarDatosCliente( "Nombre Comprador #1", "Nombre Comprador #2", "Domicilio Comprador #1", "Domicilio Comprador #2", "Domicilio Comprador #3", ID_TIPO_DOCUMENTO_CUIT, "24272242549", ID_RESPONSABILIDAD_IVA_MONOTRIBUTISTA )
print "Customer Data : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "083-00001-00000027" )
print "Customer Remit #1 : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "082-00003-01003020" )
print "Customer Remit #2 : ",
print error
# open
error = Handle_HL.AbrirComprobante( ID_TIPO_COMPROBANTE_TIQUE_FACTURA )
print "Open : ",
print error
# fixed info
send_fixed_invoice_body( Handle_HL )
# close
error = Handle_HL.CerrarComprobante()
print "Close : ",
print error
# disconect
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: ticket_debit_note
# -----------------------------------------------------------------------------
def ticket_debit_note():
#title
print "*** TICKET DEBIT NOTE ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# try cancel
error = Handle_HL.Cancelar()
print "Cancel : ",
print error
# load customer data
error = Handle_HL.CargarDatosCliente( "Nombre Comprador #1", "Nombre Comprador #2", "Domicilio Comprador #1", "Domicilio Comprador #2", "Domicilio Comprador #3", ID_TIPO_DOCUMENTO_CUIT, "24272242549", ID_RESPONSABILIDAD_IVA_RESPONSABLE_INSCRIPTO )
print "Customer Data : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "083-00001-00000027" )
print "Customer Remit #1 : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "082-00003-01003020" )
print "Customer Remit #2 : ",
print error
# open
error = Handle_HL.AbrirComprobante( ID_TIPO_COMPROBANTE_TIQUE_NOTA_DE_DEBITO )
print "Open : ",
print error
# fixed info
send_fixed_invoice_body( Handle_HL )
# close
error = Handle_HL.CerrarComprobante()
print "Close : ",
print error
# disconect
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: ticket_debit_note_B
# -----------------------------------------------------------------------------
def ticket_debit_note_B():
#title
print "*** TICKET DEBIT NOTE 'B' ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# try cancel
error = Handle_HL.Cancelar()
print "Cancel : ",
print error
# load customer data
error = Handle_HL.CargarDatosCliente( "Nombre Comprador #1", "Nombre Comprador #2", "Domicilio Comprador #1", "Domicilio Comprador #2", "Domicilio Comprador #3", ID_TIPO_DOCUMENTO_CUIT, "24272242549", ID_RESPONSABILIDAD_IVA_MONOTRIBUTISTA )
print "Customer Data : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "083-00001-00000027" )
print "Customer Remit #1 : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "082-00003-01003020" )
print "Customer Remit #2 : ",
print error
# open
error = Handle_HL.AbrirComprobante( ID_TIPO_COMPROBANTE_TIQUE_NOTA_DE_DEBITO )
print "Open : ",
print error
# fixed info
send_fixed_invoice_body( Handle_HL )
# close
error = Handle_HL.CerrarComprobante()
print "Close : ",
print error
# disconect
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: ticket_credit_note
# -----------------------------------------------------------------------------
def ticket_credit_note():
#title
print "*** TICKET CREDIT NOTE ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# try cancel
error = Handle_HL.Cancelar()
print "Cancel : ",
print error
# load customer data
error = Handle_HL.CargarDatosCliente( "Nombre Comprador #1", "Nombre Comprador #2", "Domicilio Comprador #1", "Domicilio Comprador #2", "Domicilio Comprador #3", ID_TIPO_DOCUMENTO_CUIT, "24272242549", ID_RESPONSABILIDAD_IVA_RESPONSABLE_INSCRIPTO )
print "Customer Data : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "081-0005-0007777" )
print "main source voucher : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "083-00001-00000027" )
print "Customer Remit #1 : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "082-00003-01003020" )
print "Customer Remit #2 : ",
print error
# open
error = Handle_HL.AbrirComprobante( ID_TIPO_COMPROBANTE_TIQUE_NOTA_DE_CREDITO )
print "Open : ",
print error
# fixed info
send_fixed_invoice_body( Handle_HL )
# close
error = Handle_HL.CerrarComprobante()
print "Close : ",
print error
# disconect
error = Handle_HL.Desconectar()
print "Disconect : ",
print error
# -----------------------------------------------------------------------------
# Function: ticket_credit_note_B
# -----------------------------------------------------------------------------
def ticket_credit_note_B():
#title
print "*** TICKET CREDIT NOTE 'B' ***"
# get handle from DLL
Handle_HL = windll.LoadLibrary("EpsonFiscalInterface.dll")
# connect
Handle_HL.ConfigurarVelocidad( c_int(9600).value )
Handle_HL.ConfigurarPuerto( "0" )
error = Handle_HL.Conectar()
print "Connect : ",
print error
# try cancel
error = Handle_HL.Cancelar()
print "Cancel : ",
print error
# load customer data
error = Handle_HL.CargarDatosCliente( "Nombre Comprador #1", "Nombre Comprador #2", "Domicilio Comprador #1", "Domicilio Comprador #2", "Domicilio Comprador #3", ID_TIPO_DOCUMENTO_CUIT, "24272242549", ID_RESPONSABILIDAD_IVA_MONOTRIBUTISTA )
print "Customer Data : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "081-0005-0007777" )
print "main source voucher : ",
print error
# load customer data
error = Handle_HL.CargarComprobanteAsociado( "083-00001-00000027" )