Page MenuHomePhabricator

D11837.id.diff
No OneTemporary

D11837.id.diff

diff --git a/src/applications/phortune/storage/PhortuneSubscription.php b/src/applications/phortune/storage/PhortuneSubscription.php
--- a/src/applications/phortune/storage/PhortuneSubscription.php
+++ b/src/applications/phortune/storage/PhortuneSubscription.php
@@ -207,6 +207,13 @@
$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) {
diff --git a/src/applications/phortune/subscription/PhortuneSubscriptionImplementation.php b/src/applications/phortune/subscription/PhortuneSubscriptionImplementation.php
--- a/src/applications/phortune/subscription/PhortuneSubscriptionImplementation.php
+++ b/src/applications/phortune/subscription/PhortuneSubscriptionImplementation.php
@@ -22,6 +22,13 @@
$start_epoch,
$end_epoch);
+ public function shouldInvoiceForBillingPeriod(
+ PhortuneSubscription $subscription,
+ $start_epoch,
+ $end_epoch) {
+ return true;
+ }
+
public function getCartName(
PhortuneSubscription $subscription,
PhortuneCart $cart) {
diff --git a/src/applications/phortune/worker/PhortuneSubscriptionWorker.php b/src/applications/phortune/worker/PhortuneSubscriptionWorker.php
--- a/src/applications/phortune/worker/PhortuneSubscriptionWorker.php
+++ b/src/applications/phortune/worker/PhortuneSubscriptionWorker.php
@@ -8,6 +8,13 @@
$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 @@
$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

File Metadata

Mime Type
text/plain
Expires
Oct 20 2024, 11:51 AM (4 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6730963
Default Alt Text
D11837.id.diff (2 KB)

Event Timeline