1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

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:
epriestley 2015-05-04 11:06:09 -07:00
parent 853f42e97d
commit 2c5760d0ef
2 changed files with 26 additions and 22 deletions

View file

@ -6,6 +6,7 @@ final class PhortuneCartListController
private $merchant;
private $account;
private $subscription;
private $engine;
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
@ -14,7 +15,8 @@ final class PhortuneCartListController
$account_id = $request->getURIData('accountID');
$subscription_id = $request->getURIData('subscriptionID');
$engine = new PhortuneCartSearchEngine();
$engine = id(new PhortuneCartSearchEngine())
->setViewer($viewer);
if ($merchant_id) {
$merchant = id(new PhortuneMerchantQuery())
@ -65,6 +67,8 @@ final class PhortuneCartListController
$engine->setSubscription($subscription);
}
$this->engine = $engine;
$controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($request->getURIData('queryKey'))
->setSearchEngine($engine)
@ -79,9 +83,7 @@ final class PhortuneCartListController
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
id(new PhortuneCartSearchEngine())
->setViewer($viewer)
->addNavigationItems($nav->getMenu());
$this->engine->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);

View file

@ -55,15 +55,7 @@ final class PhortuneCartSearchEngine
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new PhortuneCartQuery())
->needPurchases(true)
->withStatuses(
array(
PhortuneCart::STATUS_PURCHASING,
PhortuneCart::STATUS_CHARGED,
PhortuneCart::STATUS_HOLD,
PhortuneCart::STATUS_REVIEW,
PhortuneCart::STATUS_PURCHASED,
));
->needPurchases(true);
$viewer = $this->requireViewer();
@ -107,6 +99,19 @@ final class PhortuneCartSearchEngine
$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;
}
@ -118,9 +123,9 @@ final class PhortuneCartSearchEngine
$merchant = $this->getMerchant();
$account = $this->getAccount();
if ($merchant) {
return '/phortune/merchant/'.$merchant->getID().'/order/'.$path;
return '/phortune/merchant/orders/'.$merchant->getID().'/'.$path;
} else if ($account) {
return '/phortune/'.$account->getID().'/order/';
return '/phortune/'.$account->getID().'/order/'.$path;
} else {
return '/phortune/order/'.$path;
}
@ -128,7 +133,8 @@ final class PhortuneCartSearchEngine
protected function getBuiltinQueryNames() {
$names = array(
'all' => pht('All Orders'),
'all' => pht('Order History'),
'invoices' => pht('Unpaid Invoices'),
);
return $names;
@ -142,6 +148,8 @@ final class PhortuneCartSearchEngine
switch ($query_key) {
case 'all':
return $query;
case 'invoices':
return $query->setParameter('invoices', true);
}
return parent::buildSavedQueryFromBuiltin($query_key);
@ -180,12 +188,6 @@ final class PhortuneCartSearchEngine
$rows[] = array(
$cart->getID(),
phutil_tag(
'a',
array(
'href' => $href,
),
$cart->getName()),
$handles[$cart->getPHID()]->renderLink(),
$handles[$merchant->getPHID()]->renderLink(),
$handles[$cart->getAuthorPHID()]->renderLink(),