1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +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:
epriestley 2019-01-16 06:59:06 -08:00
parent a1516fefb6
commit 6b6c991ad4
10 changed files with 153 additions and 14 deletions

View file

@ -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',

View file

@ -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};

View file

@ -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',

View file

@ -226,21 +226,33 @@ 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,
->setContent(
array(
$details,
$cart_box,
$charges,

View file

@ -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;

View file

@ -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();
}

View file

@ -82,7 +82,7 @@ final class PhortuneInvoiceView extends AphrontTagView {
array(
'class' => 'phortune-mini-header',
),
pht('To:'));
pht('Bill To:'));
$bill_to = phutil_tag(
'td',

View file

@ -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());
}
}

View file

@ -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;
}
}

View file

@ -49,7 +49,7 @@
font-weight: bold;
text-transform: uppercase;
margin-bottom: 4px;
letter-spacing: 0.3em;
letter-spacing: 0.25em;
}
.phortune-invoice-status {