Skip to content

CustomMembership Status One-Time Task

Scope guard

  • The CRM trigger is intentionally scoped.
  • There is no "all organisations" enqueue path.
  • The task must receive either:
  • a comma-separated contactId list, or
  • a single organisationId

CRM entry points

CRM > Home > OneTimeTasks

  • Recalculate custommembership status contactId list
  • Recalculate custommembership status organisationId

Both entries use the shared genericModal in Raklet.Crm/Views/Shared/Common/_SideBar.cshtml.

Queue contracts

Contact-scoped trigger

  • Queue: recalculate-custommembership-status-contactlist
  • Payload: List<Guid>
  • Meaning: OrganisationMembership.Id values (contactId list)

Organisation-scoped trigger

  • Queue: recalculate-custommembership-status-organisation
  • Payload: IndexQueueMsg
  • Required field: OrganisationId

Worker queue

  • Queue: recalculate-custommembership-status-subscription
  • Payload: Guid
  • Meaning: root CustomMembership.Id

Processing notes

  • Contact/organisation triggers resolve the selected scope to root subscriptions first.
  • Group membership children are not enqueued separately when their parent exists in the same result set.
  • The worker calls CustomMembershipService.UpdateSubscriptionStatusByBalanceAsync(...).
  • Status calculation follows the existing balance rule:
  • balance < 0 => PastDue
  • otherwise => Active
  • Existing service-side behavior remains intact for:
  • skipped statuses (Cancelled, Frozen, Scheduled)
  • action log creation
  • membership reindex
  • cache purge
  • group membership child propagation