Skip to content

feat: add tax_id field to Company model and related forms #9673

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/company/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down
23 changes: 23 additions & 0 deletions src/backend/InvenTree/company/migrations/0075_company_tax_id.py
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
8 changes: 8 additions & 0 deletions src/backend/InvenTree/company/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/backend/InvenTree/company/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Meta:
'image',
'thumbnail',
'currency',
'tax_id',
]
read_only_fields = ['currency']

Expand Down Expand Up @@ -145,6 +146,7 @@ class Meta:
'remote_image',
'address_count',
'primary_address',
'tax_id',
]

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/forms/CompanyForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export function companyFields(): ApiFormFieldSet {
email: {
icon: <IconAt />
},
tax_id: {},
is_supplier: {},
is_manufacturer: {},
is_customer: {},
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/functions/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import {
IconStack2,
IconStatusChange,
IconTag,
IconTax,
IconTestPipe,
IconTool,
IconTools,
Expand Down Expand Up @@ -181,6 +182,7 @@ const icons: InvenTreeIconType = {
admin: IconUserBolt,
system: IconSettings,
license: IconLicense,
tax_id: IconTax,

// Part Icons
active: IconCheck,
Expand Down
7 changes: 7 additions & 0 deletions src/frontend/src/pages/company/CompanyDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ export default function CompanyDetail(props: Readonly<CompanyDetailProps>) {
label: t`Email Address`,
copy: true,
hidden: !company.email
},
{
type: 'text',
name: 'tax_id',
label: t`Tax ID`,
copy: true,
hidden: !company.tax_id
}
];

Expand Down