fix tests

This commit is contained in:
Julien Aldon
2026-03-06 11:26:02 +01:00
parent b4b4fa7643
commit c27c7598b5
10 changed files with 586 additions and 147 deletions

View File

@@ -113,7 +113,7 @@ def create_row_style_height(size: str) -> odfdo.Style:
)
def create_currency_style(name:str = 'currency-euro'):
def create_currency_style(name: str = 'currency-euro'):
"""Create a table currency style.
Paramenters:
name(str): name of the style (default to `currency-euro`).
@@ -129,6 +129,7 @@ def create_currency_style(name:str = 'currency-euro'):
</number:currency-style>"""
)
def create_cell_style(
name: str = "centered-cell",
font_size: str = '10pt',
@@ -384,12 +385,12 @@ def transform_formula_cells(sheet: odfdo.Spreadsheet):
def merge_shipment_cells(
sheet: odfdo.Spreadsheet,
prefix_header: list[str],
recurrents: list[str],
occasionnals: list[str],
shipments: list[models.Shipment]
):
sheet: odfdo.Spreadsheet,
prefix_header: list[str],
recurrents: list[str],
occasionnals: list[str],
shipments: list[models.Shipment]
):
"""Merge cells for shipment header.
"""
index = len(prefix_header) + len(recurrents) + 1
@@ -399,6 +400,7 @@ def merge_shipment_cells(
sheet.set_span((startcol, 0, endcol, 0), merge=True)
index += len(occasionnals)
def generate_recap(
contracts: list[models.Contract],
form: models.Form,
@@ -411,14 +413,14 @@ def generate_recap(
'3': 'Piece'
}
recurrents = [
f'{pr.name}{f' - {pr.quantity}{pr.quantity_unit}'
f'{pr.name}{f' - {pr.quantity}{pr.quantity_unit}'
if pr.quantity else ''} ({product_unit_map[pr.unit]})'
for pr in form.productor.products
if pr.type == models.ProductType.RECCURENT
]
recurrents.sort()
occasionnals = [
f'{pr.name}{f' - {pr.quantity}{pr.quantity_unit}'
f'{pr.name}{f' - {pr.quantity}{pr.quantity_unit}'
if pr.quantity else ''} ({product_unit_map[pr.unit]})'
for pr in form.productor.products
if pr.type == models.ProductType.OCCASIONAL
@@ -468,7 +470,7 @@ def generate_recap(
len(info_header)+len(payment_formula_letters)+len(recurrents) + 1
]
occasionnals_formula_letters = letters[
len(info_header)+len(payment_formula_letters)+
len(info_header)+len(payment_formula_letters) +
len(recurent_formula_letters):
len(info_header)+len(payment_formula_letters) +
len(recurent_formula_letters)+len(occasionnals_header) + 1
@@ -489,14 +491,14 @@ def generate_recap(
prices = compute_contract_prices(contract)
occasionnal_sorted = sorted(
[
product for product in contract.products
product for product in contract.products
if product.product.type == models.ProductType.OCCASIONAL
],
key=lambda x: (x.shipment.name, x.product.name)
)
recurrent_sorted = sorted(
[
product for product in contract.products
product for product in contract.products
if product.product.type == models.ProductType.RECCURENT
],
key=lambda x: x.product.name