endi.compute.sage package¶
Submodules¶
endi.compute.sage.base module¶
Computing tools for sage import/export
Main use:
for a given export (e.g : expense) we’ve got export modules (some mandatory, others optionnal) we build a SageExpenseBase that build the columns common to all exported lines we inherit from that for each module we build a ExpenseExport class that will connect all modules, provide public methods and yield the book lines
- class endi.compute.sage.base.BaseSageBookEntryFactory(context, request)¶
Bases :
objectBase Sage Book Entry factory : we find the main function used by export modules
- config_key_prefix = ''¶
- get_base_entry()¶
Return an entry with common parameters
- get_contribution() float¶
Return the contribution for the current invoice, the company’s one or the cae’s one by default
- get_contribution_module() CustomInvoiceBookEntryModule¶
Return the CustomInvoiceBookEntryModule used for the export of contribution
- get_part() float¶
Collect the part for pre-defined accounting bookentries export modules (RG Intere, RG externe)
- static_columns = ()¶
- property type_¶
Return A for “Analytic” book entry
- exception endi.compute.sage.base.MissingData¶
Bases :
ExceptionRaised when no data was retrieved from a lazy relationship If an element has an attribute that should point to another model, and that this model doesn’t exist anymore, we raise this exception.
- class endi.compute.sage.base.VoidProducer(context, request)¶
Bases :
object- get_book_entries(supplier_invoices)¶
Return book entries for the given supplier invoices
- Paramètres:
supplier_invoices (list) – SupplierInvoice objects
- Results:
A list
- get_item_book_entries(supplier_invoice)¶
- endi.compute.sage.base.double_lines(method)¶
Wrap a book entry generator by duplicating the analytic book entry as a general one
endi.compute.sage.expense module¶
- class endi.compute.sage.expense.BaseSageExpenseContribution(*args, **kwargs)¶
Bases :
BaseSageBookEntryFactoryBase contribution line generator used for expenses
- yield_contribution_entries(amount, **kwargs)¶
- class endi.compute.sage.expense.ExpenseExportProducer(context, request)¶
Bases :
objectExport an expense to a Sage
- get_book_entries(expenses, category=None)¶
Return the book entries for an expenselist
- get_item_book_entries(expenses, category=None)¶
- use_analytic = True¶
- use_general = True¶
- class endi.compute.sage.expense.SageExpenseBase(*args, **kwargs)¶
Bases :
BaseSageExpenseContribution- property code_journal¶
- property company_name¶
- property date¶
- get_line_libelle(expenseline: BaseExpenseLine) str¶
Libelle, but for ungroupped exports
- property libelle¶
- property num_analytique¶
- property num_endi¶
- property num_feuille¶
- set_expense(expense: ExpenseSheet)¶
- static_columns = ('code_journal', 'num_feuille', 'type_', 'num_endi', 'num_analytique', 'user_name', 'company_name')¶
- property user_name¶
- variable_columns = ('compte_cg', 'compte_tiers', 'code_tva', 'debit', 'credit', 'libelle', 'date')¶
- class endi.compute.sage.expense.SageExpenseMain(*args, **kwargs)¶
Bases :
SageExpenseBaseMain module for expense export to sage. Should be the only module, but we keep more or less the same structure as for invoice exports
- set_category(category)¶
endi.compute.sage.expense_payment module¶
- class endi.compute.sage.expense_payment.ExpensePaymentExportProducer(context, request)¶
Bases :
object- get_book_entries(payments)¶
Return book entries for the given payments
- Paramètres:
payments (list) – ExpensePayment objects
- Results:
A list of book entries
- get_item_book_entries(payment)¶
- get_modules(expense_payment)¶
Retrieve the modules to use regarding the payment to export
- Paramètres:
expense_payment (obj) – A ExpensePayment object
- Results:
The module to use
- Type renvoyé:
- main_module_factory¶
alias de
SageExpensePaymentMain
- use_analytic = True¶
- use_general = True¶
- waiver_module_factory¶
alias de
SageExpensePaymentWaiver
- class endi.compute.sage.expense_payment.SageExpensePaymentMain(context, request)¶
Bases :
BaseSageBookEntryFactory- property code_journal¶
- property code_taxe¶
- credit_bank(*args, **kwargs)¶
Return two entries from one
- property date¶
- debit_user(*args, **kwargs)¶
Return two entries from one
- property libelle¶
- property mode¶
- property num_analytique¶
- property reference¶
- set_payment(payment)¶
- static_columns = ('reference', 'code_journal', 'date', 'mode', 'libelle', 'type_', 'num_analytique', 'code_taxe')¶
- variable_columns = ('compte_cg', 'compte_tiers', 'debit', 'credit')¶
- yield_entries()¶
endi.compute.sage.invoice module¶
- class endi.compute.sage.invoice.BaseInvoiceBookEntryFactory(context, request)¶
Bases :
BaseSageBookEntryFactoryBase Sage Export module
- property code_journal¶
Return the code of the destination journal from the treasury book
- property company_name¶
- property customer_label¶
- property date¶
Return the date field
- property libelle¶
Return the label for our book entry
- property num_endi¶
Return the invoice number
- set_invoice(wrapped_invoice)¶
Set the current invoice to process
- static_columns = ('code_journal', 'date', 'num_endi', 'libelle', 'type_', 'customer_label', 'company_name', 'task_name')¶
- property task_name¶
- variable_columns = ('compte_cg', 'num_analytique', 'compte_tiers', 'code_tva', 'echeance', 'debit', 'credit')¶
- class endi.compute.sage.invoice.CustomBookEntryFactory(context, request, module_config)¶
Bases :
BaseInvoiceBookEntryFactoryA custom book entry module used to produce entries
- credit_cae(*args, **kwargs)¶
Return two entries from one
- credit_company(*args, **kwargs)¶
Return two entries from one
- debit_cae(*args, **kwargs)¶
Return two entries from one
- debit_company(*args, **kwargs)¶
Return two entries from one
- get_amount()¶
Return the amount for the current module (the same for credit or debit)
- get_part()¶
Collect the percentage to apply on this custom module
- yield_entries()¶
yield book entries
- class endi.compute.sage.invoice.InternalCustomBookEntryFactory(context, request, module_config)¶
Bases :
CustomBookEntryFactory- config_key_prefix = 'internal'¶
- class endi.compute.sage.invoice.InternalInvoiceExportProducer(context, request)¶
Bases :
InvoiceExportProducer
- class endi.compute.sage.invoice.InternalSageFacturation(context, request)¶
Bases :
SageFacturation- config_key_prefix = 'internal'¶
- class endi.compute.sage.invoice.InvoiceExportGroupper¶
Bases :
objectGroup export lines of an invoice
This groupper must be applied only to the lines of a single invoice at once.
Can do the following grouping
# Group customer (typically 411*) lines of an invoice into one
This grouping is toggled by this setting :
bookentry_sales_group_customer_entries config setting.
It relies on following fields on line item:
_mark_customer_debit=True
num_endi
- class endi.compute.sage.invoice.InvoiceExportProducer(context, request)¶
Bases :
objectbase module for treasury export @param config: application configuration dict, contains all the CAE wide account configurations
- get_book_entries(invoicelist)¶
Return the book entries for a list of invoices
- get_item_book_entries(invoice)¶
Return book entries for a single invoice
- Paramètres:
invoice (obj) – Invoice/CancelInvoice object
- Renvoie:
List of invoice book entries as lines of values
- Type renvoyé:
- use_analytic = True¶
- use_general = True¶
- class endi.compute.sage.invoice.SageFacturation(context, request)¶
Bases :
BaseInvoiceBookEntryFactoryFacturation treasury export module implements IMainInvoiceTreasury
- For each product exports exportsthree types of treasury lines
Crédit TotalHT
Crédit TVA
Débit TTC
Expenses and discounts are also exported
- Uses :
Numéro analytique de l’enseigne Compte CG produit Compte CG TVA Compte CG de l’enseigne Compte Tiers du client Code TVA
Compte CG Annexe Compte CG RRR
- Columns :
Num facture
Date
Compte CG
Numéro analytique
Compte Tiers
Code TVA
Date d’échéance
Libellés
Montant
Works together with InvoiceExportGroupper for line grouping
- credit_totalht(*args, **kwargs)¶
Return two entries from one
- credit_tva(*args, **kwargs)¶
Return two entries from one
- debit_ttc(*args, **kwargs)¶
Return two entries from one
- property num_analytique¶
Return the analytic number common to all entries in the current export module
- yield_entries()¶
Produce all the entries for the current task
- class endi.compute.sage.invoice.SageInvoice(invoice, config=None, default_tva=None)¶
Bases :
objectSage wrapper for invoices 1- Peupler les produits
- Un produit doit avoir:
TVA
HT
Compte CG Produit
Compte CG TVA
(Code TVA)
- Pour chaque ligne :
créer produit ou ajouter au produit existant
- Pour chaque ligne de remise:
créer produit ou ajouter au produit existant
- Si dépense HT ou dépense TTC:
créer produit
- expense_tva_code = None¶
- expense_tva_compte_cg = None¶
- get_product(key, compte_cg_produit, compte_cg_tva, code_tva, tva_val)¶
Return the product dict belonging to the key « compte_cg_produit »
- populate()¶
populate the products entries with the current invoice
- class endi.compute.sage.invoice.SageRGClient(context, request)¶
Bases :
BaseInvoiceBookEntryFactoryThe Rg client module
- credit_company(*args, **kwargs)¶
Return two entries from one
- debit_company(*args, **kwargs)¶
Return two entries from one
- get_amount(product)¶
Return the amount for the current module (the same for credit or debit)
- get_echeance()¶
Return the value for the « echeance » column now + 365 days
- yield_entries()¶
yield book entries
- class endi.compute.sage.invoice.SageRGInterne(context, request)¶
Bases :
BaseInvoiceBookEntryFactoryThe RGINterne module
- credit_cae(*args, **kwargs)¶
Return two entries from one
- credit_company(*args, **kwargs)¶
Return two entries from one
- debit_cae(*args, **kwargs)¶
Return two entries from one
- debit_company(*args, **kwargs)¶
Return two entries from one
- get_amount(product)¶
Return the amount for the current module (the same for credit or debit)
- yield_entries()¶
yield book entries
endi.compute.sage.payment module¶
- class endi.compute.sage.payment.InternalPaymentExportProducer(context, request)¶
Bases :
PaymentExportProducer
- class endi.compute.sage.payment.InternalSagePaymentMain(context, request)¶
Bases :
SagePaymentMain- property code_journal¶
- config_key_prefix = 'internal'¶
- property mode¶
- property reference¶
- class endi.compute.sage.payment.PaymentExportGroupper(context, request)¶
Bases :
objectGroup accounting operations of payment exports
Operations produced by the ExportProducer add some hidden columns : - _bank_remittance_id - _mark_debit_banque
Operations are grouped following one of the strategies described here under
One general operation will cumulate all data attached to a same bank_remittance
In the second strategy, analytical operations cumulate all data attached to the same bank remittance and the same company
Requirements :
This exporter only supports operations generated by a producer using both analytic and general operations. Other producers (external libraries) may not be compatible with this one
- GROUPING_STRATEGY_KEYS = {'remittance_id': ('type_', '_bank_remittance_id'), 'remittance_id+code_analytique': ('type_', '_bank_remittance_id', 'num_analytique')}¶
- class endi.compute.sage.payment.PaymentExportProducer(context, request)¶
Bases :
objectExport entries following the given path :
Invoices -> Invoice -> Payments -> Payment
- get_item_book_entries(payment)¶
Return the receipts entries for the given payment
- use_analytic = True¶
- use_general = True¶
- class endi.compute.sage.payment.SagePaymentBase(context, request)¶
Bases :
BaseSageBookEntryFactory- property code_journal¶
- property company_name¶
- property customer_label¶
- property date¶
- property libelle¶
- property mode¶
- property num_analytique¶
Return the analytic number common to all entries in the current export module
- property reference¶
- set_payment(payment)¶
- static_columns = ('reference', 'code_journal', 'date', 'mode', 'libelle', 'type_', 'num_analytique', '_mark_debit_banque', '_bank_remittance_id', 'customer_label', 'company_name', 'task_name')¶
- property task_name¶
- variable_columns = ('compte_cg', 'compte_tiers', 'code_taxe', 'debit', 'credit')¶
- class endi.compute.sage.payment.SagePaymentMain(context, request)¶
Bases :
SagePaymentBaseMain module for payment export
- credit_client(*args, **kwargs)¶
Return two entries from one
- debit_banque(*args, **kwargs)¶
Return two entries from one
- yield_entries()¶
- class endi.compute.sage.payment.SagePaymentRemittance(context, request)¶
Bases :
SagePaymentBaseOptionnal remittance module
Write metadata (libelle/reference) about remittance instead of payment
Export remittance informations instead of payments info Works together with PaymentExportGroupper for grouping
- debit_banque(*args, **kwargs)¶
Return two entries from one
- yield_entries()¶
- class endi.compute.sage.payment.SagePaymentTva(context, request)¶
Bases :
SagePaymentBaseOptionnal Tva module
- credit_tva(*args, **kwargs)¶
Return two entries from one
- debit_tva(*args, **kwargs)¶
Return two entries from one
- get_amount()¶
Returns the reversed tva amount
- yield_entries()¶
Yield all the entries for the current payment
endi.compute.sage.supplier_invoice module¶
- class endi.compute.sage.supplier_invoice.InternalSageSupplierInvoiceMain(*args, **kwargs)¶
Bases :
SageSupplierInvoiceMain- config_key_prefix = 'internal'¶
- class endi.compute.sage.supplier_invoice.InternalSupplierInvoiceExportProducer(context, request)¶
Bases :
SupplierInvoiceExportProducer- config_key_prefix = 'internal'¶
- class endi.compute.sage.supplier_invoice.SageSupplierInvoice(supplier_invoice, config=None)¶
Bases :
object- is_grouped()¶
- populate()¶
- class endi.compute.sage.supplier_invoice.SageSupplierInvoiceBase(*args, **kwargs)¶
Bases :
BaseSageExpenseContribution- property code_journal¶
- property company_name¶
- property date¶
- property num_analytique¶
- property num_endi¶
- set_supplier_invoice(wrapped_supplier_invoice)¶
- static_columns = ('code_journal', 'date', 'type_', 'num_endi', 'supplier_label', 'company_name', 'user_name', 'num_analytique')¶
- property supplier_label¶
- property user_name¶
- variable_columns = ('compte_cg', 'compte_tiers', 'code_tva', 'debit', 'credit', 'libelle')¶
- class endi.compute.sage.supplier_invoice.SageSupplierInvoiceMain(*args, **kwargs)¶
Bases :
SageSupplierInvoiceBaseMain module for supplier_invoice export to sage.
Exports :
supplier product lines
contribution lines
Lines can be grouped by expense type if the ungroup_supplier_invoices_export is not checked
- yield_entries()¶
Yield all the book entries for the current supplier invoice
- class endi.compute.sage.supplier_invoice.SupplierInvoiceExportProducer(context, request)¶
Bases :
objectExport a supplier invoice to Sage
- get_book_entries(supplier_invoices)¶
Return the book entries for an supplier_invoicelist
- get_item_book_entries(supplier_invoices)¶
- use_analytic = True¶
- use_general = True¶
endi.compute.sage.supplier_invoice_payment module¶
- class endi.compute.sage.supplier_invoice_payment.BaseSageSupplierPayment(context, request)¶
Bases :
BaseSageBookEntryFactoryBase commune aux paiements de la part CAE et pars ES.
(qui sont exportés conjointement)
- property code_journal¶
- property code_taxe¶
- property company_name¶
- property date¶
- property mode¶
- property num_analytique¶
- property num_endi¶
- property reference¶
- set_payment(payment)¶
- static_columns = ('num_endi', 'code_journal', 'date', 'mode', 'libelle', 'type_', 'num_analytique', 'code_taxe', 'reference', 'supplier_label', 'company_name', 'user_name')¶
- property supplier_label¶
- property user_name¶
- variable_columns = ('compte_cg', 'compte_tiers', 'debit', 'credit')¶
- class endi.compute.sage.supplier_invoice_payment.BaseSupplierPaymentExport(context, request)¶
Bases :
object- get_book_entries(supplier_payments)¶
Return book entries for the given supplier invoice payments
- Paramètres:
supplier_payments (list) – BaseSupplierPayment objects
- Results:
A list of book entries
- get_item_book_entries(supplier_payment)¶
- get_modules(payment)¶
- main_module = None¶
- use_analytic = True¶
- use_general = True¶
- waiver_module = None¶
- class endi.compute.sage.supplier_invoice_payment.InternalSageSupplierPaymentMain(context, request)¶
Bases :
SageSupplierPaymentMain- property code_journal¶
- config_key_prefix = 'internal'¶
- property mode¶
- property reference¶
- class endi.compute.sage.supplier_invoice_payment.InternalSupplierPaymentExportProducer(context, request)¶
Bases :
BaseSupplierPaymentExport- main_module¶
alias de
InternalSageSupplierPaymentMain
- class endi.compute.sage.supplier_invoice_payment.SageSupplierPaymentMain(context, request)¶
Bases :
BaseSageSupplierPaymentFacture fournisseur, paiements fournisseur
- credit_bank(*args, **kwargs)¶
Return two entries from one
- debit_supplier(*args, **kwargs)¶
Return two entries from one
- property libelle¶
- yield_entries()¶
- class endi.compute.sage.supplier_invoice_payment.SageSupplierUserPaymentMain(context, request)¶
Bases :
BaseSageSupplierPaymentFacture fournisseur, remboursement à l’ES de sa part avancée
- credit_bank(*args, **kwargs)¶
Return two entries from one
- debit_user(*args, **kwargs)¶
Return two entries from one
- property libelle¶
- yield_entries()¶
- class endi.compute.sage.supplier_invoice_payment.SageSupplierUserPaymentWaiver(context, request)¶
Bases :
SageSupplierUserPaymentMain- property code_journal¶
- property code_taxe¶
- credit_bank(*args, **kwargs)¶
Return two entries from one
- property mode¶
- class endi.compute.sage.supplier_invoice_payment.SupplierPaymentExportProducer(context, request)¶
Bases :
BaseSupplierPaymentExport- main_module¶
alias de
SageSupplierPaymentMain
- class endi.compute.sage.supplier_invoice_payment.SupplierUserPaymentExportProducer(context, request)¶
Bases :
BaseSupplierPaymentExport- main_module¶
alias de
SageSupplierUserPaymentMain
- waiver_module¶
alias de
SageSupplierUserPaymentWaiver
endi.compute.sage.utils module¶
- endi.compute.sage.utils.add_entries_amounts(entry1: dict, entry2: dict) Tuple[int, int]¶
We consider than either debit or credit is set on each entry.
Sum two book entries, and returns either a debit or a credit.
- endi.compute.sage.utils.fix_sage_ordering(items: Iterable[dict]) Iterable[dict]¶
Ensure the line ordering of an export suits sage.
For that, make sure each G-line is followed by all its matching A-line(s).
Requirements: - Each A-line is anotated with a “_general_counterpart” key containing its general row. - if two A-line got groupped, their G-lines should have been grouped together also
Considerations: - slicing/insertion with large python lists costs O(n), so we try avoiding it.
The algorithm consists into two passes, one to detect orphans, and one to all items (incl. orphans) in the right order.