controller module¶
pybill.lib.controller module defines the main controller of PyBill.
This controller knows how to read the XML accounting documents and how to
produce PDF, using the other classes that exist in the pybill.lib module.
-
class
pybill.lib.controller.PyBillController¶ Main controller that implements all the operations available in PyBill software.
This controller uses dedicated object for reading XML documents and producing PDF output.
-
config_register¶ Attribute that contains a config register object. This object has got a library of config files read in the various config directories and can give the config data used by a given accounting entity.
type:
ConfigRegister
-
accdoc_reader¶ Attribute that contains an XML reader object. This object can read an XML file containing an accounting document, build the corresponding entity and give the name of the config file used by this entity.
type:
AccDocXMLReader
-
pdf_writer¶ Attribute that contains a PDF writer object. This object can produce a PDF file rendering an accounting entity.
type:
PDFWriter
-
entries_generator¶ Attribute containing an entries generator object. This object can export accounting entries corresponding to accounting entities into an XML file. The XML file is compatible with pycompta software.
type:
EntriesGenerator
-
__init__()¶ Initializes a new
PyBillControllerobject.Builds the specialized objects that will be used during the operations.
-
build_entities_from_files(filenames, cfg_filename=None)¶ Builds the accounting entities from files containing XML data in PyBill Document formats (e.g. PBD-1.0).
The names of the files are given in
filenameslist. The method returns a list of couples (accounting entity, base of filename where the entity was read).Parameters: - filenames (list of
str) – List of the names (strings) of the files that contain accounting documents in XML PyBill formats (e.g. PBD-1.0). These documents will be read and stored as accounting entities (Billobjects, etc.) - cfg_filename (
str) – Name of a file containing a configuration in XML format. When specified, this configuration will be used for all the accouting entities read fromfilenamesfiles and will preempt any configuration specified in these files.
Returns: List of couples (accounting entity, base of filename where this entity was read from). The accounting entity was built from one of the file in
filenames. The base of filename is the name of this file without its extension.Return type: list of tuples (
GenericAccountingDoc,str)- filenames (list of
-
export_accounting_entries_to_xml_file(entities, filename, xml_encoding)¶ Builds accounting entries from the accounting entities and save them in an XML file.
For this method, the
entitieslist only consists in a list of accounting entities.Parameters: - entities (list of
GenericAccountingDoc) – List of accounting entities (e.g.Billobject). - filename (
str) – Name of the file where the XML accounting entries will be saved in. - xml_encoding (
str) – Encoding used for writing the XML file containing the accounting entries.
- entities (list of
-
save_entities_to_files(entities, xml_encoding)¶ Saves the accounting entities in some XML files in latest PyBill format (PBD-1.0).
Actually, the
entitieslist consists in a list of couples (accounting entity, name of the file where to save the XML document).If the file where the XML will be saved already exists, it is copied into a .old file before the XML is saved.
Parameters: - entities (list of tuples (
GenericAccountingDoc,str)) – List of couples composed of an accounting entity (e.g.Billobject) and the name of the file where the XML representation of this entity will be saved in. - xml_encoding (
str) – Encoding used for writing the XML files describing the accounting entities.
- entities (list of tuples (
-
write_pdf_to_files(entities)¶ Builds the PDF corresponding to accounting entities and saves them in files.
Actually, the
entitieslist consists in a list of couples (accounting entity, name of the file where to save the result of the PDF generation).Parameters: entities (list of tuples ( GenericAccountingDoc,str)) – List of couples composed of an accounting entity (e.g.Billobject) and the name of the file where the PDF produced for this entity will be saved in.
-