diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 8cada227c6..6b170821a6 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -91,7 +91,7 @@ return array( 'rsrc/css/application/pholio/pholio-inline-comments.css' => '722b48c2', 'rsrc/css/application/pholio/pholio.css' => '88ef5ef1', 'rsrc/css/application/phortune/phortune-credit-card-form.css' => '3b9868a8', - 'rsrc/css/application/phortune/phortune-invoice.css' => 'e41765fc', + 'rsrc/css/application/phortune/phortune-invoice.css' => '4436b241', 'rsrc/css/application/phortune/phortune.css' => '12e8251a', 'rsrc/css/application/phrequent/phrequent.css' => 'bd79cc67', 'rsrc/css/application/phriction/phriction-document-css.css' => '03380da0', @@ -788,7 +788,7 @@ return array( 'phortune-credit-card-form' => 'd12d214f', 'phortune-credit-card-form-css' => '3b9868a8', 'phortune-css' => '12e8251a', - 'phortune-invoice-css' => 'e41765fc', + 'phortune-invoice-css' => '4436b241', 'phrequent-css' => 'bd79cc67', 'phriction-document-css' => '03380da0', 'phui-action-panel-css' => '6c386cbf', diff --git a/resources/sql/autopatches/20190116.phortune.01.billing.sql b/resources/sql/autopatches/20190116.phortune.01.billing.sql new file mode 100644 index 0000000000..77d00e220e --- /dev/null +++ b/resources/sql/autopatches/20190116.phortune.01.billing.sql @@ -0,0 +1,3 @@ +ALTER TABLE {$NAMESPACE}_phortune.phortune_account + ADD billingName VARCHAR(255) NOT NULL COLLATE {$COLLATE_TEXT}, + ADD billingAddress LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a72434f9a7..04631101c4 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4905,7 +4905,9 @@ phutil_register_library_map(array( 'PholioUploadedImageView' => 'applications/pholio/view/PholioUploadedImageView.php', 'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php', 'PhortuneAccountAddManagerController' => 'applications/phortune/controller/account/PhortuneAccountAddManagerController.php', + 'PhortuneAccountBillingAddressTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php', 'PhortuneAccountBillingController' => 'applications/phortune/controller/account/PhortuneAccountBillingController.php', + 'PhortuneAccountBillingNameTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php', 'PhortuneAccountChargeListController' => 'applications/phortune/controller/account/PhortuneAccountChargeListController.php', 'PhortuneAccountController' => 'applications/phortune/controller/account/PhortuneAccountController.php', 'PhortuneAccountEditController' => 'applications/phortune/controller/account/PhortuneAccountEditController.php', @@ -11067,7 +11069,9 @@ phutil_register_library_map(array( 'PhabricatorPolicyInterface', ), 'PhortuneAccountAddManagerController' => 'PhortuneController', + 'PhortuneAccountBillingAddressTransaction' => 'PhortuneAccountTransactionType', 'PhortuneAccountBillingController' => 'PhortuneAccountProfileController', + 'PhortuneAccountBillingNameTransaction' => 'PhortuneAccountTransactionType', 'PhortuneAccountChargeListController' => 'PhortuneController', 'PhortuneAccountController' => 'PhortuneController', 'PhortuneAccountEditController' => 'PhortuneController', diff --git a/src/applications/phortune/controller/cart/PhortuneCartViewController.php b/src/applications/phortune/controller/cart/PhortuneCartViewController.php index 8387cacb07..8108c83b39 100644 --- a/src/applications/phortune/controller/cart/PhortuneCartViewController.php +++ b/src/applications/phortune/controller/cart/PhortuneCartViewController.php @@ -226,25 +226,37 @@ final class PhortuneCartViewController ->withPHIDs(array($buyer_phid)) ->needProfileImage(true) ->executeOne(); - // TODO: Add account "Contact" info $merchant_contact = new PHUIRemarkupView( - $viewer, $merchant->getContactInfo()); - $description = null; + $viewer, + $merchant->getContactInfo()); + + $account_name = $account->getBillingName(); + if (!strlen($account_name)) { + $account_name = $buyer->getRealName(); + } + + $account_contact = $account->getBillingAddress(); + if (strlen($account_contact)) { + $account_contact = new PHUIRemarkupView( + $viewer, + $account_contact); + } $view = id(new PhortuneInvoiceView()) ->setMerchantName($merchant->getName()) ->setMerchantLogo($merchant->getProfileImageURI()) ->setMerchantContact($merchant_contact) ->setMerchantFooter($merchant->getInvoiceFooter()) - ->setAccountName($buyer->getRealName()) + ->setAccountName($account_name) + ->setAccountContact($account_contact) ->setStatus($error_view) - ->setContent(array( - $description, - $details, - $cart_box, - $charges, - )); + ->setContent( + array( + $details, + $cart_box, + $charges, + )); } $page = $this->newPage() diff --git a/src/applications/phortune/editor/PhortuneAccountEditEngine.php b/src/applications/phortune/editor/PhortuneAccountEditEngine.php index ed0e4b01be..1b6f9a5040 100644 --- a/src/applications/phortune/editor/PhortuneAccountEditEngine.php +++ b/src/applications/phortune/editor/PhortuneAccountEditEngine.php @@ -99,6 +99,25 @@ final class PhortuneAccountEditEngine ->setConduitTypeDescription(pht('New list of managers.')) ->setInitialValue($object->getMemberPHIDs()) ->setValue($member_phids), + + id(new PhabricatorTextEditField()) + ->setKey('billingName') + ->setLabel(pht('Billing Name')) + ->setDescription(pht('Account name for billing purposes.')) + ->setConduitTypeDescription(pht('New account billing name.')) + ->setTransactionType( + PhortuneAccountBillingNameTransaction::TRANSACTIONTYPE) + ->setValue($object->getBillingName()), + + id(new PhabricatorTextAreaEditField()) + ->setKey('billingAddress') + ->setLabel(pht('Billing Address')) + ->setDescription(pht('Account billing address.')) + ->setConduitTypeDescription(pht('New account billing address.')) + ->setTransactionType( + PhortuneAccountBillingAddressTransaction::TRANSACTIONTYPE) + ->setValue($object->getBillingAddress()), + ); return $fields; diff --git a/src/applications/phortune/storage/PhortuneAccount.php b/src/applications/phortune/storage/PhortuneAccount.php index b0b57645c3..ade98d327f 100644 --- a/src/applications/phortune/storage/PhortuneAccount.php +++ b/src/applications/phortune/storage/PhortuneAccount.php @@ -12,11 +12,15 @@ final class PhortuneAccount extends PhortuneDAO PhabricatorPolicyInterface { protected $name; + protected $billingName; + protected $billingAddress; private $memberPHIDs = self::ATTACHABLE; public static function initializeNewAccount(PhabricatorUser $actor) { return id(new self()) + ->setBillingName('') + ->setBillingAddress('') ->attachMemberPHIDs(array()); } @@ -75,6 +79,8 @@ final class PhortuneAccount extends PhortuneDAO self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'text255', + 'billingName' => 'text255', + 'billingAddress' => 'text', ), ) + parent::getConfiguration(); } diff --git a/src/applications/phortune/view/PhortuneInvoiceView.php b/src/applications/phortune/view/PhortuneInvoiceView.php index 89ad3fd1bc..65da418cc2 100644 --- a/src/applications/phortune/view/PhortuneInvoiceView.php +++ b/src/applications/phortune/view/PhortuneInvoiceView.php @@ -82,7 +82,7 @@ final class PhortuneInvoiceView extends AphrontTagView { array( 'class' => 'phortune-mini-header', ), - pht('To:')); + pht('Bill To:')); $bill_to = phutil_tag( 'td', diff --git a/src/applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php b/src/applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php new file mode 100644 index 0000000000..f4d62b1dcb --- /dev/null +++ b/src/applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php @@ -0,0 +1,39 @@ +getBillingAddress(); + } + + public function applyInternalEffects($object, $value) { + $object->setBillingAddress($value); + } + + public function getTitle() { + return pht( + '%s updated the account billing address.', + $this->renderAuthor()); + } + + public function hasChangeDetailView() { + return true; + } + + public function getMailDiffSectionHeader() { + return pht('CHANGES TO BILLING ADDRESS'); + } + + public function newChangeDetailView() { + $viewer = $this->getViewer(); + + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) + ->setViewer($viewer) + ->setOldText($this->getOldValue()) + ->setNewText($this->getNewValue()); + } + +} diff --git a/src/applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php b/src/applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php new file mode 100644 index 0000000000..6c2cde6c9b --- /dev/null +++ b/src/applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php @@ -0,0 +1,56 @@ +getBillingName(); + } + + public function applyInternalEffects($object, $value) { + $object->setBillingName($value); + } + + public function getTitle() { + $old = $this->getOldValue(); + $new = $this->getNewValue(); + + if (strlen($old) && strlen($new)) { + return pht( + '%s changed the billing name for this account from %s to %s.', + $this->renderAuthor(), + $this->renderOldValue(), + $this->renderNewValue()); + } else if (strlen($old)) { + return pht( + '%s removed the billing name for this account (was %s).', + $this->renderAuthor(), + $this->renderOldValue()); + } else { + return pht( + '%s set the billing name for this account to %s.', + $this->renderAuthor(), + $this->renderNewValue()); + } + } + + public function validateTransactions($object, array $xactions) { + $errors = array(); + + $max_length = $object->getColumnMaximumByteLength('billingName'); + foreach ($xactions as $xaction) { + $new_value = $xaction->getNewValue(); + $new_length = strlen($new_value); + if ($new_length > $max_length) { + $errors[] = $this->newRequiredError( + pht('The billing name can be no longer than %s characters.', + new PhutilNumber($max_length))); + } + } + + return $errors; + } + +} diff --git a/webroot/rsrc/css/application/phortune/phortune-invoice.css b/webroot/rsrc/css/application/phortune/phortune-invoice.css index 34bceb4bba..59199f0c94 100644 --- a/webroot/rsrc/css/application/phortune/phortune-invoice.css +++ b/webroot/rsrc/css/application/phortune/phortune-invoice.css @@ -49,7 +49,7 @@ font-weight: bold; text-transform: uppercase; margin-bottom: 4px; - letter-spacing: 0.3em; + letter-spacing: 0.25em; } .phortune-invoice-status {