@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow Phortune accounts to customize their billing address and name

Summary:
See PHI1023. Ref T7607. Occasionally, companies need their billing address (or some other custom text) to appear on invoices to satisfy process or compliance requirements.

Allow accounts to have a custom "Billing Name" and a custom "Billing Address" which appear on invoices.

Test Plan: {F6134707}

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T7607

Differential Revision: https://secure.phabricator.com/D19979

+153 -14
+2 -2
resources/celerity/map.php
··· 91 91 'rsrc/css/application/pholio/pholio-inline-comments.css' => '722b48c2', 92 92 'rsrc/css/application/pholio/pholio.css' => '88ef5ef1', 93 93 'rsrc/css/application/phortune/phortune-credit-card-form.css' => '3b9868a8', 94 - 'rsrc/css/application/phortune/phortune-invoice.css' => 'e41765fc', 94 + 'rsrc/css/application/phortune/phortune-invoice.css' => '4436b241', 95 95 'rsrc/css/application/phortune/phortune.css' => '12e8251a', 96 96 'rsrc/css/application/phrequent/phrequent.css' => 'bd79cc67', 97 97 'rsrc/css/application/phriction/phriction-document-css.css' => '03380da0', ··· 788 788 'phortune-credit-card-form' => 'd12d214f', 789 789 'phortune-credit-card-form-css' => '3b9868a8', 790 790 'phortune-css' => '12e8251a', 791 - 'phortune-invoice-css' => 'e41765fc', 791 + 'phortune-invoice-css' => '4436b241', 792 792 'phrequent-css' => 'bd79cc67', 793 793 'phriction-document-css' => '03380da0', 794 794 'phui-action-panel-css' => '6c386cbf',
+3
resources/sql/autopatches/20190116.phortune.01.billing.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phortune.phortune_account 2 + ADD billingName VARCHAR(255) NOT NULL COLLATE {$COLLATE_TEXT}, 3 + ADD billingAddress LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT};
+4
src/__phutil_library_map__.php
··· 4905 4905 'PholioUploadedImageView' => 'applications/pholio/view/PholioUploadedImageView.php', 4906 4906 'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php', 4907 4907 'PhortuneAccountAddManagerController' => 'applications/phortune/controller/account/PhortuneAccountAddManagerController.php', 4908 + 'PhortuneAccountBillingAddressTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php', 4908 4909 'PhortuneAccountBillingController' => 'applications/phortune/controller/account/PhortuneAccountBillingController.php', 4910 + 'PhortuneAccountBillingNameTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php', 4909 4911 'PhortuneAccountChargeListController' => 'applications/phortune/controller/account/PhortuneAccountChargeListController.php', 4910 4912 'PhortuneAccountController' => 'applications/phortune/controller/account/PhortuneAccountController.php', 4911 4913 'PhortuneAccountEditController' => 'applications/phortune/controller/account/PhortuneAccountEditController.php', ··· 11067 11069 'PhabricatorPolicyInterface', 11068 11070 ), 11069 11071 'PhortuneAccountAddManagerController' => 'PhortuneController', 11072 + 'PhortuneAccountBillingAddressTransaction' => 'PhortuneAccountTransactionType', 11070 11073 'PhortuneAccountBillingController' => 'PhortuneAccountProfileController', 11074 + 'PhortuneAccountBillingNameTransaction' => 'PhortuneAccountTransactionType', 11071 11075 'PhortuneAccountChargeListController' => 'PhortuneController', 11072 11076 'PhortuneAccountController' => 'PhortuneController', 11073 11077 'PhortuneAccountEditController' => 'PhortuneController',
+22 -10
src/applications/phortune/controller/cart/PhortuneCartViewController.php
··· 226 226 ->withPHIDs(array($buyer_phid)) 227 227 ->needProfileImage(true) 228 228 ->executeOne(); 229 - // TODO: Add account "Contact" info 230 229 231 230 $merchant_contact = new PHUIRemarkupView( 232 - $viewer, $merchant->getContactInfo()); 233 - $description = null; 231 + $viewer, 232 + $merchant->getContactInfo()); 233 + 234 + $account_name = $account->getBillingName(); 235 + if (!strlen($account_name)) { 236 + $account_name = $buyer->getRealName(); 237 + } 238 + 239 + $account_contact = $account->getBillingAddress(); 240 + if (strlen($account_contact)) { 241 + $account_contact = new PHUIRemarkupView( 242 + $viewer, 243 + $account_contact); 244 + } 234 245 235 246 $view = id(new PhortuneInvoiceView()) 236 247 ->setMerchantName($merchant->getName()) 237 248 ->setMerchantLogo($merchant->getProfileImageURI()) 238 249 ->setMerchantContact($merchant_contact) 239 250 ->setMerchantFooter($merchant->getInvoiceFooter()) 240 - ->setAccountName($buyer->getRealName()) 251 + ->setAccountName($account_name) 252 + ->setAccountContact($account_contact) 241 253 ->setStatus($error_view) 242 - ->setContent(array( 243 - $description, 244 - $details, 245 - $cart_box, 246 - $charges, 247 - )); 254 + ->setContent( 255 + array( 256 + $details, 257 + $cart_box, 258 + $charges, 259 + )); 248 260 } 249 261 250 262 $page = $this->newPage()
+19
src/applications/phortune/editor/PhortuneAccountEditEngine.php
··· 99 99 ->setConduitTypeDescription(pht('New list of managers.')) 100 100 ->setInitialValue($object->getMemberPHIDs()) 101 101 ->setValue($member_phids), 102 + 103 + id(new PhabricatorTextEditField()) 104 + ->setKey('billingName') 105 + ->setLabel(pht('Billing Name')) 106 + ->setDescription(pht('Account name for billing purposes.')) 107 + ->setConduitTypeDescription(pht('New account billing name.')) 108 + ->setTransactionType( 109 + PhortuneAccountBillingNameTransaction::TRANSACTIONTYPE) 110 + ->setValue($object->getBillingName()), 111 + 112 + id(new PhabricatorTextAreaEditField()) 113 + ->setKey('billingAddress') 114 + ->setLabel(pht('Billing Address')) 115 + ->setDescription(pht('Account billing address.')) 116 + ->setConduitTypeDescription(pht('New account billing address.')) 117 + ->setTransactionType( 118 + PhortuneAccountBillingAddressTransaction::TRANSACTIONTYPE) 119 + ->setValue($object->getBillingAddress()), 120 + 102 121 ); 103 122 104 123 return $fields;
+6
src/applications/phortune/storage/PhortuneAccount.php
··· 12 12 PhabricatorPolicyInterface { 13 13 14 14 protected $name; 15 + protected $billingName; 16 + protected $billingAddress; 15 17 16 18 private $memberPHIDs = self::ATTACHABLE; 17 19 18 20 public static function initializeNewAccount(PhabricatorUser $actor) { 19 21 return id(new self()) 22 + ->setBillingName('') 23 + ->setBillingAddress('') 20 24 ->attachMemberPHIDs(array()); 21 25 } 22 26 ··· 75 79 self::CONFIG_AUX_PHID => true, 76 80 self::CONFIG_COLUMN_SCHEMA => array( 77 81 'name' => 'text255', 82 + 'billingName' => 'text255', 83 + 'billingAddress' => 'text', 78 84 ), 79 85 ) + parent::getConfiguration(); 80 86 }
+1 -1
src/applications/phortune/view/PhortuneInvoiceView.php
··· 82 82 array( 83 83 'class' => 'phortune-mini-header', 84 84 ), 85 - pht('To:')); 85 + pht('Bill To:')); 86 86 87 87 $bill_to = phutil_tag( 88 88 'td',
+39
src/applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php
··· 1 + <?php 2 + 3 + final class PhortuneAccountBillingAddressTransaction 4 + extends PhortuneAccountTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'billing-address'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getBillingAddress(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setBillingAddress($value); 14 + } 15 + 16 + public function getTitle() { 17 + return pht( 18 + '%s updated the account billing address.', 19 + $this->renderAuthor()); 20 + } 21 + 22 + public function hasChangeDetailView() { 23 + return true; 24 + } 25 + 26 + public function getMailDiffSectionHeader() { 27 + return pht('CHANGES TO BILLING ADDRESS'); 28 + } 29 + 30 + public function newChangeDetailView() { 31 + $viewer = $this->getViewer(); 32 + 33 + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) 34 + ->setViewer($viewer) 35 + ->setOldText($this->getOldValue()) 36 + ->setNewText($this->getNewValue()); 37 + } 38 + 39 + }
+56
src/applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php
··· 1 + <?php 2 + 3 + final class PhortuneAccountBillingNameTransaction 4 + extends PhortuneAccountTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'billing-name'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getBillingName(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setBillingName($value); 14 + } 15 + 16 + public function getTitle() { 17 + $old = $this->getOldValue(); 18 + $new = $this->getNewValue(); 19 + 20 + if (strlen($old) && strlen($new)) { 21 + return pht( 22 + '%s changed the billing name for this account from %s to %s.', 23 + $this->renderAuthor(), 24 + $this->renderOldValue(), 25 + $this->renderNewValue()); 26 + } else if (strlen($old)) { 27 + return pht( 28 + '%s removed the billing name for this account (was %s).', 29 + $this->renderAuthor(), 30 + $this->renderOldValue()); 31 + } else { 32 + return pht( 33 + '%s set the billing name for this account to %s.', 34 + $this->renderAuthor(), 35 + $this->renderNewValue()); 36 + } 37 + } 38 + 39 + public function validateTransactions($object, array $xactions) { 40 + $errors = array(); 41 + 42 + $max_length = $object->getColumnMaximumByteLength('billingName'); 43 + foreach ($xactions as $xaction) { 44 + $new_value = $xaction->getNewValue(); 45 + $new_length = strlen($new_value); 46 + if ($new_length > $max_length) { 47 + $errors[] = $this->newRequiredError( 48 + pht('The billing name can be no longer than %s characters.', 49 + new PhutilNumber($max_length))); 50 + } 51 + } 52 + 53 + return $errors; 54 + } 55 + 56 + }
+1 -1
webroot/rsrc/css/application/phortune/phortune-invoice.css
··· 49 49 font-weight: bold; 50 50 text-transform: uppercase; 51 51 margin-bottom: 4px; 52 - letter-spacing: 0.3em; 52 + letter-spacing: 0.25em; 53 53 } 54 54 55 55 .phortune-invoice-status {