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:
parent
511c619486
commit
ed7823f577
3 changed files with 21 additions and 1 deletions
|
@ -207,6 +207,13 @@ final class PhortuneSubscription extends PhortuneDAO
|
|||
$end_epoch);
|
||||
}
|
||||
|
||||
public function shouldInvoiceForBillingPeriod($start_epoch, $end_epoch) {
|
||||
return $this->getImplementation()->shouldInvoiceForBillingPeriod(
|
||||
$this,
|
||||
$start_epoch,
|
||||
$end_epoch);
|
||||
}
|
||||
|
||||
public function getPurchaseName(
|
||||
PhortuneProduct $product,
|
||||
PhortunePurchase $purchase) {
|
||||
|
|
|
@ -22,6 +22,13 @@ abstract class PhortuneSubscriptionImplementation {
|
|||
$start_epoch,
|
||||
$end_epoch);
|
||||
|
||||
public function shouldInvoiceForBillingPeriod(
|
||||
PhortuneSubscription $subscription,
|
||||
$start_epoch,
|
||||
$end_epoch) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getCartName(
|
||||
PhortuneSubscription $subscription,
|
||||
PhortuneCart $cart) {
|
||||
|
|
|
@ -8,6 +8,13 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
|
|||
$range = $this->getBillingPeriodRange($subscription);
|
||||
list($last_epoch, $next_epoch) = $range;
|
||||
|
||||
$should_invoice = $subscription->shouldInvoiceForBillingPeriod(
|
||||
$last_epoch,
|
||||
$next_epoch);
|
||||
if (!$should_invoice) {
|
||||
return;
|
||||
}
|
||||
|
||||
$account = $subscription->getAccount();
|
||||
$merchant = $subscription->getMerchant();
|
||||
|
||||
|
@ -21,7 +28,6 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
|
|||
$cart_implementation = id(new PhortuneSubscriptionCart())
|
||||
->setSubscription($subscription);
|
||||
|
||||
|
||||
// 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
|
||||
// someone initiates a subscription, adds some other account managers, and
|
||||
|
|
Loading…
Reference in a new issue