Commit 6b6c991a authored by epriestley's avatar epriestley
Browse files

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
parent a1516fef
......@@ -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',
......
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',
'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',
......
......@@ -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()
......
......@@ -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;
......
......@@ -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();
}
......
......@@ -82,7 +82,7 @@ final class PhortuneInvoiceView extends AphrontTagView {
array(
'class' => 'phortune-mini-header',
),
pht('To:'));
pht('Bill To:'));
$bill_to = phutil_tag(
'td',
......
<?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());
}
}
<?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;
text-transform: uppercase;
margin-bottom: 4px;
letter-spacing: 0.3em;
letter-spacing: 0.25em;
}
.phortune-invoice-status {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment