Allow accounts and merchants to review unpaid invoices in Phortune
Summary: Ref T6881. Allows accounts to browse all unpaid invoices (although we currently show all of them on the account screen anyway). Also allows merchants to browse unpaid invoices, which they could not do before. This will let us start suspending instances for nonpayment eventually. Test Plan: - Browsed unpaid invoices as various users. - Browsed merchant unpaid invoices. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T6881 Differential Revision: https://secure.phabricator.com/D12681
This commit is contained in:
parent
853f42e97d
commit
2c5760d0ef
|
@ -6,6 +6,7 @@ final class PhortuneCartListController
|
||||||
private $merchant;
|
private $merchant;
|
||||||
private $account;
|
private $account;
|
||||||
private $subscription;
|
private $subscription;
|
||||||
|
private $engine;
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
@ -14,7 +15,8 @@ final class PhortuneCartListController
|
||||||
$account_id = $request->getURIData('accountID');
|
$account_id = $request->getURIData('accountID');
|
||||||
$subscription_id = $request->getURIData('subscriptionID');
|
$subscription_id = $request->getURIData('subscriptionID');
|
||||||
|
|
||||||
$engine = new PhortuneCartSearchEngine();
|
$engine = id(new PhortuneCartSearchEngine())
|
||||||
|
->setViewer($viewer);
|
||||||
|
|
||||||
if ($merchant_id) {
|
if ($merchant_id) {
|
||||||
$merchant = id(new PhortuneMerchantQuery())
|
$merchant = id(new PhortuneMerchantQuery())
|
||||||
|
@ -65,6 +67,8 @@ final class PhortuneCartListController
|
||||||
$engine->setSubscription($subscription);
|
$engine->setSubscription($subscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->engine = $engine;
|
||||||
|
|
||||||
$controller = id(new PhabricatorApplicationSearchController())
|
$controller = id(new PhabricatorApplicationSearchController())
|
||||||
->setQueryKey($request->getURIData('queryKey'))
|
->setQueryKey($request->getURIData('queryKey'))
|
||||||
->setSearchEngine($engine)
|
->setSearchEngine($engine)
|
||||||
|
@ -79,9 +83,7 @@ final class PhortuneCartListController
|
||||||
$nav = new AphrontSideNavFilterView();
|
$nav = new AphrontSideNavFilterView();
|
||||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
||||||
|
|
||||||
id(new PhortuneCartSearchEngine())
|
$this->engine->addNavigationItems($nav->getMenu());
|
||||||
->setViewer($viewer)
|
|
||||||
->addNavigationItems($nav->getMenu());
|
|
||||||
|
|
||||||
$nav->selectFilter(null);
|
$nav->selectFilter(null);
|
||||||
|
|
||||||
|
|
|
@ -55,15 +55,7 @@ final class PhortuneCartSearchEngine
|
||||||
|
|
||||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
||||||
$query = id(new PhortuneCartQuery())
|
$query = id(new PhortuneCartQuery())
|
||||||
->needPurchases(true)
|
->needPurchases(true);
|
||||||
->withStatuses(
|
|
||||||
array(
|
|
||||||
PhortuneCart::STATUS_PURCHASING,
|
|
||||||
PhortuneCart::STATUS_CHARGED,
|
|
||||||
PhortuneCart::STATUS_HOLD,
|
|
||||||
PhortuneCart::STATUS_REVIEW,
|
|
||||||
PhortuneCart::STATUS_PURCHASED,
|
|
||||||
));
|
|
||||||
|
|
||||||
$viewer = $this->requireViewer();
|
$viewer = $this->requireViewer();
|
||||||
|
|
||||||
|
@ -107,6 +99,19 @@ final class PhortuneCartSearchEngine
|
||||||
$query->withSubscriptionPHIDs(array($subscription->getPHID()));
|
$query->withSubscriptionPHIDs(array($subscription->getPHID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($saved->getParameter('invoices')) {
|
||||||
|
$query->withInvoices(true);
|
||||||
|
} else {
|
||||||
|
$query->withStatuses(
|
||||||
|
array(
|
||||||
|
PhortuneCart::STATUS_PURCHASING,
|
||||||
|
PhortuneCart::STATUS_CHARGED,
|
||||||
|
PhortuneCart::STATUS_HOLD,
|
||||||
|
PhortuneCart::STATUS_REVIEW,
|
||||||
|
PhortuneCart::STATUS_PURCHASED,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,9 +123,9 @@ final class PhortuneCartSearchEngine
|
||||||
$merchant = $this->getMerchant();
|
$merchant = $this->getMerchant();
|
||||||
$account = $this->getAccount();
|
$account = $this->getAccount();
|
||||||
if ($merchant) {
|
if ($merchant) {
|
||||||
return '/phortune/merchant/'.$merchant->getID().'/order/'.$path;
|
return '/phortune/merchant/orders/'.$merchant->getID().'/'.$path;
|
||||||
} else if ($account) {
|
} else if ($account) {
|
||||||
return '/phortune/'.$account->getID().'/order/';
|
return '/phortune/'.$account->getID().'/order/'.$path;
|
||||||
} else {
|
} else {
|
||||||
return '/phortune/order/'.$path;
|
return '/phortune/order/'.$path;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +133,8 @@ final class PhortuneCartSearchEngine
|
||||||
|
|
||||||
protected function getBuiltinQueryNames() {
|
protected function getBuiltinQueryNames() {
|
||||||
$names = array(
|
$names = array(
|
||||||
'all' => pht('All Orders'),
|
'all' => pht('Order History'),
|
||||||
|
'invoices' => pht('Unpaid Invoices'),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $names;
|
return $names;
|
||||||
|
@ -142,6 +148,8 @@ final class PhortuneCartSearchEngine
|
||||||
switch ($query_key) {
|
switch ($query_key) {
|
||||||
case 'all':
|
case 'all':
|
||||||
return $query;
|
return $query;
|
||||||
|
case 'invoices':
|
||||||
|
return $query->setParameter('invoices', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||||
|
@ -180,12 +188,6 @@ final class PhortuneCartSearchEngine
|
||||||
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
$cart->getID(),
|
$cart->getID(),
|
||||||
phutil_tag(
|
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $href,
|
|
||||||
),
|
|
||||||
$cart->getName()),
|
|
||||||
$handles[$cart->getPHID()]->renderLink(),
|
$handles[$cart->getPHID()]->renderLink(),
|
||||||
$handles[$merchant->getPHID()]->renderLink(),
|
$handles[$merchant->getPHID()]->renderLink(),
|
||||||
$handles[$cart->getAuthorPHID()]->renderLink(),
|
$handles[$cart->getAuthorPHID()]->renderLink(),
|
||||||
|
|
Loading…
Reference in a new issue