Comment by [email protected]:
= Background =
In my country there is a standard statement file format used by all banks.
The file is exported from the banking systems. User is free to choose the
date/time period of transactions. Exported file includes one statement per
currency. Number of statements can vary in the file, as it depends on the
number of currencies used in the selected period of transactions.
File format specifies the field for party on the transaction, but there are
many cases (depends on bank and/or payment method) when party can only be
detected from the description of transaction.
= Changes to blueprint =
I suggest to use a new model `account.statement.import` instead of
`imported_attachment` (or binary field) on `account.statement`.
== account.statement.import ==
* `time`: datetime (default current datetime). It could be used to mark
the end period of exported transactions (timestamp which was selected on
the banking system).
* `file_format`: selection
* `file`: binary
* `lines`: one2many with `account.statement.import.line`. (list widget
would include these columns: date, description, statement?,
statement_journal and/or currency, amount, is_duplicate)
Each module which implements a specific file format must add the
_formatname_ to `file_format` and implement a method
_import_file_*formatname*_. It returns a list of instances of
`account.statement.import`.
== account.statement.import.line ==
* `date`: date
* `description`: text
* `amount`: decimal
* `statement_journal`: many2one with `account.journal.statement`
* `attributes`: one2many with `account.statement.import.line.attribute`
* `statement_lines`: one2many with `account.statement.line`
* ~~`state`~~: i think it is not needed
* `duplicates`: function, type *2many with `account.statement.import.line`
* `valid_duplicate`: boolean
The class has a generic method to detect duplicates using attributes: `def
detect_duplicate(cls, key)`, where `key` can be a string or list. It
returns a list of duplicated `account.statement.import.line`.
The function field `duplicates` calls (indirectly)
_get_duplicates_*formatname*_ method, which is implemented by the file
format module. In many cases it will be enough to use `detect_duplicate`
with correct key on these methods. If detection of duplicates is more
complex, _get_duplicates_*formatname*_ can implement it's own detection.
Party and Invoice detection must be implemented by file format module, but
it would be nice to have some generic mechanism/helpers to make this task
easier.
== account.statement.import.line.attribute ==
* `line`: many2one with `account.statement.import.line`
* `name`: char
* `value`: text
= Nice things to have =
It would be great if party and invoice could be added (reconciled) on the
confirmed statement.
For more information:
http://code.google.com/p/tryton/wiki/StatementImport