{"record":{"id":"82f3421a31e738b4","repo":"phacility/phabricator","slug":"unable-to-calculate-s-this-subscription-has-not","errorCode":null,"errorMessage":"Unable to calculate %s, this subscription has not been scheduled for billing yet. Wait for the trigger daemon to schedule the subscription.","messagePattern":"Unable to calculate (.+?), this subscription has not been scheduled for billing yet\\. Wait for the trigger daemon to schedule the subscription\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/phortune/management/PhabricatorPhortuneManagementInvoiceWorkflow.php","lineNumber":120,"sourceCode":"          'to define the beginning and end of the billing range.',\n          '--last',\n          '--next'));\n    } else if (!$auto_range && ($last_arg && $next_arg)) {\n      $last_time = $this->parseTimeArgument($args->getArg('last'));\n      $next_time = $this->parseTimeArgument($args->getArg('next'));\n    } else if ($auto_range && ($last_arg || $next_arg)) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Use either %s or %s and %s to specify the '.\n          'billing range, but not both.',\n          '--auto-range',\n          '--last',\n          '--next'));\n    } else {\n      $trigger = $subscription->getTrigger();\n      $event = $trigger->getEvent();\n      if (!$event) {\n        throw new PhutilArgumentUsageException(\n          pht(\n            'Unable to calculate %s, this subscription has not been '.\n            'scheduled for billing yet. Wait for the trigger daemon to '.\n            'schedule the subscription.',\n            '--auto-range'));\n      }\n      $last_time = $event->getLastEventEpoch();\n      $next_time = $event->getNextEventEpoch();\n    }\n\n    $console->writeOut(\n      \"%s\\n\",\n      pht(\n        'Preparing to invoice subscription \"%s\" from %s to %s.',\n        $subscription->getSubscriptionName(),\n        ($last_time\n          ? phabricator_datetime($last_time, $viewer)\n          : pht('subscription creation')),","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/phortune/management/PhabricatorPhortuneManagementInvoiceWorkflow.php#L102-L138","documentation":"PhutilArgumentUsageException thrown by the phortune invoice workflow in the --auto-range branch when the subscription's trigger has no scheduled event ($trigger->getEvent() is null). --auto-range derives the billing window from PhabricatorScheduledTriggerEvent's last/next epochs; if the trigger daemon has never processed this subscription's trigger, those epochs do not exist and the range cannot be computed. The fix is scheduling, not argument changes.","triggerScenarios":"Running `... --auto-range` on a brand-new subscription before the trigger daemon (phd) has ever fired; running with the daemons stopped; a subscription whose trigger was created but never activated. The code path: $subscription->getTrigger()->getEvent() returns null.","commonSituations":"Fresh Phortune test installs where phd isn't running (common in dev sandboxes); subscriptions created moments before invoicing; environments where the trigger daemon loop is disabled.","solutions":["Start the daemons with `bin/phd start` and wait for the trigger daemon to schedule the subscription (check `bin/phd status` and the trigger queue).","If you cannot wait, bypass --auto-range and pass explicit --last/--next epochs matching the intended billing period.","Verify the subscription shows a next billing date in the UI before retrying --auto-range."],"exampleFix":"# before\n$ ./bin/phortune invoice --subscription PHID-PSUB-1234abcd --auto-range\n# -> error: not scheduled for billing yet\n\n# after\n$ ./bin/phortune start  # or: bin/phd start; wait one scheduling cycle\n$ ./bin/phortune invoice --subscription PHID-PSUB-1234abcd --auto-range\n# or, without daemons:\n$ ./bin/phortune invoice --subscription PHID-PSUB-1234abcd --last 1690000000 --next 1692600000","handlingStrategy":"validation","validationCode":"// Before using --auto-range, confirm the subscription is scheduled.\n$trigger = $subscription->getTrigger();\n$event = ($trigger ? $trigger->getEvent() : null);\nif (!$event || !$event->getNextEventEpoch()) {\n  // Not scheduled yet: start daemons and wait, or fall back to --last/--next.\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `bin/phd start` in any environment using Phortune scheduling; check `bin/phd status` for the trigger daemon.","After creating a subscription, wait one trigger cycle before manual auto-range invoicing.","In daemons-off test environments, always invoice with explicit --last/--next."],"tags":["php","phabricator","phortune","cli","trigger","scheduling","billing"],"backgroundTag":"precondition-not-met","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}