From 6e7a4b9618d39aa94199437d2b64f8127e12aac1 Mon Sep 17 00:00:00 2001 From: sufyan-mukadam Date: Sat, 17 May 2025 20:22:29 +0000 Subject: [PATCH 1/6] feat: add tax_id field to Company model and related forms --- .pre-commit-config.yaml | 8 +++---- src/backend/InvenTree/company/api.py | 2 +- .../company/migrations/0075_company_tax_id.py | 23 +++++++++++++++++++ src/backend/InvenTree/company/models.py | 8 +++++++ src/backend/InvenTree/company/serializers.py | 2 ++ src/frontend/src/forms/CompanyForms.tsx | 1 + src/frontend/src/functions/icons.tsx | 2 ++ .../src/pages/company/CompanyDetail.tsx | 7 ++++++ 8 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 src/backend/InvenTree/company/migrations/0075_company_tax_id.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89659bcdc00c..64ac08e37e69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: check-yaml - id: mixed-line-ending - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.0 + rev: v0.11.10 hooks: - id: ruff-format args: [--preview] @@ -28,7 +28,7 @@ repos: --preview ] - repo: https://github.com/astral-sh/uv-pre-commit - rev: 0.6.6 + rev: 0.7.5 hooks: - id: pip-compile name: pip-compile requirements-dev.in @@ -70,13 +70,13 @@ repos: src/frontend/vite.config.ts | )$ - repo: https://github.com/biomejs/pre-commit - rev: v1.9.4 + rev: v2.0.0-beta.4 hooks: - id: biome-check additional_dependencies: ["@biomejs/biome@1.9.4"] files: ^src/frontend/.*\.(js|ts|tsx)$ - repo: https://github.com/gitleaks/gitleaks - rev: v8.24.0 + rev: v8.26.0 hooks: - id: gitleaks language_version: 1.23.6 diff --git a/src/backend/InvenTree/company/api.py b/src/backend/InvenTree/company/api.py index d4ba2c09907b..5af91875833f 100644 --- a/src/backend/InvenTree/company/api.py +++ b/src/backend/InvenTree/company/api.py @@ -60,7 +60,7 @@ def get_queryset(self): 'active', ] - search_fields = ['name', 'description', 'website'] + search_fields = ['name', 'description', 'website', 'tax_id'] ordering_fields = ['active', 'name', 'parts_supplied', 'parts_manufactured'] diff --git a/src/backend/InvenTree/company/migrations/0075_company_tax_id.py b/src/backend/InvenTree/company/migrations/0075_company_tax_id.py new file mode 100644 index 000000000000..217fb7fb01ef --- /dev/null +++ b/src/backend/InvenTree/company/migrations/0075_company_tax_id.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.21 on 2025-05-17 17:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("company", "0074_alter_manufacturerpart_link"), + ] + + operations = [ + migrations.AddField( + model_name="company", + name="tax_id", + field=models.CharField( + blank=True, + help_text="Company Tax iD", + max_length=50, + verbose_name="Tax ID", + ), + ), + ] diff --git a/src/backend/InvenTree/company/models.py b/src/backend/InvenTree/company/models.py index edf94415d9e7..9f452a3423e0 100644 --- a/src/backend/InvenTree/company/models.py +++ b/src/backend/InvenTree/company/models.py @@ -85,6 +85,7 @@ class Company( is_supplier: boolean value, is this company a supplier is_manufacturer: boolean value, is this company a manufacturer currency_code: Specifies the default currency for the company + tax_id: Tax ID for the company """ class Meta: @@ -191,6 +192,13 @@ def get_api_url(): validators=[InvenTree.validators.validate_currency_code], ) + tax_id = models.CharField( + max_length=50, + blank=True, + verbose_name=_('Tax ID'), + help_text=_('Company Tax iD'), + ) + @property def address(self): """Return the string representation for the primary address. diff --git a/src/backend/InvenTree/company/serializers.py b/src/backend/InvenTree/company/serializers.py index fa8605bcc36a..3763593378c9 100644 --- a/src/backend/InvenTree/company/serializers.py +++ b/src/backend/InvenTree/company/serializers.py @@ -52,6 +52,7 @@ class Meta: 'image', 'thumbnail', 'currency', + 'tax_id', ] read_only_fields = ['currency'] @@ -145,6 +146,7 @@ class Meta: 'remote_image', 'address_count', 'primary_address', + 'tax_id', ] @staticmethod diff --git a/src/frontend/src/forms/CompanyForms.tsx b/src/frontend/src/forms/CompanyForms.tsx index d7be251e1242..8d0ebb6c45a8 100644 --- a/src/frontend/src/forms/CompanyForms.tsx +++ b/src/frontend/src/forms/CompanyForms.tsx @@ -125,6 +125,7 @@ export function companyFields(): ApiFormFieldSet { email: { icon: }, + tax_id: {}, is_supplier: {}, is_manufacturer: {}, is_customer: {}, diff --git a/src/frontend/src/functions/icons.tsx b/src/frontend/src/functions/icons.tsx index bd9a3b03376b..1cf0a2d2f343 100644 --- a/src/frontend/src/functions/icons.tsx +++ b/src/frontend/src/functions/icons.tsx @@ -87,6 +87,7 @@ import { IconStack2, IconStatusChange, IconTag, + IconTax, IconTestPipe, IconTool, IconTools, @@ -181,6 +182,7 @@ const icons: InvenTreeIconType = { admin: IconUserBolt, system: IconSettings, license: IconLicense, + tax_id: IconTax, // Part Icons active: IconCheck, diff --git a/src/frontend/src/pages/company/CompanyDetail.tsx b/src/frontend/src/pages/company/CompanyDetail.tsx index 224ecd78c8d0..d56f0d34b373 100644 --- a/src/frontend/src/pages/company/CompanyDetail.tsx +++ b/src/frontend/src/pages/company/CompanyDetail.tsx @@ -114,6 +114,13 @@ export default function CompanyDetail(props: Readonly) { label: t`Email Address`, copy: true, hidden: !company.email + }, + { + type: 'text', + name: 'tax_id', + label: t`Tax ID`, + copy: true, + hidden: !company.tax_id } ]; From d7324a5e4cac3d75c0fab45a1d4a86893e0e5908 Mon Sep 17 00:00:00 2001 From: sufyan-mukadam <96058093+sufyan-mukadam@users.noreply.github.com> Date: Sun, 18 May 2025 13:40:10 +0100 Subject: [PATCH 2/6] Update 0075_company_tax_id.py to fix typo --- src/backend/InvenTree/company/migrations/0075_company_tax_id.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/InvenTree/company/migrations/0075_company_tax_id.py b/src/backend/InvenTree/company/migrations/0075_company_tax_id.py index 217fb7fb01ef..15f8f2ff46f8 100644 --- a/src/backend/InvenTree/company/migrations/0075_company_tax_id.py +++ b/src/backend/InvenTree/company/migrations/0075_company_tax_id.py @@ -15,7 +15,7 @@ class Migration(migrations.Migration): name="tax_id", field=models.CharField( blank=True, - help_text="Company Tax iD", + help_text="Company Tax ID", max_length=50, verbose_name="Tax ID", ), From 7d8ffca8f26b0786656e4aff41fa24601bf7d175 Mon Sep 17 00:00:00 2001 From: sufyan-mukadam <96058093+sufyan-mukadam@users.noreply.github.com> Date: Sun, 18 May 2025 13:45:00 +0100 Subject: [PATCH 3/6] Update models.py to fix typo --- src/backend/InvenTree/company/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/InvenTree/company/models.py b/src/backend/InvenTree/company/models.py index 9f452a3423e0..00ae95b6db58 100644 --- a/src/backend/InvenTree/company/models.py +++ b/src/backend/InvenTree/company/models.py @@ -196,7 +196,7 @@ def get_api_url(): max_length=50, blank=True, verbose_name=_('Tax ID'), - help_text=_('Company Tax iD'), + help_text=_('Company Tax ID'), ) @property From 61552fa85c385e5b7885d5145b1f8d78ed4ce7de Mon Sep 17 00:00:00 2001 From: sufyan-mukadam <96058093+sufyan-mukadam@users.noreply.github.com> Date: Sun, 18 May 2025 13:59:06 +0100 Subject: [PATCH 4/6] Update api_version.py --- src/backend/InvenTree/InvenTree/api_version.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index 485d16a99b64..6220aceaf95d 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,12 +1,16 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 342 +INVENTREE_API_VERSION = 343 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ +v343 -> 2025-05-18 : https://github.com/inventree/InvenTree/pull/9673 + - Adds 'tax_id' to company model + - Adds 'tax_id' to search fields in the 'CompanyList' API endpoint + v342 -> 2025-05-09 : https://github.com/inventree/InvenTree/pull/9651 - Fix serializer to match Generate API for serial numbers From 8354bb4949624b5533736d5bb2fdde4d35bdf875 Mon Sep 17 00:00:00 2001 From: sufyan-mukadam <96058093+sufyan-mukadam@users.noreply.github.com> Date: Sun, 18 May 2025 16:16:15 +0100 Subject: [PATCH 5/6] Update api_version.py to remove trailing whitespace --- src/backend/InvenTree/InvenTree/api_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index 6220aceaf95d..b35929c5c755 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -9,7 +9,7 @@ INVENTREE_API_TEXT = """ v343 -> 2025-05-18 : https://github.com/inventree/InvenTree/pull/9673 - Adds 'tax_id' to company model - - Adds 'tax_id' to search fields in the 'CompanyList' API endpoint + - Adds 'tax_id' to search fields in the 'CompanyList' API endpoint v342 -> 2025-05-09 : https://github.com/inventree/InvenTree/pull/9651 - Fix serializer to match Generate API for serial numbers From 86fc770f8fdc250858775fba2116e56437f4d779 Mon Sep 17 00:00:00 2001 From: sufyan-mukadam <96058093+sufyan-mukadam@users.noreply.github.com> Date: Sun, 18 May 2025 17:40:49 +0100 Subject: [PATCH 6/6] Update tests.py to increment 'column_mappings.count()' to 15 --- src/backend/InvenTree/importer/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/InvenTree/importer/tests.py b/src/backend/InvenTree/importer/tests.py index 45ea5052c7a9..2393feb1cfbe 100644 --- a/src/backend/InvenTree/importer/tests.py +++ b/src/backend/InvenTree/importer/tests.py @@ -39,7 +39,7 @@ def test_import_session(self): session.extract_columns() - self.assertEqual(session.column_mappings.count(), 14) + self.assertEqual(session.column_mappings.count(), 15) # Check some of the field mappings for field, col in [