From 61c175ecf17ae7ea0d9dba47188da5a3b866cc9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Thu, 5 Mar 2026 12:16:31 +0100 Subject: [PATCH] :coffin: remove unused PayslipV2 product --- .../code_samples/payslip_fra_v2_async.txt | 21 --- docs/product/fr/payslip_v2.rst | 47 ------- mindee/product/fr/__init__.py | 38 ------ mindee/product/fr/payslip/__init__.py | 38 ------ mindee/product/fr/payslip/payslip_v2.py | 39 ------ .../payslip/payslip_v2_bank_account_detail.py | 62 --------- .../product/fr/payslip/payslip_v2_document.py | 121 ------------------ .../product/fr/payslip/payslip_v2_employee.py | 88 ------------- .../product/fr/payslip/payslip_v2_employer.py | 86 ------------- .../fr/payslip/payslip_v2_employment.py | 85 ------------ .../fr/payslip/payslip_v2_pay_detail.py | 115 ----------------- .../fr/payslip/payslip_v2_pay_period.py | 74 ----------- mindee/product/fr/payslip/payslip_v2_pto.py | 69 ---------- .../fr/payslip/payslip_v2_salary_detail.py | 82 ------------ .../v1/product/fr/payslip/test_payslip_v2.py | 87 ------------- 15 files changed, 1052 deletions(-) delete mode 100644 docs/extras/code_samples/payslip_fra_v2_async.txt delete mode 100644 docs/product/fr/payslip_v2.rst delete mode 100644 mindee/product/fr/payslip/payslip_v2.py delete mode 100644 mindee/product/fr/payslip/payslip_v2_bank_account_detail.py delete mode 100644 mindee/product/fr/payslip/payslip_v2_document.py delete mode 100644 mindee/product/fr/payslip/payslip_v2_employee.py delete mode 100644 mindee/product/fr/payslip/payslip_v2_employer.py delete mode 100644 mindee/product/fr/payslip/payslip_v2_employment.py delete mode 100644 mindee/product/fr/payslip/payslip_v2_pay_detail.py delete mode 100644 mindee/product/fr/payslip/payslip_v2_pay_period.py delete mode 100644 mindee/product/fr/payslip/payslip_v2_pto.py delete mode 100644 mindee/product/fr/payslip/payslip_v2_salary_detail.py delete mode 100644 tests/v1/product/fr/payslip/test_payslip_v2.py diff --git a/docs/extras/code_samples/payslip_fra_v2_async.txt b/docs/extras/code_samples/payslip_fra_v2_async.txt deleted file mode 100644 index 5bf9366d..00000000 --- a/docs/extras/code_samples/payslip_fra_v2_async.txt +++ /dev/null @@ -1,21 +0,0 @@ -# -# Install the Python client library by running: -# pip install mindee -# - -from mindee import Client, product, AsyncPredictResponse - -# Init a new client -mindee_client = Client(api_key="my-api-key") - -# Load a file from disk -input_doc = mindee_client.source_from_path("/path/to/the/file.ext") - -# Load a file from disk and enqueue it. -result: AsyncPredictResponse = mindee_client.enqueue_and_parse( - product.fr.PayslipV2, - input_doc, -) - -# Print a brief summary of the parsed data -print(result.document) diff --git a/docs/product/fr/payslip_v2.rst b/docs/product/fr/payslip_v2.rst deleted file mode 100644 index e36fd523..00000000 --- a/docs/product/fr/payslip_v2.rst +++ /dev/null @@ -1,47 +0,0 @@ -Payslip V2 ----------- - -**Sample Code:** - -.. literalinclude:: /extras/code_samples/payslip_fra_v2_async.txt - :language: Python - -.. autoclass:: mindee.product.fr.payslip.payslip_v2.PayslipV2 - :members: - :inherited-members: - -.. autoclass:: mindee.product.fr.payslip.payslip_v2_document.PayslipV2Document - :members: - :inherited-members: - -.. autoclass:: mindee.product.fr.payslip.payslip_v2_employee.PayslipV2Employee - :members: - :inherited-members: - -.. autoclass:: mindee.product.fr.payslip.payslip_v2_employer.PayslipV2Employer - :members: - :inherited-members: - -.. autoclass:: mindee.product.fr.payslip.payslip_v2_bank_account_detail.PayslipV2BankAccountDetail - :members: - :inherited-members: - -.. autoclass:: mindee.product.fr.payslip.payslip_v2_employment.PayslipV2Employment - :members: - :inherited-members: - -.. autoclass:: mindee.product.fr.payslip.payslip_v2_salary_detail.PayslipV2SalaryDetail - :members: - :inherited-members: - -.. autoclass:: mindee.product.fr.payslip.payslip_v2_pay_detail.PayslipV2PayDetail - :members: - :inherited-members: - -.. autoclass:: mindee.product.fr.payslip.payslip_v2_pto.PayslipV2Pto - :members: - :inherited-members: - -.. autoclass:: mindee.product.fr.payslip.payslip_v2_pay_period.PayslipV2PayPeriod - :members: - :inherited-members: diff --git a/mindee/product/fr/__init__.py b/mindee/product/fr/__init__.py index a4e4f756..14b1a204 100644 --- a/mindee/product/fr/__init__.py +++ b/mindee/product/fr/__init__.py @@ -57,34 +57,6 @@ from mindee.product.fr.id_card.id_card_v2_page import ( IdCardV2Page, ) -from mindee.product.fr.payslip.payslip_v2 import PayslipV2 -from mindee.product.fr.payslip.payslip_v2_bank_account_detail import ( - PayslipV2BankAccountDetail, -) -from mindee.product.fr.payslip.payslip_v2_document import ( - PayslipV2Document, -) -from mindee.product.fr.payslip.payslip_v2_employee import ( - PayslipV2Employee, -) -from mindee.product.fr.payslip.payslip_v2_employer import ( - PayslipV2Employer, -) -from mindee.product.fr.payslip.payslip_v2_employment import ( - PayslipV2Employment, -) -from mindee.product.fr.payslip.payslip_v2_pay_detail import ( - PayslipV2PayDetail, -) -from mindee.product.fr.payslip.payslip_v2_pay_period import ( - PayslipV2PayPeriod, -) -from mindee.product.fr.payslip.payslip_v2_pto import ( - PayslipV2Pto, -) -from mindee.product.fr.payslip.payslip_v2_salary_detail import ( - PayslipV2SalaryDetail, -) from mindee.product.fr.payslip.payslip_v3 import PayslipV3 from mindee.product.fr.payslip.payslip_v3_bank_account_detail import ( PayslipV3BankAccountDetail, @@ -138,16 +110,6 @@ "IdCardV2", "IdCardV2Document", "IdCardV2Page", - "PayslipV2", - "PayslipV2BankAccountDetail", - "PayslipV2Document", - "PayslipV2Employee", - "PayslipV2Employer", - "PayslipV2Employment", - "PayslipV2PayDetail", - "PayslipV2PayPeriod", - "PayslipV2Pto", - "PayslipV2SalaryDetail", "PayslipV3", "PayslipV3BankAccountDetail", "PayslipV3Document", diff --git a/mindee/product/fr/payslip/__init__.py b/mindee/product/fr/payslip/__init__.py index d104caa4..dad14e0d 100644 --- a/mindee/product/fr/payslip/__init__.py +++ b/mindee/product/fr/payslip/__init__.py @@ -1,31 +1,3 @@ -from mindee.product.fr.payslip.payslip_v2 import PayslipV2 -from mindee.product.fr.payslip.payslip_v2_bank_account_detail import ( - PayslipV2BankAccountDetail, -) -from mindee.product.fr.payslip.payslip_v2_document import ( - PayslipV2Document, -) -from mindee.product.fr.payslip.payslip_v2_employee import ( - PayslipV2Employee, -) -from mindee.product.fr.payslip.payslip_v2_employer import ( - PayslipV2Employer, -) -from mindee.product.fr.payslip.payslip_v2_employment import ( - PayslipV2Employment, -) -from mindee.product.fr.payslip.payslip_v2_pay_detail import ( - PayslipV2PayDetail, -) -from mindee.product.fr.payslip.payslip_v2_pay_period import ( - PayslipV2PayPeriod, -) -from mindee.product.fr.payslip.payslip_v2_pto import ( - PayslipV2Pto, -) -from mindee.product.fr.payslip.payslip_v2_salary_detail import ( - PayslipV2SalaryDetail, -) from mindee.product.fr.payslip.payslip_v3 import PayslipV3 from mindee.product.fr.payslip.payslip_v3_bank_account_detail import ( PayslipV3BankAccountDetail, @@ -56,16 +28,6 @@ ) __all__ = [ - "PayslipV2", - "PayslipV2BankAccountDetail", - "PayslipV2Document", - "PayslipV2Employee", - "PayslipV2Employer", - "PayslipV2Employment", - "PayslipV2PayDetail", - "PayslipV2PayPeriod", - "PayslipV2Pto", - "PayslipV2SalaryDetail", "PayslipV3", "PayslipV3BankAccountDetail", "PayslipV3Document", diff --git a/mindee/product/fr/payslip/payslip_v2.py b/mindee/product/fr/payslip/payslip_v2.py deleted file mode 100644 index 109ac248..00000000 --- a/mindee/product/fr/payslip/payslip_v2.py +++ /dev/null @@ -1,39 +0,0 @@ -from typing import List - -from mindee.parsing.common.inference import Inference -from mindee.parsing.common.page import Page -from mindee.parsing.common.string_dict import StringDict -from mindee.product.fr.payslip.payslip_v2_document import ( - PayslipV2Document, -) - - -class PayslipV2(Inference): - """Payslip API version 2 inference prediction.""" - - prediction: PayslipV2Document - """Document-level prediction.""" - pages: List[Page[PayslipV2Document]] - """Page-level prediction(s).""" - endpoint_name = "payslip_fra" - """Name of the endpoint.""" - endpoint_version = "2" - """Version of the endpoint.""" - - def __init__(self, raw_prediction: StringDict): - """ - Payslip v2 inference. - - :param raw_prediction: Raw prediction from the HTTP response. - """ - super().__init__(raw_prediction) - - self.prediction = PayslipV2Document(raw_prediction["prediction"]) - self.pages = [] - for page in raw_prediction["pages"]: - try: - page_prediction = page["prediction"] - except KeyError: - continue - if page_prediction: - self.pages.append(Page(PayslipV2Document, page)) diff --git a/mindee/product/fr/payslip/payslip_v2_bank_account_detail.py b/mindee/product/fr/payslip/payslip_v2_bank_account_detail.py deleted file mode 100644 index 194fb22a..00000000 --- a/mindee/product/fr/payslip/payslip_v2_bank_account_detail.py +++ /dev/null @@ -1,62 +0,0 @@ -from typing import Dict, Optional - -from mindee.parsing.common.string_dict import StringDict -from mindee.parsing.common.summary_helper import clean_out_string, format_for_display -from mindee.parsing.standard.base import FieldConfidenceMixin, FieldPositionMixin - - -class PayslipV2BankAccountDetail(FieldPositionMixin, FieldConfidenceMixin): - """Information about the employee's bank account.""" - - bank_name: Optional[str] - """The name of the bank.""" - iban: Optional[str] - """The IBAN of the bank account.""" - swift: Optional[str] - """The SWIFT code of the bank.""" - page_n: int - """The document page on which the information was found.""" - - def __init__( - self, - raw_prediction: StringDict, - page_id: Optional[int] = None, - ): - self._set_confidence(raw_prediction) - self._set_position(raw_prediction) - - if page_id is None: - try: - self.page_n = raw_prediction["page_id"] - except KeyError: - pass - else: - self.page_n = page_id - - self.bank_name = raw_prediction["bank_name"] - self.iban = raw_prediction["iban"] - self.swift = raw_prediction["swift"] - - def _printable_values(self) -> Dict[str, str]: - """Return values for printing.""" - out_dict: Dict[str, str] = {} - out_dict["bank_name"] = format_for_display(self.bank_name) - out_dict["iban"] = format_for_display(self.iban) - out_dict["swift"] = format_for_display(self.swift) - return out_dict - - def to_field_list(self) -> str: - """Output the object in a format suitable for inclusion in an rST field list.""" - printable = self._printable_values() - out_str: str = f" :Bank Name: {printable['bank_name']}\n" - out_str += f" :IBAN: {printable['iban']}\n" - out_str += f" :SWIFT: {printable['swift']}\n" - return out_str.rstrip() - - def __str__(self) -> str: - """Default string representation.""" - printable = self._printable_values() - out_str: str = f"Bank Name: {printable['bank_name']}, \n" - out_str += f"IBAN: {printable['iban']}, \n" - out_str += f"SWIFT: {printable['swift']}, \n" - return clean_out_string(out_str) diff --git a/mindee/product/fr/payslip/payslip_v2_document.py b/mindee/product/fr/payslip/payslip_v2_document.py deleted file mode 100644 index 208d581e..00000000 --- a/mindee/product/fr/payslip/payslip_v2_document.py +++ /dev/null @@ -1,121 +0,0 @@ -from typing import List, Optional - -from mindee.parsing.common.prediction import Prediction -from mindee.parsing.common.string_dict import StringDict -from mindee.parsing.common.summary_helper import clean_out_string -from mindee.product.fr.payslip.payslip_v2_bank_account_detail import ( - PayslipV2BankAccountDetail, -) -from mindee.product.fr.payslip.payslip_v2_employee import PayslipV2Employee -from mindee.product.fr.payslip.payslip_v2_employer import PayslipV2Employer -from mindee.product.fr.payslip.payslip_v2_employment import PayslipV2Employment -from mindee.product.fr.payslip.payslip_v2_pay_detail import PayslipV2PayDetail -from mindee.product.fr.payslip.payslip_v2_pay_period import PayslipV2PayPeriod -from mindee.product.fr.payslip.payslip_v2_pto import PayslipV2Pto -from mindee.product.fr.payslip.payslip_v2_salary_detail import PayslipV2SalaryDetail - - -class PayslipV2Document(Prediction): - """Payslip API version 2.0 document data.""" - - bank_account_details: PayslipV2BankAccountDetail - """Information about the employee's bank account.""" - employee: PayslipV2Employee - """Information about the employee.""" - employer: PayslipV2Employer - """Information about the employer.""" - employment: PayslipV2Employment - """Information about the employment.""" - pay_detail: PayslipV2PayDetail - """Detailed information about the pay.""" - pay_period: PayslipV2PayPeriod - """Information about the pay period.""" - pto: PayslipV2Pto - """Information about paid time off.""" - salary_details: List[PayslipV2SalaryDetail] - """Detailed information about the earnings.""" - - def __init__( - self, - raw_prediction: StringDict, - page_id: Optional[int] = None, - ): - """ - Payslip document. - - :param raw_prediction: Raw prediction from HTTP response - :param page_id: Page number for multi pages pdf input - """ - super().__init__(raw_prediction, page_id) - self.bank_account_details = PayslipV2BankAccountDetail( - raw_prediction["bank_account_details"], - page_id=page_id, - ) - self.employee = PayslipV2Employee( - raw_prediction["employee"], - page_id=page_id, - ) - self.employer = PayslipV2Employer( - raw_prediction["employer"], - page_id=page_id, - ) - self.employment = PayslipV2Employment( - raw_prediction["employment"], - page_id=page_id, - ) - self.pay_detail = PayslipV2PayDetail( - raw_prediction["pay_detail"], - page_id=page_id, - ) - self.pay_period = PayslipV2PayPeriod( - raw_prediction["pay_period"], - page_id=page_id, - ) - self.pto = PayslipV2Pto( - raw_prediction["pto"], - page_id=page_id, - ) - self.salary_details = [ - PayslipV2SalaryDetail(prediction, page_id=page_id) - for prediction in raw_prediction["salary_details"] - ] - - @staticmethod - def _salary_details_separator(char: str) -> str: - out_str = " " - out_str += f"+{char * 14}" - out_str += f"+{char * 11}" - out_str += f"+{char * 38}" - out_str += f"+{char * 11}" - return out_str + "+" - - def _salary_details_to_str(self) -> str: - if not self.salary_details: - return "" - - lines = f"\n{self._salary_details_separator('-')}\n ".join( - [item.to_table_line() for item in self.salary_details] - ) - out_str = "" - out_str += f"\n{self._salary_details_separator('-')}\n " - out_str += " | Amount " - out_str += " | Base " - out_str += " | Description " - out_str += " | Rate " - out_str += f" |\n{self._salary_details_separator('=')}" - out_str += f"\n {lines}" - out_str += f"\n{self._salary_details_separator('-')}" - return out_str - - def __str__(self) -> str: - out_str: str = f":Employee:\n{self.employee.to_field_list()}\n" - out_str += f":Employer:\n{self.employer.to_field_list()}\n" - out_str += ( - f":Bank Account Details:\n{self.bank_account_details.to_field_list()}\n" - ) - out_str += f":Employment:\n{self.employment.to_field_list()}\n" - out_str += f":Salary Details: {self._salary_details_to_str()}\n" - out_str += f":Pay Detail:\n{self.pay_detail.to_field_list()}\n" - out_str += f":PTO:\n{self.pto.to_field_list()}\n" - out_str += f":Pay Period:\n{self.pay_period.to_field_list()}\n" - return clean_out_string(out_str) diff --git a/mindee/product/fr/payslip/payslip_v2_employee.py b/mindee/product/fr/payslip/payslip_v2_employee.py deleted file mode 100644 index 6fccf9eb..00000000 --- a/mindee/product/fr/payslip/payslip_v2_employee.py +++ /dev/null @@ -1,88 +0,0 @@ -from typing import Dict, Optional - -from mindee.parsing.common.string_dict import StringDict -from mindee.parsing.common.summary_helper import clean_out_string, format_for_display -from mindee.parsing.standard.base import FieldConfidenceMixin, FieldPositionMixin - - -class PayslipV2Employee(FieldPositionMixin, FieldConfidenceMixin): - """Information about the employee.""" - - address: Optional[str] - """The address of the employee.""" - date_of_birth: Optional[str] - """The date of birth of the employee.""" - first_name: Optional[str] - """The first name of the employee.""" - last_name: Optional[str] - """The last name of the employee.""" - phone_number: Optional[str] - """The phone number of the employee.""" - registration_number: Optional[str] - """The registration number of the employee.""" - social_security_number: Optional[str] - """The social security number of the employee.""" - page_n: int - """The document page on which the information was found.""" - - def __init__( - self, - raw_prediction: StringDict, - page_id: Optional[int] = None, - ): - self._set_confidence(raw_prediction) - self._set_position(raw_prediction) - - if page_id is None: - try: - self.page_n = raw_prediction["page_id"] - except KeyError: - pass - else: - self.page_n = page_id - - self.address = raw_prediction["address"] - self.date_of_birth = raw_prediction["date_of_birth"] - self.first_name = raw_prediction["first_name"] - self.last_name = raw_prediction["last_name"] - self.phone_number = raw_prediction["phone_number"] - self.registration_number = raw_prediction["registration_number"] - self.social_security_number = raw_prediction["social_security_number"] - - def _printable_values(self) -> Dict[str, str]: - """Return values for printing.""" - out_dict: Dict[str, str] = {} - out_dict["address"] = format_for_display(self.address) - out_dict["date_of_birth"] = format_for_display(self.date_of_birth) - out_dict["first_name"] = format_for_display(self.first_name) - out_dict["last_name"] = format_for_display(self.last_name) - out_dict["phone_number"] = format_for_display(self.phone_number) - out_dict["registration_number"] = format_for_display(self.registration_number) - out_dict["social_security_number"] = format_for_display( - self.social_security_number - ) - return out_dict - - def to_field_list(self) -> str: - """Output the object in a format suitable for inclusion in an rST field list.""" - printable = self._printable_values() - out_str: str = f" :Address: {printable['address']}\n" - out_str += f" :Date of Birth: {printable['date_of_birth']}\n" - out_str += f" :First Name: {printable['first_name']}\n" - out_str += f" :Last Name: {printable['last_name']}\n" - out_str += f" :Phone Number: {printable['phone_number']}\n" - out_str += f" :Registration Number: {printable['registration_number']}\n" - out_str += f" :Social Security Number: {printable['social_security_number']}\n" - return out_str.rstrip() - - def __str__(self) -> str: - """Default string representation.""" - printable = self._printable_values() - out_str: str = f"Address: {printable['address']}, \n" - out_str += f"Date of Birth: {printable['date_of_birth']}, \n" - out_str += f"First Name: {printable['first_name']}, \n" - out_str += f"Last Name: {printable['last_name']}, \n" - out_str += f"Phone Number: {printable['phone_number']}, \n" - out_str += f"Registration Number: {printable['registration_number']}, \n" - out_str += f"Social Security Number: {printable['social_security_number']}, \n" - return clean_out_string(out_str) diff --git a/mindee/product/fr/payslip/payslip_v2_employer.py b/mindee/product/fr/payslip/payslip_v2_employer.py deleted file mode 100644 index b1bf8ac5..00000000 --- a/mindee/product/fr/payslip/payslip_v2_employer.py +++ /dev/null @@ -1,86 +0,0 @@ -from typing import Dict, Optional - -from mindee.parsing.common.string_dict import StringDict -from mindee.parsing.common.summary_helper import clean_out_string, format_for_display -from mindee.parsing.standard.base import FieldConfidenceMixin, FieldPositionMixin - - -class PayslipV2Employer(FieldPositionMixin, FieldConfidenceMixin): - """Information about the employer.""" - - address: Optional[str] - """The address of the employer.""" - company_id: Optional[str] - """The company ID of the employer.""" - company_site: Optional[str] - """The site of the company.""" - naf_code: Optional[str] - """The NAF code of the employer.""" - name: Optional[str] - """The name of the employer.""" - phone_number: Optional[str] - """The phone number of the employer.""" - urssaf_number: Optional[str] - """The URSSAF number of the employer.""" - page_n: int - """The document page on which the information was found.""" - - def __init__( - self, - raw_prediction: StringDict, - page_id: Optional[int] = None, - ): - self._set_confidence(raw_prediction) - self._set_position(raw_prediction) - - if page_id is None: - try: - self.page_n = raw_prediction["page_id"] - except KeyError: - pass - else: - self.page_n = page_id - - self.address = raw_prediction["address"] - self.company_id = raw_prediction["company_id"] - self.company_site = raw_prediction["company_site"] - self.naf_code = raw_prediction["naf_code"] - self.name = raw_prediction["name"] - self.phone_number = raw_prediction["phone_number"] - self.urssaf_number = raw_prediction["urssaf_number"] - - def _printable_values(self) -> Dict[str, str]: - """Return values for printing.""" - out_dict: Dict[str, str] = {} - out_dict["address"] = format_for_display(self.address) - out_dict["company_id"] = format_for_display(self.company_id) - out_dict["company_site"] = format_for_display(self.company_site) - out_dict["naf_code"] = format_for_display(self.naf_code) - out_dict["name"] = format_for_display(self.name) - out_dict["phone_number"] = format_for_display(self.phone_number) - out_dict["urssaf_number"] = format_for_display(self.urssaf_number) - return out_dict - - def to_field_list(self) -> str: - """Output the object in a format suitable for inclusion in an rST field list.""" - printable = self._printable_values() - out_str: str = f" :Address: {printable['address']}\n" - out_str += f" :Company ID: {printable['company_id']}\n" - out_str += f" :Company Site: {printable['company_site']}\n" - out_str += f" :NAF Code: {printable['naf_code']}\n" - out_str += f" :Name: {printable['name']}\n" - out_str += f" :Phone Number: {printable['phone_number']}\n" - out_str += f" :URSSAF Number: {printable['urssaf_number']}\n" - return out_str.rstrip() - - def __str__(self) -> str: - """Default string representation.""" - printable = self._printable_values() - out_str: str = f"Address: {printable['address']}, \n" - out_str += f"Company ID: {printable['company_id']}, \n" - out_str += f"Company Site: {printable['company_site']}, \n" - out_str += f"NAF Code: {printable['naf_code']}, \n" - out_str += f"Name: {printable['name']}, \n" - out_str += f"Phone Number: {printable['phone_number']}, \n" - out_str += f"URSSAF Number: {printable['urssaf_number']}, \n" - return clean_out_string(out_str) diff --git a/mindee/product/fr/payslip/payslip_v2_employment.py b/mindee/product/fr/payslip/payslip_v2_employment.py deleted file mode 100644 index 683a624c..00000000 --- a/mindee/product/fr/payslip/payslip_v2_employment.py +++ /dev/null @@ -1,85 +0,0 @@ -from typing import Dict, Optional - -from mindee.parsing.common.string_dict import StringDict -from mindee.parsing.common.summary_helper import clean_out_string, format_for_display -from mindee.parsing.standard.base import ( - FieldConfidenceMixin, - FieldPositionMixin, - float_to_string, - to_opt_float, -) - - -class PayslipV2Employment(FieldPositionMixin, FieldConfidenceMixin): - """Information about the employment.""" - - category: Optional[str] - """The category of the employment.""" - coefficient: Optional[float] - """The coefficient of the employment.""" - collective_agreement: Optional[str] - """The collective agreement of the employment.""" - job_title: Optional[str] - """The job title of the employee.""" - position_level: Optional[str] - """The position level of the employment.""" - start_date: Optional[str] - """The start date of the employment.""" - page_n: int - """The document page on which the information was found.""" - - def __init__( - self, - raw_prediction: StringDict, - page_id: Optional[int] = None, - ): - self._set_confidence(raw_prediction) - self._set_position(raw_prediction) - - if page_id is None: - try: - self.page_n = raw_prediction["page_id"] - except KeyError: - pass - else: - self.page_n = page_id - - self.category = raw_prediction["category"] - self.coefficient = to_opt_float(raw_prediction, "coefficient") - self.collective_agreement = raw_prediction["collective_agreement"] - self.job_title = raw_prediction["job_title"] - self.position_level = raw_prediction["position_level"] - self.start_date = raw_prediction["start_date"] - - def _printable_values(self) -> Dict[str, str]: - """Return values for printing.""" - out_dict: Dict[str, str] = {} - out_dict["category"] = format_for_display(self.category) - out_dict["coefficient"] = float_to_string(self.coefficient) - out_dict["collective_agreement"] = format_for_display(self.collective_agreement) - out_dict["job_title"] = format_for_display(self.job_title) - out_dict["position_level"] = format_for_display(self.position_level) - out_dict["start_date"] = format_for_display(self.start_date) - return out_dict - - def to_field_list(self) -> str: - """Output the object in a format suitable for inclusion in an rST field list.""" - printable = self._printable_values() - out_str: str = f" :Category: {printable['category']}\n" - out_str += f" :Coefficient: {printable['coefficient']}\n" - out_str += f" :Collective Agreement: {printable['collective_agreement']}\n" - out_str += f" :Job Title: {printable['job_title']}\n" - out_str += f" :Position Level: {printable['position_level']}\n" - out_str += f" :Start Date: {printable['start_date']}\n" - return out_str.rstrip() - - def __str__(self) -> str: - """Default string representation.""" - printable = self._printable_values() - out_str: str = f"Category: {printable['category']}, \n" - out_str += f"Coefficient: {printable['coefficient']}, \n" - out_str += f"Collective Agreement: {printable['collective_agreement']}, \n" - out_str += f"Job Title: {printable['job_title']}, \n" - out_str += f"Position Level: {printable['position_level']}, \n" - out_str += f"Start Date: {printable['start_date']}, \n" - return clean_out_string(out_str) diff --git a/mindee/product/fr/payslip/payslip_v2_pay_detail.py b/mindee/product/fr/payslip/payslip_v2_pay_detail.py deleted file mode 100644 index 3ef7144c..00000000 --- a/mindee/product/fr/payslip/payslip_v2_pay_detail.py +++ /dev/null @@ -1,115 +0,0 @@ -from typing import Dict, Optional - -from mindee.parsing.common.string_dict import StringDict -from mindee.parsing.common.summary_helper import clean_out_string -from mindee.parsing.standard.base import ( - FieldConfidenceMixin, - FieldPositionMixin, - float_to_string, - to_opt_float, -) - - -class PayslipV2PayDetail(FieldPositionMixin, FieldConfidenceMixin): - """Detailed information about the pay.""" - - gross_salary: Optional[float] - """The gross salary of the employee.""" - gross_salary_ytd: Optional[float] - """The year-to-date gross salary of the employee.""" - income_tax_rate: Optional[float] - """The income tax rate of the employee.""" - income_tax_withheld: Optional[float] - """The income tax withheld from the employee's pay.""" - net_paid: Optional[float] - """The net paid amount of the employee.""" - net_paid_before_tax: Optional[float] - """The net paid amount before tax of the employee.""" - net_taxable: Optional[float] - """The net taxable amount of the employee.""" - net_taxable_ytd: Optional[float] - """The year-to-date net taxable amount of the employee.""" - total_cost_employer: Optional[float] - """The total cost to the employer.""" - total_taxes_and_deductions: Optional[float] - """The total taxes and deductions of the employee.""" - page_n: int - """The document page on which the information was found.""" - - def __init__( - self, - raw_prediction: StringDict, - page_id: Optional[int] = None, - ): - self._set_confidence(raw_prediction) - self._set_position(raw_prediction) - - if page_id is None: - try: - self.page_n = raw_prediction["page_id"] - except KeyError: - pass - else: - self.page_n = page_id - - self.gross_salary = to_opt_float(raw_prediction, "gross_salary") - self.gross_salary_ytd = to_opt_float(raw_prediction, "gross_salary_ytd") - self.income_tax_rate = to_opt_float(raw_prediction, "income_tax_rate") - self.income_tax_withheld = to_opt_float(raw_prediction, "income_tax_withheld") - self.net_paid = to_opt_float(raw_prediction, "net_paid") - self.net_paid_before_tax = to_opt_float(raw_prediction, "net_paid_before_tax") - self.net_taxable = to_opt_float(raw_prediction, "net_taxable") - self.net_taxable_ytd = to_opt_float(raw_prediction, "net_taxable_ytd") - self.total_cost_employer = to_opt_float(raw_prediction, "total_cost_employer") - self.total_taxes_and_deductions = to_opt_float( - raw_prediction, "total_taxes_and_deductions" - ) - - def _printable_values(self) -> Dict[str, str]: - """Return values for printing.""" - out_dict: Dict[str, str] = {} - out_dict["gross_salary"] = float_to_string(self.gross_salary) - out_dict["gross_salary_ytd"] = float_to_string(self.gross_salary_ytd) - out_dict["income_tax_rate"] = float_to_string(self.income_tax_rate) - out_dict["income_tax_withheld"] = float_to_string(self.income_tax_withheld) - out_dict["net_paid"] = float_to_string(self.net_paid) - out_dict["net_paid_before_tax"] = float_to_string(self.net_paid_before_tax) - out_dict["net_taxable"] = float_to_string(self.net_taxable) - out_dict["net_taxable_ytd"] = float_to_string(self.net_taxable_ytd) - out_dict["total_cost_employer"] = float_to_string(self.total_cost_employer) - out_dict["total_taxes_and_deductions"] = float_to_string( - self.total_taxes_and_deductions - ) - return out_dict - - def to_field_list(self) -> str: - """Output the object in a format suitable for inclusion in an rST field list.""" - printable = self._printable_values() - out_str: str = f" :Gross Salary: {printable['gross_salary']}\n" - out_str += f" :Gross Salary YTD: {printable['gross_salary_ytd']}\n" - out_str += f" :Income Tax Rate: {printable['income_tax_rate']}\n" - out_str += f" :Income Tax Withheld: {printable['income_tax_withheld']}\n" - out_str += f" :Net Paid: {printable['net_paid']}\n" - out_str += f" :Net Paid Before Tax: {printable['net_paid_before_tax']}\n" - out_str += f" :Net Taxable: {printable['net_taxable']}\n" - out_str += f" :Net Taxable YTD: {printable['net_taxable_ytd']}\n" - out_str += f" :Total Cost Employer: {printable['total_cost_employer']}\n" - out_str += f" :Total Taxes and Deductions: {printable['total_taxes_and_deductions']}\n" - return out_str.rstrip() - - def __str__(self) -> str: - """Default string representation.""" - printable = self._printable_values() - out_str: str = f"Gross Salary: {printable['gross_salary']}, \n" - out_str += f"Gross Salary YTD: {printable['gross_salary_ytd']}, \n" - out_str += f"Income Tax Rate: {printable['income_tax_rate']}, \n" - out_str += f"Income Tax Withheld: {printable['income_tax_withheld']}, \n" - out_str += f"Net Paid: {printable['net_paid']}, \n" - out_str += f"Net Paid Before Tax: {printable['net_paid_before_tax']}, \n" - out_str += f"Net Taxable: {printable['net_taxable']}, \n" - out_str += f"Net Taxable YTD: {printable['net_taxable_ytd']}, \n" - out_str += f"Total Cost Employer: {printable['total_cost_employer']}, \n" - out_str += ( - f"Total Taxes and Deductions: {printable['total_taxes_and_deductions']}, \n" - ) - return clean_out_string(out_str) diff --git a/mindee/product/fr/payslip/payslip_v2_pay_period.py b/mindee/product/fr/payslip/payslip_v2_pay_period.py deleted file mode 100644 index fc7f7d23..00000000 --- a/mindee/product/fr/payslip/payslip_v2_pay_period.py +++ /dev/null @@ -1,74 +0,0 @@ -from typing import Dict, Optional - -from mindee.parsing.common.string_dict import StringDict -from mindee.parsing.common.summary_helper import clean_out_string, format_for_display -from mindee.parsing.standard.base import FieldConfidenceMixin, FieldPositionMixin - - -class PayslipV2PayPeriod(FieldPositionMixin, FieldConfidenceMixin): - """Information about the pay period.""" - - end_date: Optional[str] - """The end date of the pay period.""" - month: Optional[str] - """The month of the pay period.""" - payment_date: Optional[str] - """The date of payment for the pay period.""" - start_date: Optional[str] - """The start date of the pay period.""" - year: Optional[str] - """The year of the pay period.""" - page_n: int - """The document page on which the information was found.""" - - def __init__( - self, - raw_prediction: StringDict, - page_id: Optional[int] = None, - ): - self._set_confidence(raw_prediction) - self._set_position(raw_prediction) - - if page_id is None: - try: - self.page_n = raw_prediction["page_id"] - except KeyError: - pass - else: - self.page_n = page_id - - self.end_date = raw_prediction["end_date"] - self.month = raw_prediction["month"] - self.payment_date = raw_prediction["payment_date"] - self.start_date = raw_prediction["start_date"] - self.year = raw_prediction["year"] - - def _printable_values(self) -> Dict[str, str]: - """Return values for printing.""" - out_dict: Dict[str, str] = {} - out_dict["end_date"] = format_for_display(self.end_date) - out_dict["month"] = format_for_display(self.month) - out_dict["payment_date"] = format_for_display(self.payment_date) - out_dict["start_date"] = format_for_display(self.start_date) - out_dict["year"] = format_for_display(self.year) - return out_dict - - def to_field_list(self) -> str: - """Output the object in a format suitable for inclusion in an rST field list.""" - printable = self._printable_values() - out_str: str = f" :End Date: {printable['end_date']}\n" - out_str += f" :Month: {printable['month']}\n" - out_str += f" :Payment Date: {printable['payment_date']}\n" - out_str += f" :Start Date: {printable['start_date']}\n" - out_str += f" :Year: {printable['year']}\n" - return out_str.rstrip() - - def __str__(self) -> str: - """Default string representation.""" - printable = self._printable_values() - out_str: str = f"End Date: {printable['end_date']}, \n" - out_str += f"Month: {printable['month']}, \n" - out_str += f"Payment Date: {printable['payment_date']}, \n" - out_str += f"Start Date: {printable['start_date']}, \n" - out_str += f"Year: {printable['year']}, \n" - return clean_out_string(out_str) diff --git a/mindee/product/fr/payslip/payslip_v2_pto.py b/mindee/product/fr/payslip/payslip_v2_pto.py deleted file mode 100644 index b6208af5..00000000 --- a/mindee/product/fr/payslip/payslip_v2_pto.py +++ /dev/null @@ -1,69 +0,0 @@ -from typing import Dict, Optional - -from mindee.parsing.common.string_dict import StringDict -from mindee.parsing.common.summary_helper import clean_out_string -from mindee.parsing.standard.base import ( - FieldConfidenceMixin, - FieldPositionMixin, - float_to_string, - to_opt_float, -) - - -class PayslipV2Pto(FieldPositionMixin, FieldConfidenceMixin): - """Information about paid time off.""" - - accrued_this_period: Optional[float] - """The amount of paid time off accrued in this period.""" - balance_end_of_period: Optional[float] - """The balance of paid time off at the end of the period.""" - used_this_period: Optional[float] - """The amount of paid time off used in this period.""" - page_n: int - """The document page on which the information was found.""" - - def __init__( - self, - raw_prediction: StringDict, - page_id: Optional[int] = None, - ): - self._set_confidence(raw_prediction) - self._set_position(raw_prediction) - - if page_id is None: - try: - self.page_n = raw_prediction["page_id"] - except KeyError: - pass - else: - self.page_n = page_id - - self.accrued_this_period = to_opt_float(raw_prediction, "accrued_this_period") - self.balance_end_of_period = to_opt_float( - raw_prediction, "balance_end_of_period" - ) - self.used_this_period = to_opt_float(raw_prediction, "used_this_period") - - def _printable_values(self) -> Dict[str, str]: - """Return values for printing.""" - out_dict: Dict[str, str] = {} - out_dict["accrued_this_period"] = float_to_string(self.accrued_this_period) - out_dict["balance_end_of_period"] = float_to_string(self.balance_end_of_period) - out_dict["used_this_period"] = float_to_string(self.used_this_period) - return out_dict - - def to_field_list(self) -> str: - """Output the object in a format suitable for inclusion in an rST field list.""" - printable = self._printable_values() - out_str: str = f" :Accrued This Period: {printable['accrued_this_period']}\n" - out_str += f" :Balance End of Period: {printable['balance_end_of_period']}\n" - out_str += f" :Used This Period: {printable['used_this_period']}\n" - return out_str.rstrip() - - def __str__(self) -> str: - """Default string representation.""" - printable = self._printable_values() - out_str: str = f"Accrued This Period: {printable['accrued_this_period']}, \n" - out_str += f"Balance End of Period: {printable['balance_end_of_period']}, \n" - out_str += f"Used This Period: {printable['used_this_period']}, \n" - return clean_out_string(out_str) diff --git a/mindee/product/fr/payslip/payslip_v2_salary_detail.py b/mindee/product/fr/payslip/payslip_v2_salary_detail.py deleted file mode 100644 index 4494916c..00000000 --- a/mindee/product/fr/payslip/payslip_v2_salary_detail.py +++ /dev/null @@ -1,82 +0,0 @@ -from typing import Dict, Optional - -from mindee.parsing.common.string_dict import StringDict -from mindee.parsing.common.summary_helper import clean_out_string, format_for_display -from mindee.parsing.standard.base import ( - FieldConfidenceMixin, - FieldPositionMixin, - float_to_string, - to_opt_float, -) - - -class PayslipV2SalaryDetail(FieldPositionMixin, FieldConfidenceMixin): - """Detailed information about the earnings.""" - - amount: Optional[float] - """The amount of the earnings.""" - base: Optional[float] - """The base value of the earnings.""" - description: Optional[str] - """The description of the earnings.""" - rate: Optional[float] - """The rate of the earnings.""" - page_n: int - """The document page on which the information was found.""" - - def __init__( - self, - raw_prediction: StringDict, - page_id: Optional[int] = None, - ): - self._set_confidence(raw_prediction) - self._set_position(raw_prediction) - - if page_id is None: - try: - self.page_n = raw_prediction["page_id"] - except KeyError: - pass - else: - self.page_n = page_id - - self.amount = to_opt_float(raw_prediction, "amount") - self.base = to_opt_float(raw_prediction, "base") - self.description = raw_prediction["description"] - self.rate = to_opt_float(raw_prediction, "rate") - - def _printable_values(self) -> Dict[str, str]: - """Return values for printing.""" - out_dict: Dict[str, str] = {} - out_dict["amount"] = float_to_string(self.amount) - out_dict["base"] = float_to_string(self.base) - out_dict["description"] = format_for_display(self.description) - out_dict["rate"] = float_to_string(self.rate) - 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["amount"] = float_to_string(self.amount) - out_dict["base"] = float_to_string(self.base) - out_dict["description"] = format_for_display(self.description, 36) - out_dict["rate"] = float_to_string(self.rate) - 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['amount']:<12} | " - out_str += f"{printable['base']:<9} | " - out_str += f"{printable['description']:<36} | " - out_str += f"{printable['rate']:<9} | " - return clean_out_string(out_str) - - def __str__(self) -> str: - """Default string representation.""" - printable = self._printable_values() - out_str: str = f"Amount: {printable['amount']}, \n" - out_str += f"Base: {printable['base']}, \n" - out_str += f"Description: {printable['description']}, \n" - out_str += f"Rate: {printable['rate']}, \n" - return clean_out_string(out_str) diff --git a/tests/v1/product/fr/payslip/test_payslip_v2.py b/tests/v1/product/fr/payslip/test_payslip_v2.py deleted file mode 100644 index 0ece5278..00000000 --- a/tests/v1/product/fr/payslip/test_payslip_v2.py +++ /dev/null @@ -1,87 +0,0 @@ -import json - -import pytest - -from mindee.parsing.common.document import Document -from mindee.parsing.common.page import Page -from mindee.product.fr.payslip.payslip_v2 import PayslipV2 -from mindee.product.fr.payslip.payslip_v2_document import ( - PayslipV2Document, -) -from tests.utils import V1_PRODUCT_DATA_DIR - -RESPONSE_DIR = V1_PRODUCT_DATA_DIR / "payslip_fra" / "response_v2" - -PayslipV2DocumentType = Document[ - PayslipV2Document, - Page[PayslipV2Document], -] - - -@pytest.fixture -def complete_doc() -> PayslipV2DocumentType: - file_path = RESPONSE_DIR / "complete.json" - with open(file_path, "r", encoding="utf-8") as open_file: - json_data = json.load(open_file) - return Document(PayslipV2, json_data["document"]) - - -@pytest.fixture -def empty_doc() -> PayslipV2DocumentType: - file_path = RESPONSE_DIR / "empty.json" - with open(file_path, "r", encoding="utf-8") as open_file: - json_data = json.load(open_file) - return Document(PayslipV2, json_data["document"]) - - -def test_complete_doc(complete_doc: PayslipV2DocumentType): - file_path = RESPONSE_DIR / "summary_full.rst" - with open(file_path, "r", encoding="utf-8") as open_file: - reference_str = open_file.read() - assert str(complete_doc) == reference_str - - -def test_empty_doc(empty_doc: PayslipV2DocumentType): - prediction = empty_doc.inference.prediction - assert prediction.employee.address is None - assert prediction.employee.date_of_birth is None - assert prediction.employee.first_name is None - assert prediction.employee.last_name is None - assert prediction.employee.phone_number is None - assert prediction.employee.registration_number is None - assert prediction.employee.social_security_number is None - assert prediction.employer.address is None - assert prediction.employer.company_id is None - assert prediction.employer.company_site is None - assert prediction.employer.naf_code is None - assert prediction.employer.name is None - assert prediction.employer.phone_number is None - assert prediction.employer.urssaf_number is None - assert prediction.bank_account_details.bank_name is None - assert prediction.bank_account_details.iban is None - assert prediction.bank_account_details.swift is None - assert prediction.employment.category is None - assert prediction.employment.coefficient is None - assert prediction.employment.collective_agreement is None - assert prediction.employment.job_title is None - assert prediction.employment.position_level is None - assert prediction.employment.start_date is None - assert len(prediction.salary_details) == 0 - assert prediction.pay_detail.gross_salary is None - assert prediction.pay_detail.gross_salary_ytd is None - assert prediction.pay_detail.income_tax_rate is None - assert prediction.pay_detail.income_tax_withheld is None - assert prediction.pay_detail.net_paid is None - assert prediction.pay_detail.net_paid_before_tax is None - assert prediction.pay_detail.net_taxable is None - assert prediction.pay_detail.net_taxable_ytd is None - assert prediction.pay_detail.total_cost_employer is None - assert prediction.pay_detail.total_taxes_and_deductions is None - assert prediction.pto.accrued_this_period is None - assert prediction.pto.balance_end_of_period is None - assert prediction.pto.used_this_period is None - assert prediction.pay_period.end_date is None - assert prediction.pay_period.month is None - assert prediction.pay_period.payment_date is None - assert prediction.pay_period.start_date is None - assert prediction.pay_period.year is None