Skip to content

fix(condo): DOMA-13340 subscription domain fixes#7714

Merged
nomerdvadcatpyat merged 7 commits into
mainfrom
fix/condo/DOMA-13340/subscription-domain-fixes
Jun 10, 2026
Merged

fix(condo): DOMA-13340 subscription domain fixes#7714
nomerdvadcatpyat merged 7 commits into
mainfrom
fix/condo/DOMA-13340/subscription-domain-fixes

Conversation

@nomerdvadcatpyat

@nomerdvadcatpyat nomerdvadcatpyat commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Removed virtual field SubscriptionContext.daysRemaining — was redundant and unused
  • Refactored useOrganizationSubscription to expose activeSubscriptionEndAt (string)
    and activeSubscriptionEndAtWithoutBuffer (Dayjs) instead of daysRemaining /
    daysRemainingWithoutBuffer; each consumer computes days locally — eliminates
    inconsistency between components where some used buffered dates and others didn't
  • Fixed badge: now shows remaining buffer days in red during grace period instead of hiding them
  • Fixed SubscriptionDaysIndicator: no longer shows "0 days" after subscription fully expires
  • Fixed HIGH_REVENUE_CUSTOMER display: now shows subscriptionPlanPricingRule.name
    instead of "Paid until Jan 26, 2126"
  • Extended overlap validation in SubscriptionContext to run on update → DONE transitions,
    not only on create
  • Added tests: overlap on update, buffer period active subscription, activeSubscriptionEndAt chaining

Summary by CodeRabbit

  • Bug Fixes

    • Improved subscription overlap validation to respect status transitions and exact end-date boundaries.
    • Hidden subscription plans can now be registered (previous rejection removed).
  • New Features

    • Subscription UI shows payment-buffer period separately from standard remaining days.
    • Pricing rule names are surfaced in subscription details.
  • Refactor

    • Remaining-days calculations moved to client-side; API no longer returns a computed daysRemaining field.

@nomerdvadcatpyat nomerdvadcatpyat added 👶 small Easy to review changes up to 50 lines of code ✋🙂 Review please Comments are resolved, take a look, please labels Jun 9, 2026
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 94b84e58-00df-44db-81cf-d68abc308340

📥 Commits

Reviewing files that changed from the base of the PR and between 9b2b27f and 95b6e96.

📒 Files selected for processing (19)
  • apps/condo/domains/notification/hooks/useSubscriptionExpirationNotification.ts
  • apps/condo/domains/organization/schema/Organization.test.js
  • apps/condo/domains/subscription/components/SubscriptionDaysIndicator.tsx
  • apps/condo/domains/subscription/components/SubscriptionSettingsContent/SubscriptionPlanCard/SubscriptionPlanCard.tsx
  • apps/condo/domains/subscription/gql.js
  • apps/condo/domains/subscription/hooks/useOrganizationSubscription.ts
  • apps/condo/domains/subscription/queries/SubscriptionContext.graphql
  • apps/condo/domains/subscription/schema/RegisterSubscriptionContextService.js
  • apps/condo/domains/subscription/schema/RegisterSubscriptionContextService.test.js
  • apps/condo/domains/subscription/schema/SubscriptionContext.js
  • apps/condo/domains/subscription/schema/SubscriptionContext.test.js
  • apps/condo/domains/subscription/schema/SubscriptionPlan.js
  • apps/condo/gql/index.ts
  • apps/condo/gql/operation.types.ts
  • apps/condo/lang/en/en.json
  • apps/condo/lang/es/es.json
  • apps/condo/lang/ru/ru.json
  • apps/condo/schema.graphql
  • apps/condo/schema.ts
✅ Files skipped from review due to trivial changes (3)
  • apps/condo/domains/subscription/schema/SubscriptionPlan.js
  • apps/condo/lang/ru/ru.json
  • apps/condo/gql/operation.types.ts
🚧 Files skipped from review as they are similar to previous changes (13)
  • apps/condo/domains/subscription/gql.js
  • apps/condo/domains/notification/hooks/useSubscriptionExpirationNotification.ts
  • apps/condo/domains/organization/schema/Organization.test.js
  • apps/condo/domains/subscription/schema/SubscriptionContext.test.js
  • apps/condo/schema.graphql
  • apps/condo/domains/subscription/hooks/useOrganizationSubscription.ts
  • apps/condo/domains/subscription/queries/SubscriptionContext.graphql
  • apps/condo/domains/subscription/components/SubscriptionSettingsContent/SubscriptionPlanCard/SubscriptionPlanCard.tsx
  • apps/condo/domains/subscription/schema/RegisterSubscriptionContextService.test.js
  • apps/condo/gql/index.ts
  • apps/condo/domains/subscription/schema/RegisterSubscriptionContextService.js
  • apps/condo/domains/subscription/components/SubscriptionDaysIndicator.tsx
  • apps/condo/domains/subscription/schema/SubscriptionContext.js

📝 Walkthrough

Walkthrough

This PR refactors subscription expiration/days-remaining logic by shifting computation from the useOrganizationSubscription hook to consuming components. The hook now returns activeSubscriptionEndAtWithoutBuffer instead of pre-computed daysRemaining, the server-side daysRemaining field is removed, components compute days with dayjs, hidden-plan semantics are adjusted, overlap validation is unified, and UI/components/tests are updated.

Changes

Subscription Days Remaining Refactoring

Layer / File(s) Summary
Hook contract refactoring: activeSubscriptionEndAtWithoutBuffer and buffer-period logic
apps/condo/domains/subscription/hooks/useOrganizationSubscription.ts
Adds SUBSCRIPTION_PAYMENT_BUFFER_DAYS, computes activeSubscriptionEndAtWithoutBuffer, refactors isInBufferPeriod and replaces returned daysRemaining fields with buffered end-date shape.
GraphQL schema and field updates: remove daysRemaining, add subscriptionPlanPricingRule
apps/condo/domains/subscription/schema/SubscriptionContext.js, apps/condo/domains/subscription/gql.js, apps/condo/domains/subscription/queries/SubscriptionContext.graphql, apps/condo/gql/index.ts, apps/condo/gql/operation.types.ts, apps/condo/schema.graphql, apps/condo/schema.ts
Removes daysRemaining virtual field and its selections, adds frozenPaymentInfo and subscriptionPlanPricingRule selection, and updates generated GraphQL documents and types.
Hidden plan visibility: isHidden field semantics and validation logic
apps/condo/domains/subscription/schema/SubscriptionPlan.js, apps/condo/domains/subscription/schema/RegisterSubscriptionContextService.js, apps/condo/domains/subscription/schema/RegisterSubscriptionContextService.test.js, apps/condo/schema.graphql, apps/condo/schema.ts, apps/condo/lang/*
Rewords isHidden doc to "hidden from front-end", allows hidden pricing rules to be found (removes isHidden filter), stops rejecting hidden plans during registration, narrows pricing-rule-not-found messages, and updates localization/tests accordingly.
Component integration: days computation and pricing-rule display
apps/condo/domains/notification/hooks/useSubscriptionExpirationNotification.ts, apps/condo/domains/subscription/components/SubscriptionDaysIndicator.tsx, apps/condo/domains/subscription/components/SubscriptionSettingsContent/SubscriptionPlanCard/SubscriptionPlanCard.tsx
Components now read activeSubscriptionEndAtWithoutBuffer and isInBufferPeriod from the hook and compute daysRemaining using dayjs().diff(...,'day', true). Updates visibility, progress, stroke-color, end-date rendering, and pricing-rule name handling.
Overlap validation refactoring: merge create/update paths and handle DONE status transitions
apps/condo/domains/subscription/schema/SubscriptionContext.js, apps/condo/domains/subscription/schema/SubscriptionContext.test.js
Unifies overlap validation by merging existing + resolved data, gating checks on create or resulting DONE status, excluding current record for updates, and adds update-focused overlap tests; removes obsolete daysRemaining tests.
Buffer behavior and chaining tests: activeSubscriptionEndAt calculation verification
apps/condo/domains/organization/schema/Organization.test.js
Adds tests verifying buffered activeSubscriptionEndAt chains consecutive non-trial contexts and treats contexts within the buffer window as active.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

Suggested Reviewers

  • Alexander-Turkin
  • AleX83Xpert
  • Alllex202

Poem

🐰 I hopped through dates and buffer lands,

Moved days from hooks into my hands.
Hidden plans no longer blocked the way,
Overlaps checked fair as day.
A tiny rabbit cheers this refactor play.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(condo): DOMA-13340 subscription domain fixes' directly corresponds to the main changes across the subscription domain, including refactoring subscription state management, updating buffer period display logic, and extending validation. The ticket reference (DOMA-13340) and 'subscription domain fixes' clearly summarize the scope of work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/condo/DOMA-13340/subscription-domain-fixes

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b2b27f907

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/condo/domains/subscription/schema/SubscriptionContext.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/condo/domains/subscription/schema/SubscriptionContext.js`:
- Around line 267-287: Only run the overlap check when the record's next status
will be DONE: compute nextStatus = resolvedData.status ?? existingItem.status
and if nextStatus !== SUBSCRIPTION_CONTEXT_STATUS.DONE skip the overlap query.
Modify the block using existingItem, resolvedData and operation so you gate
building the overlapFilter (and the find('SubscriptionContext',
...)/overlappingSubscriptions check) behind this nextStatus ===
SUBSCRIPTION_CONTEXT_STATUS.DONE condition; keep the existing id_not logic for
updates unchanged.

In `@apps/condo/schema.graphql`:
- Around line 109842-109843: Update the user-facing translation for
PRICING_RULE_NOT_FOUND so it matches the actual "not found" semantics: edit the
i18n entries for
api.subscription.registerSubscriptionContext.PRICING_RULE_NOT_FOUND in
apps/condo/lang/en/en.json and apps/condo/lang/es/es.json to remove the "or is
hidden" clause so the messageForUser equals "Subscription plan pricing rule not
found" (consistent with the schema.graphql `message` and the behavior asserted
in RegisterSubscriptionContextService.test.js), then regenerate any derived
schema/translation outputs (and re-run build/tests) so schema.graphql and
generated artifacts reflect the updated translations.

In `@apps/condo/schema.ts`:
- Around line 49777-49778: Update the user-facing error mapping for the
"Subscription plan pricing rule not found" entry: locate the mapping object that
has "message": "Subscription plan pricing rule not found" and change its
messageForUser value to remove the "or is hidden" clause (e.g., set
messageForUser to "Subscription plan pricing rule not found") so the generated
schema and runtime payload reflect the new semantics that hidden pricing rules
are allowed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: af3ff224-3c13-4cce-b8ee-2e78bcbfdeaa

📥 Commits

Reviewing files that changed from the base of the PR and between 9e9ef2f and 9b2b27f.

📒 Files selected for processing (16)
  • apps/condo/domains/notification/hooks/useSubscriptionExpirationNotification.ts
  • apps/condo/domains/organization/schema/Organization.test.js
  • apps/condo/domains/subscription/components/SubscriptionDaysIndicator.tsx
  • apps/condo/domains/subscription/components/SubscriptionSettingsContent/SubscriptionPlanCard/SubscriptionPlanCard.tsx
  • apps/condo/domains/subscription/gql.js
  • apps/condo/domains/subscription/hooks/useOrganizationSubscription.ts
  • apps/condo/domains/subscription/queries/SubscriptionContext.graphql
  • apps/condo/domains/subscription/schema/RegisterSubscriptionContextService.js
  • apps/condo/domains/subscription/schema/RegisterSubscriptionContextService.test.js
  • apps/condo/domains/subscription/schema/SubscriptionContext.js
  • apps/condo/domains/subscription/schema/SubscriptionContext.test.js
  • apps/condo/domains/subscription/schema/SubscriptionPlan.js
  • apps/condo/gql/index.ts
  • apps/condo/gql/operation.types.ts
  • apps/condo/schema.graphql
  • apps/condo/schema.ts

Comment thread apps/condo/domains/subscription/schema/SubscriptionContext.js
Comment thread apps/condo/schema.graphql Outdated
Comment thread apps/condo/schema.ts Outdated
@nomerdvadcatpyat nomerdvadcatpyat force-pushed the fix/condo/DOMA-13340/subscription-domain-fixes branch from 9b2b27f to 95b6e96 Compare June 10, 2026 10:29
@sonarqubecloud

Copy link
Copy Markdown

@nomerdvadcatpyat nomerdvadcatpyat merged commit 6db8bc6 into main Jun 10, 2026
84 of 85 checks passed
@nomerdvadcatpyat nomerdvadcatpyat deleted the fix/condo/DOMA-13340/subscription-domain-fixes branch June 10, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✋🙂 Review please Comments are resolved, take a look, please 👶 small Easy to review changes up to 50 lines of code

Development

Successfully merging this pull request may close these issues.

2 participants