Skip to content

Commit

Permalink
Merge pull request #8400 from kaltura/Naos-14.20.0-REACH2-577
Browse files Browse the repository at this point in the history
REACH2-577: When vendor marks task as error set its price to 0 while saving old price value
  • Loading branch information
yossipapi committed May 6, 2019
2 parents 362da87 + 34d5d49 commit 1ea6b8b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/reach/lib/kReachManager.php
Expand Up @@ -352,7 +352,13 @@ private function updateReachProfileCreditUsage(EntryVendorTask $entryVendorTask)

private function handleErrorTask(EntryVendorTask $entryVendorTask)
{
//Refund credit for tasks which could not be handled by the service provider
ReachProfilePeer::updateUsedCredit($entryVendorTask->getReachProfileId(), -$entryVendorTask->getPrice());

//Rest task price so that reports will be alligned with the total used credit
$entryVendorTask->setOldPrice($entryVendorTask->getPrice());
$entryVendorTask->setPrice(0);
$entryVendorTask->save();
}

private function invalidateAccessKey(EntryVendorTask $entryVendorTask)
Expand Down
11 changes: 11 additions & 0 deletions plugins/reach/lib/model/EntryVendorTask.php
Expand Up @@ -27,6 +27,7 @@ class EntryVendorTask extends BaseEntryVendorTask implements IRelatedObject, IIn
const CUSTOM_DATA_CREATION_MODE = 'creation_mode';
const CUSTOM_DATA_IS_REQUEST_MODERATED ='request_moderated';
const CUSTOM_DATA_TASK_DATA = 'task_data';
const CUSTOM_DATA_OLD_PRICE = 'old_price';

//setters

Expand Down Expand Up @@ -89,6 +90,11 @@ public function setTaskJobData($v)
{
$this->putInCustomData(self::CUSTOM_DATA_TASK_DATA, $v);
}

public function setOldPrice($v)
{
$this->putInCustomData(self::CUSTOM_DATA_OLD_PRICE, $v);
}

//getters

Expand Down Expand Up @@ -166,6 +172,11 @@ public function getTaskJobData()
{
return $this->getFromCustomData(self::CUSTOM_DATA_TASK_DATA);
}

public function getOldPrice()
{
return $this->getFromCustomData(self::CUSTOM_DATA_OLD_PRICE);
}

/* (non-PHPdoc)
* @see BaseEntryVendorTask::preSave()
Expand Down

0 comments on commit 1ea6b8b

Please sign in to comment.