Skip to content

PM-4904: Allow project billing account clears#21

Merged
jmgasper merged 1 commit into
devfrom
PM-4904
Apr 29, 2026
Merged

PM-4904: Allow project billing account clears#21
jmgasper merged 1 commit into
devfrom
PM-4904

Conversation

@jmgasper
Copy link
Copy Markdown
Contributor

What was broken
Clearing a billing account from an existing project did not persist. The Work UI sent an explicit null billingAccountId, but the Projects API treated that value as omitted, so the old billing account stayed on the project and appeared again after save.

Root cause
UpdateProjectDto inherited CreateProjectDto billingAccountId parsing, which normalizes null and empty string to undefined. The service clear path depended on a derived flag that is not materialized by class-transformer when only billingAccountId is sent.

What was changed
UpdateProjectDto now owns the update-time billingAccountId field, preserving null and empty string as explicit clear requests while still parsing numeric billing account ids. ProjectService now clears when the DTO billingAccountId is null, in addition to the existing internal clear flag.

Any added/updated tests
Added DTO coverage for null, empty string, and numeric billingAccountId updates. Updated the project service clear test to exercise billingAccountId: null directly.

Validation

  • pnpm test -- --runTestsByPath src/api/project/dto/update-project.dto.spec.ts src/api/project/project.service.spec.ts: passed
  • pnpm lint: passed with existing AJV strict-mode warnings
  • pnpm build: passed
  • pnpm test: failed in unrelated metadata specs that still expect publishProjectEvent calls even though publishMetadataEvent is documented as a no-op

What was broken
Clearing a billing account from an existing project did not persist. The Work UI sent an explicit null billingAccountId, but the Projects API treated that value as omitted, so the old billing account stayed on the project and appeared again after save.

Root cause
UpdateProjectDto inherited CreateProjectDto billingAccountId parsing, which normalizes null and empty string to undefined. The service clear path depended on a derived flag that is not materialized by class-transformer when only billingAccountId is sent.

What was changed
UpdateProjectDto now owns the update-time billingAccountId field, preserving null and empty string as explicit clear requests while still parsing numeric billing account ids. ProjectService now clears when the DTO billingAccountId is null, in addition to the existing internal clear flag.

Any added/updated tests
Added DTO coverage for null, empty string, and numeric billingAccountId updates. Updated the project service clear test to exercise billingAccountId: null directly.
@jmgasper jmgasper merged commit 02651ce into dev Apr 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant