mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
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
This commit is contained in:
parent
a1516fefb6
commit
6b6c991ad4
10 changed files with 153 additions and 14 deletions
|
@ -91,7 +91,7 @@ return array(
|
||||||
'rsrc/css/application/pholio/pholio-inline-comments.css' => '722b48c2',
|
'rsrc/css/application/pholio/pholio-inline-comments.css' => '722b48c2',
|
||||||
'rsrc/css/application/pholio/pholio.css' => '88ef5ef1',
|
'rsrc/css/application/pholio/pholio.css' => '88ef5ef1',
|
||||||
'rsrc/css/application/phortune/phortune-credit-card-form.css' => '3b9868a8',
|
'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/phortune/phortune.css' => '12e8251a',
|
||||||
'rsrc/css/application/phrequent/phrequent.css' => 'bd79cc67',
|
'rsrc/css/application/phrequent/phrequent.css' => 'bd79cc67',
|
||||||
'rsrc/css/application/phriction/phriction-document-css.css' => '03380da0',
|
'rsrc/css/application/phriction/phriction-document-css.css' => '03380da0',
|
||||||
|
@ -788,7 +788,7 @@ return array(
|
||||||
'phortune-credit-card-form' => 'd12d214f',
|
'phortune-credit-card-form' => 'd12d214f',
|
||||||
'phortune-credit-card-form-css' => '3b9868a8',
|
'phortune-credit-card-form-css' => '3b9868a8',
|
||||||
'phortune-css' => '12e8251a',
|
'phortune-css' => '12e8251a',
|
||||||
'phortune-invoice-css' => 'e41765fc',
|
'phortune-invoice-css' => '4436b241',
|
||||||
'phrequent-css' => 'bd79cc67',
|
'phrequent-css' => 'bd79cc67',
|
||||||
'phriction-document-css' => '03380da0',
|
'phriction-document-css' => '03380da0',
|
||||||
'phui-action-panel-css' => '6c386cbf',
|
'phui-action-panel-css' => '6c386cbf',
|
||||||
|
|
|
@ -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};
|
|
@ -4905,7 +4905,9 @@ phutil_register_library_map(array(
|
||||||
'PholioUploadedImageView' => 'applications/pholio/view/PholioUploadedImageView.php',
|
'PholioUploadedImageView' => 'applications/pholio/view/PholioUploadedImageView.php',
|
||||||
'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php',
|
'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php',
|
||||||
'PhortuneAccountAddManagerController' => 'applications/phortune/controller/account/PhortuneAccountAddManagerController.php',
|
'PhortuneAccountAddManagerController' => 'applications/phortune/controller/account/PhortuneAccountAddManagerController.php',
|
||||||
|
'PhortuneAccountBillingAddressTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php',
|
||||||
'PhortuneAccountBillingController' => 'applications/phortune/controller/account/PhortuneAccountBillingController.php',
|
'PhortuneAccountBillingController' => 'applications/phortune/controller/account/PhortuneAccountBillingController.php',
|
||||||
|
'PhortuneAccountBillingNameTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php',
|
||||||
'PhortuneAccountChargeListController' => 'applications/phortune/controller/account/PhortuneAccountChargeListController.php',
|
'PhortuneAccountChargeListController' => 'applications/phortune/controller/account/PhortuneAccountChargeListController.php',
|
||||||
'PhortuneAccountController' => 'applications/phortune/controller/account/PhortuneAccountController.php',
|
'PhortuneAccountController' => 'applications/phortune/controller/account/PhortuneAccountController.php',
|
||||||
'PhortuneAccountEditController' => 'applications/phortune/controller/account/PhortuneAccountEditController.php',
|
'PhortuneAccountEditController' => 'applications/phortune/controller/account/PhortuneAccountEditController.php',
|
||||||
|
@ -11067,7 +11069,9 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
),
|
),
|
||||||
'PhortuneAccountAddManagerController' => 'PhortuneController',
|
'PhortuneAccountAddManagerController' => 'PhortuneController',
|
||||||
|
'PhortuneAccountBillingAddressTransaction' => 'PhortuneAccountTransactionType',
|
||||||
'PhortuneAccountBillingController' => 'PhortuneAccountProfileController',
|
'PhortuneAccountBillingController' => 'PhortuneAccountProfileController',
|
||||||
|
'PhortuneAccountBillingNameTransaction' => 'PhortuneAccountTransactionType',
|
||||||
'PhortuneAccountChargeListController' => 'PhortuneController',
|
'PhortuneAccountChargeListController' => 'PhortuneController',
|
||||||
'PhortuneAccountController' => 'PhortuneController',
|
'PhortuneAccountController' => 'PhortuneController',
|
||||||
'PhortuneAccountEditController' => 'PhortuneController',
|
'PhortuneAccountEditController' => 'PhortuneController',
|
||||||
|
|
|
@ -226,25 +226,37 @@ final class PhortuneCartViewController
|
||||||
->withPHIDs(array($buyer_phid))
|
->withPHIDs(array($buyer_phid))
|
||||||
->needProfileImage(true)
|
->needProfileImage(true)
|
||||||
->executeOne();
|
->executeOne();
|
||||||
// TODO: Add account "Contact" info
|
|
||||||
|
|
||||||
$merchant_contact = new PHUIRemarkupView(
|
$merchant_contact = new PHUIRemarkupView(
|
||||||
$viewer, $merchant->getContactInfo());
|
$viewer,
|
||||||
$description = null;
|
$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())
|
$view = id(new PhortuneInvoiceView())
|
||||||
->setMerchantName($merchant->getName())
|
->setMerchantName($merchant->getName())
|
||||||
->setMerchantLogo($merchant->getProfileImageURI())
|
->setMerchantLogo($merchant->getProfileImageURI())
|
||||||
->setMerchantContact($merchant_contact)
|
->setMerchantContact($merchant_contact)
|
||||||
->setMerchantFooter($merchant->getInvoiceFooter())
|
->setMerchantFooter($merchant->getInvoiceFooter())
|
||||||
->setAccountName($buyer->getRealName())
|
->setAccountName($account_name)
|
||||||
|
->setAccountContact($account_contact)
|
||||||
->setStatus($error_view)
|
->setStatus($error_view)
|
||||||
->setContent(array(
|
->setContent(
|
||||||
$description,
|
array(
|
||||||
$details,
|
$details,
|
||||||
$cart_box,
|
$cart_box,
|
||||||
$charges,
|
$charges,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $this->newPage()
|
$page = $this->newPage()
|
||||||
|
|
|
@ -99,6 +99,25 @@ final class PhortuneAccountEditEngine
|
||||||
->setConduitTypeDescription(pht('New list of managers.'))
|
->setConduitTypeDescription(pht('New list of managers.'))
|
||||||
->setInitialValue($object->getMemberPHIDs())
|
->setInitialValue($object->getMemberPHIDs())
|
||||||
->setValue($member_phids),
|
->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;
|
return $fields;
|
||||||
|
|
|
@ -12,11 +12,15 @@ final class PhortuneAccount extends PhortuneDAO
|
||||||
PhabricatorPolicyInterface {
|
PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
|
protected $billingName;
|
||||||
|
protected $billingAddress;
|
||||||
|
|
||||||
private $memberPHIDs = self::ATTACHABLE;
|
private $memberPHIDs = self::ATTACHABLE;
|
||||||
|
|
||||||
public static function initializeNewAccount(PhabricatorUser $actor) {
|
public static function initializeNewAccount(PhabricatorUser $actor) {
|
||||||
return id(new self())
|
return id(new self())
|
||||||
|
->setBillingName('')
|
||||||
|
->setBillingAddress('')
|
||||||
->attachMemberPHIDs(array());
|
->attachMemberPHIDs(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +79,8 @@ final class PhortuneAccount extends PhortuneDAO
|
||||||
self::CONFIG_AUX_PHID => true,
|
self::CONFIG_AUX_PHID => true,
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
self::CONFIG_COLUMN_SCHEMA => array(
|
||||||
'name' => 'text255',
|
'name' => 'text255',
|
||||||
|
'billingName' => 'text255',
|
||||||
|
'billingAddress' => 'text',
|
||||||
),
|
),
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ final class PhortuneInvoiceView extends AphrontTagView {
|
||||||
array(
|
array(
|
||||||
'class' => 'phortune-mini-header',
|
'class' => 'phortune-mini-header',
|
||||||
),
|
),
|
||||||
pht('To:'));
|
pht('Bill To:'));
|
||||||
|
|
||||||
$bill_to = phutil_tag(
|
$bill_to = phutil_tag(
|
||||||
'td',
|
'td',
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneAccountBillingAddressTransaction
|
||||||
|
extends PhortuneAccountTransactionType {
|
||||||
|
|
||||||
|
const TRANSACTIONTYPE = 'billing-address';
|
||||||
|
|
||||||
|
public function generateOldValue($object) {
|
||||||
|
return $object->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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneAccountBillingNameTransaction
|
||||||
|
extends PhortuneAccountTransactionType {
|
||||||
|
|
||||||
|
const TRANSACTIONTYPE = 'billing-name';
|
||||||
|
|
||||||
|
public function generateOldValue($object) {
|
||||||
|
return $object->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -49,7 +49,7 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
letter-spacing: 0.3em;
|
letter-spacing: 0.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.phortune-invoice-status {
|
.phortune-invoice-status {
|
||||||
|
|
Loading…
Reference in a new issue