Ejemplo n.º 1
0
        private List <CheckingAccount> GetIntacctBankAccountIds()
        {
            if (_intacctAuth == null)
            {
                _intacctAuth = GetIntactAuth();
            }
            var debugLava           = GetAttributeValue(AttributeKey.EnableDebug);
            var checkingAccountList = new IntacctCheckingAccountList();
            var accountFields       = new List <string>();

            accountFields.Add("BANKACCOUNTID");
            accountFields.Add("BANKNAME");
            var postXml = checkingAccountList.GetBankAccountsXML(_intacctAuth, _financialBatch.Id, accountFields);

            var endpoint  = new IntacctEndpoint();
            var resultXml = endpoint.PostToIntacct(postXml);

            return(endpoint.ParseListCheckingAccountsResponse(resultXml, _financialBatch.Id));
        }
Ejemplo n.º 2
0
        protected void btnExportToIntacct_Click(object sender, EventArgs e)
        {
            if (_financialBatch != null)
            {
                if (GetAttributeValue(AttributeKey.ExportMode) == "OtherReceipt")
                {
                    //
                    // Capture ddl values as user preferences
                    //

                    SetBlockUserPreference("ReceiptAccountType", ddlReceiptAccountType.SelectedValue ?? "");
                    SetBlockUserPreference("PaymentMethod", ddlPaymentMethods.SelectedValue ?? "");
                }

                if (_intacctAuth == null)
                {
                    _intacctAuth = GetIntactAuth();
                }

                //
                // Create Intacct Journal XML and Post to Intacct
                //

                var endpoint  = new IntacctEndpoint();
                var debugLava = GetAttributeValue(AttributeKey.EnableDebug);
                var postXml   = new System.Xml.XmlDocument();

                if (GetAttributeValue(AttributeKey.ExportMode) == "JournalEntry")
                {
                    var journal = new IntacctJournal();
                    postXml = journal.CreateJournalEntryXML(_intacctAuth, _financialBatch.Id, GetAttributeValue(AttributeKey.JournalId), ref debugLava, GetAttributeValue(AttributeKey.JournalMemoLava));
                }
                else   // Export Mode is Other Receipt
                {
                    var    otherReceipt     = new IntacctOtherReceipt();
                    string bankAccountId    = null;
                    string undepFundAccount = null;
                    if (ddlReceiptAccountType.SelectedValue == "BankAccount")
                    {
                        SetBlockUserPreference("BankAccountId", ddlBankAccounts.SelectedValue ?? "");
                        bankAccountId = ddlBankAccounts.SelectedValue;
                    }
                    else
                    {
                        undepFundAccount = GetAttributeValue(AttributeKey.UndepositedFundsAccount);
                    }
                    postXml = otherReceipt.CreateOtherReceiptXML(_intacctAuth, _financialBatch.Id, ref debugLava, ( PaymentMethod )ddlPaymentMethods.SelectedValue.AsInteger(), bankAccountId, undepFundAccount, GetAttributeValue(AttributeKey.JournalMemoLava));
                }

                var resultXml = endpoint.PostToIntacct(postXml);
                var success   = endpoint.ParseEndpointResponse(resultXml, _financialBatch.Id, GetAttributeValue(AttributeKey.LogResponse).AsBoolean());

                if (success)
                {
                    var rockContext    = new RockContext();
                    var financialBatch = new FinancialBatchService(rockContext).Get(_batchId);
                    var changes        = new History.HistoryChangeList();

                    Session["IntacctDebugLava"] = debugLava;

                    //
                    // Close Batch if we're supposed to
                    //
                    if (GetAttributeValue(AttributeKey.CloseBatch).AsBoolean())
                    {
                        History.EvaluateChange(changes, "Status", financialBatch.Status, BatchStatus.Closed);
                        financialBatch.Status = BatchStatus.Closed;
                    }

                    //
                    // Set Date Exported
                    //
                    financialBatch.LoadAttributes();
                    var oldDate = financialBatch.GetAttributeValue("rocks.kfs.Intacct.DateExported");
                    var newDate = RockDateTime.Now;
                    History.EvaluateChange(changes, "Date Exported", oldDate, newDate.ToString());

                    //
                    // Save the changes
                    //
                    rockContext.WrapTransaction(() =>
                    {
                        if (changes.Any())
                        {
                            HistoryService.SaveChanges(
                                rockContext,
                                typeof(FinancialBatch),
                                Rock.SystemGuid.Category.HISTORY_FINANCIAL_BATCH.AsGuid(),
                                financialBatch.Id,
                                changes);
                        }
                    });

                    financialBatch.SetAttributeValue("rocks.kfs.Intacct.DateExported", newDate);
                    financialBatch.SaveAttributeValue("rocks.kfs.Intacct.DateExported", rockContext);
                }
            }

            Response.Redirect(Request.RawUrl);
        }
Ejemplo n.º 3
0
        protected void btnExportToIntacct_Click(object sender, EventArgs e)
        {
            if (_financialBatch != null)
            {
                //
                // Get Intacct Auth
                //

                var intacctAuth = new IntacctAuth()
                {
                    SenderId       = Encryption.DecryptString(GetAttributeValue("SenderId")),
                    SenderPassword = Encryption.DecryptString(GetAttributeValue("SenderPassword")),
                    CompanyId      = Encryption.DecryptString(GetAttributeValue("CompanyId")),
                    UserId         = Encryption.DecryptString(GetAttributeValue("UserId")),
                    UserPassword   = Encryption.DecryptString(GetAttributeValue("UserPassword")),
                    LocationId     = Encryption.DecryptString(GetAttributeValue("LocationId"))
                };

                //
                // Create Intacct Journal XML and Post to Intacct
                //

                var journal   = new IntacctJournal();
                var endpoint  = new IntacctEndpoint();
                var debugLava = GetAttributeValue("EnableDebug");

                var postXml   = journal.CreateJournalEntryXML(intacctAuth, _financialBatch.Id, GetAttributeValue("JournalId"), ref debugLava, GetAttributeValue("JournalMemoLava"));
                var resultXml = endpoint.PostToIntacct(postXml);
                var success   = endpoint.ParseEndpointResponse(resultXml, _financialBatch.Id, GetAttributeValue("LogResponse").AsBoolean());

                if (success)
                {
                    var rockContext    = new RockContext();
                    var financialBatch = new FinancialBatchService(rockContext).Get(_batchId);
                    var changes        = new History.HistoryChangeList();

                    Session["IntacctDebugLava"] = debugLava;

                    //
                    // Close Batch if we're supposed to
                    //
                    if (GetAttributeValue("CloseBatch").AsBoolean())
                    {
                        History.EvaluateChange(changes, "Status", financialBatch.Status, BatchStatus.Closed);
                        financialBatch.Status = BatchStatus.Closed;
                    }

                    //
                    // Set Date Exported
                    //
                    financialBatch.LoadAttributes();
                    var oldDate = financialBatch.GetAttributeValue("rocks.kfs.Intacct.DateExported");
                    var newDate = RockDateTime.Now;
                    History.EvaluateChange(changes, "Date Exported", oldDate, newDate.ToString());

                    //
                    // Save the changes
                    //
                    rockContext.WrapTransaction(() =>
                    {
                        if (changes.Any())
                        {
                            HistoryService.SaveChanges(
                                rockContext,
                                typeof(FinancialBatch),
                                Rock.SystemGuid.Category.HISTORY_FINANCIAL_BATCH.AsGuid(),
                                financialBatch.Id,
                                changes);
                        }
                    });

                    financialBatch.SetAttributeValue("rocks.kfs.Intacct.DateExported", newDate);
                    financialBatch.SaveAttributeValue("rocks.kfs.Intacct.DateExported", rockContext);
                }
            }

            Response.Redirect(Request.RawUrl);
        }