3 final class FundInitiativeMerchantTransaction
4 extends FundInitiativeTransactionType
{
6 const TRANSACTIONTYPE
= 'fund:merchant';
8 public function generateOldValue($object) {
9 return $object->getMerchantPHID();
12 public function applyInternalEffects($object, $value) {
13 $object->setMerchantPHID($value);
16 public function getTitle() {
17 $new = $this->getNewValue();
18 $new_merchant = $this->renderHandleList(array($new));
20 $old = $this->getOldValue();
21 $old_merchant = $this->renderHandleList(array($old));
25 '%s changed the merchant receiving funds from this '.
26 'initiative from %s to %s.',
27 $this->renderAuthor(),
32 '%s set the merchant receiving funds from this '.
34 $this->renderAuthor(),
39 public function getTitleForFeed() {
40 $new = $this->getNewValue();
41 $new_merchant = $this->renderHandleList(array($new));
43 $old = $this->getOldValue();
44 $old_merchant = $this->renderHandleList(array($old));
47 '%s changed the merchant receiving funds from %s '.
49 $this->renderAuthor(),
50 $this->renderObject(),
55 public function validateTransactions($object, array $xactions) {
58 if ($this->isEmptyTextTransaction($object->getMerchantPHID(), $xactions)) {
59 $errors[] = $this->newRequiredError(
60 pht('Initiatives must have a payable merchant.'));
63 foreach ($xactions as $xaction) {
64 $merchant_phid = $xaction->getNewValue();
66 // Make sure the actor has permission to edit the merchant they're
67 // selecting. You aren't allowed to send payments to an account you
69 $merchants = id(new PhortuneMerchantQuery())
70 ->setViewer($this->getActor())
71 ->withPHIDs(array($merchant_phid))
72 ->requireCapabilities(
74 PhabricatorPolicyCapability
::CAN_VIEW
,
75 PhabricatorPolicyCapability
::CAN_EDIT
,
79 $errors[] = $this->newInvalidError(
80 pht('You must specify a merchant account you control as the '.
81 'recipient of funds from this initiative.'));
88 public function getIcon() {