1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 22:40: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:
epriestley 2015-03-15 13:32:15 -07:00
parent 6b86f81fe4
commit aadec98d43
2 changed files with 10 additions and 7 deletions

View file

@ -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(),

View file

@ -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,11 +202,13 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
'Subscription has invalid billing period.')); 'Subscription has invalid billing period.'));
} }
if (PhabricatorTime::getNow() < $this_epoch) { if (empty($data['manual'])) {
throw new Exception( if (PhabricatorTime::getNow() < $this_epoch) {
pht( throw new Exception(
'Refusing to generate a subscription invoice for a billing period '. pht(
'which ends in the future.')); 'Refusing to generate a subscription invoice for a billing period '.
'which ends in the future.'));
}
} }
return array($last_epoch, $this_epoch); return array($last_epoch, $this_epoch);