NAME

Business::ISP::Ledger - Perl module for ISP accounting user/general ledger operations.

SYNOPSIS

use Business::ISP::Ledger;
my  $ledger = Business::ISP::Ledger->new();

DESCRIPTION

This module handles all ledger operations for the ISP accounting system. It will be used for legacy text-file based ledger/accounting files, and the new db system.

MODULES

new()

Instantiates a new Business::ISP::Ledger object. Returns undef upon failure.

This method is inhereted from the base class.

write_ledger({ client => USER, transaction => TRANSAC )

Use this method to write the finalized transaction to the general and user ledgers, and updates the clients balance.

Both parameters are mandatory, and are passed in within a hash reference.

USER is an Business::ISP::User object, and TRANSAC is an Business::ISP::Transac object.

Returns the invoice number of this transaction upon success.

gledger_add(USER, TRANSACTION)

* This method will be deprecated once we go into production.

Prepares the appropriate legacy-style ledger strings, and inserts them into the ISP accounting ledgers.

USER is an Business::ISP::User object, and TRANSACTION is an Business::ISP::Transac object. No error checking is performed here, as the data verification is done via Business::ISP::Transac.

Uses _gledger_write_legacy() and _uledger_write_legacy() to write out the ledger data.

Returns the invoice number of the current process as an $int.

_gledger_write_legacy(USER, DATE, ENTRY)

* This method will be deprecated once we go into production.

Writes the transaction data to the legacy style general ledger. USER is an Business::ISP::User object. DATE is a DateTime (now()) object, and ENTRY is an array reference that contains one ledger line per array element.

_uledger_write_legacy(USER, DATE, ENTRY)

* This method will be deprecated once we go into production.

Writes the transaction data to the legacy style user ledger. USER is an Business::ISP::User object. DATE is a DateTime (now()) object, and ENTRY is a hash reference that contains the entry items.

bank_receipt({ bank_receipt => RECEIPT, invoice_number => INVNUM })

This method stores a bank receipt if a transaction was done via credit card.

The parameters are passed in within a hash reference.

If only the INVNUM is passed in, the bank receipt will be returned as a scalar.

If both RECEIPT and INVNUM are passed in, the RECEIPT will be stored in the database and associated with the invoice containing INVNUM document number.

Returns undef if storing a document, or if the retrieval of a document is not successful.

get_invoice_number_legacy()

* This method will be deprecated once we go into production.

Retrieves the legacy style invoice number. Takes no parameters.

Returns the invoice number as an $int.

invoice_number( INVNUM, DATE )

DATE is an optional parameter, and must be in the form '2010-09-08'. If passed in, the return will be an array reference of all the invoice numbers that were created on that particular day. Note that INVNUM and DATE can not be passed in simultaneously, so the call will look like this:

$ledger->invoice_number( undef, '2010-09-08' );

INVNUM is a scalar integer.

If INVNUM is passed in, we will claim the next available invoice number as taken.

If INVNUM is not passed in, we return the next available invoice number that can be used.

get_uledger({ username => USERNAME, invoice_number => INVNUM })

Parameters are passed in within a hash reference.

If USERNAME is passed in, we will return an array reference of that user's invoices, or 1 if no invoices are found.

If INVNUM is passed in, will return a hash reference of that particular invoice.

If both parameters are passed in, the INVNUM will take precedence.

get_gledger({ invoice_number => INVNUM })

Parameters are passed in within a hash reference.

INVNUM is a mandatory integer parameter.

Returns an array reference containing all ledger entries related to the invoice number.

If no entries can be found, the aref will be empty.

set_invoice_number_legacy(INVOICE_NUMBER)

* This method will be deprecated once we go into full production.

Stores an updated invoice number to the legacy file-based system.

INVOICE_NUMBER is an $int. Will die() if the invoice file can not be opened. There is no return.

balance ({ username => USERNAME, balance => BALANCE })

Manages a client account financial balance. Parameters are passed in within a hash reference.

USERNAME is a mandatory parameter, BALANCE is optional.

If the optional decimal parameter BALANCE is supplied, will update the client account balance and set it to BALANCE, and return 0 if successful and undef upon failure.

If BALANCE is not passed in, the users current balance is returned.

ledger_field({ entry => ENTRY, fields => FIELDS })

Used to extract specific fields from the user or general ledger.

ENTRY is a mandatory parameter, and is a hash reference of a single row of a ledger item.

FIELDS is a mandatory parameter. It is an array reference, containing the ledger fields that you want returned.

Returns a hash reference of the field and value pairs.

sum({ date => DATE, for => FOR, total => TOTAL })

This method will add up all of the entries in the TOTAL column for each of the unique entries in the FOR column in the general ledger table.

DATE is a mandatory string parameter in the form YYYY, YYYY-MM or YYYY-MM-DD.

FOR is a string that represents the column name that you want to get a sum for.

TOTAL is a string that represents the column name that you want to create the sum of.

Returns a hash reference of the unique items in FOR, who's values are the summarized numbers in TOTAL.

AUTHOR

Steve Bertrand, steveb@cpan.org

SEE ALSO

perl(1).