Skip to content
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

Feat: LCFS - Allow Organization details to include International address headquarters #2109

Merged
merged 28 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fff034e
Feat: LCFS - Allow Organization details to include International addr…
Feb 20, 2025
5aea835
update bceid user end
Feb 20, 2025
ee0494e
.
Feb 20, 2025
140ea14
async coordinates
Feb 20, 2025
b3675e8
Merge branch 'release-1.0.0' into feat/prashanth-org-head-office-1911
prv-proton Feb 20, 2025
52afb77
Merge branch 'release-1.0.0' into feat/prashanth-org-head-office-1911
prv-proton Feb 20, 2025
c1e0bd4
Merge branch 'release-1.0.0' into feat/prashanth-org-head-office-1911
prv-proton Feb 21, 2025
88d8ff4
fix test cases
Feb 21, 2025
fdff0a9
Merge branch 'release-1.0.0' into feat/prashanth-org-head-office-1911
prv-proton Feb 21, 2025
efa030d
fix tests
Feb 21, 2025
7041402
Merge branch 'release-1.0.0' into feat/prashanth-org-head-office-1911
prv-proton Feb 21, 2025
4ef88c4
Merge branch 'release-1.0.0' into feat/prashanth-org-head-office-1911
prv-proton Feb 22, 2025
475613d
Merge branch 'release-1.0.0' into feat/prashanth-org-head-office-1911
prv-proton Feb 24, 2025
a4630db
Merge branch 'develop' into feat/prashanth-org-head-office-1911
prv-proton Feb 26, 2025
ace3a2a
updates
Feb 27, 2025
4aa81cb
Merge branch 'develop' into feat/prashanth-org-head-office-1911
prv-proton Feb 27, 2025
8472626
enforce postal code addition
Feb 27, 2025
040e986
.
Feb 27, 2025
e8b6815
.
Feb 27, 2025
10433a5
Merge branch 'develop' into feat/prashanth-org-head-office-1911
prv-proton Feb 28, 2025
9ccdd32
Merge branch 'develop' into feat/prashanth-org-head-office-1911
prv-proton Feb 28, 2025
edb9432
updates
Feb 28, 2025
f935c83
.
Feb 28, 2025
54a67e0
id updates
Feb 28, 2025
8bd03a3
Merge branch 'develop' into feat/prashanth-org-head-office-1911
prv-proton Feb 28, 2025
4ae8b2c
conflict code issues
Feb 28, 2025
3650720
add caching
Mar 1, 2025
7cf2761
review comments fix
Mar 3, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"""add record's address to organization

Revision ID: c1e2d64aeea4
Revises: 985de92bdf83
Create Date: 2025-02-19 04:17:03.668963

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "c1e2d64aeea4"
down_revision = "985de92bdf83"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"organization",
sa.Column(
"records_address",
sa.String(length=2000),
nullable=True,
comment="Organization's address in BC where records are maintained",
),
)
op.alter_column(
"compliance_report_organization_snapshot",
"service_address",
new_column_name="head_office_address",
existing_type=sa.String(length=500),
existing_nullable=True,
comment="Organization's address in BC",
)
op.alter_column(
"compliance_report_organization_snapshot",
"bc_address",
new_column_name="service_address",
existing_type=sa.String(length=500),
existing_nullable=True,
comment="Organization's address in BC",
)

# Add records_address column
op.add_column(
"compliance_report_organization_snapshot",
sa.Column(
"records_address",
sa.String(length=500),
nullable=True,
comment="Organization's address in BC where records are maintained.",
),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("organization", "records_address")
op.alter_column(
"compliance_report_organization_snapshot",
"service_address",
new_column_name="bc_address",
existing_type=sa.String(length=500),
existing_nullable=True,
comment="Organization's address in BC",
)
op.alter_column(
"compliance_report_organization_snapshot",
"head_office_address",
new_column_name="service_address",
existing_type=sa.String(length=500),
existing_nullable=True,
comment="Organization's address in BC",
)

# Drop records_address column
op.drop_column("compliance_report_organization_snapshot", "records_address")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ class ComplianceReportOrganizationSnapshot(BaseModel, Auditable):
)
email = Column(String(255), nullable=True, comment="Organization's email address")
phone = Column(String(50), nullable=True, comment="Organization's phone number")
bc_address = Column(
head_office_address = Column(
String(500), nullable=True, comment="Organization's address in BC"
)
service_address = Column(
String(500), nullable=True, comment="Organization's address for Postal Service"
)
records_address = Column(
String(500), nullable=True, comment="Organization's address in BC where records are maintained."
)

is_edited = Column(
Boolean,
Expand Down
3 changes: 3 additions & 0 deletions backend/lcfs/db/models/organization/Organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class Organization(BaseModel, Auditable, EffectiveDates):
Integer,
ForeignKey("organization_attorney_address.organization_attorney_address_id"),
)
records_address = Column(
String(2000), comment="Organization's address in BC where records are maintained"
)

org_type = relationship(
"OrganizationType", back_populates="organizations", lazy="joined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ async def test_get_snapshot_by_compliance_report_id(
operating_name="Example Operating Name",
email="[email protected]",
phone="123-456-7890",
bc_address="123 BC St.",
head_office_address="123 BC St.",
records_address="789 BC St.",
service_address="456 Service Rd.",
)
mock_org_snapshot_service.get_by_compliance_report_id = AsyncMock(
Expand All @@ -61,7 +62,8 @@ async def test_get_snapshot_by_compliance_report_id(
"operatingName": "Example Operating Name",
"email": "[email protected]",
"phone": "123-456-7890",
"bcAddress": "123 BC St.",
"headOfficeAddress": "123 BC St.",
"recordsAddress": "789 BC St.",
"serviceAddress": "456 Service Rd.",
}

Expand Down Expand Up @@ -100,7 +102,8 @@ async def test_update_compliance_report_snapshot(
operating_name="Updated Operating Name",
email="[email protected]",
phone="987-654-3210",
bc_address="789 Updated BC St.",
head_office_address="789 Updated BC St.",
records_address="756 Updated BC St.",
service_address="321 Updated Service Rd.",
).model_dump()

Expand All @@ -111,7 +114,8 @@ async def test_update_compliance_report_snapshot(
"operatingName": "Updated Operating Name",
"email": "[email protected]",
"phone": "987-654-3210",
"bcAddress": "789 Updated BC St.",
"headOfficeAddress": "789 Updated BC St.",
"recordsAddress": "756 Updated BC St.",
"serviceAddress": "321 Updated Service Rd.",
}

Expand Down
3 changes: 2 additions & 1 deletion backend/lcfs/web/api/organization_snapshot/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class OrganizationSnapshotSchema(BaseSchema):
operating_name: Optional[str] = None
email: Optional[str] = None
phone: Optional[str] = None
bc_address: Optional[str] = None
head_office_address: Optional[str] = None
records_address: Optional[str] = None
service_address: Optional[str] = None
9 changes: 6 additions & 3 deletions backend/lcfs/web/api/organization_snapshot/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async def create_organization_snapshot(self, compliance_report_id, organization_

# 2. Derive BC address and service address from OrganizationAddress
bc_address = None
head_office_address = None
org_address = organization.org_address
if organization.org_address:
bc_address_parts = [
Expand All @@ -60,15 +61,16 @@ async def create_organization_snapshot(self, compliance_report_id, organization_
org_attorney_address.country,
org_attorney_address.postalCode_zipCode,
]
service_address = ", ".join(filter(None, service_addr_parts))
head_office_address = ", ".join(filter(None, service_addr_parts))

# 3. Create the Snapshot
org_snapshot = ComplianceReportOrganizationSnapshot(
name=organization.name,
operating_name=organization.operating_name or organization.name,
email=organization.email,
phone=organization.phone,
bc_address=bc_address,
head_office_address=head_office_address,
records_address=organization.records_address,
service_address=service_address,
compliance_report_id=compliance_report_id,
)
Expand All @@ -92,7 +94,8 @@ async def update(self, request_data, compliance_report_id):
snapshot.operating_name = request_data.operating_name
snapshot.email = request_data.email
snapshot.phone = request_data.phone
snapshot.bc_address = request_data.bc_address
snapshot.head_office_address = request_data.head_office_address
snapshot.records_address = request_data.records_address
snapshot.service_address = request_data.service_address
snapshot.is_edited = True

Expand Down
3 changes: 3 additions & 0 deletions backend/lcfs/web/api/organizations/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class OrganizationCreateSchema(BaseSchema):
has_early_issuance: bool
organization_status_id: int
organization_type_id: int
records_address: Optional[str] = None
address: OrganizationAddressCreateSchema
attorney_address: OrganizationAttorneyAddressCreateSchema

Expand All @@ -168,6 +169,7 @@ class OrganizationUpdateSchema(BaseSchema):
has_early_issuance: bool
organization_status_id: Optional[int] = None
organization_type_id: Optional[int] = None
records_address: Optional[str] = None
address: Optional[OrganizationAddressCreateSchema] = []
attorney_address: Optional[OrganizationAttorneyAddressCreateSchema] = []

Expand All @@ -181,6 +183,7 @@ class OrganizationResponseSchema(BaseSchema):
edrms_record: Optional[str] = None
has_early_issuance: bool
org_status: Optional[OrganizationStatusSchema] = []
records_address: Optional[str] = None
org_address: Optional[OrganizationAddressSchema] = []
org_attorney_address: Optional[OrganizationAttorneyAddressSchema] = []

Expand Down
48 changes: 48 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"esbuild": "^0.25.0",
"i18next": "^23.8.2",
"keycloak-js": "^26.1.2",
"leaflet": "^1.9.4",
"lodash": "^4.17.21",
"material-ui-popup-state": "^5.0.10",
"mui-daterange-picker-plus": "^1.0.4",
Expand All @@ -71,6 +72,8 @@
"react-hook-form": "^7.49.2",
"react-i18next": "^14.0.3",
"react-input-mask": "^2.0.4",
"react-leaflet": "^4.2.1",
"react-leaflet-custom-control": "^1.4.0",
"react-number-format": "^5.4.3",
"react-quill": "^2.0.0",
"react-router-dom": "^6.21.1",
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/assets/locales/en/organization.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@
"earlyIssuanceIndicator": "Early issuance reporting enabled",
"edrmsLabel": "Organization profile, EDRMS record # (optional)",
"serviceAddrLabel": "Address for service (postal address)",
"streetAddrLabel": "Street address / PO box",
"streetAddrLabel": "Street address/PO box",
"addrOthLabel": "Address other (optional)",
"cityLabel": "City",
"provinceLabel": "Province",
"poLabel": "Postal / ZIP code",
"provinceStateLabel": "Province/State",
"poLabel": "Postal code",
"poZipLabel": "Postal code/ZIP code",
"cntryLabel": "Country",
"bcAddrLabel": "Address in B.C. (at which records are maintained)",
"bcAddrLabelShort": "Address in B.C. (at which records are maintained)",
"recordsAddrGuide": "Enter full address including postal code (if different than address for service)",
"bcAddrLabel": "Head office (optional)",
"bcAddrLabelShort": "Head address (optional)",
"bcRecordLabel": "Address in B.C. where records are maintained (optional)",
"bcRecordLabelShort": "Records address (optional)",
"sameAddrLabel": "Same as address for service",
"contactMsg": "to update address information.",
"usersLabel": "Users",
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/assets/locales/en/reports.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
},
"noReportsFound": "No compliance reports found",
"serviceAddrLabel": "Address for service",
"bcAddrLabel": "Address in B.C.",
"hoAddrLabel": "Head office (optional)",
"hoAddrLabelView": "Head office address",
"hoAddrLabelEdit": "Head office address (international)",
"bcRecordLabel": "Address in B.C. (where records are maintained)",
"activityHdrLabel": "Did <b>{{name}}</b> engage in any of the following activities between January 1, {{period}}, and December 31, {{period}}?",
"reportActivities": "Report activities",
"orgDetails": "Organization details",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/BCDataGrid/BCGridBase.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const BCGridBase = forwardRef(
}, [determineHeight])

const clearFilters = useCallback(() => {
const api = gridRef.current?.api
const api = gridRef?.current?.api
if (api) {
// Clear filter model
api.setFilterModel(null)
Expand All @@ -87,7 +87,7 @@ export const BCGridBase = forwardRef(

// Expose clearFilters method through ref
useImperativeHandle(ref, () => ({
...gridRef.current,
...gridRef?.current,
clearFilters
}))

Expand Down
Loading