/// <summary> /// Gets the selection. /// </summary> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(Control[] controls) { string comparisonType = (( DropDownList )controls[0]).SelectedValue; decimal?amount = (controls[1] as CurrencyBox).Text.AsDecimal(); var accountIdList = (controls[2] as AccountPicker).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService(new RockContext()).GetByIds(accountIdList); if (accounts != null && accounts.Any()) { accountGuids = accounts.Select(a => a.Guid).ToList().AsDelimited(","); } SlidingDateRangePicker slidingDateRangePicker = controls[3] as SlidingDateRangePicker; // convert pipe to comma delimited var delimitedValues = slidingDateRangePicker.DelimitedValues.Replace("|", ","); RockCheckBox cbCombineGiving = controls[4] as RockCheckBox; RockCheckBox cbUseAnalytics = controls[5] as RockCheckBox; // {2} and {3} used to store the DateRange before, but now we using the SlidingDateRangePicker return($"{comparisonType}|{amount}|||{accountGuids}|{cbCombineGiving.Checked}|{delimitedValues}|{cbUseAnalytics.Checked}"); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(Type entityType, Control[] controls) { SelectionConfig selectionConfig = new SelectionConfig(); var accountIdList = (controls[0] as AccountPicker).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService(new RockContext()).GetByIds(accountIdList); if (accounts != null && accounts.Any()) { selectionConfig.AccountGuids = accounts.Select(a => a.Guid).ToList(); } SlidingDateRangePicker slidingDateRangePicker = controls[1] as SlidingDateRangePicker; selectionConfig.StartDate = slidingDateRangePicker.DateRangeModeStart; selectionConfig.EndDate = slidingDateRangePicker.DateRangeModeEnd; selectionConfig.DateRangeMode = slidingDateRangePicker.SlidingDateRangeMode; selectionConfig.TimeUnit = slidingDateRangePicker.TimeUnit; selectionConfig.NumberOfTimeUnits = slidingDateRangePicker.NumberOfTimeUnits; selectionConfig.UseSundayDate = (controls[2] as RockCheckBox).Checked; return(selectionConfig.ToJson()); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(System.Web.UI.Control[] controls) { string delimitedAccountGuids = string.Empty; string useSundayDate = string.Empty; if (controls.Count() > 0) { AccountPicker accountPicker = controls[0] as AccountPicker; if (accountPicker != null) { var accountIds = accountPicker.SelectedValues.AsIntegerList(); var accountGuids = new FinancialAccountService(new RockContext()).GetByIds(accountIds).Select(a => a.Guid); delimitedAccountGuids = accountGuids.Select(a => a.ToString()).ToList().AsDelimited(","); } if (controls.Count() > 1) { RockCheckBox cbUseSundayDate = controls[1] as RockCheckBox; if (cbUseSundayDate != null) { useSundayDate = cbUseSundayDate.Checked.ToString(); } } if (delimitedAccountGuids != string.Empty || useSundayDate != string.Empty) { return($"{delimitedAccountGuids}|{useSundayDate}"); } } return(null); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(Type entityType, Control[] controls) { var accountIdList = (controls[0] as AccountPicker).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService(new RockContext()).GetByIds(accountIdList); if (accounts != null && accounts.Any()) { accountGuids = accounts.Select(a => a.Guid).ToList().AsDelimited(","); } return(accountGuids); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(Type entityType, Control[] controls) { var accountIdList = (controls[0] as AccountPicker).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService(new RockContext()).GetByIds(accountIdList); if (accounts != null && accounts.Any()) { accountGuids = accounts.Select(a => a.Guid).ToList().AsDelimited(","); } DateRangePicker dateRangePicker = controls[1] as DateRangePicker; return(string.Format("{0}|{1}|{2}", dateRangePicker.LowerValue, dateRangePicker.UpperValue, accountGuids)); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(System.Web.UI.Control[] controls) { if (controls.Count() == 1) { AccountPicker accountPicker = controls[0] as AccountPicker; if (accountPicker != null) { var accountIds = accountPicker.SelectedValues.AsIntegerList(); var accountGuids = new FinancialAccountService(new RockContext()).GetByIds(accountIds).Select(a => a.Guid); return(accountGuids.Select(a => a.ToString()).ToList().AsDelimited(",")); } } return(null); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(Type entityType, Control[] controls) { var accountIdList = (controls[0] as AccountPicker).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService(new RockContext()).GetByIds(accountIdList); if (accounts != null && accounts.Any()) { accountGuids = accounts.Select(a => a.Guid).ToList().AsDelimited(","); } SlidingDateRangePicker slidingDateRangePicker = controls[1] as SlidingDateRangePicker; // convert pipe to comma delimited var delimitedValues = slidingDateRangePicker.DelimitedValues.Replace("|", ","); // {1} and {2} used to store the DateRange before, but now we using the SlidingDateRangePicker return(string.Format("{0}|{1}|{2}|{3}", string.Empty, string.Empty, accountGuids, delimitedValues)); }
/// <summary> /// Shows the summary. /// </summary> /// <param name="statementTemplate">The statement template.</param> private void ShowReadonlyDetails(FinancialStatementTemplate financialStatementTemplate) { SetEditMode(false); if (financialStatementTemplate != null) { hfStatementTemplateId.SetValue(financialStatementTemplate.Id); lTitle.Text = string.Format("{0} Template", financialStatementTemplate.Name).FormatAsHtmlTitle(); hlInactive.Visible = !financialStatementTemplate.IsActive; lAccountDescription.Text = financialStatementTemplate.Description; var transactionSettings = financialStatementTemplate.ReportSettings.TransactionSettings; var detailsDescription = new DescriptionList(); if (transactionSettings.AccountSelectionOption == FinancialStatementTemplateTransactionSettingAccountSelectionOption.AllTaxDeductibleAccounts) { var accountList = new FinancialAccountService(new RockContext()).Queryable() .Where(a => a.IsActive && a.IsTaxDeductible) .ToList(); detailsDescription.Add("Accounts for Transactions", accountList.Select(a => a.Name).ToList().AsDelimited("<br/>")); } else { if (transactionSettings.SelectedAccountIds.Any()) { var accountList = new FinancialAccountService(new RockContext()) .GetByIds(transactionSettings.SelectedAccountIds) .Where(a => a.IsActive) .ToList(); detailsDescription.Add("Accounts for Transactions", accountList.Select(a => a.Name).ToList().AsDelimited("<br/>")); } } if (transactionSettings.TransactionTypeGuids.Any()) { var transactionTypes = transactionSettings.TransactionTypeGuids.Select(a => DefinedValueCache.Get(a)?.Value ?? string.Empty).ToList(); detailsDescription.Add("Transaction Types", transactionTypes.AsDelimited("<br/>")); } lDetails.Text = detailsDescription.Html; } }
/// <summary> /// Gets the selection. /// </summary> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(Control[] controls) { string comparisonType = ((DropDownList)controls[0]).SelectedValue; decimal?amount = (controls[1] as NumberBox).Text.AsDecimal(); var accountIdList = (controls[2] as AccountPicker).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService(new RockContext()).GetByIds(accountIdList); if (accounts != null && accounts.Any()) { accountGuids = accounts.Select(a => a.Guid).ToList().AsDelimited(","); } DateRangePicker dateRangePicker = controls[3] as DateRangePicker; RockCheckBox cbCombineGiving = controls[4] as RockCheckBox; return(string.Format("{0}|{1}|{2}|{3}|{4}|{5}", comparisonType, amount, dateRangePicker.LowerValue, dateRangePicker.UpperValue, accountGuids, cbCombineGiving.Checked)); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(Type entityType, Control[] controls) { var comparisonControl = controls[0] as DropDownList; var numberBoxAmount = controls[1] as CurrencyBox; var accountPicker = controls[2] as AccountPicker; var cbIncludeChildAccounts = controls[3] as RockCheckBox; var cbIgnoreInactiveAccounts = controls[4] as RockCheckBox; var slidingDateRangePicker = controls[5] as SlidingDateRangePicker; var cbCombineGiving = controls[6] as RockCheckBox; var cbUseAnalyticsTables = controls[7] as RockCheckBox; var comparisonType = comparisonControl.SelectedValue.ConvertToEnum <ComparisonType>(); decimal?amount = numberBoxAmount.Text.AsDecimal(); var accountIdList = accountPicker.SelectedValuesAsInt().ToList(); List <Guid> accountGuids; var accounts = new FinancialAccountService(new RockContext()).GetByIds(accountIdList); if (accounts != null && accounts.Any()) { accountGuids = accounts.Select(a => a.Guid).ToList(); } else { accountGuids = null; } var selectionConfig = new SelectionConfig { ComparisonType = comparisonType, Amount = amount, AccountGuids = accountGuids, IncludeChildAccounts = cbIncludeChildAccounts.Checked, IgnoreInactiveAccounts = cbIgnoreInactiveAccounts.Checked, CombineGiving = cbCombineGiving.Checked, SlidingDateRangePickerDelimitedValues = slidingDateRangePicker.DelimitedValues, UseAnalyticsModels = cbUseAnalyticsTables.Checked, }; return(selectionConfig.ToJson()); }
/// <summary> /// Reads new values entered by the user for the field /// </summary> /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param> /// <param name="configurationValues">The configuration values.</param> /// <returns></returns> public override string GetEditValue(Control control, Dictionary <string, ConfigurationValue> configurationValues) { var picker = control as AccountPicker; string result = null; if (picker != null) { var guids = new List <Guid>(); var ids = picker.SelectedValuesAsInt(); var accounts = new FinancialAccountService().Queryable().Where(a => ids.Contains(a.Id)); if (accounts.Any()) { guids = accounts.Select(a => a.Guid).ToList(); } result = string.Join(",", guids); } return(result); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(Type entityType, Control[] controls) { string comparisonType = (( DropDownList )controls[0]).SelectedValue; decimal?amount = (controls[1] as NumberBox).Text.AsDecimal(); var accountIdList = (controls[2] as AccountPicker).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService(new RockContext()).GetByIds(accountIdList); if (accounts != null && accounts.Any()) { accountGuids = accounts.Select(a => a.Guid).ToList().AsDelimited(","); } SlidingDateRangePicker slidingDateRangePicker = controls[3] as SlidingDateRangePicker; // convert pipe to comma delimited var delimitedValues = slidingDateRangePicker.DelimitedValues.Replace("|", ","); RockCheckBox cbCombineGiving = controls[4] as RockCheckBox; return(string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", comparisonType, amount, string.Empty, string.Empty, accountGuids, cbCombineGiving.Checked, delimitedValues)); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection( Type entityType, Control[] controls ) { var accountIdList = ( controls[0] as AccountPicker ).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService( new RockContext() ).GetByIds( accountIdList ); if ( accounts != null && accounts.Any() ) { accountGuids = accounts.Select( a => a.Guid ).ToList().AsDelimited( "," ); } DateRangePicker dateRangePicker = controls[1] as DateRangePicker; return string.Format( "{0}|{1}|{2}", dateRangePicker.LowerValue, dateRangePicker.UpperValue, accountGuids ); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection( System.Web.UI.Control[] controls ) { if ( controls.Count() == 1 ) { AccountPicker accountPicker = controls[0] as AccountPicker; if ( accountPicker != null ) { var accountIds = accountPicker.SelectedValues.AsIntegerList(); var accountGuids = new FinancialAccountService( new RockContext() ).GetByIds( accountIds ).Select( a => a.Guid ); return accountGuids.Select( a => a.ToString() ).ToList().AsDelimited( "," ); } } return null; }
/// <summary> /// Processes a transaction. /// </summary> /// <param name="giftElement">The gift element.</param> /// <param name="batch">The batch.</param> /// <param name="rockContext">The rock context.</param> /// <param name="envelopeAttributeId">The envelope attribute identifier.</param> /// <param name="errorMessages">The error messages.</param> /// <returns></returns> private ProcessStatus ProcessTransaction(XElement giftElement, int?batchId, int?envelopeAttributeId, int?binaryFileTypeId, string accountMatchField, out List <string> errorMessages) { errorMessages = new List <string>(); // Get batch/sequence number first as they are used in any error messages string batchNo = GetChildElementValue(giftElement, "BatchNo"); string seqNo = GetChildElementValue(giftElement, "SequenceNo"); try { using (var rockContext = new RockContext()) { // Check to see if accout/routing/check information is specified string encryptedAccountNum = GetChildElementValue(giftElement, "DFIAcct"); string encryptedRoutingNum = GetChildElementValue(giftElement, "DFID"); string checkNum = GetChildElementValue(giftElement, "CheckNum"); // Start to create the transaction var txn = new FinancialTransaction(); txn.BatchId = batchId; txn.TransactionTypeValueId = _transactionTypeContributionId; txn.TransactionDateTime = GetChildElementValue(giftElement, "GiftDate").AsDateTime(); txn.Summary = string.Format("{0}:{1}", batchNo, seqNo); txn.FinancialPaymentDetail = new FinancialPaymentDetail(); // Try to find an person to associate with this account int?personAliasId = null; if (!string.IsNullOrWhiteSpace(encryptedAccountNum) && !string.IsNullOrWhiteSpace(encryptedRoutingNum)) { // If account/routing information was included, use it to find matching person from Bank Account table // A person will be selected if there is only ONE match found with same information. var accountNum = DecryptAccountInformation(encryptedAccountNum); var routingNum = DecryptAccountInformation(encryptedRoutingNum); string checkMicrHashed = FinancialPersonBankAccount.EncodeAccountNumber(routingNum, accountNum); if (!string.IsNullOrWhiteSpace(checkMicrHashed)) { var matchedPersonIds = new FinancialPersonBankAccountService(rockContext) .Queryable() .Where(a => a.AccountNumberSecured == checkMicrHashed) .Select(a => a.PersonAlias.PersonId) .Distinct() .ToList(); if (matchedPersonIds.Count() == 1) { personAliasId = new PersonAliasService(rockContext) .GetPrimaryAliasId(matchedPersonIds.First()); } } txn.MICRStatus = MICRStatus.Success; txn.CheckMicrParts = Encryption.EncryptString(string.Format("{0}_{1}_{2}", routingNum, accountNum, checkNum)); txn.FinancialPaymentDetail.CurrencyTypeValueId = _currencyTypeCheck; txn.TransactionCode = checkNum; } else { // If account/routing number was NOT included, check for an envelope number, and if provided find first // person with same envelope number (unlike account/routing number, this will automatically select first // person when there are multiple people with same envelope number. string envelopeNum = GetChildElementValue(giftElement, "EnvNum"); if (!string.IsNullOrWhiteSpace(envelopeNum)) { int?personId = new AttributeValueService(rockContext) .Queryable().AsNoTracking() .Where(v => v.AttributeId == envelopeAttributeId && v.Value == envelopeNum) .OrderBy(v => v.EntityId) .Select(v => v.EntityId) .FirstOrDefault(); if (personId.HasValue) { personAliasId = new PersonAliasService(rockContext) .GetPrimaryAliasId(personId.Value); } txn.TransactionCode = envelopeNum; } txn.FinancialPaymentDetail.CurrencyTypeValueId = _currencyTypeCash; } txn.AuthorizedPersonAliasId = personAliasId; // Save any images if (binaryFileTypeId.HasValue) { SaveImage(txn, GetChildElementValue(giftElement, "CheckImgFront"), binaryFileTypeId.Value, string.Format("CheckImageFront_{0}:{1}", batchNo, seqNo)); SaveImage(txn, GetChildElementValue(giftElement, "CheckImgBack"), binaryFileTypeId.Value, string.Format("CheckImageBack_{0}:{1}", batchNo, seqNo)); SaveImage(txn, GetChildElementValue(giftElement, "EnvImgFront"), binaryFileTypeId.Value, string.Format("EnvelopeImageFront_{0}:{1}", batchNo, seqNo)); SaveImage(txn, GetChildElementValue(giftElement, "EnvImgBack"), binaryFileTypeId.Value, string.Format("EnvelopeImageBack_{0}:{1}", batchNo, seqNo)); } // Loop through the purposes and create the transaction detail (account) records var purposes = giftElement.Element("Purposes"); if (purposes != null) { foreach (var purpose in purposes.Descendants().Where(p => p.Name == "Purpose")) { FinancialTransactionDetail txnDetail = null; int? accountId = GetChildElementValue(purpose, "PurposeID").AsIntegerOrNull(); decimal?amount = GetChildElementValue(purpose, "Amount").AsDecimalOrNull(); if (accountId.HasValue && amount.HasValue) { var accountQry = new FinancialAccountService(rockContext).Queryable().AsNoTracking(); accountQry = accountMatchField == "FOREIGNID" ? accountQry.Where(a => a.ForeignId == accountId.Value) : accountQry.Where(a => a.Id == accountId.Value); int?rockAccountId = accountQry.Select(a => a.Id).FirstOrDefault(); if (rockAccountId.HasValue) { txnDetail = new FinancialTransactionDetail(); txnDetail.AccountId = rockAccountId.Value; txnDetail.Amount = amount.Value; txn.TransactionDetails.Add(txnDetail); _totalAmount += amount.Value; } } if (txnDetail == null) { errorMessages.Add(string.Format("Batch: {0}; Sequence: {1}; Error: Invalid Account (PurposeId:{2})", batchNo, seqNo, accountId)); } } } if (errorMessages.Any()) { return(ProcessStatus.Error); } // Save the transaction and update the batch control amount new FinancialTransactionService(rockContext).Add(txn); rockContext.SaveChanges(); return(personAliasId.HasValue ? ProcessStatus.Matched : ProcessStatus.Unmatched); } } catch (Exception ex) { errorMessages.Add(string.Format("Batch: {0}; Sequence: {1}; Error: {2}", batchNo, seqNo, ex.Message)); return(ProcessStatus.Error); } }
/// <summary> /// Gets the selection. /// </summary> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection( Control[] controls ) { string comparisonType = ( (DropDownList)controls[0] ).SelectedValue; decimal? amount = ( controls[1] as NumberBox ).Text.AsDecimal(); var accountIdList = ( controls[2] as AccountPicker ).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService( new RockContext() ).GetByIds( accountIdList ); if ( accounts != null && accounts.Any() ) { accountGuids = accounts.Select( a => a.Guid ).ToList().AsDelimited( "," ); } SlidingDateRangePicker slidingDateRangePicker = controls[3] as SlidingDateRangePicker; // convert pipe to comma delimited var delimitedValues = slidingDateRangePicker.DelimitedValues.Replace( "|", "," ); RockCheckBox cbCombineGiving = controls[4] as RockCheckBox; // {2} and {3} used to store the DateRange before, but now we using the SlidingDateRangePicker return string.Format( "{0}|{1}|{2}|{3}|{4}|{5}|{6}", comparisonType, amount, string.Empty, string.Empty, accountGuids, cbCombineGiving.Checked, delimitedValues ); }
/// <summary> /// Reads new values entered by the user for the field /// </summary> /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param> /// <param name="configurationValues">The configuration values.</param> /// <returns></returns> public override string GetEditValue( Control control, Dictionary<string, ConfigurationValue> configurationValues ) { var picker = control as AccountPicker; string result = null; if ( picker != null ) { var guids = new List<Guid>(); var ids = picker.SelectedValuesAsInt(); var accounts = new FinancialAccountService().Queryable().Where( a => ids.Contains( a.Id ) ); if ( accounts.Any() ) { guids = accounts.Select( a => a.Guid ).ToList(); } result = string.Join( ",", guids ); } return result; }
/// <summary> /// Gets the selection. /// </summary> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection( Control[] controls ) { string comparisonType = ( (DropDownList)controls[0] ).SelectedValue; decimal? amount = ( controls[1] as NumberBox ).Text.AsDecimal(); var accountIdList = ( controls[2] as AccountPicker ).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService( new RockContext() ).GetByIds( accountIdList ); if ( accounts != null && accounts.Any() ) { accountGuids = accounts.Select( a => a.Guid ).ToList().AsDelimited( "," ); } DateRangePicker dateRangePicker = controls[3] as DateRangePicker; RockCheckBox cbCombineGiving = controls[4] as RockCheckBox; return string.Format( "{0}|{1}|{2}|{3}|{4}|{5}", comparisonType, amount, dateRangePicker.LowerValue, dateRangePicker.UpperValue, accountGuids, cbCombineGiving.Checked ); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection( Type entityType, Control[] controls ) { var accountIdList = ( controls[0] as AccountPicker ).SelectedValuesAsInt().ToList(); string accountGuids = string.Empty; var accounts = new FinancialAccountService( new RockContext() ).GetByIds( accountIdList ); if ( accounts != null && accounts.Any() ) { accountGuids = accounts.Select( a => a.Guid ).ToList().AsDelimited( "," ); } SlidingDateRangePicker slidingDateRangePicker = controls[1] as SlidingDateRangePicker; // convert pipe to comma delimited var delimitedValues = slidingDateRangePicker.DelimitedValues.Replace( "|", "," ); // {1} and {2} used to store the DateRange before, but now we using the SlidingDateRangePicker return string.Format( "{0}|{1}|{2}|{3}", string.Empty, string.Empty, accountGuids, delimitedValues ); }