endi.compute.task package

Submodules

endi.compute.task.common module

Task compute methods and attributes for both ht and ttc mode

class endi.compute.task.common.CommonDiscountLineCompute(discount_line)

Bases : object

Computing tool for both ttc and ht mode in discount_line

get_tva()

Return the line discount_line tva :return: int

total()
total_ht()
class endi.compute.task.common.CommonGroupCompute(task_line_group)

Bases : object

Computing tool for both ttc and ht mode in group objects

get_tvas()

return a dict with the tvas amounts stored by tva {1960:450.56, 700:45}

get_tvas_by_product() dict

return a dict with the tvas amounts stored by product We use a key (product.compte_cg, product.tva.compte_cg)

total_ht()

Returns the ht total for this group

total_ttc()
tva_amount()

Returns the TVA total for this group

class endi.compute.task.common.CommonLineCompute(task_line)

Bases : object

Computing tool for both ttc and ht mode in task_line

get_tva()

Return the line task_line tva :return: int

class endi.compute.task.common.CommonTaskCompute(task)

Bases : object

Computing tool for both ttc and ht mode in tasks objects

static add_ht_by_tva(ret_dict, lines, operation=<built-in function add>)

Add ht sums by tva to ret_dict for the given lines

discount_total_ht()

compute the discount total

discount_total_ttc()

compute the discount total

floor(amount)
get_tvas() dict

Compute TVA amount by TVA rate

get_tvas_by_product() dict

Compute the amount of TVA by product_id

groups_total_ht()

compute the sum of the task lines total

groups_total_ttc()

compute the sum of the task lines total

post_ttc_total()

compute the sum of the post-ttc lines

total() int
total_due()

compute the total_due

total_ht() int
total_ht_rate(key: str, ht: Optional[int] = None) int

Compute a rate on the HT value of the current task

total_ttc() int
tva_amount() int

Compute the total amount of TVA for this doc

tva_ht_parts() dict

Compute HT amounts by tva

tva_native_parts() dict

Return amounts by tva in « native » mode (HT or TTC regarding the mode)

tva_ttc_parts() dict

Compute TTC amounts by tva

class endi.compute.task.common.EstimationCompute(task)

Bases : object

Computing class for estimations Adds the ability to compute deposit amounts …

deposit_amount_ttc()

Return the ttc amount of the deposit (for estimation display)

deposit_amounts_native()

Return the lines of the deposit for the different amount of tvas

(amounts are native : HT or TTC depending on estimation mode)

get_nb_payment_lines()

Returns the number of payment lines configured

manual_payment_line_amounts()

Computes the ht and tva needed to reach each payment line total

self.payment_lines are configured with TTC amounts

return a list of dict:

[{tva1:amount, tva2:amount}] (amounts are native : HT or TTC depending on estimation mode)

each dict represents the amount to pay by tva

paymentline_amount_ttc()

Return the ttc amount of payment (in equal repartition)

paymentline_amounts_native()

Compute payment lines amounts in case of equal payment repartition:

when manualDeliverables is 0

e.g :

when the user has selected 3 time-payment

Renvoie:

A dict describing the payments {“tva1”: amount1, “tva2”: amount2} (amounts are native : HT or TTC depending on estimation mode)

sold()

Compute the sold amount to finish on an exact value if we divide 10 in 3, we’d like to have something like :

3.33 3.33 3.34

(for estimation display)

class endi.compute.task.common.InvoiceCompute(task)

Bases : object

Invoice computing object Handles payments

cancelinvoice_amount(year: Optional[int] = None)

Return the amount covered by th associated cancelinvoices

Paramètres:

year – limit the considered cancel invoices to this year

compute_payments(payment_amount)

Returns payments corresponding to the payment amount If there is just one TVA rate left to be paid in the invoice it returns just one payment. If there are different TVA rate left to be paid in the invoice it returns a payment for each TVA rate

Paramètres:

payment_amount (int) – Amount coming from the UI (in biginteger

format)

Type renvoyé:

array

Renvoie:

[{“tva_id”: <Tva>.id, “amount”: 123}, …]

paid(year: Optional[int] = None)

return the amount that has already been paid

Paramètres:

year – limit the considered payments to one year

payments_sum(year: Optional[int] = None)

Return the amount covered by the recorded payments

Paramètres:

year – limit the considered payments to this year

round_payment_amount(payment_amount)

Returns a rounded value of a payment.

Paramètres:

payment_amount (int) – Amount in biginteger representation

topay()

Return the amount that still need to be paid

Compute the sum of the payments and what’s part of a valid cancelinvoice

topay_by_tvas() dict

Returns the amount to pay by tva part

Renvoie:

A dict {tva value: to pay amount}

tva_cancelinvoice_parts() dict

Returns the amounts already paid through cancelinvoices by tva

Renvoie:

A dict {tva value: canceled amount}

tva_paid_parts() dict

return the amounts already paid by tva

Renvoie:

A dict {tva value: paid amount}

endi.compute.task.task_ht module

Task computing tool Used to compute invoice, estimation or cancelinvoice totals

class endi.compute.task.task_ht.DiscountLineCompute(discount_line)

Bases : CommonDiscountLineCompute

Computing tool for discount_line objects

total()
total_ht()
tva_amount()

compute the tva amount of a line

class endi.compute.task.task_ht.GroupCompute(task_line_group)

Bases : CommonGroupCompute

task_line_group: TaskLineGroup = None
total_ttc()

Returns the TTC total for this group

class endi.compute.task.task_ht.LineCompute(task_line)

Bases : CommonLineCompute

Computing tool for line objects

total()

Compute the ttc amount of the line

total_ht()

Compute the line’s total

tva_amount()

compute the tva amount of a line

unit_ht() int
unit_ttc() int
class endi.compute.task.task_ht.TaskCompute(task)

Bases : CommonTaskCompute

class A(TaskCompute):

pass

A.total()

expenses_amount()

return the amount of the expenses

get_expense_ht()

Return a line object for the HT expense handling

get_expenses_tva()

Return the tva for the HT expenses

get_tvas()

return a dict with the tvas amounts stored by tva {1960:450.56, 700:45}

get_tvas_by_product()

Return tvas stored by product type

no_tva()

return True if all the tvas are below 0

total()

Compute TTC after tax removing

total_ht()

compute the HT amount

total_ttc()

Compute the TTC total

tva_amount()

Compute the sum of the TVAs amount of TVA

tva_ht_parts()

Return a dict with the HT amounts stored by corresponding tva value dict(tva=ht_tva_part,) for each tva value

tva_native_parts()

Return a dict with the HT amounts stored by corresponding tva value dict(tva=tva_part,) for each tva value in native compute mode (eg: HT when task.mode == “ht”)

tva_ttc_parts()

Return a dict with TTC amounts stored by corresponding tva

endi.compute.task.task_ht.get_default_tva()

Return the default tva

endi.compute.task.task_ttc module

Module de calcul des montants des devis/facture saisis en mode TTC

En mode TTC :

  • L’utilisateur saisie des montants TTC

  • la facture est une facture HT

  • Pour chaque ligne on calcule un HT en faisant une TVA inversée sur le TTC

  • Total HT = Arrondi de la somme des HT de chaque ligne (HT calculé via une TVA

inversée pour chaque ligne)

  • Total TTC = somme des TTC de chaque ligne

  • Total TVA = Total TTC - Total HT

  • Il se peut que le Total TVA soit différent de la somme des TVA de chaque ligne

  • Le total TVA du PDF peut donc différer d’un centime de ce qu’il y a dans les

écritures

class endi.compute.task.task_ttc.DiscountLineTtcCompute(discount_line)

Bases : CommonDiscountLineCompute

Computing tool for discount line ttc objects

total()
Renvoie:

float ttc amount of a line

total_ht()

compute round total ht amount of a line

tva_amount()

compute the tva amount of a line

class endi.compute.task.task_ttc.GroupTtcCompute(task_line_group)

Bases : CommonGroupCompute

Computing tool for group ttc objects

class endi.compute.task.task_ttc.LineTtcCompute(task_line)

Bases : CommonLineCompute

Computing tool for line ttc objects

total()

Compute the ttc amount of the line :rtype: int

total_ht()

Compute the line’s ht total

Type renvoyé:

int

tva_amount()

compute the tva amount of a line :rtype: int

unit_ht() int

Compute the unit ht value of the current task line based on its ttc unit value

unit_ttc() int
class endi.compute.task.task_ttc.TaskTtcCompute(task)

Bases : CommonTaskCompute

class A(TaskTtcCompute):

pass

A.total()

get_tvas() dict

Renvoie un les montants de TVA par taux

Méthode utilisée pour la présentation dans les PDFs

# TVA 20% 45€21 , TVA 7% : 4.5€
{2000: 4521000, 700: 450000}

Note sur les calculs :

Afin que le montant total TTC corresponde à la saisie, on adapte parfois les taux de TVA pour que la somme des HT + TVA = TTC

get_tvas_by_product()

Renvoie les montants par produit

Cette méthode est utilisée pour les exports comptables

Note sur les calculs :

Ici les tvas sont dispatchées par compte produit, il est possible que la somme des TVAs diffère de ce qui est dans le PDF

Voir le ticket

Choix sur les règles de calcul expliquant les différences entre get_tvas et get_tvas_by_product

https://framagit.org/endi/endi/-/issues/3688

no_tva() bool

return True if all the tvas are below 0

total()

Compute TTC after tax removing

total_ht()

compute the HT amount

total_ttc()

Compute the TTC total

tva_amount()

Compute the sum of the TVAs amount of TVA

tva_ht_parts()

Return a dict with the HT amounts stored by corresponding tva value dict(tva=ht_tva_part,) for each tva value

tva_native_parts()

Return amounts by tva in « native » mode (HT or TTC regarding the mode) Here it’s TTC

tva_ttc_parts()

Return a dict with TTC amounts stored by corresponding tva

Module contents

The task package entry