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

NAME

Business::ISP::Transac - Perl module for ISP accounting system.

SYNOPSIS

    use Business::ISP::Transac;

    # Create a new transaction, and populate it with some initial data
    my $transaction = Business::ISP::Transac->create_transaction({
                                                data    => \%data, 
                                                error   => $error
                                            });

    # Add more items to the transaction
    $transaction->add_transaction_line({ data => \%data, error => $error });

    # Purchase something
    $transation->purchase($user, $error);

    # Make a payment
    $transaction->payment($user, $error);

DESCRIPTION

This module provides the financial functions (purchase, renewal, payment) etc for the ISP accounting system applications. This is the intermediary layer between the applications and the ledgers.

This is the ONLY module that should ever have direct access to the write functions in Business::ISP::Ledger.

METHODS

new()

Creates a new Business::ISP::Transac object, and if possible, will set $self->{config} to $config->{transac}. This method is inherited from the base class. More often than not, you will want to use create_transaction() to initialize an Business::ISP::Transac object.

Initializes a new empty transaction object. This method is inhereted from the base class. More often than not, you will want to use create_transaction() instead of new().

Returns undef if an object can not be created.

create_transaction({ data => TRANSAC_INFO, error => ERROR })

Creates a new Business::ISP::Transac object.

Parameters are passed in as a hash reference.

The data parameter MUST contain a hash reference with the following keys: quantity, payment_method, item_name, comment, amount, payment, gst and pst. The error parameter is an Business::ISP::Error object. ERROR MUST be present.

Uses Business::ISP::Sanity to validate the data, and updates ERROR accordingly.

Returns ERROR if an error has been flagged, else returns itself as a hash reference.

add_transaction_line({ data => TRANSAC_INFO, error => ERROR })

Appends a new item into the transaction for transactions requiring more than a single line item.

Parameters must be passed in as a hash reference.

TRANSAC_INFO format is consistent with that in create_transaction().

ERROR is an Business::ISP::Error object. ERROR MUST be supplied.

Returns 0 upon success and the ERROR upon failure.

purchase({ NAME => VALUE })

Sends the Transac object to Business::ISP::Ledger for processing. Will die if errors are present, and the caller has not done error trapping/processing.

Valid parameters are as follows:

    client      => $client      # Business::ISP::User object
    cc_receipt  => $cc_receipt  # bank receipt string
    error       => $error       # Business::ISP::Error object

Both error and client are mandatory. Returns the invoice number of the transaction upon success.

payment({ NAME => VALUE, NAME => VALUE })

Same as purchase(), but performs special math for legacy ledger operations.

renew({ NAME => VALUE })

#FIXME: I don't think this sub is ever used!

Updates the ledger and account plan status for account renewals.

RENEWALS is a mandatory array reference parameter. Each element must contain a hashref, where each hashref is in the format plan_id => int, quantity => int.

ERROR is a manadory Business::ISP::Error object parameter.

FIXME: This sub is incomplete, so we don't know what it will return yet.

credit_card_payment({ transaction_data => DATA, error => ERROR })

There are two mandatory parameters that must be supplied within a hash reference.

ERROR is an Business::ISP::Error object, and DATA must be supplied as a hashref in the following format:

    my $transaction_data = {                        
            DollarAmount    => $amount,                        
            Card_Number     => $card_number,                        
            Expiry_Date     => $card_expiry,                        
            CardHoldersName => $card_holder,                    
        };

Returns the payment statement from the bank upon approval, or the bank response code upon failure.

calculate_invoice_amount({ username => USERNAME, data => DATA })

This method tallys up the total amount of all the line items in a transaction.

USERNAME is self explainitory. DATA is a hashref where the key is the item quantity, and the value is the dollar amount of this particular transaction.

Returns the total amount for this transaction.

AUTHOR

Steve Bertrand, <steveb at cpan.org>

BUGS

Please report any bugs or feature requests to steve at ibctech.ca

SUPPORT

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

    perldoc Business::ISP::Transac

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2012 Steve Bertrand, all rights reserved.

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