Exemple #1
0
        public double GetFederalSummaryDetails(UserDTO userDTO)
        {
            //Retreiving TaxObject from database
            double totalAmount = 0;

            try
            {
                BusinessObject.Tax1040 taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userDTO.UserId, userDTO.UserDataId);

                if (taxObject.PersonalDetails != null)
                {
                    dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                    input.Tax1040Object = taxObject;
                    var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(
                        WorkflowInvoker.Invoke(new FederalSummaryWithNoValidation(), input));


                    if (taxObject.OutputForms.Tax1040EZPage1.RefundAmount > 0)
                    {
                        totalAmount = -Math.Abs(taxObject.OutputForms.Tax1040EZPage1.RefundAmount);
                    }
                    else
                    {
                        totalAmount = taxObject.OutputForms.Tax1040EZPage1.TaxOweAmount;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandling.LogException(userDTO.UserId, "Class:PaymentRepository,Method Name:GetFederalSummaryDetails", ex);
            }
            return(totalAmount);
        }
Exemple #2
0
        //Vincent-26/06/14- Genernating 1040EZ Output Form
        public void Genernate1040EZForm(UserDTO userDTO)
        {
            userDTO.UserDataId = userDTO.UserDataId == null ? 0 : userDTO.UserDataId;

            BusinessObject.Tax1040 taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userDTO.UserId, userDTO.UserDataId);

            dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();

            input.Tax1040Object = taxObject;
            var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(
                WorkflowInvoker.Invoke(new FederalSummaryWithNoValidation(), input));

            if (userDTO.UserDataId != 0)
            {
                Utilities.PersistTaxObject(userDTO.UserId, userDTO.UserDataId, taxObject);
            }
        }
Exemple #3
0
        public Tuple <Tax1040EZPage1, List <ErrorMessage>, bool, string, long> GetFederalTaxSummary(UserDTO userDTO)
        {
            Tuple <Tax1040EZPage1, List <ErrorMessage>, bool, string, long> federalTaxSummary = null;

            try
            {
                BusinessObject.Tax1040 taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userDTO.UserId, userDTO.UserDataId);

                dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                input.Tax1040Object = taxObject;
                var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(
                    WorkflowInvoker.Invoke(new FederalSummaryWithNoValidation(), input));
                var hasEligibilityDiagnostics = HasEligibilityTaxIncome(userDTO, taxObject);

                // 09Jun2014 Sathish Persisted tax object to updated eligibility rule addd for taxable income is more that $100,000
                userDTO.UserDataId = Utilities.PersistTaxObject(userDTO.UserId, userDTO.UserDataId, taxObject);


                //var errorMessage = messageRepository.GetErrorMessages();
                //var errorMessages = new ErrorMessages(errorMessage);

                // BusinessValidationFederalTaxSummary(taxObject != null ? taxObject : null, taxObject.ErrorMessages, errorMessages);

                //Praveen 17 July 2014 Error Message displayed based on Error Type(Properly Shuffled)
                federalTaxSummary = new Tuple <Tax1040EZPage1, List <ErrorMessage>, bool, string, long>(
                    ((taxObject != null && taxObject.OutputForms != null && taxObject.OutputForms.Tax1040EZPage1 != null)
                                                   ? taxObject.OutputForms.Tax1040EZPage1 : null),
                    taxObject.ErrorMessages.FindAll(em => em.ErrorCode.StartsWith(Constants.TOPIC_TAX_AND_WRAPUP)).OrderBy(x => x.ErrorType).ToList(),
                    hasEligibilityDiagnostics,
                    Utilities.GetTaxPayerFirstNameOrNickName(taxObject),
                    userDTO.UserDataId);
                //userDTO.UserDataId = Utilities.PersistTaxObject(userDTO.UserId, userDTO.UserDataId, taxObject);

                //Vincent, 2-sep-14, Persist Audit information
                string description = "Get FederalTaxSummary, ClassName: {0}, Method Name: {1}";
                Utilities.PersistAuditInfo(userDTO.UserId, userDTO.UserDataId, description, this.GetType().Name, Constants.Tab_TAX_AND_WRAPUP, Constants.TOPIC_TAX_AND_WRAPUP);
            }
            catch (Exception ex)
            {
                ExceptionHandling.LogException(userDTO.UserId, "Class:TaxesAndWrapUpRepository,Method Name:GetFederalTaxSummary", ex);
            }
            return(federalTaxSummary);
        }
Exemple #4
0
        /// <summary>
        /// Persist EIC
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="userDataId"></param>
        /// <param name="eicData"></param>
        /// <returns></returns>
        public long PersitEarnedIncomeCredit(long userId, TaxReturnData taxReturnData, int year)
        {
            try
            {
                BusinessObject.Tax1040 taxObject;
                EIC eic = JsonConvert.DeserializeObject <EIC>(taxReturnData.TaxData);

                if (eic != null)
                {
                    taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userId, taxReturnData.UserDataId);

                    if (taxObject == null)
                    {
                        taxObject = new BusinessObject.Tax1040();
                    }

                    if (taxObject.Credits == null)
                    {
                        taxObject.Credits = new Credits();
                    }
                    taxObject.Credits.EIC = eic;

                    //Initializing Out Parameter
                    if (taxObject.ErrorMessages == null)
                    {
                        taxObject.ErrorMessages = new List <ErrorMessage>();
                    }

                    //Retrieving Error Message list from Database
                    //var errorMessage = messageRepository.GetErrorMessages();
                    var errorMessage  = HttpRuntime.Cache["ErrorMessageCollection"] as Dictionary <string, ErrorMessage>;
                    var errorMessages = new ErrorMessages(errorMessage);

                    // Clear the Error messages
                    messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_EARNED_INCOME_CREDIT);

                    BusinessValidation(taxObject.Credits.EIC, taxObject.ErrorMessages, errorMessages, year, (taxObject != null && taxObject.PersonalDetails != null &&
                                                                                                             taxObject.PersonalDetails.PrimaryTaxPayer != null &&
                                                                                                             taxObject.PersonalDetails.PrimaryTaxPayer.FilingStatus != null ? taxObject.PersonalDetails.PrimaryTaxPayer.FilingStatus : FilingStatus.None));

                    //Invoking Business Rules Validation Workflow
                    dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                    input.Tax1040Object = taxObject;

                    //Getting the AGI value from output forms porperty.
                    //25Jun2014 Sathish called AGI work flow with no validation to avoid error message update for the defect #TAX1040-14036
                    var outputGetData = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new F1040EZAdjustedGrossIncomeWithNoValidation(), input));

                    //30thJune2014 Ashok added for Form 8862 Pdf Binding
                    if (taxObject != null && taxObject.Credits != null && taxObject.Credits.EIC != null)
                    {
                        if (taxObject.Income == null)
                        {
                            taxObject.Income = new Income();
                        }
                        if (taxObject.Income.Form8862 == null)
                        {
                            taxObject.Income.Form8862 = new Form8862();
                        }

                        if (taxObject.Credits.EIC.HasClaimedAsQualifyingChild.HasValue)
                        {
                            taxObject.Income.Form8862.HasClaimedAsQualifyingChild = taxObject.Credits.EIC.HasClaimedAsQualifyingChild.Value;
                        }
                        else
                        {
                            taxObject.Income.Form8862.HasClaimedAsQualifyingChild = false;
                        }

                        if (taxObject.Credits.EIC.HasIncorrectlyReportedEarnedIncome.HasValue)
                        {
                            taxObject.Income.Form8862.HasReportedIncorrectIncome = taxObject.Credits.EIC.HasIncorrectlyReportedEarnedIncome.Value;
                        }
                        else
                        {
                            taxObject.Income.Form8862.HasReportedIncorrectIncome = false;
                        }

                        // 01Jul2014 Sathish checked nullable value and set zero
                        taxObject.Income.Form8862.DaysLivedInUS       = (taxObject.Credits.EIC.NumberOfDaysTaxPayerLivedInUS.HasValue) ? taxObject.Credits.EIC.NumberOfDaysTaxPayerLivedInUS.Value : 0;
                        taxObject.Income.Form8862.DaysSpouseLivedInUS = (taxObject.Credits.EIC.NumberOfDaysSpouseLivedInUS.HasValue) ? taxObject.Credits.EIC.NumberOfDaysSpouseLivedInUS.Value : 0;
                        taxObject.Income.Form8862.FormFilingTaxYear   = 2013;
                        taxObject.Income.IsForm8862Required           = true;
                    }

                    input.ErrorMessages = errorMessages;
                    //Checking EIC Eligibility check
                    var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new F1040EZEICEligibilityRuleCheck(), input));


                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_TAXABLE_INCOME);
                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_REQUIRED_REFUND_DETAIL);
                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_MISSING_INCOME);
                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.OTHERINCOME_TAXABLE_SOCIAL_SECURITY_AND_RAILROAD_BENEFITS);

                    dynamic federalSummaryInput = new Microsoft.Activities.Extensions.WorkflowArguments();
                    federalSummaryInput.Tax1040Object             = taxObject;
                    federalSummaryInput.IsRefundAvailableCheck    = true;
                    federalSummaryInput.IsIncomeAndRefundAllZeros = true;
                    //25 Aug 2014-Vincent- Added the SSB and RRB check in FederalSummaryWithNoValidation
                    federalSummaryInput.IsSSBAndRRBCheck = true;
                    federalSummaryInput.ErrorMessages    = errorMessages;
                    output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(
                        WorkflowInvoker.Invoke(new FederalSummaryWithNoValidation(), federalSummaryInput));

                    //Persist TaxObject.
                    taxReturnData.UserDataId = Utilities.PersistTaxObject(userId, taxReturnData.UserDataId, taxObject);

                    //Vincent, 2-sep-14, Persist Audit information
                    string description = "Persit EarnedIncomeCredit, ClassName: {0}, Method Name: {1}";
                    Utilities.PersistAuditInfo(userId, taxReturnData.UserDataId, description, this.GetType().Name, Constants.Tab_EARNED_INCOME_CREDITS, Constants.TOPIC_EARNED_INCOME_CREDIT);
                }

                return(taxReturnData.UserDataId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public dynamic GetDeductionSummary(UserDTO userDTO)
        {
            try
            {
                BusinessObject.Tax1040 taxObject;
                //Retreiving TaxObject from database
                taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userDTO.UserId, userDTO.UserDataId);

                dynamic deductionSummaryData = new ExpandoObject();

                if (taxObject == null || taxObject.PersonalDetails == null || taxObject.PersonalDetails.PrimaryTaxPayer == null)
                {
                    if (taxObject == null)
                    {
                        taxObject = new BusinessObject.Tax1040()
                        {
                            PersonalDetails = new PersonalDetails()
                            {
                                PrimaryTaxPayer = new PrimaryTaxPayer()
                                {
                                    FilingStatus = FilingStatus.Single,
                                    Person       = new Person()
                                }
                            }
                        }
                    }
                    ;

                    if (taxObject.PersonalDetails == null)
                    {
                        taxObject.PersonalDetails = new PersonalDetails()
                        {
                            PrimaryTaxPayer = new PrimaryTaxPayer()
                            {
                                FilingStatus = FilingStatus.Single,
                                Person       = new Person()
                            }
                        };
                    }

                    if (taxObject.PersonalDetails.PrimaryTaxPayer == null)
                    {
                        taxObject.PersonalDetails.PrimaryTaxPayer = new PrimaryTaxPayer()
                        {
                            FilingStatus = FilingStatus.Single,
                            Person       = new Person()
                        };
                    }

                    Tuple <long, bool> userDataId = personalInfoRepository.PersistPrimaryTaxPayer(taxObject.PersonalDetails.PrimaryTaxPayer, userDTO.UserId, userDTO.UserDataId);

                    deductionSummaryData.UserDataId = userDataId.Item1;

                    //Retrieving TaxObject from database
                    //26Aug2014 Sathish Get Tax object after personal info persist to get the error message list
                    taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userDTO.UserId, deductionSummaryData.UserDataId);
                }
                else
                {
                    deductionSummaryData.UserDataId = userDTO.UserDataId;
                }



                deductionSummaryData.PrimaryTaxPayerName = Utilities.GetTaxPayerFirstNameOrNickName(taxObject);



                dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                input.Tax1040Object = taxObject;
                var output =
                    Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(
                        WorkflowInvoker.Invoke(new F1040EZStandardDeductionWithNoValidation(), input));

                deductionSummaryData.TotalWorksheetStandardDeduction = output.TotalWorksheetStandardDeduction;

                //To DO
                //20Aug2014-Code Added by Thileep to Obtain the List of Error Messages from DB.
                //var errorMessagesFromDB = messageRepository.GetErrorMessages();
                //var errorMessagesAll = new ErrorMessages(errorMessagesFromDB);

                //taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_TAXABLE_INCOME);
                //taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_REQUIRED_REFUND_DETAIL);
                //taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_MISSING_INCOME);

                //dynamic federalSummaryInput = new Microsoft.Activities.Extensions.WorkflowArguments();
                //federalSummaryInput.Tax1040Object = taxObject;
                //federalSummaryInput.IsTaxableIncomeExceedCheck = true;
                //federalSummaryInput.IsRefundAvailableCheck = true;
                //federalSummaryInput.IsIncomeAndRefundAllZeros = true;
                //federalSummaryInput.ErrorMessages = errorMessagesAll;
                //output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(
                //                                         WorkflowInvoker.Invoke(new FederalSummaryWithNoValidation(), federalSummaryInput));

                ////Persist TaxObject.
                //Utilities.PersistTaxObject(userDTO.UserId, userDTO.UserDataId, taxObject);


                //Bala, 1-sep-14, Get Audit information
                string description = "Get Deduction Summary, ClassName: {0}, Method Name: {1}";
                Utilities.PersistAuditInfo(userDTO.UserId, userDTO.UserDataId, description, this.GetType().Name, Constants.Tab_DEDUCTION_INFO, string.Empty);

                return(deductionSummaryData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #6
0
        /// <summary>
        /// Delete and then Persist Form1099G.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="userDataId"></param>
        /// <param name="form1099GId"></param>
        /// <param name="errorMessageList"></param>
        public void DeleteAndPersistUnemployment(UserDTO userDTO, Tax1040.BusinessObject.Tax1040 refTaxObject = null) // 05Jun2014 Sathish added optional parameter taxobject used in delete spouse info while changing filling status MFJ to single
        {
            try
            {
                // 05Jun2014 Sathish check optional parameter which is used in deleting spouse info
                if (refTaxObject == null)
                {
                    //Retrieving TaxObject from database
                    taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userDTO.UserId, userDTO.UserDataId);
                }
                else
                {
                    taxObject = refTaxObject;
                }

                //Converting Json to Form1099G by DeSerializing
                if (taxObject != null && taxObject.Income != null && taxObject.Income.Form1099G != null)
                {
                    int index = taxObject.Income.Form1099G.FindIndex(form => form.Form1099GId == userDTO.FormId);

                    if (index >= 0)
                    {
                        //Delete the current Form1099G object.
                        taxObject.Income.Form1099G.RemoveAt(index);

                        // Clear the Error messages
                        messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_UNEMPLOYMENT_COMPENSATION, userDTO.FormId);
                    }


                    //10Jul2014 Sathish added coded to check Taxable Income Eligibility
                    dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                    input.Tax1040Object = taxObject;

                    //Obtain the List of Error Messages from DB.
                    //var errorMessagesFromDB = messageRepository.GetErrorMessages();
                    var errorMessagesFromDB = HttpRuntime.Cache["ErrorMessageCollection"] as Dictionary <string, ErrorMessage>;
                    var errorMessagesAll    = new ErrorMessages(errorMessagesFromDB);
                    //Assisn error message list into workflow input param.
                    input.ErrorMessages = errorMessagesAll;

                    //10Jul2014 Sathish added coded to check Taxable Income Eligibility
                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_TAXABLE_INCOME);

                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_REQUIRED_REFUND_DETAIL);
                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_MISSING_INCOME);
                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.OTHERINCOME_TAXABLE_SOCIAL_SECURITY_AND_RAILROAD_BENEFITS);

                    // var taxableIncome = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new F1040EZTaxableIncomeEligibilityCheck(), input));
                    dynamic federalSummaryInput = new Microsoft.Activities.Extensions.WorkflowArguments();
                    federalSummaryInput.Tax1040Object = taxObject;
                    federalSummaryInput.IsTaxableIncomeExceedCheck = true;
                    federalSummaryInput.IsRefundAvailableCheck     = true;
                    federalSummaryInput.IsIncomeAndRefundAllZeros  = true;
                    //25 Aug 2014-Vincent- Added the SSB and RRB check in FederalSummaryWithNoValidation
                    federalSummaryInput.IsSSBAndRRBCheck = true;
                    federalSummaryInput.ErrorMessages    = errorMessagesAll;
                    var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(
                        WorkflowInvoker.Invoke(new FederalSummaryWithNoValidation(), federalSummaryInput));

                    //Added by Ashok for EIC Eligibility Check
                    // Clear the Error messages
                    //messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_EARNED_INCOME_CREDIT);

                    //03Sep2014-Thileep Changed code to Remove EIC errormessages which has Message Type EI only
                    taxObject.ErrorMessages.RemoveAll(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT && (err.MessageType == Constants.MESSAGE_TYPE_EI));

                    dynamic eicEligbilityInput = new Microsoft.Activities.Extensions.WorkflowArguments();
                    eicEligbilityInput.Tax1040Object = taxObject;
                    eicEligbilityInput.ErrorMessages = errorMessagesAll;
                    //Check if EIC with espect to AGI
                    output = AGICheck(taxObject, input);
                    //02Sep2014-  Thileep added  to Remove EIC Error messages when EIC Eligibility fails
                    if (!output.HasEarnedIncomeCredit)
                    {
                        taxObject.ErrorMessages.RemoveAll(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT &&
                                                          (err.MessageType == Constants.MESSAGE_TYPE_RF || err.MessageType == Constants.MESSAGE_TYPE_V || err.MessageType == Constants.MESSAGE_TYPE_BR));
                    }
                }

                //Persist latest TaxObject.
                Utilities.PersistTaxObject(userDTO.UserId, userDTO.UserDataId, taxObject);

                //02-Sep-2014 Bhavani Audit functionality implementation
                var description = "Delete Unemployment: " + userDTO.FormId + ", ClassName: {0}, Method Name: {1}";
                Utilities.PersistAuditInfo(userDTO.UserId, userDTO.UserDataId, description, GetType().Name, Constants.Tab_INCOME, Constants.TOPIC_UNEMPLOYMENT_COMPENSATION);
            }
            catch (Exception ex)
            {
                ExceptionHandling.LogException(userDTO.UserId, "Class:UnemploymentRepository,Method Name:DeleteAndPersistUnemployment", ex);
            }
        }
Exemple #7
0
        /// <summary>
        /// Create and Persist Unemployment
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="taxReturnData"></param>
        /// <returns></returns>
        public dynamic CreateAndPersistUnemployment(long userId, TaxReturnData taxReturnData)
        {
            dynamic userDataIDand1099GId = new ExpandoObject();
            long    form1099GId          = 0;

            try
            {
                //Retrieving TaxObject from database
                taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userId, taxReturnData.UserDataId);

                //Converting Json to Form1099G by DeSerializing
                Form1099G form1099g = JsonConvert.DeserializeObject <Form1099G>(taxReturnData.TaxData);
                if (taxObject != null)
                {
                    //Get TaxPayer and Spouse Names.
                    taxPayerAndSpouseNames = Utilities.GetTaxPayerAndSpouseName(taxObject);

                    if (taxObject.Income == null)
                    {
                        taxObject.Income = new Income();
                    }
                }

                if (taxObject.Income.Form1099G != null && taxObject.Income.Form1099G.Any())
                {
                    int index = taxObject.Income.Form1099G.FindIndex(form => form.Form1099GId == form1099g.Form1099GId);

                    if (index < 0)
                    {
                        //Saravanan N - 3rd April, 2014 - Current Form1099G is new one. So created ID for this.
                        form1099g.Form1099GId = taxObject.Income.Form1099G.Max(frm => frm.Form1099GId) + 1;

                        //Adding new Form1099G to the TaxObject Form1099GList
                        taxObject.Income.Form1099G.Add(form1099g);
                        form1099GId = 0;
                    }
                    else
                    {
                        taxObject.Income.Form1099G[index] = form1099g;
                        form1099GId = form1099g.Form1099GId;
                    }
                }
                else
                {
                    //Saravanan N - 3rd April, 2014 - Form1099G doesn't exists for this user. Hence, assign 1 as its ID.
                    form1099g.Form1099GId = 1;

                    //Creating Instance if Form1099GList section is Null
                    taxObject.Income.Form1099G = new List <Form1099G> {
                        form1099g
                    };
                    form1099GId = 0;
                    //Adding new Form1099G to the TaxObject W2List
                }

                if (taxObject.ErrorMessages == null)
                {
                    taxObject.ErrorMessages = new List <ErrorMessage>();
                }

                //Retrieving Error Message list from Database
                messageRepository = new MessagesRepository();
                //var errorMessage = messageRepository.GetErrorMessages();

                var errorMessage  = HttpRuntime.Cache["ErrorMessageCollection"] as Dictionary <string, ErrorMessage>;
                var errorMessages = new ErrorMessages(errorMessage);

                // Clear the Error messages
                messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_UNEMPLOYMENT_COMPENSATION);

                //Required and Validation check for current Form1099G.
                FilingStatus filingStatus = FilingStatus.None;
                if (taxObject.PersonalDetails != null && taxObject.PersonalDetails.PrimaryTaxPayer != null)
                {
                    filingStatus = taxObject.PersonalDetails.PrimaryTaxPayer.FilingStatus;
                }
                if (taxObject.Income.Form1099G != null && taxObject.Income.Form1099G.Any())
                {
                    BusinessFieldValidations(taxObject.Income.Form1099G, filingStatus, taxObject.ErrorMessages, errorMessages);
                }

                // Clear the Error messages
                //messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_EARNED_INCOME_CREDIT);
                //02Sep2014-Thileep Changed code to Remove EIC errormessages which has Message Type EI only
                taxObject.ErrorMessages.RemoveAll(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT && (err.MessageType == Constants.MESSAGE_TYPE_EI));


                //14thJuly2014 Ashok - Added logic for Clearing EIC Worksheet, Form 8862 and EIC classes when failing EIC eligibility
                dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                input.Tax1040Object = taxObject;
                input.ErrorMessages = errorMessages;

                //Check if EIC with espect to AGI
                var output = AGICheck(taxObject, input);

                //Invoking Business Rules Validation Workflow
                //dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                //input.Tax1040Object = taxObject;
                input.ErrorMessages = errorMessages;
                output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new
                                                                                                                 F1099GBusinessValidationRule(), input));


                //10Jul2014 Sathish added coded to check Taxable Income Eligibility
                taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_TAXABLE_INCOME);

                taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_REQUIRED_REFUND_DETAIL);
                taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_MISSING_INCOME);
                taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.OTHERINCOME_TAXABLE_SOCIAL_SECURITY_AND_RAILROAD_BENEFITS);

                // var taxableIncome = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new F1040EZTaxableIncomeEligibilityCheck(), input));
                dynamic federalSummaryInput = new Microsoft.Activities.Extensions.WorkflowArguments();
                federalSummaryInput.Tax1040Object = taxObject;
                federalSummaryInput.IsTaxableIncomeExceedCheck = true;
                federalSummaryInput.IsRefundAvailableCheck     = true;
                federalSummaryInput.IsIncomeAndRefundAllZeros  = true;
                //25 Aug 2014-Vincent- Added the SSB and RRB check in FederalSummaryWithNoValidation
                federalSummaryInput.IsSSBAndRRBCheck = true;
                federalSummaryInput.ErrorMessages    = errorMessages;
                output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(
                    WorkflowInvoker.Invoke(new FederalSummaryWithNoValidation(), federalSummaryInput));


                //Saravanan N - 7th May, 2014 - Check if any hard stop (Eligibility Check found) in workflow for Unemployment.
                var isEligibilityCheckFailed = taxObject.ErrorMessages.Any(errMsg => errMsg.Topic ==
                                                                           Constants.TOPIC_UNEMPLOYMENT_COMPENSATION && errMsg.ErrorCode.Equals(Constants.F1099G__REPAID_AMOUNT_FOR_EARLIER_YEAR));

                //Added by Ashok for EIC Eligibility Check
                // Clear the Error messages
                //messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_EARNED_INCOME_CREDIT);

                //03Sep2014-Thileep Changed code to Remove EIC errormessages which has Message Type EI only
                taxObject.ErrorMessages.RemoveAll(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT && (err.MessageType == Constants.MESSAGE_TYPE_EI));

                dynamic eicEligbilityInput = new Microsoft.Activities.Extensions.WorkflowArguments();
                eicEligbilityInput.Tax1040Object = taxObject;
                eicEligbilityInput.ErrorMessages = errorMessages;
                //Check if EIC with espect to AGI
                output = AGICheck(taxObject, input);

                //02Sep2014-  Thileep added  to Remove EIC Error messages when EIC Eligibility fails
                if (!output.HasEarnedIncomeCredit)
                {
                    taxObject.ErrorMessages.RemoveAll(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT &&
                                                      (err.MessageType == Constants.MESSAGE_TYPE_RF || err.MessageType == Constants.MESSAGE_TYPE_V || err.MessageType == Constants.MESSAGE_TYPE_BR));
                }

                taxReturnData.UserDataId = Utilities.PersistTaxObject(userId, taxReturnData.UserDataId, taxObject);

                userDataIDand1099GId.UserDataId  = taxReturnData.UserDataId;
                userDataIDand1099GId.Form1099GId = form1099g.Form1099GId;
                userDataIDand1099GId.isEligibilityCheckFailed = isEligibilityCheckFailed;

                //02-Sep-2014 Bhavani Audit functionality implementation
                var description = form1099GId <= 0 ? "Persist Unemployment: " + form1099GId + ", ClassName: {0}, Method Name: {1}"
                                                   : "Update Unemployment: " + form1099GId + ", ClassName: {0}, Method Name: {1}";
                Utilities.PersistAuditInfo(userId, taxReturnData.UserDataId, description, GetType().Name, Constants.Tab_INCOME, Constants.TOPIC_UNEMPLOYMENT_COMPENSATION);
            }
            catch (Exception ex)
            {
                ExceptionHandling.LogException(userId, "Class:UnemploymentRepository,Method Name:CreateAndPersistUnemployment", ex);
            }

            return(userDataIDand1099GId);
        }
Exemple #8
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            MessagesRepository messageRepository = new MessagesRepository();

            var tax1040 = new Tax1040();

            tax1040.ErrorMessages      = new List <ErrorMessage>();
            tax1040.Income             = new Income();
            tax1040.Income.W2Wages     = new List <W2>();
            tax1040.Income.Form1099INT = new List <Form1099INT>();
            tax1040.Income.Form1099OID = new List <Form1099OID>();
            tax1040.Income.Form1099G   = new List <Form1099G>();
            tax1040.PersonalDetails    = new PersonalDetails();
            tax1040.PersonalDetails.PrimaryTaxPayer        = new PrimaryTaxPayer();
            tax1040.PersonalDetails.PrimaryTaxPayer.Person = new Person();

            tax1040.PersonalDetails.PrimaryTaxPayer.Person.HasClaimedAsDependent = chkHasClaimedAsDependent.Checked;
            tax1040.PersonalDetails.PrimaryTaxPayer.Person.IsBankruptcyDebtor    = chkIsBankruptcyDebtor.Checked;
            tax1040.PersonalDetails.PrimaryTaxPayer.FilingStatus = (FilingStatus)ddlFilingStatus.SelectedIndex;
            tax1040.PersonalDetails.Spouse        = new Spouse();
            tax1040.PersonalDetails.Spouse.Person = new Person();

            if (!string.IsNullOrEmpty(txttaxpayer.Text))
            {
                tax1040.PersonalDetails.Spouse.Person.DateOfBirth = Convert.ToDateTime(txttaxpayer.Text);
            }

            if (!string.IsNullOrEmpty(txtSpouseDOB.Text))
            {
                tax1040.PersonalDetails.PrimaryTaxPayer.Person.DateOfBirth = Convert.ToDateTime(txtSpouseDOB.Text);
            }

            tax1040.PersonalDetails.PrimaryTaxPayer.Person.IsLegallyBlind = chktaxpayerblind.Checked;
            tax1040.PersonalDetails.Spouse.Person.IsLegallyBlind          = chkspouseblind.Checked;
            tax1040.Deductions = new Deductions();
            tax1040.Deductions.HasAGIDeductions      = chkHasAGIDeductions.Checked;
            tax1040.Deductions.HasItemizedDeductions = chkHasItemizedDeductions.Checked;

            tax1040.Credits = new Credits();
            tax1040.Credits.HasCreditsToClaim       = chkHasCreditsToClaim.Checked;
            tax1040.Credits.HasEstimatedTaxPayments = chkHasEstimatedTaxPayments.Checked;
            tax1040.Credits.HasEstimatedTaxPayments = chkHasEstimatedTaxPayments.Checked;

            tax1040.TaxesAndPenalties = new TaxesAndPenalties();
            tax1040.TaxesAndPenalties.HasAlternativeMinimumTax      = chkHasAlternativeMinimumTax.Checked;
            tax1040.TaxesAndPenalties.HasOwedHouseholdEmploymentTax = chkHasOwedHouseholdEmploymentTax.Checked;

            tax1040.Income.HasIncomeFromOtherSources = chkHasIncomeFromOtherSources.Checked;

            //var errorMessageCollection = messageRepository.GetErrorMessages();
            var           errorMessageCollection = HttpRuntime.Cache["ErrorMessageCollection"] as Dictionary <string, ErrorMessage>;
            ErrorMessages errormessages          = new ErrorMessages(errorMessageCollection);
            dynamic       input = new Microsoft.Activities.Extensions.WorkflowArguments();

            tax1040.ErrorMessages = new List <ErrorMessage>()
            {
                new ErrorMessage()
                {
                    ErrorType = "Error",
                    ErrorText = "Sample Error1"
                },
                new ErrorMessage()
                {
                    ErrorType = "Error",
                    ErrorText = "Sample Error2"
                },
                new ErrorMessage()
                {
                    ErrorType = "Error",
                    ErrorText = "Sample Error3"
                },
            };
            input.Tax1040Object = tax1040;
            input.ErrorMessages = errormessages;

            Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new F1040EzEligibilityRuleCheck(), input));



            if (tax1040.ErrorMessages.Any())
            {
                foreach (var message in tax1040.ErrorMessages)
                {
                    ValidationError.Display(message.ErrorType + " : " + message.ErrorText);
                }
                lblError.Visible = true;
            }
        }
        //Saravanan N - 20th May, 2014 - Code refactored from its Controller.
        /// <summary>
        /// Get OtherIncome Summary
        /// </summary>
        /// <param name="userInputData"></param>
        /// <returns></returns>
        public System.Tuple <OtherIncome, IEnumerable <ErrorMessage>, string, string, string, string> GetOtherIncomeSummary(dynamic userInputData)
        {
            try
            {
                OtherIncome otherIncome = null;
                IEnumerable <ErrorMessage> lstErrorMessages = null;


                //Get TaxObject from Database.
                BusinessObject.Tax1040 taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(Utilities.ConvertToLong(userInputData.userId.Value),
                                                                                               Utilities.ConvertToLong(userInputData.userDataId.Value));

                if (taxObject != null)
                {
                    //Tax Payer and Spouse name
                    taxPayerAndSpouseNames = Utilities.GetTaxPayerAndSpouseName(taxObject);


                    if (taxObject.Income != null && taxObject.Income.OtherIncome != null)
                    {
                        otherIncome = taxObject.Income.OtherIncome;
                    }

                    if (taxObject.ErrorMessages != null)
                    {
                        //If ErrorMessages doesn't have any object it returns count as 1 for NULL object. So removing this NULL object from the list.
                        taxObject.ErrorMessages.RemoveAll(err => err == null);

                        if (taxObject.ErrorMessages.Count > 0)
                        {
                            //Get Other Income related error messages.
                            // 17Jun2014 Sathish reterived all the error message including eligibility rule for navigation to hot stop from summary
                            lstErrorMessages = taxObject.ErrorMessages.Where(err => err.Topic == Constants.TOPIC_OTHER_INCOME_SSB_RRB ||
                                                                             err.Topic == Constants.TOPIC_OTHER_INCOME_Alaska ||
                                                                             err.Topic == Constants.TOPIC_OTHER_INCOME_State_And_Local ||
                                                                             err.Topic == Constants.TOPIC_OTHER_INCOME).OrderBy(x => x.ErrorType);
                        }
                    }

                    // Clearing the eligibility Error messages.
                    //SSB & RRB
                    messageRepository.ClearErrorMessages(taxObject.ErrorMessages, topic: Constants.TOPIC_OTHER_INCOME, errorCode: "OtherIncome_ER2");

                    //Workflow Validation Section
                    dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                    input.Tax1040Object = taxObject;

                    //var errorMessage = messageRepository.GetErrorMessages();
                    var errorMessage  = HttpRuntime.Cache["ErrorMessageCollection"] as Dictionary <string, ErrorMessage>;
                    var errorMessages = new ErrorMessages(errorMessage);
                    input.ErrorMessages = errorMessages;

                    //Vincent-30Jun2014-Rechecking the Eligibility Check For ER2

                    if (taxObject != null && taxObject.Income != null && taxObject.Income.OtherIncome != null && taxObject.Income.OtherIncome.SSB != null && taxObject.Income.OtherIncome.RRB != null)
                    {
                        //Saravanan N - 1st Aug, 2014 - While user removing Box 5 (SSB & RRB) for Spouse then also this workflow has to be called. Otherwise the modification in Spouse which will be reflected in workflow only while TaxPayer Net Benefits (SSB & RRB) value exists.
                        //Vincent-16July2014-Check the SSB & RRB TaxpayerNet Benefits as NULL
                        //Checking if the SSB & RRB as value and not equal to Zero.
                        //if ((taxObject.Income.OtherIncome.SSB.TaxpayerNetBenefits != null || taxObject.Income.OtherIncome.RRB.TaxpayerNetBenefits != null))
                        //{
                        var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new
                                                                                                                             Form1040EZSSBEligibilityWithNoValidation(), input));
                        //}
                    }

                    //Saravanan N - 1st Aug, 2014 - If ER2 already exists, now the user changed Box 5 value as 0 or empty then the IsLine2SSBTaxable property in SSBWorksheet will be set False. Based on this bool variable the error message will be removed from Taxobject.
                    if (taxObject.F1040EZ != null && taxObject.F1040EZ.F1040EZWorkSheets != null && taxObject.F1040EZ.F1040EZWorkSheets.SSBWorkSheet != null && taxObject.F1040EZ.F1040EZWorkSheets.SSBWorkSheet.IsLine2SSBTaxable == false)
                    {
                        //Remoe already existing eligibility error in tax object.
                        taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.OTHERINCOME_TAXABLE_SOCIAL_SECURITY_AND_RAILROAD_BENEFITS);
                    }

                    if (taxObject != null && taxObject.UserDataId != 0)
                    {
                        Utilities.PersistTaxObject(userInputData.userId.Value, userInputData.userDataId.Value, taxObject);
                    }
                }

                //02-Sep-2014 Bhavani Audit functionality implementation
                var description = "Get OtherIncome Summary, ClassName: {0}, Method Name: {1}";
                Utilities.PersistAuditInfo(userInputData.userId.Value, userInputData.userDataId.Value, description, GetType().Name, Constants.Tab_INCOME, Constants.TOPIC_OTHER_INCOME);

                return(new Tuple <OtherIncome, IEnumerable <ErrorMessage>, string, string, string, string>(otherIncome, lstErrorMessages, taxPayerAndSpouseNames.Item1, taxPayerAndSpouseNames.Item2, taxPayerAndSpouseNames.Item3, taxPayerAndSpouseNames.Item4));
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var tax1040 = new Tax1040();

            tax1040.Income             = new Income();
            tax1040.Income.W2Wages     = new List <W2>();
            tax1040.Income.Form1099INT = new List <Form1099INT>();
            tax1040.Income.Form1099OID = new List <Form1099OID>();
            tax1040.Income.Form1099G   = new List <Form1099G>();
            //tax1040.Income.OtherIncome.SocialSecurityBenefits = new List<SocialSecurityBenefits>();
            //tax1040.Income.OtherIncome.RailroadRetirementBenefits = new List<RailroadRetirementIncome>();

            var w21 = new W2();
            var w22 = new W2();
            var w23 = new W2();


            var form1099Int1 = new Form1099INT();
            var form1099Int2 = new Form1099INT();

            var form1099OID1 = new Form1099OID();
            var form1099OID2 = new Form1099OID();
            var form1099OID3 = new Form1099OID();

            var form1099G1 = new Form1099G();
            var form1099G2 = new Form1099G();
            var form1099G3 = new Form1099G();


            var socialSecurityBenefit = new SocialSecurityBenefits();
            var railRoadRetirement    = new RailroadRetirementIncome(); //added a New Instance

            //W2
            if (!string.IsNullOrEmpty(txtW21.Text))
            {
                w21.WagesAmount = Convert.ToDouble(txtW21.Text);
            }
            if (!string.IsNullOrEmpty(txtFTW21.Text))
            {
                w21.FederalTaxWithholdingAmount = Convert.ToDouble(txtFTW21.Text);
            }

            tax1040.Income.W2Wages.Add(w21);

            if (!string.IsNullOrEmpty(txtW22.Text))
            {
                w22.WagesAmount = Convert.ToDouble(txtW22.Text);
            }
            if (!string.IsNullOrEmpty(txtFTW2.Text))
            {
                w22.FederalTaxWithholdingAmount = Convert.ToDouble(txtFTW2.Text);
            }

            tax1040.Income.W2Wages.Add(w22);

            if (!string.IsNullOrEmpty(txtW23.Text))
            {
                w23.WagesAmount = Convert.ToDouble(txtW23.Text);
            }
            if (!string.IsNullOrEmpty(txtFTW3.Text))
            {
                w23.FederalTaxWithholdingAmount = Convert.ToDouble(txtFTW3.Text);
            }

            tax1040.Income.W2Wages.Add(w23);

            if (!string.IsNullOrEmpty((txtw2Line11Amount.Text)))
            {
                w21.NonQualifiedPlansAmount = Convert.ToDouble(txtw2Line11Amount.Text);
            }

            //W2 Line 8B

            tax1040.Income.W2Wages[0].W2EmployerCodes = new List <W2EmployerCode>();
            var W2Emp1 = new W2EmployerCode();

            W2Emp1.EmployerCode = (EmployerCode)ddlw212a.SelectedIndex;

            if (!string.IsNullOrEmpty(txtW212aAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW212aAmount.Text);
            }
            tax1040.Income.W2Wages[0].W2EmployerCodes.Add(W2Emp1);

            W2Emp1 = new W2EmployerCode();
            W2Emp1.EmployerCode = (EmployerCode)ddlW212b.SelectedIndex;
            if (!string.IsNullOrEmpty(txtW212bAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW212bAmount.Text);
            }
            tax1040.Income.W2Wages[0].W2EmployerCodes.Add(W2Emp1);


            tax1040.Income.W2Wages[1].W2EmployerCodes = new List <W2EmployerCode>();

            W2Emp1 = new W2EmployerCode();
            W2Emp1.EmployerCode = (EmployerCode)ddlw2212a.SelectedIndex;

            if (!string.IsNullOrEmpty(txtW2212aAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW2212aAmount.Text);
            }

            tax1040.Income.W2Wages[1].W2EmployerCodes.Add(W2Emp1);

            W2Emp1 = new W2EmployerCode();
            W2Emp1.EmployerCode = (EmployerCode)ddlW2212b.SelectedIndex;

            if (!string.IsNullOrEmpty(txtW2212bAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW2212bAmount.Text);
            }
            tax1040.Income.W2Wages[1].W2EmployerCodes.Add(W2Emp1);



            tax1040.Income.W2Wages[2].W2EmployerCodes = new List <W2EmployerCode>();
            W2Emp1 = new W2EmployerCode();
            W2Emp1.EmployerCode = (EmployerCode)ddlw2312a.SelectedIndex;

            if (!string.IsNullOrEmpty(txtW2312aAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW2312aAmount.Text);
            }

            tax1040.Income.W2Wages[2].W2EmployerCodes.Add(W2Emp1);

            W2Emp1 = new W2EmployerCode();
            W2Emp1.EmployerCode = (EmployerCode)ddlW2312b.SelectedIndex;
            if (!string.IsNullOrEmpty(txtW2312bAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW2312bAmount.Text);
            }
            tax1040.Income.W2Wages[2].W2EmployerCodes.Add(W2Emp1);


            //1099 INT
            if (!string.IsNullOrEmpty(txtIntrestIncome1.Text))
            {
                form1099Int1.InterestIncome = Convert.ToDouble(txtIntrestIncome1.Text);
            }
            if (!string.IsNullOrEmpty(txtFTWIntInc1.Text))
            {
                form1099Int1.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFTWIntInc1.Text);
            }
            tax1040.Income.Form1099INT.Add(form1099Int1);
            if (!string.IsNullOrEmpty(txtIntrestIncome2.Text))
            {
                form1099Int2.InterestIncome = Convert.ToDouble(txtIntrestIncome2.Text);
            }
            if (!string.IsNullOrEmpty(txtFTWIntInc2.Text))
            {
                form1099Int2.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFTWIntInc2.Text);
            }
            tax1040.Income.Form1099INT.Add(form1099Int2);

            //OID
            if (!string.IsNullOrEmpty(txtOID1.Text))
            {
                form1099OID1.OriginalIssueDiscount = Convert.ToDouble(txtOID1.Text);
            }
            if (!string.IsNullOrEmpty(txtFDOID1.Text))
            {
                form1099OID1.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDOID1.Text);
            }
            if (!string.IsNullOrEmpty(txtOPIOID1.Text))
            {
                form1099OID1.OtherPeriodicInterest = Convert.ToDouble(txtOPIOID1.Text);
            }
            tax1040.Income.Form1099OID.Add(form1099OID1);

            if (!string.IsNullOrEmpty(txtOID2.Text))
            {
                form1099OID2.OriginalIssueDiscount = Convert.ToDouble(txtOID2.Text);
            }
            if (!string.IsNullOrEmpty(txtFDOID2.Text))
            {
                form1099OID2.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDOID2.Text);
            }
            if (!string.IsNullOrEmpty(txtOPIOID2.Text))
            {
                form1099OID2.OtherPeriodicInterest = Convert.ToDouble(txtOPIOID2.Text);
            }
            tax1040.Income.Form1099OID.Add(form1099OID2);

            if (!string.IsNullOrEmpty(txtOID3.Text))
            {
                form1099OID3.OriginalIssueDiscount = Convert.ToDouble(txtOID3.Text);
            }
            if (!string.IsNullOrEmpty(txtFDOID3.Text))
            {
                form1099OID3.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDOID3.Text);
            }
            if (!string.IsNullOrEmpty(txtOPIOID3.Text))
            {
                form1099OID3.OtherPeriodicInterest = Convert.ToDouble(txtOPIOID3.Text);
            }
            tax1040.Income.Form1099OID.Add(form1099OID3);

            //..UnEmployment
            if (!string.IsNullOrEmpty(txtg1.Text))
            {
                form1099G1.UnEmploymentCompensation = Convert.ToDouble(txtg1.Text);
            }
            if (!string.IsNullOrEmpty(txtFDG1.Text))
            {
                form1099G1.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDG1.Text);
            }
            //if (!string.IsNullOrEmpty(txtAlaska1.Text))
            //{
            //    form1099G1.AlaskaPermanentFundDividend = Convert.ToDouble(txtAlaska1.Text);
            //}
            tax1040.Income.Form1099G.Add(form1099G1);

            if (!string.IsNullOrEmpty(txtg2.Text))
            {
                form1099G2.UnEmploymentCompensation = Convert.ToDouble(txtg2.Text);
            }
            if (!string.IsNullOrEmpty(txtFDG2.Text))
            {
                form1099G2.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDG2.Text);
            }
            //if (!string.IsNullOrEmpty(txtAlaska2.Text))
            //{
            //    form1099G2.AlaskaPermanentFundDividend = Convert.ToDouble(txtAlaska2.Text);
            //}
            tax1040.Income.Form1099G.Add(form1099G2);

            if (!string.IsNullOrEmpty(txtg3.Text))
            {
                form1099G3.UnEmploymentCompensation = Convert.ToDouble(txtg3.Text);
            }
            if (!string.IsNullOrEmpty(txtFDG3.Text))
            {
                form1099G3.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDG3.Text);
            }
            //if (!string.IsNullOrEmpty(txtAlaska3.Text))
            //{
            //    form1099G3.AlaskaPermanentFundDividend = Convert.ToDouble(txtAlaska3.Text);
            //}
            tax1040.Income.Form1099G.Add(form1099G3);


            //SSB

            if (!string.IsNullOrEmpty(txtNetBenefitSSB.Text))
            {
                socialSecurityBenefit.TaxpayerNetBenefits = Convert.ToDouble(txtNetBenefitSSB.Text);
            }
            if (!string.IsNullOrEmpty(txtFederalWithSSB.Text))
            {
                socialSecurityBenefit.TaxPayerFederalTaxWithheld = Convert.ToDouble(txtFederalWithSSB.Text);
            }
            //tax1040.Income.OtherIncome.SocialSecurityBenefits.Add(socialSecurityBenefit);


            //RRB
            // Modified By:Vincent Modified date:17/2/14
            //Comment: Made the changes in the instance and the Text box field.

            if (!string.IsNullOrEmpty(txtNetBenefitRRB.Text))
            {
                railRoadRetirement.TaxpayerNetBenefits = Convert.ToDouble(txtNetBenefitRRB.Text);
            }
            if (!string.IsNullOrEmpty(txtFederalWithRRB.Text))
            {
                railRoadRetirement.TaxPayerFederalTaxWithheld = Convert.ToDouble(txtFederalWithRRB.Text);
            }
            //tax1040.Income.OtherIncome.RailroadRetirementBenefits.Add(railRoadRetirement);


            tax1040.PersonalDetails = new PersonalDetails();
            tax1040.PersonalDetails.PrimaryTaxPayer        = new PrimaryTaxPayer();
            tax1040.PersonalDetails.PrimaryTaxPayer.Person = new Person();
            tax1040.PersonalDetails.PrimaryTaxPayer.Person.HasClaimedAsDependent = chkHasClaimedAsDependentTP.Checked;
            //Primary Tax Payer DOB
            if (!string.IsNullOrEmpty(txtPrimaryTaxPayerDOB.Text))
            {
                tax1040.PersonalDetails.PrimaryTaxPayer.Person.DateOfBirth =
                    Convert.ToDateTime(txtPrimaryTaxPayerDOB.Text);
            }


            tax1040.PersonalDetails.PrimaryTaxPayer.FilingStatus = (FilingStatus)ddlFilingStatus.SelectedIndex;
            tax1040.PersonalDetails.Spouse        = new Spouse();
            tax1040.PersonalDetails.Spouse.Person = new Person();

            //Spouse Tax Payer DOB
            if (!string.IsNullOrEmpty(txtSpouseDOB.Text))
            {
                tax1040.PersonalDetails.Spouse.Person.DateOfBirth = Convert.ToDateTime(txtSpouseDOB.Text);
            }

            tax1040.PersonalDetails.Spouse.Person.HasClaimedAsDependent = chkHasClaimedAsDependentS.Checked;

            //EIC
            tax1040.Credits     = new Credits();
            tax1040.Credits.EIC = new EIC();
            tax1040.Credits.EIC.IsInUSMorethanHalfYear               = chkLivedInUSStatus.Checked;
            tax1040.Credits.EIC.HasValidSSN                          = chkVaildSSN.Checked;
            tax1040.Credits.EIC.HasClaimedAsQualifyingChild          = chkQualifyingChild.Checked;
            tax1040.Credits.EIC.HasReceivedIRSNoticeOnEICNotEligible = chkIRSNotice.Checked;
            tax1040.Credits.EIC.HasReceivedIRSNoticeOnFiling8862     = chkIRSFiling8862.Checked;
            if (!string.IsNullOrEmpty(txtTaxableScholarshipAmount.Text))
            {
                tax1040.Credits.EIC.TaxableScholarshipCredit = Convert.ToDouble(txtTaxableScholarshipAmount.Text);
            }

            if (!string.IsNullOrEmpty(txtPensionPlansAmount.Text))
            {
                tax1040.Credits.EIC.PensionAnnuity = Convert.ToDouble(txtPensionPlansAmount.Text);
            }

            if (!string.IsNullOrEmpty(txtPenalInstitutionAmount.Text))
            {
                tax1040.Credits.EIC.PenalInstitutionInmateWages = Convert.ToDouble(txtPenalInstitutionAmount.Text);
            }


            //Account
            //25Jul2014 Sathish as discussed moved IRS to federal filing
            tax1040.Filing = new Filing();
            tax1040.Filing.FederalFiling                 = new FederalFiling();
            tax1040.Filing.FederalFiling.IRS             = new IRS();
            tax1040.Filing.FederalFiling.IRS.BankDetails = new BankDetails();
            tax1040.Filing.FederalFiling.IRS.BankDetails.AccountNumber        = "12345678901234567";
            tax1040.Filing.FederalFiling.IRS.BankDetails.RoutingTransitNumber = "123456789";

            tax1040.ThirdPartyDesignee                  = new ThirdPartyDesignee();
            tax1040.PaidTaxReturnPreparers              = new PaidTaxReturnPreparers();
            tax1040.PaidTaxReturnPreparers.Firm         = new Organization();
            tax1040.PaidTaxReturnPreparers.Firm.Address = new Address();
            tax1040.PaidTaxReturnPreparers.Firm.Address.CompanyAddress = new CompanyAddress();
            tax1040.ThirdPartyDesignee.PIN          = "12345";
            tax1040.ThirdPartyDesignee.DesigneeName = "CHARLES";
            tax1040.ThirdPartyDesignee.PhoneNumber  = "1234556767";

            //spouse
            tax1040.PersonalDetails.Spouse.Person.SSN = "123456";
            tax1040.PaidTaxReturnPreparers.PTIN       = "PIN";
            tax1040.PaidTaxReturnPreparers.Date       = DateTime.Now;
            tax1040.PaidTaxReturnPreparers.Firm.Name  = "JEEVAN";
            tax1040.PaidTaxReturnPreparers.Firm.Address.CompanyAddress.District = "NEY JERSY";
            tax1040.PaidTaxReturnPreparers.Firm.EIN = "EIN";
            //tax1040.PaidTaxReturnPreparers.Firm.ControlNumber = 1234567;

            tax1040.ThirdPartyDesignee.PhoneNumber = "123456789";

            var errorMessage = messagesRepository.GetErrorMessages();

            //Converting dictionary
            var errorMessages = new ErrorMessages(errorMessage);

            dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();

            input.Tax1040Object = tax1040;
            input.ErrorMessages = errorMessages;
            //pass it to the activity no need to cast it
            var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new F1040EZLineByLineCalculation(), input));

            if (tax1040.ErrorMessages.Any())
            {
                foreach (var message in tax1040.ErrorMessages)
                {
                    ValidationError.Display(message.ErrorType + " : " + message.ErrorText);
                }
                lblError.Visible = true;
            }
            else
            {
                Tax1040 tax1040Object = output["Tax1040Object"];
                var     bind          = new F1040EZPDFBinding();
                byte[]  pdfData       = bind.OutPutForm(tax1040Object, Constants.FORM1040EZ_BINDING);

                Response.Clear();
                Response.AddHeader("Accept-Header", pdfData.Length.ToString());
                Response.ContentType = "application/pdf";

                Response.AddHeader("Content-Disposition", "attachment; filename=  FinalBinding" + ".pdf");

                Response.AddHeader("content-length", pdfData.Length.ToString());
                Response.BinaryWrite(pdfData);
                Response.End();
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var tax1040 = new Tax1040();

            tax1040.Income             = new Income();
            tax1040.Income.W2Wages     = new List <W2>();
            tax1040.Income.Form1099INT = new List <Form1099INT>();
            tax1040.Income.Form1099OID = new List <Form1099OID>();
            tax1040.Income.Form1099G   = new List <Form1099G>();
            //Added

            var w21 = new W2();
            var w22 = new W2();
            var w23 = new W2();


            var form1099Int1 = new Form1099INT();
            var form1099Int2 = new Form1099INT();

            var form1099OID1 = new Form1099OID();
            var form1099OID2 = new Form1099OID();
            var form1099OID3 = new Form1099OID();


            var form1099G1 = new Form1099G();
            var form1099G2 = new Form1099G();
            var form1099G3 = new Form1099G();

            form1099G1.Form1099StateInfo = new List <Form1099StateInformation>();
            form1099G2.Form1099StateInfo = new List <Form1099StateInformation>();
            form1099G3.Form1099StateInfo = new List <Form1099StateInformation>();

            var form1099G1StateInfo1 = new Form1099StateInformation();
            var form1099G2StateInfo2 = new Form1099StateInformation();
            var form1099G3StateInfo3 = new Form1099StateInformation();

            form1099OID1.Form1099StateInfo = new List <Form1099StateInformation>();
            form1099OID2.Form1099StateInfo = new List <Form1099StateInformation>();
            form1099OID3.Form1099StateInfo = new List <Form1099StateInformation>();

            var form1099OIDStateInfo1 = new Form1099StateInformation();
            var form1099OIDStateInfo2 = new Form1099StateInformation();
            var form1099OIDStateInfo3 = new Form1099StateInformation();

            form1099Int1.Form1099StateInfo = new List <Form1099StateInformation>();
            form1099Int2.Form1099StateInfo = new List <Form1099StateInformation>();

            var form1099IntStateInfo1 = new Form1099StateInformation();
            var form1099IntStateInfo2 = new Form1099StateInformation();

            w21.W2StateLocalTaxInfo = new List <W2StateLocalTaxInfo>();
            w22.W2StateLocalTaxInfo = new List <W2StateLocalTaxInfo>();
            w23.W2StateLocalTaxInfo = new List <W2StateLocalTaxInfo>();

            var w2StateLocalTaxInfo1 = new W2StateLocalTaxInfo();
            var w2StateLocalTaxInfo2 = new W2StateLocalTaxInfo();
            var w2StateLocalTaxInfo3 = new W2StateLocalTaxInfo();


            var socialSecurityBenefit1 = new SocialSecurityBenefits();
            var socialSecurityBenefit2 = new SocialSecurityBenefits();

            var railRoadRetirement1 = new RailroadRetirementIncome();
            var railRoadRetirement2 = new RailroadRetirementIncome(); //added a New Instance

            //tax1040.Income.OtherIncome=new OtherIncome
            //    {
            //        SocialSecurityBenefits = new List<SocialSecurityBenefits>(),
            //        RailroadRetirementBenefits = new List<RailroadRetirementIncome>()
            //    };
            tax1040.Income.OtherIncome     = new OtherIncome();
            tax1040.Income.OtherIncome.RRB = new RailroadRetirementIncome();
            tax1040.Income.OtherIncome.SSB = new SocialSecurityBenefits();

            //form8862
            var form8862 = new Form8862();
            //
            var form8862Page1 = new Tax8862Page1();

            //W2
            if (!string.IsNullOrEmpty(txtW21.Text))
            {
                w21.WagesAmount = Convert.ToDouble(txtW21.Text);
            }
            if (!string.IsNullOrEmpty(txtFTW21.Text))
            {
                w21.FederalTaxWithholdingAmount = Convert.ToDouble(txtFTW21.Text);
            }
            if (!string.IsNullOrEmpty(txtSocialSecurityWages1.Text))
            {
                w21.SocialSecurityWagesAmount = Convert.ToDouble(txtSocialSecurityWages1.Text);
            }

            if (!string.IsNullOrEmpty(txtSocialSecurityWithholding1.Text))
            {
                w21.SocialSecurityTaxWithholdingAmount = Convert.ToDouble(txtSocialSecurityWithholding1.Text);
            }
            ////newly added by vincent for UI Input
            if (!string.IsNullOrEmpty(txtMedicareWithheld1.Text))
            {
                w21.MedicareTaxWithholdingAmount = Convert.ToDouble(txtMedicareWithheld1.Text);
            }

            if (!string.IsNullOrEmpty(txtAllocatedTips1.Text))
            {
                w21.AllocatedTipsAmount = Convert.ToDouble(txtAllocatedTips1.Text);
            }

            if (!string.IsNullOrEmpty(txtDependentCareBenefits1.Text))
            {
                w21.DependentCareBenefitsAmount = Convert.ToDouble(txtDependentCareBenefits1.Text);
            }

            if (!string.IsNullOrEmpty(txtMedicareWages1.Text))
            {
                w21.MedicareWagesAmount = Convert.ToDouble(txtMedicareWages1.Text);
            }

            tax1040.Income.W2Wages.Add(w21);


            //added
            if (!string.IsNullOrEmpty(txtStateWagesWTH1.Text))
            {
                w2StateLocalTaxInfo1.StateTaxWithholdingAmount = Convert.ToDouble(txtStateWagesWTH1.Text);
            }
            if (!string.IsNullOrEmpty(txtStateWages1.Text))
            {
                w2StateLocalTaxInfo1.StateWagesAmount = Convert.ToDouble(txtStateWages1.Text);
            }

            w21.W2StateLocalTaxInfo.Add(w2StateLocalTaxInfo1);

            //w22
            if (!string.IsNullOrEmpty(txtW22.Text))
            {
                w22.WagesAmount = Convert.ToDouble(txtW22.Text);
            }
            if (!string.IsNullOrEmpty(txtFTW2.Text))
            {
                w22.FederalTaxWithholdingAmount = Convert.ToDouble(txtFTW2.Text);
            }

            if (!string.IsNullOrEmpty(txtSocialSecurityWages2.Text))
            {
                w22.SocialSecurityWagesAmount = Convert.ToDouble(txtSocialSecurityWages2.Text);
            }

            if (!string.IsNullOrEmpty(txtSocialSecurityWithholding2.Text))
            {
                w22.SocialSecurityTaxWithholdingAmount = Convert.ToDouble(txtSocialSecurityWithholding2.Text);
            }
            ////newly added by vincent for UI Input
            if (!string.IsNullOrEmpty(txtMedicareWithheld2.Text))
            {
                w22.MedicareTaxWithholdingAmount = Convert.ToDouble(txtMedicareWithheld2.Text);
            }

            if (!string.IsNullOrEmpty(txtAllocatedTips2.Text))
            {
                w22.AllocatedTipsAmount = Convert.ToDouble(txtAllocatedTips2.Text);
            }

            if (!string.IsNullOrEmpty(txtDependentCareBenefits2.Text))
            {
                w22.DependentCareBenefitsAmount = Convert.ToDouble(txtDependentCareBenefits2.Text);
            }

            if (!string.IsNullOrEmpty(txtMedicareWages2.Text))
            {
                w22.MedicareWagesAmount = Convert.ToDouble(txtMedicareWages2.Text);
            }

            tax1040.Income.W2Wages.Add(w22);
            //added
            if (!string.IsNullOrEmpty(txtStateWagesWTH2.Text))
            {
                w2StateLocalTaxInfo2.StateTaxWithholdingAmount = Convert.ToDouble(txtStateWagesWTH2.Text);
            }
            if (!string.IsNullOrEmpty(txtStateWages2.Text))
            {
                w2StateLocalTaxInfo2.StateWagesAmount = Convert.ToDouble(txtStateWages2.Text);
            }
            w22.W2StateLocalTaxInfo.Add(w2StateLocalTaxInfo2);

            //w23
            if (!string.IsNullOrEmpty(txtW23.Text))
            {
                w23.WagesAmount = Convert.ToDouble(txtW23.Text);
            }
            if (!string.IsNullOrEmpty(txtFTW3.Text))
            {
                w23.FederalTaxWithholdingAmount = Convert.ToDouble(txtFTW3.Text);
            }


            if (!string.IsNullOrEmpty(txtSocialSecurityWages3.Text))
            {
                w23.SocialSecurityWagesAmount = Convert.ToDouble(txtSocialSecurityWages3.Text);
            }

            if (!string.IsNullOrEmpty(txtSocialSecurityWithholding3.Text))
            {
                w23.SocialSecurityTaxWithholdingAmount = Convert.ToDouble(txtSocialSecurityWithholding3.Text);
            }
            ////newly added by vincent for UI Input
            if (!string.IsNullOrEmpty(txtMedicareWithheld3.Text))
            {
                w23.MedicareTaxWithholdingAmount = Convert.ToDouble(txtMedicareWithheld3.Text);
            }

            if (!string.IsNullOrEmpty(txtAllocatedTips3.Text))
            {
                w23.AllocatedTipsAmount = Convert.ToDouble(txtAllocatedTips3.Text);
            }
            if (!string.IsNullOrEmpty(txtDependentCareBenefits3.Text))
            {
                w23.DependentCareBenefitsAmount = Convert.ToDouble(txtDependentCareBenefits3.Text);
            }

            if (!string.IsNullOrEmpty(txtMedicareWages3.Text))
            {
                w23.MedicareWagesAmount = Convert.ToDouble(txtMedicareWages3.Text);
            }


            tax1040.Income.W2Wages.Add(w23);
            //added
            if (!string.IsNullOrEmpty(txtStateWagesWTH3.Text))
            {
                w2StateLocalTaxInfo3.StateTaxWithholdingAmount = Convert.ToDouble(txtStateWagesWTH3.Text);
            }
            if (!string.IsNullOrEmpty(txtStateWages3.Text))
            {
                w2StateLocalTaxInfo3.StateWagesAmount = Convert.ToDouble(txtStateWages3.Text);
            }

            w23.W2StateLocalTaxInfo.Add(w2StateLocalTaxInfo3);

            if (!string.IsNullOrEmpty((txtw2Line11Amount.Text)))
            {
                w21.NonQualifiedPlansAmount = Convert.ToDouble(txtw2Line11Amount.Text);
            }

            //W2 Line 8B

            tax1040.Income.W2Wages[0].W2EmployerCodes = new List <W2EmployerCode>();
            var W2Emp1 = new W2EmployerCode();

            W2Emp1.EmployerCode = (EmployerCode)ddlw212a.SelectedIndex;

            if (!string.IsNullOrEmpty(txtW212aAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW212aAmount.Text);
            }
            tax1040.Income.W2Wages[0].W2EmployerCodes.Add(W2Emp1);

            W2Emp1 = new W2EmployerCode();
            W2Emp1.EmployerCode = (EmployerCode)ddlW212b.SelectedIndex;
            if (!string.IsNullOrEmpty(txtW212bAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW212bAmount.Text);
            }
            tax1040.Income.W2Wages[0].W2EmployerCodes.Add(W2Emp1);


            tax1040.Income.W2Wages[1].W2EmployerCodes = new List <W2EmployerCode>();

            W2Emp1 = new W2EmployerCode();
            W2Emp1.EmployerCode = (EmployerCode)ddlw2212a.SelectedIndex;

            if (!string.IsNullOrEmpty(txtW2212aAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW2212aAmount.Text);
            }

            tax1040.Income.W2Wages[1].W2EmployerCodes.Add(W2Emp1);

            W2Emp1 = new W2EmployerCode();
            W2Emp1.EmployerCode = (EmployerCode)ddlW2212b.SelectedIndex;

            if (!string.IsNullOrEmpty(txtW2212bAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW2212bAmount.Text);
            }
            tax1040.Income.W2Wages[1].W2EmployerCodes.Add(W2Emp1);



            tax1040.Income.W2Wages[2].W2EmployerCodes = new List <W2EmployerCode>();
            W2Emp1 = new W2EmployerCode();
            W2Emp1.EmployerCode = (EmployerCode)ddlw2312a.SelectedIndex;

            if (!string.IsNullOrEmpty(txtW2312aAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW2312aAmount.Text);
            }

            tax1040.Income.W2Wages[2].W2EmployerCodes.Add(W2Emp1);

            W2Emp1 = new W2EmployerCode();
            W2Emp1.EmployerCode = (EmployerCode)ddlW2312b.SelectedIndex;
            if (!string.IsNullOrEmpty(txtW2312bAmount.Text))
            {
                W2Emp1.Amount = Convert.ToDouble(txtW2312bAmount.Text);
            }
            tax1040.Income.W2Wages[2].W2EmployerCodes.Add(W2Emp1);


            //1099 INT
            if (!string.IsNullOrEmpty(txtIntrestIncome1.Text))
            {
                form1099Int1.InterestIncome = Convert.ToDouble(txtIntrestIncome1.Text);
            }
            if (!string.IsNullOrEmpty(txtFTWIntInc1.Text))
            {
                form1099Int1.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFTWIntInc1.Text);
            }
            //newly added by vivek from UI
            if (!string.IsNullOrEmpty(txtEarlyWithdrawalPenalty1.Text))
            {
                form1099Int1.EarlyWithdrawalPenalty = Convert.ToDouble(txtEarlyWithdrawalPenalty1.Text);
            }

            if (!string.IsNullOrEmpty(txtInvestment1.Text))
            {
                form1099Int1.InvestmentExpenses = Convert.ToDouble(txtInvestment1.Text);
            }
            if (!string.IsNullOrEmpty(txtForeignTaxPaid1.Text))
            {
                form1099Int1.ForeignTaxPaid = Convert.ToDouble(txtForeignTaxPaid1.Text);
            }
            tax1040.Income.Form1099INT.Add(form1099Int1);
            //added
            if (!string.IsNullOrEmpty(txtStateTaxWithHoldInt1.Text))
            {
                form1099IntStateInfo1.StateTaxWithholdingAmount = Convert.ToDouble(txtStateTaxWithHoldInt1.Text);

                form1099OID1.Form1099StateInfo.Add(form1099IntStateInfo1);
            }

            if (!string.IsNullOrEmpty(txtIntrestIncome2.Text))
            {
                form1099Int2.InterestIncome = Convert.ToDouble(txtIntrestIncome2.Text);
            }
            if (!string.IsNullOrEmpty(txtFTWIntInc2.Text))
            {
                form1099Int2.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFTWIntInc2.Text);
            }
            //newly added by vivek from UI
            if (!string.IsNullOrEmpty(txtEarlyWithdrawalPenalty2.Text))
            {
                form1099Int2.EarlyWithdrawalPenalty = Convert.ToDouble(txtEarlyWithdrawalPenalty2.Text);
            }

            if (!string.IsNullOrEmpty(txtInvestment2.Text))
            {
                form1099Int2.InvestmentExpenses = Convert.ToDouble(txtInvestment2.Text);
            }
            if (!string.IsNullOrEmpty(txtForeignTaxPaid2.Text))
            {
                form1099Int2.ForeignTaxPaid = Convert.ToDouble(txtForeignTaxPaid2.Text);
            }
            tax1040.Income.Form1099INT.Add(form1099Int2);

            //added

            if (!string.IsNullOrEmpty(txtStateTaxWithHoldInt2.Text))
            {
                form1099IntStateInfo2.StateTaxWithholdingAmount = Convert.ToDouble(txtStateTaxWithHoldInt2.Text);

                form1099OID1.Form1099StateInfo.Add(form1099IntStateInfo2);
            }

            //OID
            if (!string.IsNullOrEmpty(txtOID1.Text))
            {
                form1099OID1.OriginalIssueDiscount = Convert.ToDouble(txtOID1.Text);
            }
            if (!string.IsNullOrEmpty(txtFDOID1.Text))
            {
                form1099OID1.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDOID1.Text);
            }
            if (!string.IsNullOrEmpty(txtOPIOID1.Text))
            {
                form1099OID1.OtherPeriodicInterest = Convert.ToDouble(txtOPIOID1.Text);
            }
            //newly added by vivek from UI
            if (!string.IsNullOrEmpty(txtWithdrawalPenalty1.Text))
            {
                form1099OID1.EarlyWithdrawalPenalty = Convert.ToDouble(txtWithdrawalPenalty1.Text);
            }

            //10/3/14 Vincent made the changes in input text box ID
            if (!string.IsNullOrEmpty(txtMarketDiscount1.Text))
            {
                form1099OID1.IncomeMarketDiscount = Convert.ToDouble(txtMarketDiscount1.Text);
            }
            if (!string.IsNullOrEmpty(txtUSTreasury1.Text))
            {
                form1099OID1.USTreasuryObligations = Convert.ToDouble(txtUSTreasury1.Text);
            }
            if (!string.IsNullOrEmpty(txtInvestmentExpenses1.Text))
            {
                form1099OID1.InvestmentExpenses = Convert.ToDouble(txtInvestmentExpenses1.Text);
            }
            tax1040.Income.Form1099OID.Add(form1099OID1);
            //add
            if (!string.IsNullOrEmpty(txtAcquisition1.Text))
            {
                form1099OID1.AcquisitionPremium = Convert.ToDouble(txtAcquisition1.Text);
            }

            if (!string.IsNullOrEmpty(txtStateTaxWithHoldOID1.Text))
            {
                form1099OIDStateInfo1.StateTaxWithholdingAmount = Convert.ToDouble(txtStateTaxWithHoldOID1.Text);

                form1099OID1.Form1099StateInfo.Add(form1099OIDStateInfo1);
            }


            if (!string.IsNullOrEmpty(txtOID2.Text))
            {
                form1099OID2.OriginalIssueDiscount = Convert.ToDouble(txtOID2.Text);
            }
            if (!string.IsNullOrEmpty(txtFDOID2.Text))
            {
                form1099OID2.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDOID2.Text);
            }
            if (!string.IsNullOrEmpty(txtOPIOID2.Text))
            {
                form1099OID2.OtherPeriodicInterest = Convert.ToDouble(txtOPIOID2.Text);
            }

            //newly added by vivek from UI
            if (!string.IsNullOrEmpty(txtWithdrawalPenalty2.Text))
            {
                form1099OID2.EarlyWithdrawalPenalty = Convert.ToDouble(txtWithdrawalPenalty2.Text);
            }

            if (!string.IsNullOrEmpty(txtMarketDiscount2.Text))
            {
                form1099OID2.IncomeMarketDiscount = Convert.ToDouble(txtMarketDiscount2.Text);
            }
            if (!string.IsNullOrEmpty(txtUSTreasury2.Text))
            {
                form1099OID2.USTreasuryObligations = Convert.ToDouble(txtUSTreasury2.Text);
            }
            if (!string.IsNullOrEmpty(txtInvestmentExpenses2.Text))
            {
                form1099OID2.InvestmentExpenses = Convert.ToDouble(txtInvestmentExpenses2.Text);
            }
            tax1040.Income.Form1099OID.Add(form1099OID2);
            //added
            if (!string.IsNullOrEmpty(txtAcquisition2.Text))
            {
                form1099OID2.AcquisitionPremium = Convert.ToDouble(txtAcquisition2.Text);
            }

            if (!string.IsNullOrEmpty(txtStateTaxWithHoldOID2.Text))
            {
                form1099OIDStateInfo2.StateTaxWithholdingAmount = Convert.ToDouble(txtStateTaxWithHoldOID2.Text);

                form1099OID2.Form1099StateInfo.Add(form1099OIDStateInfo2);
            }

            if (!string.IsNullOrEmpty(txtOID3.Text))
            {
                form1099OID3.OriginalIssueDiscount = Convert.ToDouble(txtOID3.Text);
            }
            if (!string.IsNullOrEmpty(txtFDOID3.Text))
            {
                form1099OID3.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDOID3.Text);
            }
            if (!string.IsNullOrEmpty(txtOPIOID3.Text))
            {
                form1099OID3.OtherPeriodicInterest = Convert.ToDouble(txtOPIOID3.Text);
            }
            //newly added by vivek from UI
            if (!string.IsNullOrEmpty(txtWithdrawalPenalty3.Text))
            {
                form1099OID3.EarlyWithdrawalPenalty = Convert.ToDouble(txtWithdrawalPenalty3.Text);
            }

            if (!string.IsNullOrEmpty(txtMarketDiscount3.Text))
            {
                form1099OID3.IncomeMarketDiscount = Convert.ToDouble(txtMarketDiscount3.Text);
            }
            if (!string.IsNullOrEmpty(txtUSTreasury3.Text))
            {
                form1099OID3.USTreasuryObligations = Convert.ToDouble(txtUSTreasury3.Text);
            }
            if (!string.IsNullOrEmpty(txtInvestmentExpenses3.Text))
            {
                form1099OID3.InvestmentExpenses = Convert.ToDouble(txtInvestmentExpenses3.Text);
            }
            tax1040.Income.Form1099OID.Add(form1099OID3);
            //added
            if (!string.IsNullOrEmpty(txtAcquisition3.Text))
            {
                form1099OID3.AcquisitionPremium = Convert.ToDouble(txtAcquisition3.Text);
            }

            if (!string.IsNullOrEmpty(txtStateTaxWithHoldOID3.Text))
            {
                form1099OIDStateInfo3.StateTaxWithholdingAmount = Convert.ToDouble(txtStateTaxWithHoldOID3.Text);

                form1099OID3.Form1099StateInfo.Add(form1099OIDStateInfo3);
            }

            //..UnEmployment
            if (!string.IsNullOrEmpty(txtg1.Text))
            {
                form1099G1.UnEmploymentCompensation = Convert.ToDouble(txtg1.Text);
            }
            if (!string.IsNullOrEmpty(txtFDG1.Text))
            {
                form1099G1.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDG1.Text);
            }
            //if (!string.IsNullOrEmpty(txtAlaska1.Text))
            //{

            //    form1099G1.AlaskaPermanentFundDividend = Convert.ToDouble(txtAlaska1.Text);
            //}
            //added
            //if (!string.IsNullOrEmpty(txtStateLocalTax1.Text))
            //{

            //    form1099G1.StateOrLocalIncomeTaxRefunds = Convert.ToDouble(txtStateLocalTax1.Text);
            //}

            if (!string.IsNullOrEmpty(txtStateTaxWithHold1.Text))
            {
                form1099G1StateInfo1.StateTaxWithholdingAmount = Convert.ToDouble(txtStateTaxWithHold1.Text);
                form1099G1.Form1099StateInfo.Add(form1099G1StateInfo1);
            }


            tax1040.Income.Form1099G.Add(form1099G1);

            if (!string.IsNullOrEmpty(txtg2.Text))
            {
                form1099G2.UnEmploymentCompensation = Convert.ToDouble(txtg2.Text);
            }
            if (!string.IsNullOrEmpty(txtFDG2.Text))
            {
                form1099G2.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDG2.Text);
            }
            //if (!string.IsNullOrEmpty(txtAlaska2.Text))
            //{
            //    form1099G2.AlaskaPermanentFundDividend = Convert.ToDouble(txtAlaska2.Text);
            //}
            //added
            //if (!string.IsNullOrEmpty(txtStateLocalTax2.Text))
            //{
            //    form1099G2.StateOrLocalIncomeTaxRefunds = Convert.ToDouble(txtStateLocalTax2.Text);
            //}
            if (!string.IsNullOrEmpty(txtStateTaxWithHold2.Text))
            {
                form1099G2StateInfo2.StateTaxWithholdingAmount = Convert.ToDouble(txtStateTaxWithHold2.Text);
                form1099G2.Form1099StateInfo.Add(form1099G2StateInfo2);
            }

            tax1040.Income.Form1099G.Add(form1099G2);

            if (!string.IsNullOrEmpty(txtg3.Text))
            {
                form1099G3.UnEmploymentCompensation = Convert.ToDouble(txtg3.Text);
            }
            if (!string.IsNullOrEmpty(txtFDG3.Text))
            {
                form1099G3.FederalTaxWithHoldingAmount = Convert.ToDouble(txtFDG3.Text);
            }
            //if (!string.IsNullOrEmpty(txtAlaska3.Text))
            //{
            //    form1099G3.AlaskaPermanentFundDividend = Convert.ToDouble(txtAlaska3.Text);
            //}

            //added
            //if (!string.IsNullOrEmpty(txtStateLocalTax3.Text))
            //{
            //    form1099G3.StateOrLocalIncomeTaxRefunds = Convert.ToDouble(txtStateLocalTax3.Text);
            //}

            if (!string.IsNullOrEmpty(txtStateTaxWithHold3.Text))
            {
                form1099G3StateInfo3.StateTaxWithholdingAmount = Convert.ToDouble(txtStateTaxWithHold3.Text);
                form1099G3.Form1099StateInfo.Add(form1099G3StateInfo3);
            }

            tax1040.Income.Form1099G.Add(form1099G3);

            ////SSB

            if (!string.IsNullOrEmpty(txtNetBenefitSSB1.Text))
            {
                socialSecurityBenefit1.TaxpayerNetBenefits = Convert.ToDouble(txtNetBenefitSSB1.Text);
            }
            if (!string.IsNullOrEmpty(txtFederalWithSSB1.Text))
            {
                socialSecurityBenefit1.TaxPayerFederalTaxWithheld = Convert.ToDouble(txtFederalWithSSB1.Text);
            }

            if (!string.IsNullOrEmpty(txtNetBenefitSSB2.Text))
            {
                socialSecurityBenefit1.SpouseNetBenefits = Convert.ToDouble(txtNetBenefitSSB2.Text);
            }
            if (!string.IsNullOrEmpty(txtFederalWithSSB2.Text))
            {
                socialSecurityBenefit1.SpouseFederalTaxWithheld = Convert.ToDouble(txtFederalWithSSB2.Text);
            }
            tax1040.Income.OtherIncome.SSB = socialSecurityBenefit1;

            ////added

            //if (!string.IsNullOrEmpty(txtNetBenefitSSB2.Text))
            //{
            //    socialSecurityBenefit2.NetBenefits = Convert.ToDouble(txtNetBenefitSSB2.Text);
            //}
            //if (!string.IsNullOrEmpty(txtFederalWithSSB2.Text))
            //{
            //    socialSecurityBenefit2.FederalTaxWithholdingAmount = Convert.ToDouble(txtFederalWithSSB2.Text);
            //}
            //tax1040.Income.OtherIncome.SocialSecurityBenefits.Add(socialSecurityBenefit2);

            //if (!string.IsNullOrEmpty(txtIntrestIncome2.Text))
            //{
            //    form1099Int2.InterestIncome = Convert.ToDouble(txtIntrestIncome2.Text);
            //}

            //RRB
            // Modified By:Vincent Modified date:17/2/14
            //Comment: Made the changes in the instance and the Text box field.
            if (!string.IsNullOrEmpty(txtNetBenefitRRB1.Text))
            {
                railRoadRetirement1.TaxpayerNetBenefits = Convert.ToDouble(txtNetBenefitRRB1.Text);
            }
            if (!string.IsNullOrEmpty(txtFederalWithRRB1.Text))
            {
                railRoadRetirement1.TaxPayerFederalTaxWithheld = Convert.ToDouble(txtFederalWithRRB1.Text);
            }

            if (!string.IsNullOrEmpty(txtNetBenefitRRB2.Text))
            {
                railRoadRetirement1.SpouseNetBenefits = Convert.ToDouble(txtNetBenefitRRB2.Text);
            }
            if (!string.IsNullOrEmpty(txtFederalWithRRB2.Text))
            {
                railRoadRetirement1.SpouseFederalTaxWithheld = Convert.ToDouble(txtFederalWithRRB2.Text);
            }

            tax1040.Income.OtherIncome.RRB = railRoadRetirement1;

            //if (!string.IsNullOrEmpty(txtNetBenefitRRB2.Text))
            //{
            //    railRoadRetirement2.NetBenefits = Convert.ToDouble(txtNetBenefitRRB2.Text);
            //}
            //if (!string.IsNullOrEmpty(txtFederalWithRRB2.Text))
            //{
            //    railRoadRetirement2.FederalTaxWithholdingAmount = Convert.ToDouble(txtFederalWithRRB2.Text);
            //}
            //tax1040.Income.OtherIncome.RailroadRetirementBenefits.Add(railRoadRetirement2);

            // //form8862
            form8862.HasEICdisallowed = chkEICdisallowed.Checked;

            form8862.HasReportedIncorrectIncome = chkReportedIncorrectIncome.Checked;

            form8862.HasDaysLivedInUS = chkDaysLivedInUS.Checked;

            //Bala, 26-Jun-14, added for Testing purpose
            form8862Page1.HasReportedIncorrectIncome  = chkReportedIncorrectIncome.Checked;
            form8862Page1.HasClaimedAsQualifyingChild = chkQualifyingChild.Checked;
            form8862Page1.YearOfFiling = 2015;

            if (!string.IsNullOrEmpty(txtTaxpayer8862.Text))
            {
                form8862.DaysLivedInUS = Convert.ToInt32(txtTaxpayer8862.Text);
                form8862Page1.DaysTaxPayerLivedInUS = Convert.ToInt32(txtTaxpayer8862.Text);
            }

            if (!string.IsNullOrEmpty(txtspouse8862.Text))
            {
                form8862.DaysSpouseLivedInUS      = Convert.ToInt32(txtspouse8862.Text);
                form8862Page1.DaysSpouseLivedInUS = Convert.ToInt32(txtspouse8862.Text);
            }
            tax1040.Income.Form8862 = form8862;

            tax1040.PersonalDetails = new PersonalDetails();
            tax1040.PersonalDetails.PrimaryTaxPayer        = new PrimaryTaxPayer();
            tax1040.PersonalDetails.PrimaryTaxPayer.Person = new Person();
            tax1040.PersonalDetails.PrimaryTaxPayer.Person.HasClaimedAsDependent = chkHasClaimedAsDependentTP.Checked;

            tax1040.PersonalDetails.PrimaryTaxPayer.Person.FirstName = "Primary Tax Payer.";
            tax1040.PersonalDetails.PrimaryTaxPayer.Person.SSN       = "22-344-1234";

            //Primary Tax Payer DOB
            if (!string.IsNullOrEmpty(txtPrimaryTaxPayerDOB.Text))
            {
                tax1040.PersonalDetails.PrimaryTaxPayer.Person.DateOfBirth =
                    Convert.ToDateTime(txtPrimaryTaxPayerDOB.Text);
            }
            //Date of death
            if (!string.IsNullOrEmpty(txtTpDateOfDeath.Text))
            {
                tax1040.PersonalDetails.PrimaryTaxPayer.Person.DateOfDeath =
                    Convert.ToDateTime(txtTpDateOfDeath.Text);
            }

            tax1040.PersonalDetails.PrimaryTaxPayer.FilingStatus = (FilingStatus)ddlFilingStatus.SelectedIndex;
            tax1040.PersonalDetails.Spouse        = new Spouse();
            tax1040.PersonalDetails.Spouse.Person = new Person();

            //Spouse Tax Payer DOB
            if (!string.IsNullOrEmpty(txtSpouseDOB.Text))
            {
                tax1040.PersonalDetails.Spouse.Person.DateOfBirth = Convert.ToDateTime(txtSpouseDOB.Text);
            }

            //Spouse Date of death
            if (!string.IsNullOrEmpty(txtSpouseDateOfDeath.Text))
            {
                tax1040.PersonalDetails.Spouse.Person.DateOfDeath = Convert.ToDateTime(txtSpouseDateOfDeath.Text);
            }
            tax1040.PersonalDetails.Spouse.Person.HasClaimedAsDependent = chkHasClaimedAsDependentS.Checked;

            //EIC
            tax1040.Credits     = new Credits();
            tax1040.Credits.EIC = new EIC();
            tax1040.Credits.EIC.IsInUSMorethanHalfYear               = chkLivedInUSStatus.Checked;
            tax1040.Credits.EIC.HasValidSSN                          = chkVaildSSN.Checked;
            tax1040.Credits.EIC.HasClaimedAsQualifyingChild          = chkQualifyingChild.Checked;
            tax1040.Credits.EIC.HasReceivedIRSNoticeOnEICNotEligible = chkIRSNotice.Checked;
            tax1040.Credits.EIC.HasReceivedIRSNoticeOnFiling8862     = chkIRSFiling8862.Checked;
            if (!string.IsNullOrEmpty(txtTaxableScholarshipAmount.Text))
            {
                tax1040.Credits.EIC.TaxableScholarshipCredit = Convert.ToDouble(txtTaxableScholarshipAmount.Text);
            }

            if (!string.IsNullOrEmpty(txtPensionPlansAmount.Text))
            {
                tax1040.Credits.EIC.PensionAnnuity = Convert.ToDouble(txtPensionPlansAmount.Text);
            }

            if (!string.IsNullOrEmpty(txtPenalInstitutionAmount.Text))
            {
                tax1040.Credits.EIC.PenalInstitutionInmateWages = Convert.ToDouble(txtPenalInstitutionAmount.Text);
            }
            //Account
            //25Jul2014 Sathish as discussed moved IRS to federal filing
            tax1040.Filing = new Filing();
            tax1040.Filing.FederalFiling                 = new FederalFiling();
            tax1040.Filing.FederalFiling.IRS             = new IRS();
            tax1040.Filing.FederalFiling.IRS.BankDetails = new BankDetails();
            tax1040.Filing.FederalFiling.IRS.BankDetails.AccountNumber        = "12345678901234567";
            tax1040.Filing.FederalFiling.IRS.BankDetails.RoutingTransitNumber = "123456789";

            tax1040.ThirdPartyDesignee                  = new ThirdPartyDesignee();
            tax1040.PaidTaxReturnPreparers              = new PaidTaxReturnPreparers();
            tax1040.PaidTaxReturnPreparers.Firm         = new Organization();
            tax1040.PaidTaxReturnPreparers.Firm.Address = new Address();
            tax1040.PaidTaxReturnPreparers.Firm.Address.CompanyAddress = new CompanyAddress();
            tax1040.ThirdPartyDesignee.PIN          = "12345";
            tax1040.ThirdPartyDesignee.DesigneeName = "CHARLES";
            tax1040.ThirdPartyDesignee.PhoneNumber  = "1234556767";

            //spouse
            tax1040.PersonalDetails.Spouse.Person.SSN = "123456";
            tax1040.PaidTaxReturnPreparers.PTIN       = "PIN";
            tax1040.PaidTaxReturnPreparers.Date       = DateTime.Now;
            tax1040.PaidTaxReturnPreparers.Firm.Name  = "JEEVAN";
            tax1040.PaidTaxReturnPreparers.Firm.Address.CompanyAddress.District = "NEY JERSY";
            tax1040.PaidTaxReturnPreparers.Firm.EIN = "EIN";
            //tax1040.PaidTaxReturnPreparers.Firm.ControlNumber = 1234567;

            tax1040.ThirdPartyDesignee.PhoneNumber = "123456789";

            //var errorMessage = messageRepository.GetErrorMessages();
            var errorMessage = HttpRuntime.Cache["ErrorMessageCollection"] as Dictionary <string, ErrorMessage>;
            //Converting dictionary
            var errorMessages = new ErrorMessages(errorMessage);

            tax1040.ErrorMessages = new List <ErrorMessage>();
            dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();

            // Added to check the Worksheet Bindings
            tax1040.OutputForms = new OutputForms();
            //tax1040.OutputForms.Tax1040EZPage1 = new Tax1040EZPage1();
            //var tax1040EZPage1 = new Tax1040EZPage1();
            //tax1040EZPage1.TotalWages = 10000;
            //tax1040EZPage1.AdjustedGrossIncome = 15500;
            //tax1040EZPage1.TaxableInterest = 1000;
            //tax1040EZPage1.TEI = 200;
            //tax1040EZPage1.UnemploymentCompensation = 400;
            //tax1040.OutputForms.Tax1040EZPage1 = tax1040EZPage1;
            tax1040.OutputForms.Tax8862Page1 = form8862Page1;

            input.Tax1040Object = tax1040;

            input.ErrorMessages = errorMessages;
            // pass it to the activity no need to cast it
            //var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new Tax1040WorkFlow.WorkFlow.Activities.F1040EZLineByLineCalculation(), input));
            //As

            var output = input;


            // Added to check the Worksheet Bindings
            //var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new Tax1040WorkFlow.WorkFlow.F1040EZStandardDeduction(), input));
            //var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new Tax1040WorkFlow.WorkFlow.Activities.Form1040EZSSBEligiblity(), input));
            //var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new Tax1040WorkFlow.WorkFlow.Activities.F1040EZEarnedIncomeCreditCalculation(), input));
            if (tax1040.ErrorMessages != null && tax1040.ErrorMessages.Any())
            {
                foreach (var message in tax1040.ErrorMessages)
                {
                    ValidationError.Display(message.ErrorType + " : " + message.ErrorText);
                }

                lblError.Visible = true;

                //TODO:Have to Handle in later.

                //if (!tax1040.ErrorMessages.Any(er => er.ErrorType == Constants.ErrorTypes.ERROR))
                //{
                //    Generate1040EZForm(output);
                //}
            }
            else
            {
                Generate1040EZForm(output);
            }

            Generate1040EZForm(output);
        }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="taxReturnData"></param>
        /// <returns></returns>
        public Tuple <long, bool> PersistTaxesAndWrapUpData(long userId, TaxReturnData taxReturnData)
        {
            Tuple <long, bool> userData = null;

            try
            {
                JTL.Tax1040.BusinessObject.Tax1040 taxObject;

                //Retrieving TaxObject from database
                taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userId, taxReturnData.UserDataId);


                //28May2014 Sathish Creat person if person detail not updated. Used in federal tax and wrap up work flow for line 10 calc.
                if (taxObject == null || taxObject.PersonalDetails == null || taxObject.PersonalDetails.PrimaryTaxPayer == null)
                {
                    if (taxObject == null)
                    {
                        taxObject = new BusinessObject.Tax1040()
                        {
                            PersonalDetails = new PersonalDetails()
                            {
                                PrimaryTaxPayer = new PrimaryTaxPayer()
                                {
                                    FilingStatus = FilingStatus.Single,
                                    Person       = new Person()
                                }
                            }
                        }
                    }
                    ;

                    if (taxObject.PersonalDetails == null)
                    {
                        taxObject.PersonalDetails = new PersonalDetails()
                        {
                            PrimaryTaxPayer = new PrimaryTaxPayer()
                            {
                                FilingStatus = FilingStatus.Single,
                                Person       = new Person()
                            }
                        };
                    }

                    if (taxObject.PersonalDetails.PrimaryTaxPayer == null)
                    {
                        taxObject.PersonalDetails.PrimaryTaxPayer = new PrimaryTaxPayer()
                        {
                            FilingStatus = FilingStatus.Single,
                            Person       = new Person()
                        };
                    }

                    Tuple <long, bool> userDataId = personalInfoRepository.PersistPrimaryTaxPayer(taxObject.PersonalDetails.PrimaryTaxPayer, userId, taxReturnData.UserDataId, Constants.TOPIC_PERSONAL_FILINGSTATUS);

                    taxReturnData.UserDataId = userDataId.Item1;

                    //Retrieving TaxObject from database
                    //26Aug2014 Sathish Get Tax object after personal info persist to get the error message list
                    taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userId, taxReturnData.UserDataId);
                }



                //Converting Json to OtherIncome by DeSerializing
                TaxesAndPenalties taxesAndPenalties = JsonConvert.DeserializeObject <TaxesAndPenalties>(taxReturnData.TaxData);

                if (taxObject != null && taxesAndPenalties != null)
                {
                    taxObject.TaxesAndPenalties = new TaxesAndPenalties();
                    taxObject.TaxesAndPenalties = taxesAndPenalties;
                }

                if (taxObject.ErrorMessages == null)
                {
                    taxObject.ErrorMessages = new List <ErrorMessage>();
                }


                // Clear the Error messages exist for this topic.
                messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_TAX_AND_WRAPUP);


                //Workflow Validation Section
                dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                input.Tax1040Object = taxObject;

                //var errorMessage = messageRepository.GetErrorMessages();
                var errorMessage  = HttpRuntime.Cache["ErrorMessageCollection"] as Dictionary <string, ErrorMessage>;
                var errorMessages = new ErrorMessages(errorMessage);
                input.ErrorMessages = errorMessages;


                //BusinessFieldValidations(otherIncome, taxObject.ErrorMessages, errorMessages);
                if (taxObject.TaxesAndPenalties != null)
                {
                    var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new TaxAndWrapUpEligibilityCheck(), input));
                    hasEligibilityDiagnostics = taxObject.ErrorMessages.Any(em => em.Topic == Constants.TOPIC_TAX_AND_WRAPUP && em.ErrorCode.StartsWith(Constants.TOPIC_TAX_AND_WRAPUP + "_ER"));

                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_REQUIRED_REFUND_DETAIL);
                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_MISSING_INCOME);
                    dynamic federalSummaryInput = new Microsoft.Activities.Extensions.WorkflowArguments();
                    federalSummaryInput.Tax1040Object = taxObject;
                    federalSummaryInput.IsTaxableIncomeExceedCheck = true;
                    federalSummaryInput.IsRefundAvailableCheck     = true;
                    federalSummaryInput.IsIncomeAndRefundAllZeros  = true;
                    federalSummaryInput.ErrorMessages = errorMessages;
                    output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(
                        WorkflowInvoker.Invoke(new FederalSummaryWithNoValidation(), federalSummaryInput));
                }

                BusinessValidation(taxObject.TaxesAndPenalties, taxObject.ErrorMessages, errorMessages);

                taxReturnData.UserDataId = Utilities.PersistTaxObject(userId, taxReturnData.UserDataId, taxObject);


                userData = new Tuple <long, bool>(taxReturnData.UserDataId, hasEligibilityDiagnostics);

                //vincent, 2-sep-14, Persist Audit information
                string description = "Persist TaxesAndWrapUpData, ClassName: {0}, Method Name: {1}";
                Utilities.PersistAuditInfo(userId, taxReturnData.UserDataId, description, this.GetType().Name, Constants.Tab_TAX_AND_WRAPUP, Constants.TOPIC_TAX_AND_WRAPUP);
            }
            catch (Exception ex)
            {
                ExceptionHandling.LogException(userId, "Class:TaxesAndWrapUpRepository,Method Name:PersistTaxesAndWrapUpData", ex);
            }
            return(userData);
        }
        /// <summary>
        /// Delete and then Persist Form1099G.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="userDataId"></param>
        /// <param name="form1099GId"></param>
        /// <param name="errorMessageList"></param>
        public void DeleteAndPersistOtherIncome(long userId, long userDataId, OtherIncomeType otherIncomeType)
        {
            JTL.Tax1040.BusinessObject.Tax1040 taxObject;
            try
            {
                //Retrieving TaxObject from database
                taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userId, userDataId);

                //Converting Json to Form1099G by DeSerializing
                if (taxObject != null && taxObject.Income != null && taxObject.Income.OtherIncome != null)
                {
                    switch (otherIncomeType)
                    {
                    case OtherIncomeType.SocialSecurityAndRailRoadBenefits:
                        taxObject.Income.OtherIncome.SSB          = null;
                        taxObject.Income.OtherIncome.RRB          = null;
                        taxObject.Income.OtherIncome.HasSsbAndRrb = false;
                        // Clear the Error messages
                        messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_OTHER_INCOME_SSB_RRB);

                        //Vincent - 17 June, 2014 - Clear Eligibility HardStopper Errors.
                        messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_OTHER_INCOME, 0, "OtherIncome_ER2");
                        //Yogalakshmi - 2nd July 2014 - To clear the datas in SSB & RRB Worksheet when the records are deleted.
                        if (taxObject.F1040EZ != null && taxObject.F1040EZ.F1040EZWorkSheets != null &&
                            taxObject.F1040EZ.F1040EZWorkSheets.SSBWorkSheet != null)
                        {
                            taxObject.F1040EZ.F1040EZWorkSheets.SSBWorkSheet = null;
                            Utilities.PersistTaxObject(userId, userDataId, taxObject);
                        }
                        break;

                    case OtherIncomeType.AlaskaDividendIncome:
                        taxObject.Income.OtherIncome.AlaskaPermanentFundDividend = null;
                        taxObject.Income.OtherIncome.HasAlaskaPermanantFund      = false;
                        // Clear the Error messages
                        messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_OTHER_INCOME_Alaska);

                        break;

                    //Added by prasana on 15.07.2014 after Income spec update 2.3
                    case OtherIncomeType.StateTaxRefund:
                        taxObject.Income.OtherIncome.StateOrLocalIncomeTaxRefunds          = null;
                        taxObject.Income.OtherIncome.HasStateTaxRefund                     = false;
                        taxObject.Income.OtherIncome.HasStateAndLocalTaxDeductionPriorYear = false;
                        // Clear the Error messages
                        messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_OTHER_INCOME_State_And_Local);
                        break;
                    }

                    //10Jul2014 Sathish added coded to check Taxable Income Eligibility
                    dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                    input.Tax1040Object = taxObject;

                    //Obtain the List of Error Messages from DB.
                    //var errorMessagesFromDB = messageRepository.GetErrorMessages();
                    var errorMessagesFromDB = HttpRuntime.Cache["ErrorMessageCollection"] as Dictionary <string, ErrorMessage>;
                    var errorMessagesAll    = new ErrorMessages(errorMessagesFromDB);
                    //Assisn error message list into workflow input param.
                    input.ErrorMessages = errorMessagesAll;

                    //10Jul2014 Sathish added coded to check Taxable Income Eligibility
                    taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_TAXABLE_INCOME);
                    var taxableIncome = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke
                                                                                                             (new F1040EZTaxableIncomeEligibilityCheck(), input));

                    //02-Sep-2014 Bhavani Audit functionality implementation

                    var topicName = string.Empty;
                    switch (otherIncomeType)
                    {
                    case OtherIncomeType.AlaskaDividendIncome:
                        topicName = Constants.TOPIC_OTHER_INCOME_Alaska;
                        break;

                    case OtherIncomeType.StateTaxRefund:
                        topicName = Constants.TOPIC_OTHER_INCOME_State_And_Local;
                        break;

                    case OtherIncomeType.SocialSecurityAndRailRoadBenefits:
                        topicName = Constants.TOPIC_OTHER_INCOME_SSB_RRB;
                        break;
                    }
                    var description = "Delete OtherIncome: " + otherIncomeType + ", ClassName: {0}, Method Name: {1}";
                    Utilities.PersistAuditInfo(userId, userDataId, description, GetType().Name, Constants.Tab_INCOME, topicName);
                }


                //Persist latest TaxObject.
                taxReturnDataService.PersistTaxReturnData(userId, string.Empty, Utilities.ConvertTaxObjectToJSON(taxObject), string.Empty, userDataId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #14
0
        /// <summary>
        /// Get Credit Summary by UserId and UserDataId
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="userDataId"></param>
        /// <returns></returns>
        public dynamic GetCreditSummary(UserDTO userDTO)
        {
            try
            {
                BusinessObject.Tax1040 taxObject;

                //Retreiving TaxObject from database
                taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userDTO.UserId, userDTO.UserDataId);

                dynamic creditSummaryData = new ExpandoObject();
                IEnumerable <ErrorMessage> lstErrorMessages = null;
                creditSummaryData.PrimaryTaxPayerName = Constants.TAXPAYER_DEFAULT_DISPAY_NAME;
                creditSummaryData.TotalEIC            = 0;

                if (taxObject != null)
                {
                    PersonalDetails personalDetails = taxObject.PersonalDetails;

                    if (personalDetails != null)
                    {
                        if (personalDetails.PrimaryTaxPayer != null && personalDetails.PrimaryTaxPayer.Person != null)
                        {
                            if (!string.IsNullOrEmpty(personalDetails.PrimaryTaxPayer.Person.NickName))
                            {
                                creditSummaryData.PrimaryTaxPayerName = personalDetails.PrimaryTaxPayer.Person.NickName;
                            }
                            else if (!string.IsNullOrEmpty(personalDetails.PrimaryTaxPayer.Person.FirstName))
                            {
                                creditSummaryData.PrimaryTaxPayerName = personalDetails.PrimaryTaxPayer.Person.FirstName;
                            }
                        }
                    }


                    if (taxObject.ErrorMessages != null)
                    {
                        //If ErrorMessages doesn't have any object it returns count as 1 for NULL object. So removing this NULL object from the list.
                        taxObject.ErrorMessages.RemoveAll(err => err == null);

                        if (taxObject.ErrorMessages.Count > 0)
                        {
                            //Get Other Income related error messages.
                            //Vincent-17Jun2014-Checking for EIC Information calculation for EIC credits.
                            lstErrorMessages = taxObject.ErrorMessages.Where(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT && err.ErrorType.StartsWith("Information"));
                        }
                    }

                    //Vincent -18Jun2014-Added EIC Eligibility check.
                    var EICEligibility = false;
                    // 16Jul2014 Sathish commented the above code and checked EIC eligibility using work flow
                    dynamic EICEligibilityCheck = new Microsoft.Activities.Extensions.WorkflowArguments();
                    EICEligibilityCheck.Tax1040Object = taxObject;
                    Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new F1040EZEICEligibilityRuleCheckForSummary(), EICEligibilityCheck));

                    Utilities.EICEligibilityCheck(taxObject);
                    //if (lstErrorMessages != null && lstErrorMessages.ToList().Count <= 0) // 16Jul2014 Sathish EIC Eligibility fails if no error count
                    if (taxObject.Credits != null && taxObject.Credits.HasEarnedIncomeCredits.HasValue && taxObject.Credits.HasEarnedIncomeCredits.Value) // 16Jul2014 Sathish checked eic eligibility based on EIC TODO: Need to check EIC elgibility based on the flag
                    {
                        EICEligibility = taxObject.Credits.HasEarnedIncomeCredits.Value;

                        dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                        input.Tax1040Object = taxObject;

                        var output =
                            Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(
                                WorkflowInvoker.Invoke(new F1040EZEarnedIncomeCreditWithNoValidation(), input));
                        creditSummaryData.TotalEIC = output.TotalEIC;
                    }
                    else
                    {
                        //Vincent - 25 Jun 2014 - Defect 14034 - IF EIC Credits fails then in EIC Worksheeet object should be cleared.
                        //if (taxObject != null && taxObject.F1040EZ != null && taxObject.F1040EZ.F1040EZWorkSheets != null &&
                        //    taxObject.F1040EZ.F1040EZWorkSheets.EICWorkSheet != null)
                        //{
                        //    taxObject.F1040EZ.F1040EZWorkSheets.EICWorkSheet = null;
                        //    if (userDTO.UserDataId != 0)
                        //    {
                        //        Utilities.PersistTaxObject(userDTO.UserId, userDTO.UserDataId, taxObject);
                        //    }
                        //}
                        if (taxObject != null && taxObject.F1040EZ != null && taxObject.F1040EZ.F1040EZWorkSheets != null)
                        {
                            taxObject.F1040EZ.F1040EZWorkSheets.IsEICWorkSheetRequired = false;
                            if (taxObject.F1040EZ.F1040EZWorkSheets.EICWorkSheet != null)
                            {
                                taxObject.F1040EZ.F1040EZWorkSheets.EICWorkSheet = null;
                            }
                        }
                    }
                    if (userDTO.UserDataId != 0)
                    {
                        Utilities.PersistTaxObject(userDTO.UserId, userDTO.UserDataId, taxObject);
                    }
                    //Vincent-17Jun2014-Getting required field validation and Warning error message.
                    //Sathish 30Jun2014 Shown all the error message in the summary including summary and diagnotics as suggested by praveen
                    //Praveen 17 July 2014 Error Message displayed based on Error Type(Properly Shuffled)
                    creditSummaryData.ErrorMessages = taxObject.ErrorMessages.Where(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT).OrderBy(x => x.ErrorType);
                    //EIC Eligibility check data.
                    creditSummaryData.EICEligibility = EICEligibility;
                }

                //Vincent, 2-sep-14, Persist Audit information
                string description = "Get Credit Summary, ClassName: {0}, Method Name: {1}";
                Utilities.PersistAuditInfo(userDTO.UserId, userDTO.UserDataId, description, this.GetType().Name, Constants.Tab_EARNED_INCOME_CREDITS, Constants.TOPIC_EARNED_INCOME_CREDIT);

                return(creditSummaryData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #15
0
        // 18Jun2014 Sathish Return returned selected income to show or hide
        public System.Tuple <double, double, double, double, string, System.Tuple <bool, bool, bool, bool>, IEnumerable <ErrorMessage> > GetIncomeSummary(long userId, long userDataId)
        {
            double wagesAmount          = 0;
            double interestIncomeAmount = 0;
            IEnumerable <ErrorMessage> lstErrorMessages = null;
            double unemploymentCompensationAmount       = 0;
            double otherIncomeAmount = 0;
            //27Aug2014-Thileep changed nickname variable for both Firstname,Nickname are null values
            string nickName = Constants.DEFAULT_TAX_PAYER_NAME;

            bool hasW2Wages                  = false;
            bool hasInterestIncome           = false;
            bool hasUnemploymentCompensation = false;
            bool hasOtherIncome              = false;

            var taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userId, userDataId);



            //Get Nick Name.
            if (taxObject.PersonalDetails != null && taxObject.PersonalDetails.PrimaryTaxPayer != null &&
                taxObject.PersonalDetails.PrimaryTaxPayer.Person != null && taxObject.PersonalDetails.PrimaryTaxPayer.Person.NickName != null &&
                taxObject.PersonalDetails.PrimaryTaxPayer.Person.NickName != string.Empty)
            {
                nickName = taxObject.PersonalDetails.PrimaryTaxPayer.Person.NickName;
            }
            else if (taxObject.PersonalDetails != null && taxObject.PersonalDetails.PrimaryTaxPayer != null &&
                     taxObject.PersonalDetails.PrimaryTaxPayer.Person != null && taxObject.PersonalDetails.PrimaryTaxPayer.Person.FirstName != null &&
                     taxObject.PersonalDetails.PrimaryTaxPayer.Person.FirstName != string.Empty)
            {
                nickName = taxObject.PersonalDetails.PrimaryTaxPayer.Person.FirstName;
            }

            if (taxObject != null)
            {
                if (taxObject.Income != null)
                {
                    dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                    input.Tax1040Object = taxObject;
                    var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new IncomeSummaryCalculation(), input));
                    wagesAmount                    = output.TotalWagesAmount;
                    interestIncomeAmount           = output.TotalInterestIncomeAmount;
                    unemploymentCompensationAmount = output.TotalUnemploymentAmount;
                    otherIncomeAmount              = output.TotalOtherIncomeAmount;

                    hasW2Wages                  = taxObject.Income.HasW2Wages;
                    hasInterestIncome           = taxObject.Income.HasInterestIncome;
                    hasUnemploymentCompensation = taxObject.Income.HasUnemploymentCompensation;
                    hasOtherIncome              = taxObject.Income.HasOtherIncome;
                }

                //Swapnesh - 28th July, 2014 - Get ErrorMessage if exists.
                if (taxObject.ErrorMessages != null)
                {
                    //If ErrorMessages doesn't have any object it returns count as 1 for NULL object. So removing this NULL object from the list.
                    taxObject.ErrorMessages.RemoveAll(err => err == null);

                    if (taxObject.ErrorMessages.Count > 0)
                    {
                        lstErrorMessages = taxObject.ErrorMessages
                                           .Where(a => a.Tab == Constants.Tab_INCOME)
                                           .OrderBy(x => x.ErrorType).ThenBy(a => a.Topic);
                    }
                }
            }

            // 18Jun2014 Sathish Return returned selected income to show or hide
            System.Tuple <bool, bool, bool, bool> incomeSummary = new System.Tuple <bool, bool, bool, bool>
                                                                      (hasW2Wages, hasInterestIncome, hasUnemploymentCompensation, hasOtherIncome);
            return(new System.Tuple <double, double, double, double, string, System.Tuple <bool, bool, bool, bool>, IEnumerable <ErrorMessage> >(wagesAmount, interestIncomeAmount,
                                                                                                                                                 unemploymentCompensationAmount, otherIncomeAmount,
                                                                                                                                                 nickName,
                                                                                                                                                 incomeSummary,
                                                                                                                                                 lstErrorMessages));
        }
Exemple #16
0
        /// <summary>
        /// Get EIC based UserId and UserDataId
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="userDataId"></param>
        /// <returns></returns>
        public Tuple <EIC, string, bool, IEnumerable <ErrorMessage>, long, FilingStatus, Tuple <double, double, IEnumerable <ErrorMessage> > > GetEarnedIncomeCredit(UserDTO userDTO)
        {
            try
            {
                //local variable declaration.
                var taxPayerName = string.Empty;
                BusinessObject.Tax1040 taxObject;
                FilingStatus           filingStatus = FilingStatus.None;
                string primaryTaxPayerSSN = string.Empty, spouseSSN = string.Empty;
                double annualGrossIncome = 0L;
                double totalW2Wages = 0L;
                double totaltaxableScholarshipAmount = 0L, totalNonQualifiedPlansAmount = 0L;
                bool   isEicEligible = false;
                IEnumerable <ErrorMessage> taxObjectErrorList = null;
                IEnumerable <ErrorMessage> eicErrorList       = null;

                //Retreiving TaxObject from database
                taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userDTO.UserId, userDTO.UserDataId);

                //01August2014 - Added by Ashok Kumar Setting defalult filing status as Single
                if (taxObject == null || taxObject.PersonalDetails == null || taxObject.PersonalDetails.PrimaryTaxPayer == null)
                {
                    if (taxObject == null)
                    {
                        taxObject = new BusinessObject.Tax1040()
                        {
                            PersonalDetails = new PersonalDetails()
                            {
                                PrimaryTaxPayer = new PrimaryTaxPayer()
                                {
                                    FilingStatus = FilingStatus.Single,
                                    Person       = new Person()
                                }
                            }
                        }
                    }
                    ;

                    if (taxObject.PersonalDetails == null)
                    {
                        taxObject.PersonalDetails = new PersonalDetails()
                        {
                            PrimaryTaxPayer = new PrimaryTaxPayer()
                            {
                                FilingStatus = FilingStatus.Single,
                                Person       = new Person()
                            }
                        };
                    }

                    if (taxObject.PersonalDetails.PrimaryTaxPayer == null)
                    {
                        taxObject.PersonalDetails.PrimaryTaxPayer = new PrimaryTaxPayer()
                        {
                            FilingStatus = FilingStatus.Single,
                            Person       = new Person()
                        };
                    }
                    Tuple <long, bool> userDataId = personalInfoRepository.PersistPrimaryTaxPayer(taxObject.PersonalDetails.PrimaryTaxPayer, userDTO.UserId, userDTO.UserDataId);
                    userDTO.UserDataId = userDataId.Item1;

                    //Retrieving TaxObject from database
                    //26Aug2014 Sathish Get Tax object after personal info persist to get the error message list
                    taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userDTO.UserId, userDTO.UserDataId);
                }



                //Assigning Filing Status as Single if no filing status is selected.
                if (taxObject != null)
                {
                    //Get PrimaryTaxPayer  Nick / First Name.
                    if (taxObject.PersonalDetails != null)
                    {
                        if (taxObject.PersonalDetails.PrimaryTaxPayer != null)
                        {
                            //Get PrimaryTaxPayer FilingStatus.
                            filingStatus = taxObject.PersonalDetails.PrimaryTaxPayer.FilingStatus;
                            if (taxObject.PersonalDetails.PrimaryTaxPayer.Person != null)
                            {
                                primaryTaxPayerSSN = taxObject.PersonalDetails.PrimaryTaxPayer.Person.SSN;
                            }
                            if (taxObject.PersonalDetails.PrimaryTaxPayer.FilingStatus == FilingStatus.MarriedFilingJointly && taxObject.PersonalDetails.Spouse.Person != null)
                            {
                                spouseSSN = taxObject.PersonalDetails.Spouse.Person.SSN;
                            }
                        }
                        if (taxObject.ErrorMessages != null)
                        {
                            eicErrorList = taxObject.ErrorMessages.Where(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT &&
                                                                         (err.MessageType == Constants.MESSAGE_TYPE_RF || err.MessageType == Constants.MESSAGE_TYPE_V)).ToList();
                        }
                    }
                }

                // 09Jun2014 Sathish get tax payer name from common method in utilites
                taxPayerName = Utilities.GetTaxPayerFirstNameOrNickName(taxObject);

                //TODO: Saravanan N - 23rd April, 2014 - The ErrorMessage should be removed after workflow changes done. - START
                //Retrieving Error Message list from Database
                messageRepository = new MessagesRepository();
                //var errorMessage = messageRepository.GetErrorMessages();
                var errorMessage  = HttpRuntime.Cache["ErrorMessageCollection"] as Dictionary <string, ErrorMessage>;
                var errorMessages = new ErrorMessages(errorMessage);
                //TODO: Saravanan N - 23rd April, 2014 - The ErrorMessage should be removed after workflow changes done. - END

                //AGI Workflow call.
                //Invoking Business Rules Validation Workflow
                dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                input.Tax1040Object = taxObject;
                //25Jun2014 Sathish called AGI work flow with no validation to avoid error message update for the defect #TAX1040-14036
                var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new F1040EZAdjustedGrossIncomeWithNoValidation(), input));

                //Get the output value from workflow.
                if (output != null)
                {
                    annualGrossIncome             = output.AnnualGrossIncome;
                    totalW2Wages                  = output.TotalW2Wages;
                    totalNonQualifiedPlansAmount  = output.NonQualifiedPlansAmount;
                    totaltaxableScholarshipAmount = output.TaxableScholarshipAmount;
                }

                //07Jul2014 Sathish called EIC work flow to check age limit for Primary and spouse tax payer for the defect #TAX1040-14069
                //messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_EARNED_INCOME_CREDIT);
                taxObject.ErrorMessages.RemoveAll(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT && (err.MessageType == Constants.MESSAGE_TYPE_EI));
                input.ErrorMessages = errorMessages;
                output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new F1040EZEICEligibilityRuleCheck(), input));

                //Check ECI Eligiblity
                //30thJuly2014 - Added Condtions for checking Valid SSN for both taxpayer and Spouse
                //11August2014 Ashok Kumar modified EIC Eligibility Check based on EIC Information Error Messages
                //20August2014 Thileep Kumar modified Valid SSN on EIC Eligibility Check
                if (((filingStatus == FilingStatus.Single && annualGrossIncome <= Constants.EIC_SINGLE_ADJUSTED_GROSS_INCOME &&
                      !taxObject.ErrorMessages.Any(err => err.ErrorCode == Constants.EIC_INFO_TAXPAYER_AGE_LIMIT ||
                                                   err.ErrorCode == Constants.EIC_INFO_TAXPAYER_CLAIM_DEPENDENT) &&
                      (!Utilities.IsStringEmpty(primaryTaxPayerSSN) && Utilities.IsValidSSNorITIN(primaryTaxPayerSSN))) ||
                     (filingStatus == FilingStatus.MarriedFilingJointly && annualGrossIncome <= Constants.EIC_MFJ_ADJUSTED_GROSS_INCOME &&
                      !taxObject.ErrorMessages.Any(err => err.ErrorCode == Constants.EIC_INFO_TAXPAYER_AGE_LIMIT ||
                                                   err.ErrorCode == Constants.EIC_INFO_TAXPAYER_SPOUSE_AGE_LIMIT ||
                                                   err.ErrorCode == Constants.EIC_INFO_TAXPAYER_CLAIM_DEPENDENT ||
                                                   err.ErrorCode == Constants.EIC_INFO_TAXPAYER_SPOUSE_CLAIM_DEPENDENT) &&
                      (!Utilities.IsStringEmpty(primaryTaxPayerSSN) && Utilities.IsValidSSNorITIN(primaryTaxPayerSSN)) &&
                      (!Utilities.IsStringEmpty(spouseSSN) && Utilities.IsValidSSNorITIN(spouseSSN)))) &&
                    totalW2Wages > 0 && !taxObject.ErrorMessages.Any(err => err.ErrorCode == Constants.EIC_INFO_TAXPAYER_INVESTMENT_INCOME_LIMIT))
                {
                    isEicEligible = true;
                }
                else
                {
                    //Vincent - 25 Jun 2014 - Defect 14034 - IF EIC Credits fails then in EIC objects should be cleared.
                    //if (taxObject != null && taxObject.UserDataId != 0)
                    if (taxObject != null)
                    {
                        //If EIC eligbility fails in AGI calculation, Taxobject's EIC object should be cleared while loading this page.
                        //if (taxObject.Credits != null && taxObject.Credits.EIC != null)
                        //{
                        //    taxObject.Credits.EIC = null;
                        //}

                        //If EIC eligbility fails in AGI calculation, worksheet EIC object should be cleared in output form while loading this page.
                        if (taxObject.F1040EZ != null && taxObject.F1040EZ.F1040EZWorkSheets != null)
                        {
                            taxObject.F1040EZ.F1040EZWorkSheets.IsEICWorkSheetRequired = false;
                            if (taxObject.F1040EZ.F1040EZWorkSheets.EICWorkSheet != null)
                            {
                                taxObject.F1040EZ.F1040EZWorkSheets.EICWorkSheet = null;
                            }
                        }
                        //14thJuly2014 Ashok - Added for Clearing Form 8862 class and setting IsForm8862Required false when failing EIC eligibility
                        if (taxObject.Income != null)
                        {
                            taxObject.Income.IsForm8862Required = false;
                            if (taxObject.Income.Form8862 != null)
                            {
                                taxObject.Income.Form8862 = null;
                            }
                        }
                        //30July2014-Thileep Added to Get EligiblityInformation Messages in Credit Section
                        if (taxObject.ErrorMessages != null)
                        {
                            taxObject.ErrorMessages.RemoveAll(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT &&
                                                              (err.MessageType == Constants.MESSAGE_TYPE_RF || err.MessageType == Constants.MESSAGE_TYPE_V ||
                                                               err.MessageType == Constants.MESSAGE_TYPE_BR));
                            taxObjectErrorList = taxObject.ErrorMessages.Where(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT && err.MessageType == Constants.MESSAGE_TYPE_EI);
                            eicErrorList       = taxObject.ErrorMessages.Where(err => err.Topic == Constants.TOPIC_EARNED_INCOME_CREDIT &&
                                                                               (err.MessageType == Constants.MESSAGE_TYPE_RF || err.MessageType == Constants.MESSAGE_TYPE_V)).ToList();
                        }
                    }
                }
                Utilities.PersistTaxObject(userDTO.UserId, userDTO.UserDataId, taxObject);
                Tuple <double, double, IEnumerable <ErrorMessage> > wagesNonQualifiedAndTaxableScholarshipAmount =
                    new Tuple <double, double, IEnumerable <ErrorMessage> >(totalNonQualifiedPlansAmount, totaltaxableScholarshipAmount, eicErrorList);
                return(new Tuple <EIC,
                                  string,
                                  bool,
                                  IEnumerable <ErrorMessage>,
                                  long, FilingStatus,
                                  Tuple <double, double, IEnumerable <ErrorMessage> > >(
                           ((taxObject != null && taxObject.Credits != null && taxObject.Credits.EIC != null) ? taxObject.Credits.EIC : null),
                           taxPayerName,
                           isEicEligible,
                           taxObjectErrorList,
                           userDTO.UserDataId,
                           filingStatus,
                           wagesNonQualifiedAndTaxableScholarshipAmount));

                //Vincent, 2-sep-14, Persist Audit information
                string description = "Get EarnedIncomeCredit, ClassName: {0}, Method Name: {1}";
                Utilities.PersistAuditInfo(userDTO.UserId, userDTO.UserDataId, description, this.GetType().Name, Constants.Tab_EARNED_INCOME_CREDITS, Constants.TOPIC_EARNED_INCOME_CREDIT);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //Saravanan N - 20th May, 2014 - Return type altered as long.
        /// <summary>
        /// Persist Other Income.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="sessionData"></param>
        /// <param name="otherIncomeData"></param>
        /// <param name="historyData"></param>
        /// <param name="userDataId"></param>
        /// <param name="errorMessageList"></param>
        /// <returns></returns>
        public Tuple <long, bool> PersistOtherIncome(dynamic taxReturn)
        {
            long          userId        = 0;
            TaxReturnData taxReturnData = null;

            JTL.Tax1040.BusinessObject.Tax1040 taxObject = null;
            bool hasEligibilityDiagnostics = false;
            //Commented to diaplay Error Message for defect 14176
            //bool fromIncomeGateway = false;
            OtherIncome otherIncome = null;
            bool        isNew       = false;

            try
            {
                if (taxReturn != null)
                {
                    taxReturnData = JsonConvert.DeserializeObject <TaxReturnData>(taxReturn.TaxReturnData.ToString());
                    userId        = Utilities.ConvertToLong(taxReturn.userId);

                    //Retrieving TaxObject from database
                    taxObject = Utilities.GetTaxObjectByUserIdAndUserDataId(userId, taxReturnData.UserDataId);

                    //Converting Json to OtherIncome by DeSerializing
                    otherIncome = JsonConvert.DeserializeObject <OtherIncome>(taxReturnData.TaxData);

                    //Check whether this Persist call coming from OtherIncomeGateway page.
                    //fromIncomeGateway = taxReturn.fromIncomeGateway;
                }

                if (taxObject != null && otherIncome != null)
                {
                    if (taxObject.Income == null)
                    {
                        taxObject.Income = new Income();
                        isNew            = true;
                    }
                    else
                    {
                        isNew = false;
                    }
                    taxObject.Income.OtherIncome = otherIncome;
                }

                //Commented to diaplay Error Message for defect 14176
                //if (!fromIncomeGateway)
                //{
                if (taxObject.ErrorMessages == null)
                {
                    taxObject.ErrorMessages = new List <ErrorMessage>();
                }

                // Clear the Error messages
                //SSB & RRB
                messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_OTHER_INCOME_SSB_RRB);
                //Alaska
                messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_OTHER_INCOME_Alaska);
                //State & Local
                messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_OTHER_INCOME_State_And_Local);
                //Other Income for Eligibility Section
                messageRepository.ClearErrorMessages(taxObject.ErrorMessages, Constants.TOPIC_OTHER_INCOME);
                //Workflow Validation Section
                dynamic input = new Microsoft.Activities.Extensions.WorkflowArguments();
                input.Tax1040Object = taxObject;

                //var errorMessage = messageRepository.GetErrorMessages();
                var errorMessage  = HttpRuntime.Cache["ErrorMessageCollection"] as Dictionary <string, ErrorMessage>;
                var errorMessages = new ErrorMessages(errorMessage);
                input.ErrorMessages = errorMessages;

                // TODO 4-June-14 vivek Added eligibility work flow

                if (taxObject != null && taxObject.Income != null && taxObject.Income.OtherIncome != null && taxObject.Income.OtherIncome.SSB != null && taxObject.Income.OtherIncome.RRB != null)
                {
                    //Saravanan N - 1st Aug, 2014 - While user removing Box 5 (SSB & RRB) for Spouse then also this workflow has to be called. Otherwise the modification in Spouse which will be reflected in workflow only while TaxPayer Net Benefits (SSB & RRB) value exists.
                    //Vincent-16July2014-Check the SSB & RRB TaxpayerNet Benefits as NULL
                    //Checking if the SSB & RRB as value and not equal to Zero.
                    //if ((taxObject.Income.OtherIncome.SSB.TaxpayerNetBenefits != null || taxObject.Income.OtherIncome.RRB.TaxpayerNetBenefits != null))
                    //{
                    var output = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke(new
                                                                                                                         Form1040EZSSBEligibilityWithNoValidation(), input));
                    //}


                    //Saravanan N - 1st Aug, 2014 - If ER2 already exists, now the user changed Box 5 value as 0 or empty then the IsLine2SSBTaxable property in SSBWorksheet will be set False. Based on this bool variable the error message will be removed from Taxobject.
                    if (taxObject.F1040EZ != null && taxObject.F1040EZ.F1040EZWorkSheets != null && taxObject.F1040EZ.F1040EZWorkSheets.SSBWorkSheet != null && taxObject.F1040EZ.F1040EZWorkSheets.SSBWorkSheet.IsLine2SSBTaxable == false)
                    {
                        //Remoe already existing eligibility error in tax object.
                        taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.OTHERINCOME_TAXABLE_SOCIAL_SECURITY_AND_RAILROAD_BENEFITS);
                    }
                }

                BusinessFieldValidations(otherIncome, taxObject.ErrorMessages, errorMessages);



                //TODO vivek - 7-4-14 need to be change the work flow.
                var output1 = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke
                                                                                                   (new OtherIncomeBusinessRuleValidation(), input));

                //10Jul2014 Sathish added coded to check Taxable Income Eligibility
                taxObject.ErrorMessages.RemoveAll(em => em.ErrorCode == Constants.TAX_AND_WRAP_UP_TAXABLE_INCOME);
                var taxableIncome = Microsoft.Activities.Extensions.WorkflowArguments.FromDictionary(WorkflowInvoker.Invoke
                                                                                                         (new F1040EZTaxableIncomeEligibilityCheck(), input));


                //Hard Stopper Check
                hasEligibilityDiagnostics = taxObject.ErrorMessages.Any(em => em.Topic ==
                                                                        Constants.TOPIC_OTHER_INCOME && em.ErrorCode.StartsWith("OtherIncome_ER"));
                //}

                if (taxObject != null)
                {
                    taxReturnData.UserDataId = Utilities.PersistTaxObject(userId, taxReturnData.UserDataId, taxObject);
                }

                //02-Sep-2014 Bhavani Audit functionality implementation
                var description = isNew ? "Persist OtherIncome, ClassName: {0}, Method Name: {1}"
                                        : "Update OtherIncome:, ClassName: {0}, Method Name: {1}";
                Utilities.PersistAuditInfo(userId, taxReturnData.UserDataId, description, GetType().Name, Constants.Tab_INCOME, Constants.TOPIC_OTHER_INCOME);


                return(new Tuple <long, bool>(taxReturnData.UserDataId, hasEligibilityDiagnostics));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }