Ejemplo n.º 1
0
 protected function setVariableValues() {
 	$this->setVariable('currency', Pap_Common_Utils_CurrencyUtils::getDefaultCurrency()->getSymbol());
 	$this->setVariable('payaffiliateslist', $this->payAffiliatesList->getHtml());
 	$this->setVariable('amounttopay', $this->payAffiliatesList->getAmountToPay());
     $this->setVariable('approvedcommissions', $this->payAffiliatesList->getApprovedCommissions());
     $this->setVariable('pendingcommissions', $this->payAffiliatesList->getPendingCommissions());
     $this->setVariable('declinedcommissions', $this->payAffiliatesList->getDeclinedCommissions());        
 }    
Ejemplo n.º 2
0
	protected function setVariableValues() {
	    $this->setVariable('currency', Pap_Common_Utils_CurrencyUtils::getDefaultCurrency()->getSymbol());

	    $this->setStatsVariables();    
	    
	    $this->setVariableRaw('commissionsList', new Pap_Mail_Reports_List($this->createTransactionList($this->statsParams)));
		$this->setVariableRaw('salesList', new Pap_Mail_Reports_List($this->getSalesList()));
		$this->setVariableRaw('actionsList', new Pap_Mail_Reports_List($this->getActionsList()));
	}
Ejemplo n.º 3
0
 /**
  *
  * @service affiliate_invoice read
  * @param $fields
  */
 public function previewInvoice(Gpf_Rpc_Params $params) {
     $form = new Gpf_Rpc_Form($params);
     
     $user = new Pap_Affiliates_User();
     
     $applyVat = $form->getFieldValue('applyVat');
     $payoutInvoice = $form->getFieldValue('payoutInvoice');
     
     
     $user->setId($form->getFieldValue('userid'));
     try {
         $user->load();
     } catch (Gpf_Exception $e) {
         $this->invoiceHtml = $this->_("You have to select user");
         return $this;
     }
     
     $currency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency();
     $payout = new Pap_Common_Payout($user, $currency, 1, 123456);
     $payout->setApplyVat($applyVat);
     $payout->generateInvoice($payoutInvoice);
     $this->invoiceHtml = $payout->getInvoice(); 
     return $this;
 }
	private function createList() {
		$payAffTemplate = new Gpf_Templates_Template('pay_affiliates_list.tpl', 'merchants');
		$payAffTemplate->assignByRef('payaffiliates', $this->iterator);
		$payAffTemplate->assignByRef('currency', Pap_Common_Utils_CurrencyUtils::getDefaultCurrency()->getSymbol());
		return $payAffTemplate->getHTML();
	}
Ejemplo n.º 5
0
 /**
  * Get default currency symbol
  */
 private function getDefaultCurrencySymbol() {
     $defaultCurrency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency();
     return $defaultCurrency->getSymbol();
 }
Ejemplo n.º 6
0
	/**
     * formats the value to the standard currency format according to the default currency settings
     * For example 2.0001 will be transformed to $ 2.0001. Does not round the number.
     *
     * @param string $value
     * @return string
     */
    public static function stringToCurrencyFormat($value) {
        if ($value == null || $value == '') {
            return $value;
        }

        $defaultCurrency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency();
        if($defaultCurrency == NULL) {
            return $value;
        }
        
        $currencySymbol = $defaultCurrency->getSymbol();
        $currencyWhereDisplay = $defaultCurrency->getWhereDisplay();
        
        if ($currencyWhereDisplay == Pap_Common_Utils_CurrencyUtils::WHEREDISPLAY_LEFT) {
            return $currencySymbol.' '.$value;
        }
        return $value.' '.$currencySymbol;
    }
	/**
	 * @param Gpf_Data_Row $row
	 */
	private function addVATData(Gpf_Data_Row $row) {
	    try {
            $user = new Pap_Common_User();
            $user->setId($row->get('userid'));
            $user->load();
	    } catch (Gpf_Exception $e) {
            $row->add('vat', $this->_('N/A'));
            $row->add('amounttopay', $this->_('N/A'));
            return;
        }

        $currency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency();

        $payout = new Pap_Common_Payout($user, $currency, $row->get(Pap_Db_Table_Transactions::COMMISSION), null);

        if (!$payout->getApplyVat()) {
            $row->add('vat', $this->_('N/A'));
            $row->add('amounttopay', $row->get(Pap_Db_Table_Transactions::COMMISSION));
            return;
        }
        $row->add('vat', $payout->getVatPercentage() . ' %');
        $row->add('amounttopay', $payout->getAmountWithVat());
	}
    /**
     * @service pay_affiliate write
     * @return Gpf_Rpc_Form
     */
    public function payAffiliates(Gpf_Rpc_Params $params) {
    	$form = new Gpf_Rpc_Form($params);    	    	        

    	$this->saveNotificationSettings($form);       	       
        $currency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency();
        $payoutHistory = $this->createPayoutHistoryItem($form);
        
        foreach ($this->getAffiliatesToPaySelect()->getAllRowsIterator() as $row) {
            $user = new Pap_Common_User();
            $user->fillFromRecord($row);
            $payout = new Pap_Common_Payout($user, $currency, $row->get('amountRaw'), $this->generateInvoiceNumber());
            $payout->setPayoutHistory($payoutHistory);
            $payout->generateInvoice();
            try {
                $payout->save();
            } catch (Gpf_DbEngine_Row_ConstraintException $e) {
            	$form->setErrorMessage($this->_('Failed to pay affiliates %s', $e->getMessage()));            	
            	continue;
            }
            $this->markTransactionsAsPaid($payout);
            $this->sendEmails($payout);

            Gpf_Plugins_Engine::extensionPoint('PostAffiliate.Pap_Merchants_Payout_PayAffiliatesForm.payAffiliates', $user);
        }           
             
        $form->setInfoMessage($this->_('Affiliates successfully paid'));        
        
        return $form;
    }