NAME

WebService::Avalara::AvaTax - Avalara SOAP interface as compiled Perl methods

VERSION

version 0.003

SYNOPSIS

use WebService::Avalara::AvaTax;
my $avatax = WebService::Avalara::AvaTax->new(
    username => 'avalara@example.com',
    password => 'sekrit',
);
my $answer_ref = $avatax->ping;

DESCRIPTION

This class provides a Perl method API for Avalara AvaTax web services. The first call to any AvaTax SOAP operation uses XML::Compile::WSDL11 to compile and execute against the specified Avalara AvaTax service; subsequent calls can vary the parameters but will use the same compiled code.

METHODS

Available method names are dynamically loaded from the AvaTax WSDL file's operations, and can be passed either a hash or reference to a hash with the necessary parameters. In scalar context they return a reference to a hash containing the results of the SOAP call; in list context they return the results hashref and an XML::Compile::SOAP::Trace object suitable for debugging and exception handling.

As of this writing the following operations are published in the Avalara AvaTax schema. Consult Avalara's Help Center for full documentation on input and output parameters for each operation.

If there is no result then an exception will be thrown.

get_tax

Example:

use DateTime;
use DateTime::Format::XSD;
my ( $answer_ref, $trace ) = $avatax->get_tax(
    CustomerCode => 'ABC4335',
    DocDate      => DateTime::Format::XSD->format_datetime(
        DateTime->new( year => 2014, month => 1, day => 1 ) ),
    CompanyCode  => 'APITrialCompany',
    DocCode      => 'INV001',
    DetailLevel  =>  'Tax',
    Commit       => 0,
    DocType      => 'SalesInvoice',
);

post_tax

Example:

use DateTime;
use DateTime::Format::XSD;
my ( $answer_ref, $trace ) = $avatax->post_tax(
    CompanyCode => 'APITrialCompany',
    DocType     => 'SalesInvoice',
    DocCode     => 'INV001',
    Commit      => 0,
    DocDate     => DateTime::Format::XSD->format_datetime(
        DateTime->new(year => 2014, month => 1, day => 1) ),
    TotalTax    => '14.27',
    TotalAmount => 175,
    NewDocCode  => 'INV001-1',
);

commit_tax

Example:

my ( $answer_ref, $trace ) = $avatax->commit_tax(
    DocCode     => 'INV001',
    DocType     => 'SalesInvoice',
    CompanyCode => 'APITrialCompany',
    NewDocCode  => 'INV001-1',
);

cancel_tax

Example:

my ( $answer_ref, $trace ) = $avatax->cancel_tax(
    CompanyCode => 'APITrialCompany',
    DocType     => 'SalesInvoice',
    DocCode     => 'INV001',
    CancelCode  => 'DocVoided',
);

adjust_tax

get_tax_history

Example:

my ( $answer_ref, $trace ) = $avatax->get_tax_history(
    CompanyCode => 'APITrialCompany',
    DocType     => 'SalesInvoice',
    DocCode     => 'INV001',
    DetailLevel => 'Tax',
);

is_authorized

Example:

my ( $answer_ref, $trace ) = $avatax->is_authorized(
    Operations => join ', ' => qw(
        Ping
        IsAuthorized
        GetTax
        PostTax
        GetTaxHistory
        CommitTax
        CancelTax
        AdjustTax
    ),
);

ping

Example:

use List::Util 1.33 'any';
my ( $answer_ref, $trace ) = $avatax->ping;
for my $code ( $result_ref->{parameters}{PingResult}{ResultCode} ) {
    if ( $code eq 'Success' ) { say $code; last }
    if ( $code eq 'Warning' ) {
        warn $result_ref->{parameters}{PingResult}{Messages};
        last;
    }
    if ( any {$code eq $_} qw(Error Exception) ) {
        die $result_ref->{parameters}{PingResult}{Messages};
    }
}

reconcile_tax_history

apply_payment

tax_summary_fetch

OTHER METHODS AND ATTRIBUTES

Because this class consumes the WebService::Avalara::AvaTax::Role::Connection role, it also has that role's attributes and methods. Please consult that module for attributes important for establishing a connection such as username and password. You can also use other attributes, such as the user_agent attribute to access the LWP::UserAgent used to retrieve and call the AvaTax service, or the wsdl method to access the underlying XML::Compile::WSDL11 object.

SEE ALSO

Business::Tax::Avalara

An alternative that uses Avalara's REST API.

XML::Compile::SOAP and XML::Compile::WSDL11

Part of the XML::Compile suite and the basis for this distribution. It's helpful to understand these in order to debug or extend this module.

SUPPORT

Perldoc

You can find documentation for this module with the perldoc command.

perldoc WebService::Avalara::AvaTax

Websites

The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

Bugs / Feature Requests

Please report any bugs or feature requests through the web interface at https://github.com/mjgardner/WebService-Avalara-AvaTax/issues. You will be automatically notified of any progress on the request by the system.

Source Code

The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)

https://github.com/mjgardner/WebService-Avalara-AvaTax

git clone git://github.com/mjgardner/WebService-Avalara-AvaTax.git

AUTHOR

Mark Gardner <mjgardner@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by ZipRecruiter.

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