mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
Correct use of "trigger.this-epoch" vs "trigger.next-epoch"
These parameters were set inconsistently. Use the value that the storage task uses. Also, allow `bin/phortune invoice` to invoice in the past and future to aid testing.
This commit is contained in:
parent
6b86f81fe4
commit
aadec98d43
2 changed files with 10 additions and 7 deletions
|
@ -153,7 +153,8 @@ final class PhabricatorPhortuneManagementInvoiceWorkflow
|
|||
array(
|
||||
'subscriptionPHID' => $subscription->getPHID(),
|
||||
'trigger.last-epoch' => $last_time,
|
||||
'trigger.next-epoch' => $next_time,
|
||||
'trigger.this-epoch' => $next_time,
|
||||
'manual' => true,
|
||||
),
|
||||
array(
|
||||
'objectPHID' => $subscription->getPHID(),
|
||||
|
|
|
@ -187,7 +187,7 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
|
|||
// creation date as the start of the billing period.
|
||||
$last_epoch = $subscription->getDateCreated();
|
||||
}
|
||||
$this_epoch = idx($data, 'trigger.next-epoch');
|
||||
$this_epoch = idx($data, 'trigger.this-epoch');
|
||||
|
||||
if (!$last_epoch || !$this_epoch) {
|
||||
throw new PhabricatorWorkerPermanentFailureException(
|
||||
|
@ -202,11 +202,13 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
|
|||
'Subscription has invalid billing period.'));
|
||||
}
|
||||
|
||||
if (PhabricatorTime::getNow() < $this_epoch) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Refusing to generate a subscription invoice for a billing period '.
|
||||
'which ends in the future.'));
|
||||
if (empty($data['manual'])) {
|
||||
if (PhabricatorTime::getNow() < $this_epoch) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Refusing to generate a subscription invoice for a billing period '.
|
||||
'which ends in the future.'));
|
||||
}
|
||||
}
|
||||
|
||||
return array($last_epoch, $this_epoch);
|
||||
|
|
Loading…
Reference in a new issue