endi.models.task package

Subpackages

Submodules

endi.models.task.actions module

This module contains

  • Action managers handling status changes for Sale documents

  • Callbacks fired when the documents status are changed (official number,

remote internal document generation …)

endi.models.task.actions.estimation_valid_callback(request, task, **kw)

Estimation validation callback

Paramètres:
  • request (obj) – The current pyramid request

  • task (obj) – The current context

endi.models.task.actions.get_internalcancelinvoice_state_manager() ActionManager

Construit le state manager pour les avoirs internes

endi.models.task.actions.get_internalestimation_state_manager() ActionManager

Renvoie un state manager pour les devis internes

endi.models.task.actions.get_internalinvoice_state_manager() ActionManager

Construit le state manager pour les factures internes

endi.models.task.actions.get_signed_status_actions()

Return actions available for setting the signed_status attribute on Estimation objects

endi.models.task.actions.internalestimation_valid_callback(request, task, **kw)

InternalEstimation validation callback

Paramètres:
  • request (obj) – The current pyramid request

  • task (obj) – The current InternalEstimation

endi.models.task.actions.internalinvoice_valid_callback(request, task, **kw)

Invoice validation callback

Paramètres:
  • request (obj) – The current pyramid request

  • task (obj) – The current context

endi.models.task.actions.invoice_valid_callback(request, task, **kw)

Invoice validation callback

Paramètres:
  • request (obj) – The current pyramid request

  • task (obj) – The current context

endi.models.task.estimation module

The estimation model

class endi.models.task.estimation.Estimation(user, company, project, **kw)

Bases : Task

Estimation Model

add_default_payment_line()
address
all_lines
auto_validated
business
business_id
business_type
business_type_id
check_signed_status_allowed(status, request, **kw)
children
company
company_id
company_index
created_at
customer
customer_id
date
decimal_to_display
deposit
deposit_amount_ttc()
deposit_amounts_native()
description
discounts
display_ttc
display_units
end_date
estimation_computer = None
expenses
expenses_ht
exports
file_requirements
files
first_visit
frozen_settings
gen_business()

Generate a business based on this Task

Renvoie:

A new business instance

Type renvoyé:

endi.models.project.business.Business

gen_deposit_invoice(request, user)

Generate a deposit invoice based on the current estimation

Paramètres:

user (obj) – User instance, the user generating the document

Type renvoyé:

class:Invoice

gen_invoice(request, payment_line, user)

Generate an invoice based on a payment line

Paramètres:
  • payment_line (obj) – The payment line we ask an Invoice for

  • user (obj) – User instance, the user generating the document

Type renvoyé:

class:Invoice

geninv
get_nb_payment_lines()
property global_status

hook on status and paid status to update css classes representing icons :return: a String

ht
id
insurance
insurance_id
internal_number
invoices
legacy_number
line_groups
mandatory_mentions
manualDeliverables
manual_payment_line_amounts()
mentions
mode
name
notes
official_number
owner
owner_id
parent: Any
parent_id
paymentDisplay
payment_conditions
payment_lines
paymentline_amount_ttc()
paymentline_amounts_native()
payments
pdf_file
pdf_file_hash
pdf_file_id
phase
phase_id
post_ttc_lines
price_study
progress_invoicing_plan
project
project_id
project_index
round_floor
set_default_validity_duration()

Set last validity duration used by the company or CAE default config if none

set_signed_status(status, request, **kw)

set the signed status of a task through the state machine

signed_state_manager = <endi.models.action_manager.ActionManager object>
signed_status
sold()
start_date
status
status_comment
status_date
status_user
status_user_id
statuses
ttc
tva
type_
update_payment_lines(request, payment_times=None)
updated_at
validation_state_manager = <endi.models.action_manager.ActionManager object>
validation_status_history
validity_duration
workplace
class endi.models.task.estimation.PaymentLine(**kwargs)

Bases : Base

payments lines

amount
date
description
duplicate()

duplicate a paymentline

id
order
task
task_id
endi.models.task.estimation.get_estimation_years(kw=None)

Return a cached query for the years we have estimations configured

Paramètres:

kw – is here only for API compatibility

endi.models.task.insurance module

Modèle pour les assurances dans les devis et factures

class endi.models.task.insurance.TaskInsuranceOption(**kwargs)

Bases : ConfigurableOption

Insurance options

active
full_text
id
property is_used
label
order
rate
title
type_

endi.models.task.internalestimation module

class endi.models.task.internalestimation.InternalEstimation(user, company, project, **kw)

Bases : Estimation

address
all_lines
auto_validated
business
business_id
business_type
business_type_id
children
company
company_id
company_index
created_at
customer
customer_id
date
decimal_to_display
deposit
description
discounts
display_ttc
display_units
end_date
expenses
expenses_ht
exports
file_requirements
files
first_visit
frozen_settings
geninv
ht
id
insurance
insurance_id
internal = True
internal_number
invoices
legacy_number
line_groups
mandatory_mentions
manualDeliverables
mentions
mode
name
notes
official_number
owner
owner_id
parent: Any
parent_id
paymentDisplay
payment_conditions
payment_lines
payments
pdf_file
pdf_file_hash
pdf_file_id
phase
phase_id
post_ttc_lines
prefix = 'internal'
price_study
progress_invoicing_plan
project
project_id
project_index
round_floor
signed_status
start_date
status
status_comment
status_date
status_user
status_user_id
statuses
supplier_order
supplier_order_id
sync_with_customer(request)
ttc
tva
type_
updated_at
validation_state_manager = <endi.models.action_manager.ActionManager object>
validation_status_history
validity_duration
workplace

endi.models.task.internalinvoice module

class endi.models.task.internalinvoice.InternalCancelInvoice(user, company, project, **kw)

Bases : CancelInvoice

address
all_lines
auto_validated
business
business_id
business_type
business_type_id
children
company
company_id
company_index
created_at
customer
customer_id
date
decimal_to_display
description
discounts
display_ttc
display_units
end_date
expenses
expenses_ht
exported
exports
file_requirements
files
financial_year
first_visit
frozen_settings
ht
id
insurance
insurance_id
internal = True
internal_number
invoice
invoice_id
invoicing_mode
legacy_number
line_groups
mandatory_mentions
mentions
mode
name
notes
official_number
owner
owner_id
parent: Any
parent_id
payment_conditions
payments
pdf_file
pdf_file_hash
pdf_file_id
phase
phase_id
post_ttc_lines
prefix = 'internal'
price_study
progress_invoicing_plan
project
project_id
project_index
round_floor
start_date
status
status_comment
status_date
status_user
status_user_id
statuses
supplier_invoice
supplier_invoice_id
sync_with_customer(request)
ttc
tva
type_
updated_at
validation_state_manager = <endi.models.action_manager.ActionManager object>
validation_status_history
workplace
class endi.models.task.internalinvoice.InternalInvoice(user, company, project, **kw)

Bases : Invoice

address
all_lines
auto_validated
business
business_id
business_type
business_type_id
cancelinvoices
children
company
company_id
company_index
created_at
customer
customer_id
date
decimal_to_display
description
discounts
display_ttc
display_units
end_date
estimation
estimation_id
expenses
expenses_ht
exported
exports
file_requirements
files
financial_year
first_visit
frozen_settings
ht
id
insurance
insurance_id
internal = True
internal_number
invoice_computer = None
invoicing_mode
legacy_number
line_groups
mandatory_mentions
mentions
mode
name
notes
official_number
owner
owner_id
paid_status
parent: Any
parent_id
payment_conditions
payments
pdf_file
pdf_file_hash
pdf_file_id
phase
phase_id
post_ttc_lines
prefix = 'internal'
price_study
progress_invoicing_plan
project
project_id
project_index
round_floor
start_date
status
status_comment
status_date
status_user
status_user_id
statuses
supplier_invoice
supplier_invoice_id
sync_with_customer(request)
ttc
tva
type_
updated_at
urssaf_payment_request
valid_cancelinvoices
validation_state_manager = <endi.models.action_manager.ActionManager object>
validation_status_history
workplace

endi.models.task.internalpayment module

class endi.models.task.internalpayment.InternalPayment(**kwargs)

Bases : BaseTaskPayment

amount
created_at
date
exported
exports
id
internal = True
property mode
sync_with_customer(request, action, **kw)
task
task_id
tva
tva_id
type_
updated_at
user
user_id

endi.models.task.invoice module

Invoice model

class endi.models.task.invoice.CancelInvoice(user, company, project, **kw)

Bases : Task

CancelInvoice model Could also be called negative invoice

CLASSIC_MODE = 'classic'
PROGRESS_MODE = 'progress'
address
all_lines
auto_validated
business
business_id
business_type
business_type_id
children
company
company_id
company_index
created_at
customer
customer_id
date
decimal_to_display
description
discounts
display_ttc
display_units
end_date
expenses
expenses_ht
exported
exports
file_requirements
files
financial_year
first_visit
frozen_settings
property global_status

hook on status and paid status to update css classes representing icons :return: a Sting

ht
id
insurance
insurance_id
internal_number
invoice
invoice_id
invoicing_mode
is_tolate()

Return False

legacy_number
line_groups
mandatory_mentions
mentions
mode
name
notes
official_number
owner
owner_id
parent: Any
parent_id
payment_conditions
payments
pdf_file
pdf_file_hash
pdf_file_id
phase
phase_id
post_ttc_lines
price_study
progress_invoicing_plan
project
project_id
project_index
round_floor
start_date
status
status_comment
status_date
status_user
status_user_id
statuses
ttc
tva
type_
updated_at
validation_state_manager = <endi.models.action_manager.ActionManager object>
validation_status_history
workplace
class endi.models.task.invoice.Invoice(user, company, project, **kw)

Bases : Task

Invoice Model

CLASSIC_MODE = 'classic'
PROGRESS_MODE = 'progress'
address
all_lines
auto_validated
business
business_id
business_type
business_type_id
cancelinvoice_amount()
cancelinvoices
check_resulted(force_resulted=False)

Check if the invoice is resulted or not and set the appropriate status

children
company
company_id
company_index
compute_payments(payment_amount)
created_at
customer
customer_id
date
decimal_to_display
description
discounts
display_ttc
display_units
end_date
estimation
estimation_id
expenses
expenses_ht
exported
exports
file_requirements
files
financial_year
first_visit
frozen_settings
gen_cancelinvoice(request, user)

Return a cancel invoice with self’s informations

get_next_row_index()
property global_status

hook on status and paid status to update css classes representing icons :return: a Sting

historize_paid_status(user)

Records the current paid_status in history

Paramètres:

user – the user who just changed paid status.

ht
id
insurance
insurance_id
internal_number
invoice_computer = None
invoicing_mode
is_resulted()

Check if the current paid amount covers the Invoice amount

Type renvoyé:

bool

is_tolate()

Return True if a payment is expected since more than 45 days

legacy_number
line_groups
mandatory_mentions
mentions
mode
name
notes
official_number
owner
owner_id
paid(year: Optional[int] = None)

return the amount that has already been paid

Paramètres:

year – limit the considered payments to one year

paid_status
parent: Any
parent_id
payment_conditions
payments
pdf_file
pdf_file_hash
pdf_file_id
phase
phase_id
post_ttc_lines
price_study
progress_invoicing_plan
project
project_id
project_index
round_floor
set_deposit_label()
set_project(project)
set_sold_label()
start_date
status
status_comment
status_date
status_user
status_user_id
statuses
topay()
topay_by_tvas()
ttc
tva
tva_cancelinvoice_parts()
tva_paid_parts()
type_
updated_at
urssaf_payment_request
valid_cancelinvoices
validation_state_manager = <endi.models.action_manager.ActionManager object>
validation_status_history
workplace
endi.models.task.invoice.get_invoice_years(kw=None)

Return a cached query for the years we have invoices configured

Paramètres:

kw – is here only for API compatibility

endi.models.task.mentions module

Modèle pour les mentions dans les devis et factures

class endi.models.task.mentions.TaskMention(**kwargs)

Bases : ConfigurableOption

active
business_type_rel
full_text
help_text
id
property is_used
label
order
title
type_

endi.models.task.options module

class endi.models.task.options.PaymentConditions(**kwargs)

Bases : ConfigurableOption

active
default
id
label
order
type_

endi.models.task.payment module

Invoice’s payment model

class endi.models.task.payment.BankRemittance(**kwargs)

Bases : TimeStampedMixin, Base

Remises en banque

bank
bank_id
closed
created_at
get_grouped_payments()

Retourne la liste des encaissements d’une remise groupés par pièce (eg: chèque qui règle plusieurs factures) pour les exports

get_total_amount()
id
is_exported()
payment_mode
payments
remittance_date
updated_at
class endi.models.task.payment.BaseTaskPayment(**kwargs)

Bases : TimeStampedMixin, Base

amount
created_at
date
exported
exports
get_amount() int
get_company_id() int
get_tva_amount() float
id
internal = False
property invoice
property parent
precision = 5
task
task_id
tva
tva_id
type_
updated_at
user
user_id
year
class endi.models.task.payment.Payment(**kwargs)

Bases : BaseTaskPayment

Payment entry

amount
bank
bank_id
bank_remittance
bank_remittance_id
check_number
created_at
customer_bank
customer_bank_id
date
exported
exports
id
issuer
mode
task
task_id
tva
tva_id
type_
updated_at
user
user_id

endi.models.task.task module

Task model represents a base task, with a status, an owner, a phase

class endi.models.task.task.DiscountLine(**kwargs)

Bases : Base

A discount line

amount
description
duplicate()

return the equivalent InvoiceLine

classmethod from_price_study_discount(discount)
get_tva()
id
on_before_commit(request, state, attributes=None)

Handle actions before commit

Paramètres:
  • request (obj) – Pyramid request

  • state (str) – A str (add/update/delete)

  • attributes (dict) – The attributes that were recently modified

(default None)

task
task_id
total()
total_ht()
tva
tva_amount()
class endi.models.task.task.FrozenSettingsModelMixin

Bases : object

Allows to store/retrieve a frozen settings dict/list as JSON

Could be used for something else than Task

freeze_settings()
frozen_settings = Column(None, JSON(), table=None, default=ColumnDefault({}))
frozen_settings_initialize(frozen_settings) dict
class endi.models.task.task.PostTTCLine(**kwargs)

Bases : Base

A content line that come after the invoice TTC total for information purpose only (eg: acomptes perçus non facturés, primes CEE)

amount
id
label
on_before_commit(request, state, attributes=None)

Handle actions before commit

Paramètres:
  • request (obj) – Pyramid request

  • state (str) – A str (add/update/delete)

  • attributes (dict) – The attributes that were recently modified

(default None)

task
task_id
class endi.models.task.task.Task(user, company, project, **kw)

Bases : FrozenSettingsModelMixin, OfficialNumberMixin, ValidationStatusHolderMixin, Node

Metadata pour une tâche (estimation, invoice)

add_default_task_line_group()
add_ht_by_tva(ret_dict, lines)
address
all_lines
property attachments

File that are attached to this task but not to any sale requirement

auto_validated
business
business_id
business_type
business_type_id
cache_totals(request=None)

Cache Task totals from outside events scope

Paramètres:

request (obj) – The Pyramid request

change_status(key, status)

fired on status change, barely logs what is happening

check_status_allowed(status, request, **kw)
children
company
company_id
company_index
computer = None
classmethod create(request, customer, data: dict, no_price_study: bool = False) Task
created_at
customer
customer_id
date
decimal_to_display
property default_line_group
description
discount_total_ht()
discounts
display_ttc
display_units
duplicate(request, user, **kw)

DUplicate the current Task

Mandatory args :

user

The user duplicating this Task

customer

project

end_date
estimation_types = ('estimation', 'internalestimation')
expenses
expenses_amount()

Expense amounts (Not used in newer Tasks)

expenses_ht
exports
file_requirement_service

alias de TaskFileRequirementService

file_requirements
files
classmethod find_task_status_date(official_number, year)
first_visit
fix_lines_mode()

Ensure that Task.mode is consistent with TaskLine.mode

floor(amount) int
format_amount(amount, trim=True, grouping=True, precision=2)
frozen_settings
frozen_settings_initialize()

Persist business specific labels on the Task object

gen_business()

Generate a business based on this Task

Renvoie:

A new business instance

Type renvoyé:

endi.models.project.business.Business

get_company()

Return the company owning this task

get_company_id()

Return the id of the company owning this task

get_customer()

Return the customer of the current task

classmethod get_customer_task_factory(customer)

Renvoie la classe à utiliser pour créer une Task pour le client donné

get_default_product_id(products=None, default_tva=None)

Try to find a default product_id regarding the current context

Paramètres:
  • request (obj) – A pyramid request with a Task context

  • products (list) – A list of Product instances

  • tva (obj) – The default tva

Type renvoyé:

int or None

get_default_tva(tva_options=None)

Return the default tva to be used in this specific context

  • The last used in the document

or - The default one

Paramètres:
  • request (obj) – The pyramid request with a Task context

  • tva_options (list) – The available options for the end user

Type renvoyé:

str

get_expense_ht()

Expense HT amount (Not used in newer Tasks)

get_file_requirements(scoped=False, file_type_id=None)

Return the file requirements related to this Task :param bool scoped: If True, return only the file requirements that are directly associated with this Task

get_file_requirements_status()

Return the status of the indicators concerning this Task

get_groups()
get_main_sequence_number()
get_price_study()
get_progress_invoicing_plan()
get_rate(rate_name: str) float
get_rate_level(rate_name: str) str
get_selectable_products()
get_selectable_tvas()
get_tva_objects()
get_tvas() dict

Build a dict grouping TVA amounts by tva values

Renvoie:

{tva_value: tva_amount} {2000: 2000000, 1000: 1000000}

Tva value is in 10*2 format Tva amount is in 10*5 format

get_tvas_by_product()

Tva amounts grouped by products

get_type_label()
classmethod get_valid_estimations(*args, **kwargs)
classmethod get_valid_invoices(*args, **kwargs)
classmethod get_waiting_estimations(*args)
classmethod get_waiting_invoices(*args)
groups_total_ht()
groups_total_ttc()
has_line_dates()
has_price_study()
has_progress_invoicing_plan()
ht
id
initialize_business_type_data()

Initialize the data related to the Task’s business type

  • File requirements

  • Mandatory Mentions

insurance
insurance_id
internal = False
internal_number
invoice_types = ('invoice', 'cancelinvoice', 'internalinvoice', 'internalcancelinvoice')
is_training()
json_totals(request)

Collect totals and returns a json representation of all values

legacy_number
line_groups
mandatory_mentions
max_lines_date()
mention_service

alias de TaskMentionService

mentions
min_lines_date()
mode
name
naming_service

alias de NamingService

no_tva()
notes
official_number
on_before_commit(request, action, changes=None)

Handles actions to be run before commiting modifications to the current Task

owner
owner_id
parent: Any
parent_id
payment_conditions
payments
pdf_file
pdf_file_hash
pdf_file_id
phase
phase_id
post_ttc_lines
post_ttc_total()
prefix = ''
price_study
progress_invoicing_plan
project
project_id
project_index
classmethod query_by_antenne_id(antenne_id: int, query=None, payment=False)
classmethod query_by_follower_id(follower_id: int, query=None, payment=False)
classmethod query_by_validator_id(validator_id: int, query=None)
round_floor
set_auto_validated()

Set Task as auto_validated

set_display_ttc()

Set last display_ttc value used by the company :return: number

set_display_units()

Set last display_units value used by the company :return: number

set_numbers(company_index, project_index)

Handle all attributes related to the given number

Paramètres:
  • company_index (int) – The index of the task in the company

  • project_index (int) – The index of the task in its project

set_price_study(request)
set_progress_invoicing_plan(request)
set_status(status, request, **kw)

set the status of a task through the state machine

start_date
status
status_comment
status_date
status_user
status_user_id
statuses
total()

Total TTC + expenses (Same as total_ttc in newer Tasks)

total_due()
classmethod total_estimated(*args, **kwargs) int
total_ht() int
total_ht_rate(rate_name: str, ht: Optional[int] = None) int

Compute the amount that will be covered by the « rate_name » contribution

Paramètres:

rate_name (str) – contribution/insurance …

classmethod total_income(*args, **kwargs)
total_insurance(ht: Optional[int] = None) int
total_ttc()

TTC total without expenses (Same as total in newer Tasks)

ttc
tva
tva_amount()

Sum of TVA amounts

tva_ht_parts()

Build a dict grouping total HT amounts by associated tva

tva_native_parts()

Build a dict grouping total HT or TTC (depending mode) amounts by associated tva

tva_ttc_parts()

Build a dict gropuing total TTC amounts by associated TVA

type_
unset_price_study(request)
unset_progress_invoicing_plan(request)
update_indicators()

Update indicators related to this Task

  • Complete the indicators that are already satisfied

updated_at
validation_state_manager = None
validation_status_history
workplace
class endi.models.task.task.TaskLine(**kwargs)

Bases : Base

Estimation/Invoice/CancelInvoice lines

computer = None
cost
date
description
duplicate()

duplicate a line

classmethod from_price_study_product(product)
classmethod from_price_study_work(work)
classmethod from_price_study_work_item(work_item)
classmethod from_sale_product(sale_product, document=None)

Build an instance based on the given sale_product

Paramètres:

sale_product (obj) – A SaleProduct instance

Pararm obj document:

The Estimation/Invoice…

Renvoie:

A TaskLine instance

classmethod from_sale_product_work_item(work_item, document=None)

Build an instance based on the given SaleProductWorkItem

gen_cancelinvoice_line()

Return a cancel invoice line duplicating this one

get_tva()
group
group_id
id
is_in_hours
mode
month
on_before_commit(request, state, attributes=None)

Handle actions before commit

Paramètres:
  • request (obj) – Pyramid request

  • state (str) – A str (add/update/delete)

  • attributes (dict) – The attributes that were recently modified

(default None)

order
price_study_product
product
product_id
progress_invoicing_product
quantity
task
total()
total_ht()
tva
tva_amount()
unit_ht()
unit_ttc()
unity
year
class endi.models.task.task.TaskLineGroup(**kwargs)

Bases : Base

Group of lines

description
display_details
duplicate()
classmethod from_price_study_product(product)

Build an instance based on the given BasePriceStudyProduct

classmethod from_sale_product_work(product, document=None)

Build an instance based on the given SaleProductWork

Paramètres:
  • product (obj) – The original SaleProductWork

  • document (obj) – The Estimatin/Invoice …

gen_cancelinvoice_group(request)
get_tvas()
get_tvas_by_product()
id
lines
on_before_commit(request, state, attributes=None)

Handle actions before commit

Paramètres:
  • request (obj) – Pyramid request

  • state (str) – A str (add/update/delete)

  • attributes (dict) – The attributes that were recently modified

(default None)

order
price_study_chapter
progress_invoicing_chapter
task
task_id
title
total_ht()
total_ttc()
tva_amount()
endi.models.task.task.cache_amounts(mapper, connection, target)

Set amounts in the cached amount vars to be able to provide advanced search … options in the invoice list page

endi.models.task.task.cache_parent_amounts(mapper, connection, target)

Set amounts in the cached amount vars to be able to provide advanced search … options in the invoice list page

endi.models.task.task.freeze_settings(mapper, connection, target)

endi.models.task.unity module

Models for work unit (days, …)

class endi.models.task.unity.WorkUnit(**kwargs)

Bases : Base

Work unit, used to build the price list

classmethod get_by_label(label: str, case_sensitive: bool = False) Optional[WorkUnit]
id
label

Module contents

The task package entry