# Moratoriums Billing Recovery (Beta)



<Callout type="warn">
  This feature is currently in beta and may be subject to change. Before using it in production, please contact your Socotra representative.
</Callout>

Overview [#overview]

Billing workflows such as invoice generation, delinquency, and autopay will resume when their scheduled jobs execute and deferred work queues are processed.

Invoicing [#invoicing]

Upon resumption of invoice generation, a single catchup invoice will be generated containing all receivable amounts that would have been invoiced during the moratorium period. If specified in the `billingHoldScope` object, this catchup invoice will have a `dueTime` scheduled based on the moratorium's `endTime` plus `deferredInvoiceDueOffsetDays`. Otherwise, the invoice will be scheduled according to the applicable installment plan.

Depending on the volume of policies affected by a given moratorium, the catchup invoice may take some time to generate, with all invoices expected to be generated within 24 hours of the expiry of the moratorium.

Auto Pay [#auto-pay]

Auto-Pay functionality applies exclusively to invoices that have already been generated. In scenarios where invoice generation has been suspended, no new invoices will be created, eliminating any Auto-Pay concerns.

For existing invoices, whether generated prior to the moratorium becoming effective, or created because invoice generation was not suspended, the following behavior applies when Auto-Pay is suspended:

When an invoice's scheduled Auto-Pay execution time is reached, the system will automatically defer the payment attempt by 24 hours. This process continues daily until the moratorium is lifted. During each deferral, the system recognizes that the policy is subject to an active moratorium and postpones the Auto-Pay attempt accordingly.

Deliquency [#deliquency]

Delinquency entities for policies governed by the moratorium will continue to be created during suspension but will remain in the `preGrace` state. Existing delinquencies in the `inGrace` state will maintain that status until their `graceEndAt` time is reached, at which point they will revert to the `preGrace` state.

Billing Lifecycle Jobs [#billing-lifecycle-jobs]

Details of rescheduled autopay jobs can be found by fetching the <ApiLink name="fetchInvoiceLifecycleJobData">lifecycle job data</ApiLink> for an invoice.

Get the list of suspended delinquencies using a `policyLocator` or `delinquencyLocator`.

<ApiEndpoint name="getSuspendedDelinquencies" />

<ApiSchema name="SuspendedDelinquencyListResponse" />

<ApiSchema name="SuspendedDelinquency" />

<ApiEndpoint name="fetchCreateDelinquenciesJobDataForInvoice" />

<ApiEndpoint name="fetchDelinquencyMoratoriumJobsForTenant" />

<ApiSchema name="DelinquencyMoratoriumJobsListResponse" />

<ApiSchema name="WorkflowContextDelinquencyMoratoriumJobData" />

<ApiSchema name="DelinquencyMoratoriumJobData" />

<ApiEndpoint name="runDelinquencyMoratoriumsWorkflow" />


## API Reference

GET /billing/{tenantLocator}/delinquencies/suspended/list — getSuspendedDelinquencies
Tags: delinquencies-controller
Permissions: read, list
Parameters:
  tenantLocator (uuid, path, required)
  delinquencyLocator (ulid, query)
  policyLocator (ulid, query)
  offset (integer, query)
  count (integer, query)
Responses:
  200 SuspendedDelinquencyListResponse — OK

GET /billing/{tenantLocator}/jobs/delinquencies/invoices/{invoiceLocator}/list — fetchCreateDelinquenciesJobDataForInvoice
Tags: jobs-controller
Permissions: read, list
Parameters:
  tenantLocator (uuid, path, required)
  invoiceLocator (ulid, path, required)
  offset (integer, query)
  count (integer, query)
  extended (boolean, query)
Responses:
  200 DelinquencyCreateJobDataListResponse — OK

GET /billing/{tenantLocator}/jobs/delinquencies/moratoriums/list — fetchDelinquencyMoratoriumJobsForTenant
Tags: jobs-controller
Permissions: read, list
Parameters:
  tenantLocator (uuid, path, required)
  offset (integer, query)
  count (integer, query)
Responses:
  200 DelinquencyMoratoriumJobsListResponse — OK

POST /billing/{tenantLocator}/jobs/delinquencies/moratoriums — runDelinquencyMoratoriumsWorkflow
Tags: jobs-controller
Permissions: write
Parameters:
  tenantLocator (uuid, path, required)
Responses:
  200 — OK

SuspendedDelinquencyListResponse
Properties:
  listCompleted (boolean, required)
  items (SuspendedDelinquency[], required)

SuspendedDelinquency
Properties:
  delinquencyLocator (ulid, required)
  policyLocator (ulid, required)
  moratoriumType (string, required)
  startTime (datetime, required)
  endTime (datetime, required)

DelinquencyMoratoriumJobsListResponse
Properties:
  listCompleted (boolean, required)
  items (WorkflowContextDelinquencyMoratoriumJobData[], required)

WorkflowContextDelinquencyMoratoriumJobData
Properties:
  workflowJobLocator (ulid, required)
  workflowType (Enum LATTICE_AND_INSTALLMENTS_GENERATION | INVOICE_GENERATION | INVOICE_LIFECYCLE | PAYMENT_EXECUTION | DELINQUENCY_MORATORIUM_EXECUTION, required)
  contextData (DelinquencyMoratoriumJobData, required)
  completedAt (datetime)
  createdAt (datetime, required)

DelinquencyMoratoriumJobData
Properties:
  status (Enum queued | finished | failed | running, required)
  startTime (datetime, required)
  finishTime (datetime, required)
  error (string, required)