• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CRM_Core_BAO_FinancialTrxn类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中CRM_Core_BAO_FinancialTrxn的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_FinancialTrxn类的具体用法?PHP CRM_Core_BAO_FinancialTrxn怎么用?PHP CRM_Core_BAO_FinancialTrxn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CRM_Core_BAO_FinancialTrxn类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testCreate

 /**
  * Check method create()
  */
 public function testCreate()
 {
     $contactId = $this->individualCreate();
     $financialTypeId = 1;
     $this->contributionCreate(array('contact_id' => $contactId), $financialTypeId);
     $params = array('contribution_id' => $financialTypeId, 'to_financial_account_id' => 1, 'trxn_date' => 20091021184930.0, 'trxn_type' => 'Debit', 'total_amount' => 10, 'net_amount' => 90.0, 'currency' => 'USD', 'payment_processor' => 'Dummy', 'trxn_id' => 'test_01014000');
     $FinancialTrxn = CRM_Core_BAO_FinancialTrxn::create($params);
     $result = $this->assertDBNotNull('CRM_Core_BAO_FinancialTrxn', $FinancialTrxn->id, 'total_amount', 'id', 'Database check on updated financial trxn record.');
     $this->assertEquals($result, 10, 'Verify financial trxn total_amount.');
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:13,代码来源:FinancialTrxnTest.php


示例2: testGetPartialPaymentTrxn

 /**
  * Test getPartialPaymentTrxn function.
  */
 public function testGetPartialPaymentTrxn()
 {
     $contributionTest = new CRM_Contribute_BAO_ContributionTest();
     list($lineItems, $contribution) = $contributionTest->addParticipantWithContribution();
     $contribution = (array) $contribution;
     $params = array('contribution_id' => $contribution['id'], 'total_amount' => 100.0);
     $trxn = CRM_Core_BAO_FinancialTrxn::getPartialPaymentTrxn($contribution, $params);
     $this->assertEquals('100.00', $trxn->total_amount, 'Amount does not match.');
     $totalPaymentAmount = CRM_Core_BAO_FinancialTrxn::getTotalPayments($contribution['id']);
     $this->assertEquals('250.00', $totalPaymentAmount, 'Amount does not match.');
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:14,代码来源:FinancialTrxnTest.php


示例3: preProcess

 public function preProcess()
 {
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE);
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
     $enitityType = NULL;
     if ($this->_component == 'event') {
         $enitityType = 'participant';
         $this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id');
     }
     $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
     $this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($eventId);
     $paymentInfo = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($this->_id, $enitityType);
     $paymentDetails = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component);
     $this->_amtPaid = $paymentDetails['paid'];
     $this->_amtTotal = $paymentDetails['total'];
     if (!empty($paymentInfo['refund_due'])) {
         $paymentAmt = $this->_refund = $paymentInfo['refund_due'];
         $this->_paymentType = 'refund';
     } elseif (!empty($paymentInfo['amount_owed'])) {
         $paymentAmt = $this->_owed = $paymentInfo['amount_owed'];
         $this->_paymentType = 'owed';
     } else {
         CRM_Core_Error::fatal(ts('No payment information found for this record'));
     }
     //set the payment mode - _mode property is defined in parent class
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     if (!empty($this->_mode) && $this->_paymentType == 'refund') {
         CRM_Core_Error::fatal(ts('Credit card payment is not for Refund payments use'));
     }
     list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
     if (!$this->_refund) {
         $this->assignProcessors();
         // also check for billing information
         // get the billing location type
         $this->assignBillingType();
     }
     $this->assign('contributionMode', $this->_mode);
     $this->assign('contactId', $this->_contactId);
     $this->assign('component', $this->_component);
     $this->assign('id', $this->_id);
     $this->assign('paymentType', $this->_paymentType);
     $this->assign('paymentAmt', abs($paymentAmt));
     $this->_paymentProcessor = array('billing_mode' => 1);
     $title = $this->_refund ? "Refund for {$this->_contributorDisplayName}" : "Payment from {$this->_contributorDisplayName}";
     if ($title) {
         CRM_Utils_System::setTitle(ts('%1', array(1 => $title)));
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:51,代码来源:AdditionalPayment.php


示例4: testGetTotalPayments

 /**
  * Test getTotalPayments function.
  */
 public function testGetTotalPayments()
 {
     $contactId = $this->individualCreate();
     $params = array('contact_id' => $contactId, 'currency' => 'USD', 'financial_type_id' => 1, 'contribution_status_id' => 2, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'is_pay_later' => 1, 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'non_deductible_amount' => 0.0, 'total_amount' => 200.0, 'fee_amount' => 5, 'net_amount' => 195, 'trxn_id' => '22ereerwwe4444yy', 'invoice_id' => '86ed39e9e9yy6ef6541621ce0eafe7eb81', 'thankyou_date' => '20080522');
     $contribution = CRM_Contribute_BAO_Contribution::create($params);
     $this->assertEquals($params['trxn_id'], $contribution->trxn_id);
     $this->assertEquals($contactId, $contribution->contact_id);
     $totalPaymentAmount = CRM_Core_BAO_FinancialTrxn::getTotalPayments($contribution->id);
     $this->assertEquals(0, $totalPaymentAmount, 'Amount not matching.');
     //update contribution amount
     $params['id'] = $contribution->id;
     $params['contribution_status_id'] = 1;
     $contribution = CRM_Contribute_BAO_Contribution::create($params);
     $this->assertEquals($params['trxn_id'], $contribution->trxn_id);
     $this->assertEquals($params['contribution_status_id'], $contribution->contribution_status_id);
     $totalPaymentAmount = CRM_Core_BAO_FinancialTrxn::getTotalPayments($contribution->id);
     $this->assertEquals('200.00', $totalPaymentAmount, 'Amount not matching.');
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:21,代码来源:FinancialTrxnTest.php


示例5: createDiscountTrxn

 /**
  * to create trxn entry if an event has discount.
  *
  * @param int     $eventID  event id
  * @param array   $contributionParams  contribution params.
  *
  * @static
  */
 static function createDiscountTrxn($eventID, $contributionParams, $feeLevel)
 {
     // CRM-11124
     $checkDiscount = CRM_Core_BAO_Discount::findSet($eventID, 'civicrm_event');
     if (!empty($checkDiscount)) {
         $feeLevel = current($feeLevel);
         $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventID, NULL);
         $query = "SELECT cpfv.amount FROM `civicrm_price_field_value` cpfv\nLEFT JOIN civicrm_price_field cpf ON cpfv.price_field_id = cpf.id\nWHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
         $params = array(1 => array($priceSetId, 'Integer'), 2 => array($feeLevel, 'String'));
         $mainAmount = CRM_Core_DAO::singleValueQuery($query, $params);
         $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Discounts Account is' "));
         $contributionParams['trxnParams']['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($contributionParams['contribution']->financial_type_id, $relationTypeId);
         if (CRM_Utils_Array::value('from_financial_account_id', $contributionParams['trxnParams'])) {
             $contributionParams['trxnParams']['total_amount'] = $mainAmount - $contributionParams['total_amount'];
             $contributionParams['trxnParams']['payment_processor_id'] = $contributionParams['trxnParams']['payment_instrument_id'] = $contributionParams['trxnParams']['check_number'] = $contributionParams['trxnParams']['trxn_id'] = $contributionParams['trxnParams']['net_amount'] = $contributionParams['trxnParams']['fee_amount'] = NULL;
             CRM_Core_BAO_FinancialTrxn::create($contributionParams['trxnParams']);
         }
     }
     return;
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:28,代码来源:Participant.php


示例6: recordAdjustedAmt

 /**
  * Record adjusted amount.
  *
  * @param int $updatedAmount
  * @param int $paidAmount
  * @param int $contributionId
  *
  * @param int $taxAmount
  * @param bool $updateAmountLevel
  *
  * @return bool|\CRM_Core_BAO_FinancialTrxn
  */
 public static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount = NULL, $updateAmountLevel = NULL)
 {
     $pendingAmount = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
     $pendingAmount = CRM_Utils_Array::value('total_amount', $pendingAmount, 0);
     $balanceAmt = $updatedAmount - $paidAmount;
     if ($paidAmount != $pendingAmount) {
         $balanceAmt -= $pendingAmount;
     }
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
     $pendingRefundStatusId = array_search('Pending refund', $contributionStatuses);
     $completedStatusId = array_search('Completed', $contributionStatuses);
     $updatedContributionDAO = new CRM_Contribute_BAO_Contribution();
     $adjustedTrxn = $skip = FALSE;
     if ($balanceAmt) {
         if ($balanceAmt > 0 && $paidAmount != 0) {
             $contributionStatusVal = $partiallyPaidStatusId;
         } elseif ($balanceAmt < 0 && $paidAmount != 0) {
             $contributionStatusVal = $pendingRefundStatusId;
         } elseif ($paidAmount == 0) {
             //skip updating the contribution status if no payment is made
             $skip = TRUE;
             $updatedContributionDAO->cancel_date = 'null';
             $updatedContributionDAO->cancel_reason = NULL;
         }
         // update contribution status and total amount without trigger financial code
         // as this is handled in current BAO function used for change selection
         $updatedContributionDAO->id = $contributionId;
         if (!$skip) {
             $updatedContributionDAO->contribution_status_id = $contributionStatusVal;
         }
         $updatedContributionDAO->total_amount = $updatedContributionDAO->net_amount = $updatedAmount;
         $updatedContributionDAO->fee_amount = 0;
         $updatedContributionDAO->tax_amount = $taxAmount;
         if (!empty($updateAmountLevel)) {
             $updatedContributionDAO->amount_level = $updateAmountLevel;
         }
         $updatedContributionDAO->save();
         // adjusted amount financial_trxn creation
         $updatedContribution = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contributionId), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
         $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
         $toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($updatedContribution->financial_type_id, $relationTypeId);
         $adjustedTrxnValues = array('from_financial_account_id' => NULL, 'to_financial_account_id' => $toFinancialAccount, 'total_amount' => $balanceAmt, 'status_id' => $completedStatusId, 'payment_instrument_id' => $updatedContribution->payment_instrument_id, 'contribution_id' => $updatedContribution->id, 'trxn_date' => date('YmdHis'), 'currency' => $updatedContribution->currency);
         $adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues);
     }
     return $adjustedTrxn;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:59,代码来源:Participant.php


示例7: completeTransaction


//.........这里部分代码省略.........
                     $membershipLog['membership_type_id'] = $membership->membership_type_id;
                     CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
                     //update related Memberships.
                     CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
                     //update the membership type key of membership relatedObjects array
                     //if it has changed after membership update
                     if ($membershipTypeIdKey != $membership->membership_type_id) {
                         $memberships[$membership->membership_type_id] = $membership;
                         $contribution->_relatedObjects['membership'][$membership->membership_type_id] = $membership;
                         unset($contribution->_relatedObjects['membership'][$membershipTypeIdKey]);
                         unset($memberships[$membershipTypeIdKey]);
                     }
                 }
             }
         }
     } else {
         // event
         $eventParams = array('id' => $objects['event']->id);
         $values['event'] = array();
         CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
         $eventParams = array('id' => $objects['event']->id);
         $values['event'] = array();
         CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
         //get location details
         $locationParams = array('entity_id' => $objects['event']->id, 'entity_table' => 'civicrm_event');
         $values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
         $ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'module' => 'CiviEvent');
         list($custom_pre_id, $custom_post_ids) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         $values['custom_pre_id'] = $custom_pre_id;
         $values['custom_post_id'] = $custom_post_ids;
         $contribution->source = ts('Online Event Registration') . ': ' . $values['event']['title'];
         if ($values['event']['is_email_confirm']) {
             $contribution->receipt_date = self::$_now;
             $values['is_email_receipt'] = 1;
         }
         $participant->status_id = 1;
         $participant->save();
     }
     if (CRM_Utils_Array::value('net_amount', $input, 0) == 0 && CRM_Utils_Array::value('fee_amount', $input, 0) != 0) {
         $input['net_amount'] = $input['amount'] - $input['fee_amount'];
     }
     $addLineItems = FALSE;
     if (empty($contribution->id)) {
         $addLineItems = TRUE;
     }
     $contribution->contribution_status_id = 1;
     $contribution->is_test = $input['is_test'];
     $contribution->fee_amount = CRM_Utils_Array::value('fee_amount', $input, 0);
     $contribution->net_amount = CRM_Utils_Array::value('net_amount', $input, 0);
     $contribution->trxn_id = $input['trxn_id'];
     $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
     $contribution->thankyou_date = CRM_Utils_Date::isoToMysql($contribution->thankyou_date);
     $contribution->cancel_date = 'null';
     if (CRM_Utils_Array::value('check_number', $input)) {
         $contribution->check_number = $input['check_number'];
     }
     if (CRM_Utils_Array::value('payment_instrument_id', $input)) {
         $contribution->payment_instrument_id = $input['payment_instrument_id'];
     }
     $contribution->save();
     //add lineitems for recurring payments
     if (CRM_Utils_Array::value('contributionRecur', $objects) && $objects['contributionRecur']->id && $addLineItems) {
         $this->addrecurLineItems($objects['contributionRecur']->id, $contribution->id);
     }
     // next create the transaction record
     $paymentProcessor = '';
     if (isset($objects['paymentProcessor'])) {
         if (is_array($objects['paymentProcessor'])) {
             $paymentProcessor = $objects['paymentProcessor']['payment_processor_type'];
         } else {
             $paymentProcessor = $objects['paymentProcessor']->payment_processor_type;
         }
     }
     if ($contribution->trxn_id) {
         $trxnParams = array('contribution_id' => $contribution->id, 'trxn_date' => isset($input['trxn_date']) ? $input['trxn_date'] : self::$_now, 'trxn_type' => 'Debit', 'total_amount' => $input['amount'], 'fee_amount' => $contribution->fee_amount, 'net_amount' => $contribution->net_amount, 'currency' => $contribution->currency, 'payment_processor' => $paymentProcessor, 'trxn_id' => $contribution->trxn_id);
         $trxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams);
     }
     self::updateRecurLinkedPledge($contribution);
     // create an activity record
     if ($input['component'] == 'contribute') {
         //CRM-4027
         $targetContactID = NULL;
         if (CRM_Utils_Array::value('related_contact', $ids)) {
             $targetContactID = $contribution->contact_id;
             $contribution->contact_id = $ids['related_contact'];
         }
         CRM_Activity_BAO_Activity::addActivity($contribution, NULL, $targetContactID);
         // event
     } else {
         CRM_Activity_BAO_Activity::addActivity($participant);
     }
     CRM_Core_Error::debug_log_message("Contribution record updated successfully");
     $transaction->commit();
     // CRM-9132 legacy behaviour was that receipts were sent out in all instances. Still sending
     // when array_key 'is_email_receipt doesn't exist in case some instances where is needs setting haven't been set
     if (!array_key_exists('is_email_receipt', $values) || $values['is_email_receipt'] == 1) {
         self::sendMail($input, $ids, $objects, $values, $recur, FALSE);
     }
     CRM_Core_Error::debug_log_message("Success: Database updated and mail sent");
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:BaseIPN.php


示例8: getPaymentInfo

 /**
  * Get list of payments displayed by Contribute_Page_PaymentInfo.
  *
  * @param int $id
  * @param $component
  * @param bool $getTrxnInfo
  * @param bool $usingLineTotal
  *
  * @return mixed
  */
 public static function getPaymentInfo($id, $component, $getTrxnInfo = FALSE, $usingLineTotal = FALSE)
 {
     if ($component == 'event') {
         $entity = 'participant';
         $entityTable = 'civicrm_participant';
         $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $id, 'contribution_id', 'participant_id');
         if (!$contributionId) {
             if ($primaryParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $id, 'registered_by_id')) {
                 $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $primaryParticipantId, 'contribution_id', 'participant_id');
                 $id = $primaryParticipantId;
             }
             if (!$contributionId) {
                 return;
             }
         }
     }
     $total = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
     $baseTrxnId = !empty($total['trxn_id']) ? $total['trxn_id'] : NULL;
     $isBalance = NULL;
     if ($baseTrxnId) {
         $isBalance = TRUE;
     } else {
         $baseTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contributionId);
         $baseTrxnId = $baseTrxnId['financialTrxnId'];
         $isBalance = FALSE;
     }
     if (!CRM_Utils_Array::value('total_amount', $total) || $usingLineTotal) {
         // for additional participants
         if ($entityTable == 'civicrm_participant') {
             $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
             $total = 0;
             foreach ($ids as $val) {
                 $total += CRM_Price_BAO_LineItem::getLineTotal($val, $entityTable);
             }
         } else {
             $total = CRM_Price_BAO_LineItem::getLineTotal($id, $entityTable);
         }
     } else {
         $baseTrxnId = $total['trxn_id'];
         $total = $total['total_amount'];
     }
     $paymentBalance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($id, $entity, FALSE, $total);
     $contributionIsPayLater = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'is_pay_later');
     $feeRelationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Expense Account is' "));
     $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'financial_type_id');
     $feeFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeId, $feeRelationTypeId);
     if ($paymentBalance == 0 && $contributionIsPayLater) {
         $paymentBalance = $total;
     }
     $info['total'] = $total;
     $info['paid'] = $total - $paymentBalance;
     $info['balance'] = $paymentBalance;
     $info['id'] = $id;
     $info['component'] = $component;
     $info['payLater'] = $contributionIsPayLater;
     $rows = array();
     if ($getTrxnInfo && $baseTrxnId) {
         // Need to exclude fee trxn rows so filter out rows where TO FINANCIAL ACCOUNT is expense account
         $sql = "\nSELECT ft.total_amount, con.financial_type_id, ft.payment_instrument_id, ft.trxn_date, ft.trxn_id, ft.status_id, ft.check_number\nFROM civicrm_contribution con\n  LEFT JOIN civicrm_entity_financial_trxn eft ON (eft.entity_id = con.id AND eft.entity_table = 'civicrm_contribution')\n  INNER JOIN civicrm_financial_trxn ft ON ft.id = eft.financial_trxn_id AND ft.to_financial_account_id != {$feeFinancialAccount}\nWHERE con.id = {$contributionId}\n";
         // conditioned WHERE clause
         if ($isBalance) {
             // if balance trxn exists don't include details of it in transaction info
             $sql .= " AND ft.id != {$baseTrxnId} ";
         }
         $resultDAO = CRM_Core_DAO::executeQuery($sql);
         $statuses = CRM_Contribute_PseudoConstant::contributionStatus();
         $financialTypes = CRM_Contribute_PseudoConstant::financialType();
         while ($resultDAO->fetch()) {
             $paidByLabel = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id);
             $paidByName = CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id);
             $val = array('total_amount' => $resultDAO->total_amount, 'financial_type' => $financialTypes[$resultDAO->financial_type_id], 'payment_instrument' => $paidByLabel, 'receive_date' => $resultDAO->trxn_date, 'trxn_id' => $resultDAO->trxn_id, 'status' => $statuses[$resultDAO->status_id]);
             if ($paidByName == 'Check') {
                 $val['check_number'] = $resultDAO->check_number;
             }
             $rows[] = $val;
         }
         $info['transaction'] = $rows;
     }
     return $info;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:90,代码来源:Contribution.php


示例9: add

 /**
  * Add the financial items and financial trxn.
  *
  * @param object $lineItem
  *   Line item object.
  * @param object $contribution
  *   Contribution object.
  * @param bool $taxTrxnID
  *
  * @return void
  */
 public static function add($lineItem, $contribution, $taxTrxnID = FALSE, $trxnId = NULL)
 {
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
     $itemStatus = NULL;
     if ($contribution->contribution_status_id == array_search('Completed', $contributionStatuses) || $contribution->contribution_status_id == array_search('Pending refund', $contributionStatuses)) {
         $itemStatus = array_search('Paid', $financialItemStatus);
     } elseif ($contribution->contribution_status_id == array_search('Pending', $contributionStatuses) || $contribution->contribution_status_id == array_search('In Progress', $contributionStatuses)) {
         $itemStatus = array_search('Unpaid', $financialItemStatus);
     } elseif ($contribution->contribution_status_id == array_search('Partially paid', $contributionStatuses)) {
         $itemStatus = array_search('Partially paid', $financialItemStatus);
     }
     $params = array('transaction_date' => CRM_Utils_Date::isoToMysql($contribution->receive_date), 'contact_id' => $contribution->contact_id, 'amount' => $lineItem->line_total, 'currency' => $contribution->currency, 'entity_table' => 'civicrm_line_item', 'entity_id' => $lineItem->id, 'description' => ($lineItem->qty != 1 ? $lineItem->qty . ' of ' : '') . ' ' . $lineItem->label, 'status_id' => $itemStatus);
     if ($taxTrxnID) {
         $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
         $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
         $params['amount'] = $lineItem->tax_amount;
         $params['description'] = $taxTerm;
         $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
     } else {
         $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
     }
     if ($lineItem->financial_type_id) {
         $searchParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $lineItem->financial_type_id, 'account_relationship' => $accountRel);
         $result = array();
         CRM_Financial_BAO_FinancialTypeAccount::retrieve($searchParams, $result);
         $params['financial_account_id'] = CRM_Utils_Array::value('financial_account_id', $result);
     }
     if (empty($trxnId)) {
         $trxn = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution->id, 'ASC', TRUE);
         $trxnId['id'] = $trxn['financialTrxnId'];
     }
     return self::create($params, NULL, $trxnId);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:45,代码来源:FinancialItem.php


示例10: _checkFinancialRecords

 /**
  * @param array $params
  * @param $context
  */
 public function _checkFinancialRecords($params, $context)
 {
     $entityParams = array('entity_id' => $params['id'], 'entity_table' => 'civicrm_contribution');
     $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $params['id']));
     $this->assertEquals($contribution['total_amount'] - $contribution['fee_amount'], $contribution['net_amount']);
     if ($context == 'pending') {
         $trxn = CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams);
         $this->assertNull($trxn, 'No Trxn to be created until IPN callback');
         return;
     }
     $trxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams));
     $trxnParams = array('id' => $trxn['financial_trxn_id']);
     if ($context != 'online' && $context != 'payLater') {
         $compareParams = array('to_financial_account_id' => 6, 'total_amount' => 100, 'status_id' => 1);
     }
     if ($context == 'feeAmount') {
         $compareParams['fee_amount'] = 50;
     } elseif ($context == 'online') {
         $compareParams = array('to_financial_account_id' => 12, 'total_amount' => 100, 'status_id' => 1);
     } elseif ($context == 'payLater') {
         $compareParams = array('to_financial_account_id' => 7, 'total_amount' => 100, 'status_id' => 2);
     }
     $this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $trxnParams, $compareParams);
     $entityParams = array('financial_trxn_id' => $trxn['financial_trxn_id'], 'entity_table' => 'civicrm_financial_item');
     $entityTrxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams));
     $fitemParams = array('id' => $entityTrxn['entity_id']);
     $compareParams = array('amount' => 100, 'status_id' => 1, 'financial_account_id' => 1);
     if ($context == 'payLater') {
         $compareParams = array('amount' => 100, 'status_id' => 3, 'financial_account_id' => 1);
     }
     $this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $fitemParams, $compareParams);
     if ($context == 'feeAmount') {
         $maxParams = array('entity_id' => $params['id'], 'entity_table' => 'civicrm_contribution');
         $maxTrxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($maxParams, TRUE));
         $trxnParams = array('id' => $maxTrxn['financial_trxn_id']);
         $compareParams = array('to_financial_account_id' => 5, 'from_financial_account_id' => 6, 'total_amount' => 50, 'status_id' => 1);
         $trxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['id'], 'DESC');
         $this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $trxnParams, $compareParams);
         $fitemParams = array('entity_id' => $trxnId['financialTrxnId'], 'entity_table' => 'civicrm_financial_trxn');
         $compareParams = array('amount' => 50, 'status_id' => 1, 'financial_account_id' => 5);
         $this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $fitemParams, $compareParams);
     }
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:47,代码来源:ContributionTest.php


示例11: testIsPaymentFlagForPending

 /**
  * Create() method (create and update modes).
  */
 public function testIsPaymentFlagForPending()
 {
     $contactId = Contact::createIndividual();
     $ids = array('contribution' => NULL);
     $params = array('contact_id' => $contactId, 'currency' => 'USD', 'financial_type_id' => 1, 'contribution_status_id' => 2, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'is_pay_later' => 1, 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'non_deductible_amount' => 0.0, 'total_amount' => 200.0, 'fee_amount' => 5, 'net_amount' => 195, 'trxn_id' => '22ereerwww4444yy', 'invoice_id' => '86ed39c9e9yy6ef6541621ce0eafe7eb81', 'thankyou_date' => '20080522');
     $contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
     $this->assertEquals($params['trxn_id'], $contribution->trxn_id, 'Check for transcation id creation.');
     $this->assertEquals($contactId, $contribution->contact_id, 'Check for contact id  creation.');
     $trxnArray = array('trxn_id' => $params['trxn_id'], 'is_payment' => 0);
     $defaults = array();
     $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults);
     $this->assertEquals(2, $financialTrxn->N, 'Mismatch count for is payment flag.');
     $trxnArray['is_payment'] = 1;
     $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults);
     $this->assertEquals(NULL, $financialTrxn, 'Mismatch count for is payment flag.');
     //update contribution amount
     $ids = array('contribution' => $contribution->id);
     $params['contribution_status_id'] = 1;
     $contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
     $this->assertEquals($params['trxn_id'], $contribution->trxn_id, 'Check for transcation id .');
     $this->assertEquals($params['contribution_status_id'], $contribution->contribution_status_id, 'Check for status updation.');
     $trxnArray = array('trxn_id' => $params['trxn_id'], 'is_payment' => 1);
     $defaults = array();
     $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults);
     $this->assertEquals(1, $financialTrxn->N, 'Mismatch count for is payment flag.');
     $trxnArray['is_payment'] = 0;
     $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults);
     $this->assertEquals(2, $financialTrxn->N, 'Mismatch count for is payment flag.');
     //Delete Contribution
     $this->contributionDelete($contribution->id);
     //Delete Contact
     Contact::delete($contactId);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:36,代码来源:ContributionTest.php


示例12: processPremium

 /**
  * Process the Premium Information.
  *
  * @param array $params
  * @param int $contributionID
  * @param int $premiumID
  * @param array $options
  */
 public static function processPremium($params, $contributionID, $premiumID = NULL, $options = array())
 {
     $selectedProductID = $params['product_name'][0];
     $selectedProductOptionID = CRM_Utils_Array::value(1, $params['product_name']);
     $dao = new CRM_Contribute_DAO_ContributionProduct();
     $dao->contribution_id = $contributionID;
     $dao->product_id = $selectedProductID;
     $dao->fulfilled_date = CRM_Utils_Date::processDate($params['fulfilled_date'], NULL, TRUE);
     $isDeleted = FALSE;
     //CRM-11106
     $premiumParams = array('id' => $selectedProductID);
     $productDetails = array();
     CRM_Contribute_BAO_ManagePremiums::retrieve($premiumParams, $productDetails);
     $dao->financial_type_id = CRM_Utils_Array::value('financial_type_id', $productDetails);
     if (!empty($options[$selectedProductID])) {
         $dao->product_option = $options[$selectedProductID][$selectedProductOptionID];
     }
     if ($premiumID) {
         $ContributionProduct = new CRM_Contribute_DAO_ContributionProduct();
         $ContributionProduct->id = $premiumID;
         $ContributionProduct->find(TRUE);
         if ($ContributionProduct->product_id == $selectedProductID) {
             $dao->id = $premiumID;
         } else {
             $ContributionProduct->delete();
             $isDeleted = TRUE;
         }
     }
     $dao->save();
     //CRM-11106
     if ($premiumID == NULL || $isDeleted) {
         $premiumParams = array('cost' => CRM_Utils_Array::value('cost', $productDetails), 'currency' => CRM_Utils_Array::value('currency', $productDetails), 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $productDetails), 'contributionId' => $contributionID);
         if ($isDeleted) {
             $premiumParams['oldPremium']['product_id'] = $ContributionProduct->product_id;
             $premiumParams['oldPremium']['contribution_id'] = $ContributionProduct->contribution_id;
         }
         CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($premiumParams);
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:47,代码来源:AdditionalInfo.php


示例13: setDefaultValues

 /**
  * Set default values.
  *
  * @return array
  */
 public function setDefaultValues()
 {
     $defaults = $this->_values;
     // Set defaults for pledge payment.
     if ($this->_ppID) {
         $defaults['total_amount'] = CRM_Utils_Array::value('scheduled_amount', $this->_pledgeValues['pledgePayment']);
         $defaults['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_pledgeValues);
         $defaults['currency'] = CRM_Utils_Array::value('currency', $this->_pledgeValues);
         $defaults['option_type'] = 1;
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         return $defaults;
     }
     $defaults['frequency_interval'] = 1;
     $defaults['frequency_unit'] = 'month';
     // Set soft credit defaults.
     CRM_Contribute_Form_SoftCredit::setDefaultValues($defaults, $this);
     if ($this->_mode) {
         // @todo - remove this function as the parent does it too.
         $config = CRM_Core_Config::singleton();
         // Set default country from config if no country set.
         if (empty($defaults["billing_country_id-{$this->_bltID}"])) {
             $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
         }
         if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) {
             $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
         }
         $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
         $defaults = array_merge($defaults, $billingDefaults);
     }
     if ($this->_id) {
         $this->_contactID = $defaults['contact_id'];
     }
     // Set $newCredit variable in template to control whether link to credit card mode is included.
     $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments());
     // Fix the display of the monetary value, CRM-4038.
     if (isset($defaults['total_amount'])) {
         if (!empty($defaults['tax_amount'])) {
             $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
             if (!(CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails))) {
                 $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'] - $defaults['tax_amount'], NULL, '%a');
             }
         } else {
             $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'], NULL, '%a');
         }
     }
     if (isset($defaults['non_deductible_amount'])) {
         $defaults['non_deductible_amount'] = CRM_Utils_Money::format($defaults['non_deductible_amount'], NULL, '%a');
     }
     if (isset($defaults['fee_amount'])) {
         $defaults['fee_amount'] = CRM_Utils_Money::format($defaults['fee_amount'], NULL, '%a');
     }
     if (isset($defaults['net_amount'])) {
         $defaults['net_amount'] = CRM_Utils_Money::format($defaults['net_amount'], NULL, '%a');
     }
     if ($this->_contributionType) {
         $defaults['financial_type_id'] = $this->_contributionType;
     }
     if (empty($defaults['payment_instrument_id'])) {
         $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
     }
     if (!empty($defaults['is_test'])) {
         $this->assign('is_test', TRUE);
     }
     $this->assign('showOption', TRUE);
     // For Premium section.
     if ($this->_premiumID) {
         $this->assign('showOption', FALSE);
         $options = isset($this->_options[$this->_productDAO->product_id]) ? $this->_options[$this->_productDAO->product_id] : "";
         if (!$options) {
             $this->assign('showOption', TRUE);
         }
         $options_key = CRM_Utils_Array::key($this->_productDAO->product_option, $options);
         if ($options_key) {
             $defaults['product_name'] = array($this->_productDAO->product_id, trim($options_key));
         } else {
             $defaults['product_name'] = array($this->_productDAO->product_id);
         }
         if ($this->_productDAO->fulfilled_date) {
             list($defaults['fulfilled_date']) = CRM_Utils_Date::setDateDefaults($this->_productDAO->fulfilled_date);
         }
     }
     if (isset($this->userEmail)) {
         $this->assign('email', $this->userEmail);
     }
     if (!empty($defaults['is_pay_later'])) {
         $this->assign('is_pay_later', TRUE);
     }
     $this->assign('contribution_status_id', CRM_Utils_Array::value('contribution_status_id', $defaults));
     if (CRM_Utils_Array::value('contribution_status_id', $defaults) == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded')) {
         $defaults['refund_trxn_id'] = CRM_Core_BAO_FinancialTrxn::getRefundTransactionTrxnID($this->_id);
     } else {
         $defaults['refund_trxn_id'] = isset($defaults['trxn_id']) ? $defaults['trxn_id'] : NULL;
     }
     $dates = array('receive_date', 'receipt_date', 'cancel_date', 'thankyou_date');
//.........这里部分代码省略.........
开发者ID:wdecraene,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php


示例14: recordAdjustedAmt

 /**
  * @param $updatedAmount
  * @param $paidAmount
  * @param $contributionId
  */
 static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId)
 {
     $balanceAmt = $updatedAmount - $paidAmount;
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
     $pendngRefundStatusId = array_search('Pending refund', $contributionStatuses);
     $completedStatusId = array_search('Completed', $contributionStatuses);
     $updatedContributionDAO = new CRM_Contribute_BAO_Contribution();
     if ($balanceAmt) {
         if ($balanceAmt > 0 && $paidAmount != 0) {
             $contributionStatusVal = $partiallyPaidStatusId;
         } elseif ($balanceAmt < 0 && $paidAmount != 0) {
             $contributionStatusVal = $pendngRefundStatusId;
         } elseif ($paidAmount == 0) {
             $contributionStatusVal = $completedStatusId;
             $updatedContributionDAO->cancel_date = 'null';
             $updatedContributionDAO->cancel_reason = NULL;
         }
         // update contribution status and total amount without trigger financial code
         // as this is handled in current BAO function used for change selection
         $updatedContributionDAO->id = $contributionId;
         $updatedContributionDAO->contribution_status_id = $contributionStatusVal;
         $updatedContributionDAO->total_amount = $updatedAmount;
         $updatedContributionDAO->save();
         $ftDetail = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
         // adjusted amount financial_trxn creation
         if (empty($ftDetail['trxn_id'])) {
             $updatedContribution = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contributionId), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
             $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
             $toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($updatedContribution->financial_type_id, $relationTypeId);
             $adjustedTrxnValues = array('from_financial_account_id' => NULL, 'to_financial_account_id' => $toFinancialAccount, 'total_amount' => $balanceAmt, 'status_id' => CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name'), 'payment_instrument_id' => $updatedContribution->payment_instrument_id, 'contribution_id' => $updatedContribution->id, 'trxn_date' => date('YmdHis'), 'currency' => $updatedContribution->currency);
             $adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues);
         } else {
             // update the financial trxn amount as well, as the fee selections has been updated
             if ($balanceAmt != $ftDetail['total_amount']) {
                 CRM_Core_DAO::setFieldValue('CRM_Core_BAO_FinancialTrxn', $ftDetail['trxn_id'], 'total_amount', $balanceAmt);
             }
         }
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:45,代码来源:Participant.php


示例15: processContribution

 /**
  * Process the contribution
  *
  * @return void
  * @access public
  */
 static function processContribution(&$form, $params, $result, $contactID, $pending = FALSE, $isAdditionalAmount = FALSE)
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $config = CRM_Core_Config::singleton();
     $now = date('YmdHis');
     $receiptDate = NULL;
     if ($form->_values['event']['is_email_confirm']) {
         $receiptDate = $now;
     }
     //CRM-4196
     if ($isAdditionalAmount) {
         $params['amount_level'] = $params['amount_level'] . ts(' (multiple participants)') . CRM_Core_DAO::VALUE_SEPARATOR;
     }
     $contribParams = array('contact_id' => $contactID, 'contribution_type_id' => $form->_values['event']['contribution_type_id'] ? $form->_values['eve 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CRM_Core_BAO_Location类代码示例发布时间:2022-05-20
下一篇:
PHP CRM_Core_BAO_File类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap