/** * Creates a new Contribution record. The $mixAmountArray shouuld be an array of array items, where each array item is * indexed with * 0 - the StewardshipFundId that should be credited (as an integer) * 1 - the amount (as a float) * * @param Login $objLogin * @param Person $objPerson * @param StewardshipStack $objStack * @param integer $intStewardshipContributionTypeId * @param string $strSource the "source" of the contribution (e.g. for checks, it's the check number, for CC, it's the authorization number) * @param mixed[][] $mixAmountArray the array of arrays containing amounts and fund ids * @param QDateTime $dttEntered optional (will use Now() if null) * @param QDateTime $dttCleared optional (will remain as null if null) * @param CheckingAccountLookup $objCheckingAccountLookup optional * @param string $strNote optional * @param boolean $blnRefreshOtherTotalAmounts whether or not to refresh the Stack's and Batch's ActualTotalAmount (defaults to true) * @return StewardshipContribution */ public static function Create(Login $objLogin, Person $objPerson, StewardshipStack $objStack, $intStewardshipContributionTypeId, $strSource, $mixAmountArray, QDateTime $dttEntered = null, QDateTime $dttCleared = null, CheckingAccountLookup $objCheckingAccountLookup = null, $strNote = null, $blnRefreshOtherTotalAmounts = true) { $objContribution = new StewardshipContribution(); $objContribution->CreatedByLogin = $objLogin; $objContribution->UnpostedFlag = true; $objContribution->Person = $objPerson; $objContribution->StewardshipContributionTypeId = $intStewardshipContributionTypeId; $objContribution->StewardshipBatchId = $objStack->StewardshipBatchId; $objContribution->StewardshipStack = $objStack; $objContribution->CheckingAccountLookup = $objCheckingAccountLookup; if ($dttEntered) { $objContribution->DateEntered = $dttEntered; } else { $objContribution->DateEntered = QDateTime::Now(); } $objContribution->DateCredited = $objContribution->DateEntered; $objContribution->DateCleared = $dttCleared; $objContribution->Note = $strNote; switch ($objContribution->StewardshipContributionTypeId) { case StewardshipContributionType::Check: case StewardshipContributionType::ReturnedCheck: $objContribution->CheckNumber = $strSource; break; case StewardshipContributionType::CreditCard: case StewardshipContributionType::CreditCardRecurring: $objContribution->AuthorizationNumber = $strSource; break; case StewardshipContributionType::Cash: case StewardshipContributionType::Stock: case StewardshipContributionType::Summary: case StewardshipContributionType::Automobile: case StewardshipContributionType::Other: $objContribution->AlternateSource = $strSource; break; default: throw new Exception('Unhandled ContributionTypeId'); } $objContribution->Save(); foreach ($mixAmountArray as $mixAmount) { $objContribution->CreateAmount($mixAmount[0], $mixAmount[1], false); } $objContribution->RefreshTotalAmount(); if ($blnRefreshOtherTotalAmounts) { $objContribution->StewardshipStack->RefreshActualTotalAmount(); $objContribution->StewardshipBatch->RefreshActualTotalAmount(); } return $objContribution; }