1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Allow subscriptions to decline to generate an invoice

Summary: This is a useful capability in Phacility for disabled/suspended instances.

Test Plan: Used `bin/phortune invoice` to invoice a disabled instance, saw it decline to invoice.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11837
This commit is contained in:
epriestley 2015-02-22 05:39:17 -08:00
parent 511c619486
commit ed7823f577
3 changed files with 21 additions and 1 deletions

View file

@ -207,6 +207,13 @@ final class PhortuneSubscription extends PhortuneDAO
$end_epoch); $end_epoch);
} }
public function shouldInvoiceForBillingPeriod($start_epoch, $end_epoch) {
return $this->getImplementation()->shouldInvoiceForBillingPeriod(
$this,
$start_epoch,
$end_epoch);
}
public function getPurchaseName( public function getPurchaseName(
PhortuneProduct $product, PhortuneProduct $product,
PhortunePurchase $purchase) { PhortunePurchase $purchase) {

View file

@ -22,6 +22,13 @@ abstract class PhortuneSubscriptionImplementation {
$start_epoch, $start_epoch,
$end_epoch); $end_epoch);
public function shouldInvoiceForBillingPeriod(
PhortuneSubscription $subscription,
$start_epoch,
$end_epoch) {
return true;
}
public function getCartName( public function getCartName(
PhortuneSubscription $subscription, PhortuneSubscription $subscription,
PhortuneCart $cart) { PhortuneCart $cart) {

View file

@ -8,6 +8,13 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
$range = $this->getBillingPeriodRange($subscription); $range = $this->getBillingPeriodRange($subscription);
list($last_epoch, $next_epoch) = $range; list($last_epoch, $next_epoch) = $range;
$should_invoice = $subscription->shouldInvoiceForBillingPeriod(
$last_epoch,
$next_epoch);
if (!$should_invoice) {
return;
}
$account = $subscription->getAccount(); $account = $subscription->getAccount();
$merchant = $subscription->getMerchant(); $merchant = $subscription->getMerchant();
@ -21,7 +28,6 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
$cart_implementation = id(new PhortuneSubscriptionCart()) $cart_implementation = id(new PhortuneSubscriptionCart())
->setSubscription($subscription); ->setSubscription($subscription);
// TODO: This isn't really ideal. It would be better to use an application // TODO: This isn't really ideal. It would be better to use an application
// actor than the original author of the subscription. In particular, if // actor than the original author of the subscription. In particular, if
// someone initiates a subscription, adds some other account managers, and // someone initiates a subscription, adds some other account managers, and