1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 16:30:59 +01:00

Give Phortune carts a proper isInvoice flag

Summary:
See some earlier discussion in D11593:

> One thing I'm vaguely thinking about is the possibilty that users may be able to invoice one another directly, eventually. For example, we might invoice a contracting client.
> We might need an `isInvoice` flag eventually, but `subscriptionPHID` is a reasonable stand-in for now.

This adds such a flag.

Test Plan:
  - Generated an ad-hoc invoice and verified it showed up in the right place.
  - Used `bin/phortune invoice` to invoice a subscription and verified it worked correctly.
  - Paid an invoice and saw it leave "pending invoices" status.

{F377029}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D12480
This commit is contained in:
epriestley 2015-04-20 10:05:44 -07:00
parent 0195e751c6
commit 01c99335fd
8 changed files with 43 additions and 30 deletions

View file

@ -7,8 +7,8 @@
*/
return array(
'names' => array(
'core.pkg.css' => 'bf29d341',
'core.pkg.js' => 'a626d14c',
'core.pkg.css' => '7d05ad2a',
'core.pkg.js' => 'dfea788f',
'darkconsole.pkg.js' => '8ab24e01',
'differential.pkg.css' => '3500921f',
'differential.pkg.js' => 'c0506961',
@ -27,7 +27,7 @@ return array(
'rsrc/css/aphront/panel-view.css' => '8427b78d',
'rsrc/css/aphront/phabricator-nav-view.css' => '7aeaf435',
'rsrc/css/aphront/table-view.css' => '59e2c0f8',
'rsrc/css/aphront/tokenizer.css' => 'c10c061e',
'rsrc/css/aphront/tokenizer.css' => '86a13f7f',
'rsrc/css/aphront/tooltip.css' => '7672b60f',
'rsrc/css/aphront/two-column.css' => '16ab3ad2',
'rsrc/css/aphront/typeahead-browse.css' => 'efe293a0',
@ -147,7 +147,7 @@ return array(
'rsrc/css/phui/phui-remarkup-preview.css' => '19ad512b',
'rsrc/css/phui/phui-spacing.css' => '042804d6',
'rsrc/css/phui/phui-status.css' => '888cedb8',
'rsrc/css/phui/phui-tag-view.css' => 'ea469f3a',
'rsrc/css/phui/phui-tag-view.css' => '402691cc',
'rsrc/css/phui/phui-text.css' => 'cf019f54',
'rsrc/css/phui/phui-timeline-view.css' => 'b0fbc4d7',
'rsrc/css/phui/phui-workboard-view.css' => '3279cbbf',
@ -450,7 +450,7 @@ return array(
'rsrc/js/core/KeyboardShortcutManager.js' => 'c1700f6f',
'rsrc/js/core/MultirowRowManager.js' => 'b5d57730',
'rsrc/js/core/Notification.js' => '0c6946e7',
'rsrc/js/core/Prefab.js' => 'b972bdcd',
'rsrc/js/core/Prefab.js' => '6920d200',
'rsrc/js/core/ShapedRequest.js' => '7cbe244b',
'rsrc/js/core/TextAreaUtils.js' => '5c93c52c',
'rsrc/js/core/Title.js' => 'df5e11d2',
@ -510,7 +510,7 @@ return array(
'aphront-pager-view-css' => '2e3539af',
'aphront-panel-view-css' => '8427b78d',
'aphront-table-view-css' => '59e2c0f8',
'aphront-tokenizer-control-css' => 'c10c061e',
'aphront-tokenizer-control-css' => '86a13f7f',
'aphront-tooltip-css' => '7672b60f',
'aphront-two-column-view-css' => '16ab3ad2',
'aphront-typeahead-control-css' => '0e403212',
@ -744,7 +744,7 @@ return array(
'phabricator-notification-menu-css' => '3c9d8aa1',
'phabricator-object-selector-css' => '029a133d',
'phabricator-phtize' => 'd254d646',
'phabricator-prefab' => 'b972bdcd',
'phabricator-prefab' => '6920d200',
'phabricator-profile-css' => '1a20dcbf',
'phabricator-remarkup-css' => 'e10512ff',
'phabricator-search-results-css' => '15c71110',
@ -806,7 +806,7 @@ return array(
'phui-remarkup-preview-css' => '19ad512b',
'phui-spacing-css' => '042804d6',
'phui-status-list-view-css' => '888cedb8',
'phui-tag-view-css' => 'ea469f3a',
'phui-tag-view-css' => '402691cc',
'phui-text-css' => 'cf019f54',
'phui-timeline-view-css' => 'b0fbc4d7',
'phui-workboard-view-css' => '3279cbbf',
@ -1296,6 +1296,18 @@ return array(
'6882e80a' => array(
'javelin-dom',
),
'6920d200' => array(
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-typeahead',
'javelin-tokenizer',
'javelin-typeahead-preloaded-source',
'javelin-typeahead-ondemand-source',
'javelin-dom',
'javelin-stratcom',
'javelin-util',
),
'69adf288' => array(
'javelin-install',
),
@ -1469,6 +1481,10 @@ return array(
'phabricator-tooltip',
'changeset-view-manager',
),
'86a13f7f' => array(
'aphront-typeahead-control-css',
'phui-tag-view-css',
),
'87cb6b51' => array(
'javelin-behavior',
'javelin-dom',
@ -1707,18 +1723,6 @@ return array(
'javelin-dom',
'javelin-util',
),
'b972bdcd' => array(
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-typeahead',
'javelin-tokenizer',
'javelin-typeahead-preloaded-source',
'javelin-typeahead-ondemand-source',
'javelin-dom',
'javelin-stratcom',
'javelin-util',
),
'bba9eedf' => array(
'javelin-behavior',
'javelin-stratcom',
@ -1764,9 +1768,6 @@ return array(
'javelin-util',
'phabricator-shaped-request',
),
'c10c061e' => array(
'aphront-typeahead-control-css',
),
'c1700f6f' => array(
'javelin-install',
'javelin-util',

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_phortune.phortune_cart
ADD isInvoice BOOL NOT NULL;

View file

@ -0,0 +1,2 @@
UPDATE {$NAMESPACE}_phortune.phortune_cart
SET isInvoice = 1 WHERE subscriptionPHID IS NOT NULL;

View file

@ -41,7 +41,7 @@ final class PhortuneCartViewController
$resume_uri = null;
switch ($cart->getStatus()) {
case PhortuneCart::STATUS_READY:
if ($authority && $request->getStr('invoice')) {
if ($authority && $cart->getIsInvoice()) {
// We arrived here by following the ad-hoc invoice workflow, and
// are acting with merchant authority.

View file

@ -167,13 +167,14 @@ final class PhortuneMerchantInvoiceCreateController
->setMetadataValue('adhoc.name', $v_name)
->save();
// TODO: Actually mark these as invoices. Right now, there's no easy
// way to do that.
$cart
->setIsInvoice(1)
->save();
$cart->activateCart();
$cart_id = $cart->getID();
$uri = "/merchant/{$merchant_id}/cart/{$cart_id}/?invoice=true";
$uri = "/merchant/{$merchant_id}/cart/{$cart_id}/";
$uri = $this->getApplicationURI($uri);
return id(new AphrontRedirectResponse())->setURI($uri);

View file

@ -203,12 +203,12 @@ final class PhortuneCartQuery
if ($this->invoices) {
$where[] = qsprintf(
$conn,
'cart.status = %s AND cart.subscriptionPHID IS NOT NULL',
'cart.status = %s AND cart.isInvoice = 1',
PhortuneCart::STATUS_READY);
} else {
$where[] = qsprintf(
$conn,
'cart.status != %s OR cart.subscriptionPHID IS NULL',
'cart.status != %s OR cart.isInvoice = 0',
PhortuneCart::STATUS_READY);
}
}

View file

@ -21,6 +21,7 @@ final class PhortuneCart extends PhortuneDAO
protected $status;
protected $metadata = array();
protected $mailKey;
protected $isInvoice;
private $account = self::ATTACHABLE;
private $purchases = self::ATTACHABLE;
@ -35,6 +36,7 @@ final class PhortuneCart extends PhortuneDAO
->setAuthorPHID($actor->getPHID())
->setStatus(self::STATUS_BUILDING)
->setAccountPHID($account->getPHID())
->setIsInvoice(0)
->attachAccount($account)
->setMerchantPHID($merchant->getPHID())
->attachMerchant($merchant);
@ -531,6 +533,7 @@ final class PhortuneCart extends PhortuneDAO
'cartClass' => 'text128',
'mailKey' => 'bytes20',
'subscriptionPHID' => 'phid?',
'isInvoice' => 'bool',
),
self::CONFIG_KEY_SCHEMA => array(
'key_account' => array(

View file

@ -59,7 +59,11 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
->setMetadataValue('epoch.end', $next_epoch)
->save();
$cart->setSubscriptionPHID($subscription->getPHID());
$cart
->setSubscriptionPHID($subscription->getPHID())
->setIsInvoice(1)
->save();
$cart->activateCart();
try {