Subclass for all bank statements importers of new generation (since 1.1). More...
Public Member Functions | |
get_importer_name () | |
Get importer name. |
Static Public Member Functions | |
static | get_drivers () |
Gets available drivers. | |
static | download (Bank_account_Model $bank_account, Bank_Account_Settings $settings, $send_emails, $send_sms) |
Tries to download statement and then import it. | |
static | import (Bank_account_Model $bank_account, $filename, $ext, $send_emails=TRUE, $send_sms=FALSE) |
Imports a bank statement placed in a file that is given by the filename to bank account that is given by its database model. |
Public Attributes | |
const | DIR = 'importers' |
Dir with driver classes. |
Protected Member Functions | |
__construct (Bank_account_Model $bam) | |
Creates new instance od bank statement import. | |
get_user_id () | |
User ID of caller of this importer. | |
get_bank_account () | |
Gets bank account for which the importer is evaulating imports. | |
set_file_data ($fd) | |
Sets bank statement file data (content of a file) | |
get_file_data () | |
Gets bank statement file data (content of a file) | |
add_error ($error, $translate=TRUE) | |
Adds given error to the start of the error stack. | |
add_exception_error (Exception $e, $translate=TRUE) | |
Add given exception as error to the start of the error stack. | |
add_affected_member ($member_id) | |
Adds member as affected by this parsed statement. | |
get_errors () | |
Gets error trace. | |
find_member_by_vs ($variable_symbol, $error_correction=TRUE) | |
Finds member ID by variable method. | |
before_download (Bank_account_Model $bank_account, Bank_Account_Settings $settings) | |
This method may be implemented in order to do some action before downloading of a bank statement. | |
do_download (Bank_account_Model $bank_account, Bank_Account_Settings $settings, $url) | |
This method enables to download a bank statement. | |
check_file_data_format () | |
Checks whether the file content that is stored into a fileData property has valid format. | |
get_header_data () | |
Gets header data of file data format. | |
parse_file_data () | |
Parses a file data into a semantic interpretation of its content. | |
store (&$stats=array()) | |
Stores data that are obtain via parse_file_data method (stored internally. | |
notify_affected_members () | |
Informs affected members by email or SMS according to setting variables inform_affected_member_by_email and inform_affected_member_by_sms. |
Static Protected Member Functions | |
static | factory ($bank_account, $ext) |
Creates an instance of file importer driver that is capable of importing bank statement. |
Subclass for all bank statements importers of new generation (since 1.1).
Import is made using import static method that is the only public method of this class (only one that is called).
New importers (drivers) should implement this abstract class and then info about them must be added into drivers array in this class. Driver handles checking of format, parsing, saving data into database. On the other hand this class handles opening of file, notifying of affected users, error handling, variable key searching and grouping drivers in order to provide an independent of driver on another parts of system. Drivers should be located at directory defined by DIR constant that contains a relative location to this class.
Lifecycle of importer is following:
|
protected |
Creates new instance od bank statement import.
Bank_account_Model | $bam |
|
protected |
Adds member as affected by this parsed statement.
Later if statement is succefully parsed and saved these members are inform by notification.
integer | $member_id |
|
protected |
Adds given error to the start of the error stack.
string | $error | Error messsage |
boolean | $translate | Should be error message translated before adding? |
|
protected |
Add given exception as error to the start of the error stack.
Exception | $e | |
boolean | $translate | Should be exception message translated before adding? |
|
protected |
This method may be implemented in order to do some action before downloading of a bank statement.
Does not do anything by default.
Bank_account_Model | $bank_account | |
Bank_Account_Settings | $settings |
Exception | On any error |
Reimplemented in Fio_Bank_Statement_File_Importer.
|
abstractprotected |
Checks whether the file content that is stored into a fileData property has valid format.
This method checks only a format (syntax), semantic meaning of content is examined later.
An error in the format may be add into error stack (addError) that is later displayed to user if this function returns FALSE.
Reimplemented in Csv_Fio_Bank_Statement_File_Importer, Json_Fio_Bank_Statement_File_Importer, and Txt_Tatra_Banka_Statement_File_Importer.
|
protected |
This method enables to download a bank statement.
By default it simply download file from the specified URL. If other type of download is needed that this method should be overriden.
Bank_account_Model | $bank_account | |
Bank_Account_Settings | $settings | |
string | $url | Prepare download URL |
Reimplemented in Txt_Tatra_Banka_Statement_File_Importer.
|
static |
Tries to download statement and then import it.
This action contains just getting of a file URL from bank settings. Then this URL with another info is passed to import method which does the rest of the job.
Bank_account_Model | $bank_account | Bank account ot which the statement is imported |
Bank_Account_Settings | $settings | |
boolean | $send_emails | Send notification of affected members by e-mail |
boolean | $send_sms | Send notification of affected members by sms |
InvalidArgumentException | On invalid bank account settings that cannot be use for proper download |
|
staticprotected |
Creates an instance of file importer driver that is capable of importing bank statement.
Bank_account_Model | $bank_account | |
string | $ext | File extension |
InvalidArgumentException | On invalid file or bank account entity |
|
protected |
Finds member ID by variable method.
If given variable symbol is not founded in the database and a variable key generator is active and capable of error correction than the variable key is tried repared and searched again.
Variable_Symbol_Model $vk_model
string | $variable_symbol | |
boolean | $error_correction | May be used error correction for VS? |
|
protected |
Gets bank account for which the importer is evaulating imports.
|
static |
Gets available drivers.
|
protected |
Gets error trace.
|
protected |
Gets bank statement file data (content of a file)
|
abstractprotected |
Gets header data of file data format.
This method is used for checking if the bank statement correspondes to bank account in the database.
Data must be available in any time after calling of check_file_data_format method.
An error in the format may be add into error stack (addError) that is later displayed to user if this function returns FALSE.
If bank statement file not providing any header information NULL can be returned to skip assert for bank account match.
Reimplemented in Csv_Fio_Bank_Statement_File_Importer, Json_Fio_Bank_Statement_File_Importer, and Txt_Tatra_Banka_Statement_File_Importer.
Bank_Statement_File_Importer::get_importer_name | ( | ) |
Get importer name.
|
protected |
User ID of caller of this importer.
(user who calls it)
|
static |
Imports a bank statement placed in a file that is given by the filename to bank account that is given by its database model.
Throws error exceptions with translated error description if any error occures.
Bank_account_Model | $bank_account | Bank account ot which the statement is imported |
string | $filename | Full path to imported file |
string | $ext | File extension |
boolean | $send_emails | Send notification of affected members by e-mail |
boolean | $send_sms | Send notification of affected members by sms |
InvalidArgumentException | On invalid file or bank account entity |
Exception | On any error during parsing or storing of statement |
|
protected |
Informs affected members by email or SMS according to setting variables inform_affected_member_by_email and inform_affected_member_by_sms.
|
abstractprotected |
Parses a file data into a semantic interpretation of its content.
This interpretation must be defined by implementing class.
An error in the format may be add into error stack (addError) that is later displayed to user if this function returns FALSE.
Reimplemented in Csv_Fio_Bank_Statement_File_Importer, Json_Fio_Bank_Statement_File_Importer, and Txt_Tatra_Banka_Statement_File_Importer.
|
protected |
Sets bank statement file data (content of a file)
string | $fd |
|
abstractprotected |
Stores data that are obtain via parse_file_data method (stored internally.
All transfers are stored in the database and grouped using statement entity. This statement entity is than returned.
This method should also set affected members in order to notify them.
An error in the format may be add into error stack (addError) that is later displayed to user if this function returns FALSE.
array | $stats | Statistics about imported statement |
Duplicity_Exception | On transfers that were already imported |
Reimplemented in Fio_Bank_Statement_File_Importer, and Tatra_Banka_Statement_File_Importer.