mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-25 06:50:55 +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(
|
array(
|
||||||
'subscriptionPHID' => $subscription->getPHID(),
|
'subscriptionPHID' => $subscription->getPHID(),
|
||||||
'trigger.last-epoch' => $last_time,
|
'trigger.last-epoch' => $last_time,
|
||||||
'trigger.next-epoch' => $next_time,
|
'trigger.this-epoch' => $next_time,
|
||||||
|
'manual' => true,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'objectPHID' => $subscription->getPHID(),
|
'objectPHID' => $subscription->getPHID(),
|
||||||
|
|
|
@ -187,7 +187,7 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
|
||||||
// creation date as the start of the billing period.
|
// creation date as the start of the billing period.
|
||||||
$last_epoch = $subscription->getDateCreated();
|
$last_epoch = $subscription->getDateCreated();
|
||||||
}
|
}
|
||||||
$this_epoch = idx($data, 'trigger.next-epoch');
|
$this_epoch = idx($data, 'trigger.this-epoch');
|
||||||
|
|
||||||
if (!$last_epoch || !$this_epoch) {
|
if (!$last_epoch || !$this_epoch) {
|
||||||
throw new PhabricatorWorkerPermanentFailureException(
|
throw new PhabricatorWorkerPermanentFailureException(
|
||||||
|
@ -202,12 +202,14 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
|
||||||
'Subscription has invalid billing period.'));
|
'Subscription has invalid billing period.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($data['manual'])) {
|
||||||
if (PhabricatorTime::getNow() < $this_epoch) {
|
if (PhabricatorTime::getNow() < $this_epoch) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
pht(
|
pht(
|
||||||
'Refusing to generate a subscription invoice for a billing period '.
|
'Refusing to generate a subscription invoice for a billing period '.
|
||||||
'which ends in the future.'));
|
'which ends in the future.'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return array($last_epoch, $this_epoch);
|
return array($last_epoch, $this_epoch);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue