Skip to content

✨ bump FR EnergyBillV1 to V1.2 & US HealthcareCardV1 to V1.1 #308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/extras/guide/energy_bill_fra_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,19 @@ Details of energy consumption.

A `EnergyBillV1EnergyUsage` implements the following attributes:

* **consumption** (`float`): The price per unit of energy consumed.
* **description** (`str`): Description or details of the energy usage.
* **end_date** (`str`): The end date of the energy usage.
* **start_date** (`str`): The start date of the energy usage.
* **tax_rate** (`float`): The rate of tax applied to the total cost.
* **total** (`float`): The total cost of energy consumed.
* **unit** (`str`): The unit of measurement for energy consumption.

#### Possible values include:
- kWh
- m3
- L

* **unit_price** (`float`): The price per unit of energy consumed.
Fields which are specific to this product; they are not used in any other product.

Expand All @@ -169,7 +177,7 @@ A `EnergyBillV1MeterDetail` implements the following attributes:
- water
- None

* **unit** (`str`): The unit of measurement for energy consumption, which can be kW, m³, or L.
* **unit** (`str`): The unit of power for energy consumption.
Fields which are specific to this product; they are not used in any other product.

### Subscription Field
Expand Down
6 changes: 5 additions & 1 deletion mindee/product/fr/energy_bill/energy_bill_v1_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


class EnergyBillV1Document(Prediction):
"""Energy Bill API version 1.0 document data."""
"""Energy Bill API version 1.2 document data."""

contract_id: StringField
"""The unique identifier associated with a specific contract."""
Expand Down Expand Up @@ -164,11 +164,13 @@ def _subscription_to_str(self) -> str:
@staticmethod
def _energy_usage_separator(char: str) -> str:
out_str = " "
out_str += f"+{char * 13}"
out_str += f"+{char * 38}"
out_str += f"+{char * 12}"
out_str += f"+{char * 12}"
out_str += f"+{char * 10}"
out_str += f"+{char * 11}"
out_str += f"+{char * 17}"
out_str += f"+{char * 12}"
return out_str + "+"

Expand All @@ -181,11 +183,13 @@ def _energy_usage_to_str(self) -> str:
)
out_str = ""
out_str += f"\n{self._energy_usage_separator('-')}\n "
out_str += " | Consumption"
out_str += " | Description "
out_str += " | End Date "
out_str += " | Start Date"
out_str += " | Tax Rate"
out_str += " | Total "
out_str += " | Unit of Measure"
out_str += " | Unit Price"
out_str += f" |\n{self._energy_usage_separator('=')}"
out_str += f"\n {lines}"
Expand Down
18 changes: 16 additions & 2 deletions mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class EnergyBillV1EnergyUsage(FieldPositionMixin, FieldConfidenceMixin):
"""Details of energy consumption."""

consumption: Optional[float]
"""The price per unit of energy consumed."""
description: Optional[str]
"""Description or details of the energy usage."""
end_date: Optional[str]
Expand All @@ -23,6 +25,8 @@ class EnergyBillV1EnergyUsage(FieldPositionMixin, FieldConfidenceMixin):
"""The rate of tax applied to the total cost."""
total: Optional[float]
"""The total cost of energy consumed."""
unit: Optional[str]
"""The unit of measurement for energy consumption."""
unit_price: Optional[float]
"""The price per unit of energy consumed."""
page_n: int
Expand All @@ -44,53 +48,63 @@ def __init__(
else:
self.page_n = page_id

self.consumption = to_opt_float(raw_prediction, "consumption")
self.description = raw_prediction["description"]
self.end_date = raw_prediction["end_date"]
self.start_date = raw_prediction["start_date"]
self.tax_rate = to_opt_float(raw_prediction, "tax_rate")
self.total = to_opt_float(raw_prediction, "total")
self.unit = raw_prediction["unit"]
self.unit_price = to_opt_float(raw_prediction, "unit_price")

def _printable_values(self) -> Dict[str, str]:
"""Return values for printing."""
out_dict: Dict[str, str] = {}
out_dict["consumption"] = float_to_string(self.consumption)
out_dict["description"] = format_for_display(self.description)
out_dict["end_date"] = format_for_display(self.end_date)
out_dict["start_date"] = format_for_display(self.start_date)
out_dict["tax_rate"] = float_to_string(self.tax_rate)
out_dict["total"] = float_to_string(self.total)
out_dict["unit"] = format_for_display(self.unit)
out_dict["unit_price"] = float_to_string(self.unit_price)
return out_dict

def _table_printable_values(self) -> Dict[str, str]:
"""Return values for printing inside an RST table."""
out_dict: Dict[str, str] = {}
out_dict["consumption"] = float_to_string(self.consumption)
out_dict["description"] = format_for_display(self.description, 36)
out_dict["end_date"] = format_for_display(self.end_date, 10)
out_dict["start_date"] = format_for_display(self.start_date, None)
out_dict["tax_rate"] = float_to_string(self.tax_rate)
out_dict["total"] = float_to_string(self.total)
out_dict["unit"] = format_for_display(self.unit, None)
out_dict["unit_price"] = float_to_string(self.unit_price)
return out_dict

def to_table_line(self) -> str:
"""Output in a format suitable for inclusion in an rST table."""
printable = self._table_printable_values()
out_str: str = f"| {printable['description']:<36} | "
out_str: str = f"| {printable['consumption']:<11} | "
out_str += f"{printable['description']:<36} | "
out_str += f"{printable['end_date']:<10} | "
out_str += f"{printable['start_date']:<10} | "
out_str += f"{printable['tax_rate']:<8} | "
out_str += f"{printable['total']:<9} | "
out_str += f"{printable['unit']:<15} | "
out_str += f"{printable['unit_price']:<10} | "
return clean_out_string(out_str)

def __str__(self) -> str:
"""Default string representation."""
printable = self._printable_values()
out_str: str = f"Description: {printable['description']}, \n"
out_str: str = f"Consumption: {printable['consumption']}, \n"
out_str += f"Description: {printable['description']}, \n"
out_str += f"End Date: {printable['end_date']}, \n"
out_str += f"Start Date: {printable['start_date']}, \n"
out_str += f"Tax Rate: {printable['tax_rate']}, \n"
out_str += f"Total: {printable['total']}, \n"
out_str += f"Unit of Measure: {printable['unit']}, \n"
out_str += f"Unit Price: {printable['unit_price']}, \n"
return clean_out_string(out_str)
6 changes: 3 additions & 3 deletions mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EnergyBillV1MeterDetail(FieldPositionMixin, FieldConfidenceMixin):
meter_type: Optional[str]
"""The type of energy meter."""
unit: Optional[str]
"""The unit of measurement for energy consumption, which can be kW, m³, or L."""
"""The unit of power for energy consumption."""
page_n: int
"""The document page on which the information was found."""

Expand Down Expand Up @@ -50,13 +50,13 @@ def to_field_list(self) -> str:
printable = self._printable_values()
out_str: str = f" :Meter Number: {printable['meter_number']}\n"
out_str += f" :Meter Type: {printable['meter_type']}\n"
out_str += f" :Unit of Measure: {printable['unit']}\n"
out_str += f" :Unit of Power: {printable['unit']}\n"
return out_str.rstrip()

def __str__(self) -> str:
"""Default string representation."""
printable = self._printable_values()
out_str: str = f"Meter Number: {printable['meter_number']}, \n"
out_str += f"Meter Type: {printable['meter_type']}, \n"
out_str += f"Unit of Measure: {printable['unit']}, \n"
out_str += f"Unit of Power: {printable['unit']}, \n"
return clean_out_string(out_str)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class HealthcareCardV1Document(Prediction):
"""Healthcare Card API version 1.0 document data."""
"""Healthcare Card API version 1.1 document data."""

company_name: StringField
"""The name of the company that provides the healthcare plan."""
Expand Down