Add Code128C and UPC-A
This commit is contained in:
parent
446aa7dabb
commit
e1286ea689
|
@ -4,7 +4,7 @@
|
|||
"Peter Stuifzand <peter@stuifzand.eu>"
|
||||
],
|
||||
"dynamic_config" : 0,
|
||||
"generated_by" : "Dist::Milla version v1.0.3, Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.120921",
|
||||
"generated_by" : "Dist::Milla version v1.0.3, Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.132510",
|
||||
"license" : [
|
||||
"perl_5"
|
||||
],
|
||||
|
|
|
@ -64,7 +64,7 @@ sub format {
|
|||
$self->add_line($vars->{price}, 32);
|
||||
|
||||
# add_barcode
|
||||
$self->add_barcode($vars->{barcode});
|
||||
$self->add_barcode($vars->{barcode}, $vars->{barcode_type} // 'EAN13');
|
||||
|
||||
# add_count
|
||||
$self->add_count($vars->{count});
|
||||
|
@ -98,13 +98,25 @@ sub add_line {
|
|||
sub add_barcode {
|
||||
my $self = shift;
|
||||
my $barcode = shift;
|
||||
my $type = shift;
|
||||
|
||||
my $code = ""; # EAN13 of Code128C
|
||||
|
||||
$code .= "^BEN,,Y,N"; # EAN13
|
||||
my $ean = $type eq 'EAN13';
|
||||
|
||||
# Code128C code = "^BCN,,Y,N";
|
||||
# barcode = ">;" + barcode;
|
||||
if ($type eq 'EAN13') {
|
||||
$code .= "^BEN,,Y,N"; # EAN13
|
||||
}
|
||||
elsif ($type eq 'Code128C') { # Code128C
|
||||
$code = "^BCN,,Y,N";
|
||||
$barcode = ">;" . $barcode;
|
||||
}
|
||||
elsif ($type eq 'UPC-A') { # UPC-A
|
||||
$code = "^BUN,,Y,N,Y";
|
||||
}
|
||||
else {
|
||||
die "Unknown type $type for barcode";
|
||||
}
|
||||
|
||||
$self->append_data("^BY2,2,56^FT32,158" . $code . "\r\n^FD" . $barcode . "^FS");
|
||||
return;
|
||||
|
|
8
script/sendtest.pl
Normal file → Executable file
8
script/sendtest.pl
Normal file → Executable file
|
@ -10,10 +10,14 @@ use ZMQ::Constants ':all';
|
|||
|
||||
my $zmq_context = ZMQ::Context->new(1);
|
||||
|
||||
my $printer = Kassa::Net::Kassabon->new($zmq_context, 'tcp://192.168.1.97:9999');
|
||||
my $addr = 'tcp://192.168.1.82:9999';
|
||||
my $printer = Kassa::Net::Kassabon->new($zmq_context, $addr);
|
||||
|
||||
print "Sending test barcode to $addr\n";
|
||||
|
||||
my $p = Protocol::Zebra::Label->new;
|
||||
my $data = $p->format({ name => "Test label met een langere tekst adf df efe efei hemelsblauw", price => 'EUR 1,10', barcode => '812345678901', count => 1 });
|
||||
my $data = $p->format({ name => "Test label met een langere tekst adf df efe efei hemelsblauw", price => 'EUR 1,10',
|
||||
barcode => '879465002795', barcode_type => 'UPC-A', count => 1 });
|
||||
|
||||
$printer->send($data);
|
||||
|
||||
|
|
|
@ -22,5 +22,13 @@ is_string($p->format({ name => "Test product met een langere naam", barcode => "
|
|||
."^BY2,2,56^FT32,158^BEN,,Y,N\r\n^FD812345678901^FS"
|
||||
."^PQ1,0,1,Y^XZ\r\n");
|
||||
|
||||
is_string($p->format({ name => "Test product met een langere naam", barcode => "812345678901", barcode_type => 'Code128C', price => "EUR 1,00", count => 1 }),
|
||||
"^XA~TA000~JSN~LT0^MNW^MTD^PON^PMN^LH0,0^JMA^PR2,2~SD25~JO^JUS^LRY^CI0^XZ^XA^MMT^PW254^LL0203^LS0"
|
||||
."^FT16,32^A0N,20,20^FH\\^FDTest product met een^FS"
|
||||
."^FT16,54^A0N,20,20^FH\\^FDlangere naam^FS"
|
||||
."^FT16,92^A0N,32,32^FH\\^FDEUR 1,00^FS"
|
||||
."^BY2,2,56^FT32,158^BCN,,Y,N\r\n^FD>;812345678901^FS"
|
||||
."^PQ1,0,1,Y^XZ\r\n");
|
||||
|
||||
done_testing();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user