コード例 #1
0
        private void DisplayResults()
        {
            RockContext rockContext = new RockContext();

            var statementYear = PageParameter(PageParameterKey.StatementYear).AsIntegerOrNull() ?? RockDateTime.Now.Year;

            FinancialTransactionDetailService financialTransactionDetailService = new FinancialTransactionDetailService(rockContext);

            Person targetPerson = CurrentPerson;

            var personGuid = PageParameter(PageParameterKey.PersonGuid).AsGuidOrNull();

            if (personGuid.HasValue)
            {
                // if "AllowPersonQueryString is False", only use the PersonGuid if it is a Guid of one of the current person's businesses
                var isCurrentPersonsBusiness = targetPerson != null && targetPerson.GetBusinesses().Any(b => b.Guid == personGuid.Value);
                if (GetAttributeValue(AttributeKey.AllowPersonQueryString).AsBoolean() || isCurrentPersonsBusiness)
                {
                    var person = new PersonService(rockContext).Get(personGuid.Value);
                    if (person != null)
                    {
                        targetPerson = person;
                    }
                }
            }

            FinancialStatementGeneratorOptions financialStatementGeneratorOptions = new FinancialStatementGeneratorOptions();
            var startDate = new DateTime(statementYear, 1, 1);

            financialStatementGeneratorOptions.StartDate    = startDate;
            financialStatementGeneratorOptions.EndDate      = startDate.AddYears(1);
            financialStatementGeneratorOptions.RenderMedium = "Html";

            var financialStatementTemplateGuid = this.GetAttributeValue(AttributeKey.FinancialStatementTemplate).AsGuidOrNull() ?? Rock.SystemGuid.FinancialStatementTemplate.ROCK_DEFAULT.AsGuid();

            financialStatementGeneratorOptions.FinancialStatementTemplateId = new FinancialStatementTemplateService(rockContext).GetId(financialStatementTemplateGuid);

            FinancialStatementGeneratorRecipient financialStatementGeneratorRecipient = new FinancialStatementGeneratorRecipient();

            if (targetPerson.GivingGroupId.HasValue)
            {
                financialStatementGeneratorRecipient.GroupId = targetPerson.GivingGroupId.Value;
            }
            else
            {
                financialStatementGeneratorRecipient.GroupId  = targetPerson.PrimaryFamilyId ?? 0;
                financialStatementGeneratorRecipient.PersonId = targetPerson.Id;
            }

            FinancialStatementGeneratorRecipientRequest financialStatementGeneratorRecipientRequest = new FinancialStatementGeneratorRecipientRequest(financialStatementGeneratorOptions)
            {
                FinancialStatementGeneratorRecipient = financialStatementGeneratorRecipient
            };

            var result = FinancialStatementGeneratorHelper.GetStatementGeneratorRecipientResult(financialStatementGeneratorRecipientRequest, this.CurrentPerson);

            Response.Write(result.Html);
            Response.End();
        }
コード例 #2
0
 /// <summary>
 /// Copies the base properties from a source FinancialStatementGeneratorRecipientResult object
 /// </summary>
 /// <param name="source">The source.</param>
 public void CopyPropertiesFrom(FinancialStatementGeneratorRecipientResult source)
 {
     this.ContributionTotal  = source.ContributionTotal;
     this.FooterHtmlFragment = source.FooterHtmlFragment;
     this.Html        = source.Html;
     this.OptedOut    = source.OptedOut;
     this.PledgeTotal = source.PledgeTotal;
     this.Recipient   = source.Recipient;
 }
コード例 #3
0
        /// <summary>
        /// PDFs the file exists.
        /// </summary>
        /// <param name="recipient">The recipient.</param>
        /// <param name="reportRockStatementGeneratorStatementsTemporaryDirectory">The report rock statement generator statements temporary directory.</param>
        /// <returns></returns>
        internal static bool PdfFileExists(this FinancialStatementGeneratorRecipient recipient, string reportRockStatementGeneratorStatementsTemporaryDirectory)
        {
            var filePath = recipient.GetPdfDocumentFilePath(reportRockStatementGeneratorStatementsTemporaryDirectory);

            if (File.Exists(filePath) && PdfReader.TestPdfFile(filePath) != 0)
            {
                return(true);
            }

            return(false);
        }
コード例 #4
0
        /// <summary>
        /// Gets the PDF document.
        /// </summary>
        /// <param name="financialStatementGeneratorRecipientResult">The financial statement generator recipient result.</param>
        /// <param name="reportRockStatementGeneratorStatementsTemporaryDirectory">The report rock statement generator statements temporary directory.</param>
        /// <returns></returns>
        internal static PdfDocument GetPdfDocument(this FinancialStatementGeneratorRecipient recipient, string reportRockStatementGeneratorStatementsTemporaryDirectory)
        {
            var filePath = recipient.GetPdfDocumentFilePath(reportRockStatementGeneratorStatementsTemporaryDirectory);

            if (File.Exists(filePath))
            {
                return(PdfReader.Open(filePath, PdfDocumentOpenMode.Import));
            }

            return(null);
        }
コード例 #5
0
        /// <summary>
        /// Return just the first part of the zip code
        /// </summary>
        /// <param name="recipient">The recipient.</param>
        /// <returns></returns>
        internal static string GetFiveDigitPostalCode(this FinancialStatementGeneratorRecipient recipient)
        {
            // return just the first part of the zip code
            // 85013-4567 => 85013
            // 85013-1234 => 85013
            // 85083 => 85083
            // 60540654-1234 => 60540654 (unexpected length, so just grab the first number)
            // null => "00000"

            var firstFive = Regex.Match(recipient?.PostalCode ?? "00000", @"\d+").Value;

            return(firstFive);
        }
コード例 #6
0
 /// <summary>
 /// Copies the base properties from a source FinancialStatementGeneratorRecipient object
 /// </summary>
 /// <param name="source">The source.</param>
 public void CopyPropertiesFrom(FinancialStatementGeneratorRecipient source)
 {
     this.ContributionTotal                  = source.ContributionTotal;
     this.Country                            = source.Country;
     this.GroupId                            = source.GroupId;
     this.HasValidMailingAddress             = source.HasValidMailingAddress;
     this.IsComplete                         = source.IsComplete;
     this.IsInternationalAddress             = source.IsInternationalAddress;
     this.LastName                           = source.LastName;
     this.LocationId                         = source.LocationId;
     this.NickName                           = source.NickName;
     this.OptedOut                           = source.OptedOut;
     this.PaperlessStatementsIndividualCount = source.PaperlessStatementsIndividualCount;
     this.PaperlessStatementUploaded         = source.PaperlessStatementUploaded;
     this.PersonId                           = source.PersonId;
     this.PostalCode                         = source.PostalCode;
     this.RenderedPageCount                  = source.RenderedPageCount;
 }
コード例 #7
0
 /// <summary>
 /// Copies the base properties from a source FinancialStatementGeneratorRecipientRequest object
 /// </summary>
 /// <param name="source">The source.</param>
 public void CopyPropertiesFrom(FinancialStatementGeneratorRecipientRequest source)
 {
     this.FinancialStatementGeneratorOptions   = source.FinancialStatementGeneratorOptions;
     this.FinancialStatementGeneratorRecipient = source.FinancialStatementGeneratorRecipient;
 }
コード例 #8
0
        /// <summary>
        /// Gets the PDF document file path.
        /// </summary>
        /// <param name="financialStatementGeneratorRecipientResult">The financial statement generator recipient result.</param>
        /// <param name="currentDayTemporaryDirectory">The current day temporary directory.</param>
        /// <returns></returns>
        internal static string GetPdfDocumentFilePath(this FinancialStatementGeneratorRecipient recipient, string currentDayTemporaryDirectory)
        {
            string pdfTempFileName = $"{GetRecipientKey( recipient )}.pdf";

            return(Path.Combine(currentDayTemporaryDirectory, "Statements", pdfTempFileName));
        }
コード例 #9
0
 /// <summary>
 /// Gets the recipient key.
 /// </summary>
 /// <param name="recipient">The recipient.</param>
 /// <returns></returns>
 internal static string GetRecipientKey(this FinancialStatementGeneratorRecipient recipient)
 {
     return($"GroupId_{recipient.GroupId}_PersonID_{recipient.PersonId}_LocationID_{recipient.LocationId}");
 }