endi.views.export package

Submodules

endi.views.export.bpf module

class endi.views.export.bpf.BPFExportView(*args, **kwargs)

Bases : BaseExportView

before()

Launched before anything is done

check(query)

Check items are valid for export

Paramètres:

items (obj) – A Sqlalchemy query

Renvoie:

a 2-uple (valid, messages_dict) where messages_dict is in the form {“title”: A message block title, « errors »: [error messages]}

dbsession: DBSESSION
generate_bpf_ods(bpf_data_query, invoicing_year)
get_forms()
Renvoie:

the forms to be rendered in the form {formname: {“title”: A title, “form”: “The form object”}}

Type renvoyé:

dict or OrderedDict

produce_file_and_record(items, form_name, appstruct)

Fonction en charge de produire le fichier de sortie

Par défaut, on enregistre également l’historique et on enregistre le statut « exporté »

query(query_params_dict, form_name)
Paramètres:
  • appstruct (dict) – The validated form datas

  • form_name (str) – The name of the form that was submitted

Renvoie:

a Sqlalchemy query collecting items to be exported

request: Request
session: ISession
title = 'Export du Bilan Pédagogique de Formation (BPF)'
endi.views.export.bpf.includeme(config)

endi.views.export.expense module

class endi.views.export.expense.SageExpenseExportPage(*args, **kwargs)

Bases : BaseExportView

Sage Expense export views

before()

Launched before anything is done

check(expenses)

Check if we can export the expenses

Paramètres:

expenses – the expenses to export

Renvoie:

a 2-uple (is_ok, messages)

config_keys = ('compte_cg_ndf', 'code_journal_ndf')
dbsession: DBSESSION
get_filename(writer)
get_forms()

Implement parent get_forms method

query(appstruct, form_name)

Base Query for expenses :param appstruct: params passed in the query for expense export :param str form_name: The submitted form’s name

record_export(expenses, form_name, appstruct, export_file)

Record in the log the export that has just been done

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

Renvoie:

A response object

record_exported(expenses, form_name, appstruct)

Tag the exported expenses

Paramètres:

expenses – The expenses we are exporting

request: Request
session: ISession
title = 'Export des écritures des notes de dépenses'
writer_interface = <InterfaceClass endi.interfaces.ITreasuryExpenseWriter>
endi.views.export.expense.add_routes(config)
endi.views.export.expense.add_views(config)
endi.views.export.expense.includeme(config)

endi.views.export.expense_payment module

class endi.views.export.expense_payment.ExpensePaymentExportPage(*args, **kwargs)

Bases : SingleExpensePaymentExportPage

Provide an expense payment export page

dbsession: DBSESSION
get_forms()

Implement parent get_forms method

query(query_params_dict, form_name)

Retrieve the exports we want to export

request: Request
session: ISession
property title
validate_form(forms)

Validate a submitted form if needed

class endi.views.export.expense_payment.SingleExpensePaymentExportPage(*args, **kwargs)

Bases : BaseExportView

Provide an expense payment export page for a single expense payment

admin_route_name = '/admin/expenses/payment_accounting'
before()

Launched before anything is done

check(payments)

Check that the given expense_payments can be exported

Paramètres:

payments (obj) – A SQLA query of ExpensePayment objects

dbsession: DBSESSION
get_filename(writer)
query(appstruct, form_name)
Paramètres:
  • appstruct (dict) – The validated form datas

  • form_name (str) – The name of the form that was submitted

Renvoie:

a Sqlalchemy query collecting items to be exported

record_export(expense_payments, form_name, appstruct, export_file)

Record in the log the export that has just been done

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

Renvoie:

A response object

record_exported(payments, form_name, appstruct)

Record that those payments have already been exported

request: Request
session: ISession
property title
validate_form(forms)

Validate a submitted form if needed

writer_interface = <InterfaceClass endi.interfaces.ITreasuryExpensePaymentWriter>
endi.views.export.expense_payment.add_routes(config)
endi.views.export.expense_payment.add_views(config)
endi.views.export.expense_payment.includeme(config)

endi.views.export.invoice module

Invoice related exports views

class endi.views.export.invoice.SageInvoiceExportPage(*args, **kwargs)

Bases : SageSingleInvoiceExportPage

Provide a sage export view compound of :
  • a form for date to date invoice exports

  • a form for number to number invoice export

check_num_invoices(invoices)

Return the number of invoices to export

dbsession: DBSESSION
get_forms()

Return the different invoice search forms

populate_action_menu()

Add a back button to the action menu

query(query_params_dict, form_name)
Paramètres:
  • appstruct (dict) – The validated form datas

  • form_name (str) – The name of the form that was submitted

Renvoie:

a Sqlalchemy query collecting items to be exported

request: Request
session: ISession
property title
validate_form(forms)

Return a a void form name and an appstruct so processing goes on

class endi.views.export.invoice.SageSingleInvoiceExportPage(*args, **kwargs)

Bases : BaseExportView

Single invoice export page

admin_route_name = '/admin/sales/accounting'
before()

Launched before anything is done

check(invoices)

Check that the given invoices are “exportable”

check_num_invoices(invoices)

Return the number of invoices to export

dbsession: DBSESSION
get_filename(writer)
populate_action_menu()

Add a back button to the action menu

query(appstruct, formname)
Paramètres:
  • appstruct (dict) – The validated form datas

  • form_name (str) – The name of the form that was submitted

Renvoie:

a Sqlalchemy query collecting items to be exported

record_export(invoices, form_name, appstruct, export_file)

Record in the log the export that has just been done

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

Renvoie:

A response object

record_exported(invoices, form_name, appstruct)

Record exported elements in the database

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

request: Request
session: ISession
property title
validate_form(forms)

Return a a void form name and an appstruct so processing goes on

writer_interface = <InterfaceClass endi.interfaces.ITreasuryInvoiceWriter>
endi.views.export.invoice.add_routes(config)
endi.views.export.invoice.add_views(config)
endi.views.export.invoice.includeme(config)

endi.views.export.log_list module

Export log list view

class endi.views.export.log_list.BaseExportLogListView(*args, **kwargs)

Bases : BaseListView

Export log listing view

dbsession: DBSESSION
default_direction = 'desc'
default_sort = 'datetime'
filter_date(query, appstruct)
filter_export_type(query, appstruct)
filter_user_id(query, appstruct)
query()

The main query, should be overrided by a subclass

request: Request
schema = <endi.forms.export.AccountingExportLogEntryListSchema object at 140624107360656 (named )>
session: ISession
sort_columns = {'datetime': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'export_type': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'user_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
title = 'Historique des exports comptables'
endi.views.export.log_list.includeme(config)

endi.views.export.payment module

class endi.views.export.payment.PaymentExportPage(*args, **kwargs)

Bases : SinglePaymentExportPage

Provide a sage export view compound of multiple forms for payment exports

before()

Launched before anything is done

dbsession: DBSESSION
get_forms()

Return the different payment search forms

query(query_params_dict, form_name)
Paramètres:
  • appstruct (dict) – The validated form datas

  • form_name (str) – The name of the form that was submitted

Renvoie:

a Sqlalchemy query collecting items to be exported

request: Request
session: ISession
property title
validate_form(forms)

Validate a submitted form if needed

class endi.views.export.payment.SinglePaymentExportPage(*args, **kwargs)

Bases : BaseExportView

View used to export a single payment

admin_route_name = '/admin/sales/receipts'
before()

Launched before anything is done

check(payments)

Check that the given payments are “exportable” :param obj payments: a SQLA query of BaseTaskPayments

dbsession: DBSESSION
get_filename(writer)
query(appstruct, formname)
Paramètres:
  • appstruct (dict) – The validated form datas

  • form_name (str) – The name of the form that was submitted

Renvoie:

a Sqlalchemy query collecting items to be exported

record_export(payments, form_name, appstruct, export_file)

Record in the log the export that has just been done

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

Renvoie:

A response object

record_exported(payments, form_name, appstruct)

Record exported elements in the database

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

request: Request
session: ISession
property title
validate_form(forms)

Validate a submitted form if needed

writer_interface = <InterfaceClass endi.interfaces.ITreasuryPaymentWriter>
endi.views.export.payment.add_routes(config)
endi.views.export.payment.add_views(config)
endi.views.export.payment.includeme(config)

endi.views.export.routes module

endi.views.export.routes.includeme(config)

endi.views.export.supplier_invoice module

class endi.views.export.supplier_invoice.SageSupplierInvoiceExportPage(*args, **kwargs)

Bases : BaseExportView

Sage SupplierInvoice export views

before()

Launched before anything is done

check(supplier_invoices)

Check if we can export the supplier_invoices

Paramètres:

supplier_invoices – the supplier_invoices to export

Renvoie:

a 2-uple (is_ok, messages)

config_keys = ('code_journal_frns', 'internalcode_journal_frns')
dbsession: DBSESSION
get_filename(writer)
get_forms()

Implement parent get_forms method

query(appstruct, form_name)

Base Query for supplier invoices :param appstruct: params passed in the query for the export :param str form_name: The submitted form’s name

record_export(supplier_invoices, form_name, appstruct, export_file)

Record in the log the export that has just been done

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

Renvoie:

A response object

record_exported(supplier_invoices, form_name, appstruct)

Tag the exported supplier_invoices

Paramètres:

supplier_invoices – The supplier_invoices we are exporting

request: Request
session: ISession
title = 'Export des écritures des factures fournisseurs'
writer_interface = <InterfaceClass endi.interfaces.ITreasurySupplierInvoiceWriter>
endi.views.export.supplier_invoice.add_routes(config)
endi.views.export.supplier_invoice.add_views(config)
endi.views.export.supplier_invoice.includeme(config)

endi.views.export.supplier_payment module

class endi.views.export.supplier_payment.SingleSupplierPaymentExportPage(*args, **kwargs)

Bases : BaseExportView

before()

Launched before anything is done

check(supplier_payments)

Check that the given supplier_payments can be exported

Paramètres:

supplier_payments (obj) – A SQLA query of

SupplierInvoiceSupplierPayment objects

dbsession: DBSESSION
get_filename(writer)
query(query_params_dict, form_name)

Retrieve the exports we want to export

record_export(supplier_payments, form_name, appstruct, export_file)

Record in the log the export that has just been done

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

Renvoie:

A response object

record_exported(supplier_payments, form_name, appstruct)

Record that those supplier_payments have already been exported

request: Request
session: ISession
validate_form(forms)

Validate a submitted form if needed

writer_interface = <InterfaceClass endi.interfaces.ITreasurySupplierPaymentWriter>
class endi.views.export.supplier_payment.SupplierPaymentExportPage(*args, **kwargs)

Bases : SingleSupplierPaymentExportPage

Provide a supplier payment export page

dbsession: DBSESSION
get_forms()

Implement parent get_forms method

query(query_params_dict, form_name)

Retrieve the exports we want to export

request: Request
session: ISession
title = 'Export des écritures des paiements des factures fournisseurs'
validate_form(forms)

Validate a submitted form if needed

endi.views.export.supplier_payment.add_routes(config)
endi.views.export.supplier_payment.add_views(config)
endi.views.export.supplier_payment.includeme(config)

endi.views.export.utils module

endi.views.export.utils.find_task_status_date(official_number: str, year: Optional[int] = None)

Query the database to retrieve a task with the given number and year and returns its status_date

Paramètres:
  • official_number (str) – The official number

  • year (int) – The financial year associated to the invoice

Renvoie:

The document’s status_date

Type renvoyé:

datetime.dateime

endi.views.export.utils.format_export_type(db_export_type)
endi.views.export.utils.get_bpf_year_form(request, title, prefix='bpf')
Paramètres:

request (obj) – Pyramid request object

Type renvoyé:

deform.Form

Renvoie:

a form for bpf export (agregate of BusinessBPFData)

endi.views.export.utils.get_expense_all_form(request, counter, title='Exporter les dépenses non exportées', prefix='')

Return a void form used to export all non-exported documents

Paramètres:

counter (obj) – An iterator used for form id generation

endi.views.export.utils.get_expense_form(request, counter, title, prefix='expense')

Return a form for expense export :param obj request: Pyramid request object :returns: class:deform.Form

endi.views.export.utils.get_expense_number_form(request, counter, title, prefix='expense')

Return a form for expense export by official number :param counter: the iterator used to insert various forms in the same page

endi.views.export.utils.get_expense_payment_all_form(request, counter)

Return a void form used to export all non-exported documents

Paramètres:

counter (obj) – An iterator used for form id generation

endi.views.export.utils.get_expense_payment_period_form(request)

Return the period search form

endi.views.export.utils.get_invoice_all_form(request)

Return a void form used to export all non-exported documents

endi.views.export.utils.get_invoice_number_form(request, counter, title="Exporter les factures à partir d'un numéro")

Return the search form used to search invoices by number+year

endi.views.export.utils.get_invoice_period_form(request, counter, title='Exporter les factures sur une période donnée')

Return the period search form

Paramètres:

counter (obj) – An iterator used for form id generation

endi.views.export.utils.get_payment_all_form(request)

Return a void form used to export all non-exported documents

endi.views.export.utils.get_payment_period_form(request, counter)

Return the period search form

Paramètres:

counter (obj) – An iterator used for form id generation

endi.views.export.utils.get_supplier_invoice_all_form(request)

Return a void form used to export all non-exported supplier invoices

Paramètres:

counter (obj) – An iterator used for form id generation

endi.views.export.utils.get_supplier_invoice_form(request, counter)

Return a form for supplier invoice export :param obj request: Pyramid request object :returns: class:deform.Form

endi.views.export.utils.get_supplier_invoice_number_form(request, counter, title)

Return a form for supplier invoice export by official_number :param counter: the iterator used to insert various forms in the same page

endi.views.export.utils.get_supplier_invoice_period_form(request, counter)

Return a form used to export supplier invoices from date to date :param obj counter: An iterator used for form id generation

endi.views.export.utils.get_supplier_payment_all_form(request)

Return a void form used to export all non-exported documents

endi.views.export.utils.get_supplier_payment_number_form(request, counter)

Return a form for supplier invoice export by official_number :param counter: the iterator used to insert various forms in the same page

endi.views.export.utils.get_supplier_payment_period_form(request, counter)
Paramètres:

counter (obj) – An iterator used for form id generation

endi.views.export.utils.query_invoices_for_export(start_number=None, end_number=None, year=None, start_date=None, end_date=None, **kwargs)

Build a query to get a range of tasks between two dates

start_number/end_number are converted to the associated task date

Paramètres:
  • start_number (str) – First invoice we want to export

  • end_number (str) – Last invoice we want to export

  • year (int) – The financial_year (for number export)

  • start_date (date) – The start_date for the export

  • end_date (date) – The end date for the export

  • kwargs (dict) – Dict of options passed to the Task.get_valid_invoices

query

Module contents

class endi.views.export.BaseExportView(*args, **kwargs)

Bases : BaseListView

Base export view Provide skeleton for export view development

  • Return forms

  • Validate form datas

  • Check elements can be exported

  • Return error messages

  • Return the generated file

admin_route_name = '/admin'
before()

Launched before anything is done

check(items)

Check items are valid for export

Paramètres:

items (obj) – A Sqlalchemy query

Renvoie:

a 2-uple (valid, messages_dict) where messages_dict is in the form {“title”: A message block title, « errors »: [error messages]}

dbsession: DBSESSION
get_filename(writer)
get_forms()
Renvoie:

the forms to be rendered in the form {formname: {“title”: A title, “form”: “The form object”}}

Type renvoyé:

dict or OrderedDict

get_preview_items(items, form_name, appstruct=None)

Return all the elements to be previewed

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

Renvoie:

A response object

get_writer()
help_message = None
produce_file_and_record(items, form_name, appstruct)

Fonction en charge de produire le fichier de sortie

Par défaut, on enregistre également l’historique et on enregistre le statut « exporté »

query(appstruct, form_name)
Paramètres:
  • appstruct (dict) – The validated form datas

  • form_name (str) – The name of the form that was submitted

Renvoie:

a Sqlalchemy query collecting items to be exported

record_export(items, form_name, appstruct, file_obj)

Record in the log the export that has just been done

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

Renvoie:

A response object

record_exported(items, form_name, appstruct)

Record exported elements in the database

Paramètres:
  • items (list) – the items to render

  • form_name (str) – The name of the form that was submitted

  • appstruct (dict) – The validated datas

request: Request
session: ISession
validate_form(forms) Tuple[Optional[str], Optional[dict]]

Validate a submitted form if needed

write_file(models: Iterable[object], form_name: str, appstruct: dict) Tuple[object, object]

Add a file to the request.response

Paramètres:
  • models – the items to render

  • form_name – The name of the form that was submitted

  • appstruct – The validated datas

Renvoie:

A tuple [file, response object]

writer_interface = None
endi.views.export.get_value_from_writer(writer: <InterfaceClass endi.interfaces.ITreasuryWriter>, operation_line) Iterator[tuple]

Compute values that will be written to the end file

Used by preview