public function getItemEarnings(GcrTransactionItem $item)
 {
     $earnings = 0;
     $purchase = $item->getPurchase();
     if ($purchase->isPayoff()) {
         $earnings = $item->getAmount();
     } else {
         $seller = $purchase->getSellerUser();
         if ($seller && $seller->isSameUser($this->user)) {
             $earnings = $item->getDistribution()->getSeller();
         }
     }
     return $earnings;
 }
 protected function setTotals(GcrTransactionItem $item)
 {
     $distribution = $item->getDistribution();
     $this->current_item_amounts['earnings'] = $this->account->getItemEarnings($item);
     $this->current_item_amounts['total'] = $distribution->getTotal();
     $this->current_item_amounts['seller'] = $this->account->getSellerEarnings($item);
     $this->current_item_amounts['fees'] = $this->current_item_amounts['total'] - $this->current_item_amounts['seller'];
     $purchase = $item->getPurchase();
     if (!$purchase->isPayoff()) {
         $this->totals['total_gross'] += $this->current_item_amounts['total'];
     }
     $this->totals['total_fees'] += $this->current_item_amounts['fees'];
     $this->totals['total_earnings'] += $this->current_item_amounts['earnings'];
     $this->totals['total_seller'] += $this->current_item_amounts['seller'];
     $this->totals['record_count']++;
 }
 public function getItemEarnings(GcrTransactionItem $item)
 {
     $earnings = 0;
     $purchase = $item->getPurchase();
     if ($purchase->isPayoff()) {
         $payoff = GcrPayoffTable::getInstance()->find($purchase->getPurchaseTypeId());
         if ($payoff->isEschoolPayoff()) {
             $earnings = $item->getAmount();
         }
     } else {
         if ($this->isRemoteItem($item)) {
             $earnings = $item->getDistribution()->getCommission();
         } else {
             $earnings = $item->getDistribution()->getOwner();
         }
     }
     return $earnings;
 }