The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Business::DPD::Label - one DPD label

SYNOPSIS

    use Business::DPD::Label;
    my $label = Business::DPD::Label->new( $dpd, {
        zip             => '12555',
        country         => 'DE',
        depot           => '1090',
        serial          => '50123456%0878',
        service_code    => '101',    
        weight          => '6 kg',
    });
    $label->calc_fields;
    say $label->tracking_number;
    say $label->d_sort;

    use Business::DPD::Label;
    my $label2 = Business::DPD::Label->new( $dpd, {
        address => Business::DPD::Address->new($dpd, {
            name1   => 'Hans Mustermann GmbH',
            street  => 'Musterstr. 12a',
            postal  => '63741',
            city    => 'Aschaffenburg',
            country => 'DE',
            phone   => '06021/112',
        }),
        serial          => '9700001010',
        service_code    => '101',
        shipment_count_this => 1,
        shipment_count_total => 2,
        reference_number => [ 'Testpaket2' ],
        weight_g        => 6000,
    });

DESCRIPTION

Calculate the data that's needed for a valid addresse label.

METHODS

Public Methods

new

    my $label = Business::DPD::Label->new( $dpd, {
        zip             => '12555',
        country         => 'DE',
        depot           => '1090',
        serial          => '5012345678',
        service_code    => '101',
    });

TODO?: take a Business::DPD::Address as an agrument (instead of zip & country)

calc_fields

    $label->calc_fields;

Calculate all caluclatable fields from the provided data using the DPD database from $schema:

  target_country

calc_tracking_number

    $label->calc_tracking_number;

Calulates the tracking number and stores it in tracking_number. tracking_number consists of

   DDDDXXLLLLLLLLP
      | |     |  |
      | |     |  +-> iso7064_mod37_36_checksum      L
      | |     +----> serial                         12345678
      | +----------> first two positions of serial  50
      +------------> depot                          1090

We additionally store the checksum in checksum_tracking_number and the tracking_number_without_checksum

calc_routing

    $label->calc_routing;
    $label->o_sort

Calculates the following fields:

  o_sort d_sort d_depot barcode_id
  

calc_target_country_code

    $label->calc_target_country_code;

Store the numeric country code from the alpha2 target country (i.e.: 'DE' -> 276) into target_country_code

service_text

 $label->service_text

Returns the service text for the given service code

calc_barcode

    $label->calc_barcode;

Generate the various parts of the barcode, which are:

  • code

    PPPPPPPTTTTTTTTTTTTTTSSSCCC

  • code_human

    PPPPPPPTTTTTTTTTTTTTTSSSCCCP

  • code_barcode

    IPPPPPPPTTTTTTTTTTTTTTSSSCCC

And here's the explanation of those strange letter:

    IPPPPPPPTTTTTTTTTTTTTTSSSCCCP
    |   |          |       |  | |
    |   |          |       |  | +-> iso7064_mod37_36_checksum         Z
    |   |          |       |  +---> target_country_code               276
    |   |          |       +------> service_code                      101
    |   |          +--------------> tracking_number_without_checksum  01905002345615
    |   +-------------------------> zip (zero padded)                 0012555
    +-----------------------------> barcode_id                        %                   

TODO

* weiters:

kennzeichnung (kleingewicht, Express) Servicetext Servicecode

needed methods

* one object for one address * required fields ** target country ** target zipcode ** laufende nummer ** depot number ** service code * semi-required ** address data * optional ** referenznummer ** auftragsnummer ** gewicht ** n of m ** template

AUTHOR

RevDev <we {at} revdev.at>

SEE ALSO

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.