protected void btnRemoveDateExported_Click(object sender, EventArgs e) { if (_financialBatch != null) { var rockContext = new RockContext(); var financialBatch = new FinancialBatchService(rockContext).Get(_batchId); var changes = new History.HistoryChangeList(); // // Open Batch is we Closed it // if (GetAttributeValue("CloseBatch").AsBoolean()) { History.EvaluateChange(changes, "Status", financialBatch.Status, BatchStatus.Open); financialBatch.Status = BatchStatus.Open; } // // Remove Date Exported // financialBatch.LoadAttributes(); var oldDate = financialBatch.GetAttributeValue("rocks.kfs.ShelbyFinancials.DateExported").AsDateTime().ToString(); var newDate = string.Empty; History.EvaluateChange(changes, "Date Exported", oldDate, newDate); // // 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.ShelbyFinancials.DateExported", newDate); financialBatch.SaveAttributeValue("rocks.kfs.ShelbyFinancials.DateExported", rockContext); } Response.Redirect(Request.RawUrl); }
/// <summary> /// Handles the Click event of the lbDownload control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void lbDownload_Click(object sender, EventArgs e) { var parameters = RockPage.PageParameters(); var records = GLRecordsForBatch(_batch, dpDate.SelectedDate.Value, tbAccountingPeriod.Text.Trim(), tbJournalType.Text.Trim()); if (!UserCanEdit) { return; } // // Update the batch to reflect that it has been exported. // using (var rockContext = new RockContext()) { FinancialBatch batch = new FinancialBatchService(rockContext).Get(_batch.Id); batch.LoadAttributes(); batch.SetAttributeValue("GLExported", "true"); batch.SaveAttributeValues(rockContext); IsExported = 1; rockContext.SaveChanges(); } // // Send the results as a CSV file for download. // Page.EnableViewState = false; Page.Response.Clear(); Page.Response.ContentType = "text/plain"; Page.Response.AppendHeader("Content-Disposition", "attachment; filename=GLTRN2000.txt"); Page.Response.Write(string.Join("\r\n", records.Select(r => r.ToString()).ToArray())); Page.Response.Flush(); Page.Response.End(); }
protected void btnExportToShelbyFinancials_Click(object sender, EventArgs e) { Session["JournalType"] = ddlJournalType.SelectedValue; Session["AccountingPeriod"] = tbAccountingPeriod.Text; if (_financialBatch != null) { var rockContext = new RockContext(); var sfJournal = new SFJournal(); var journalCode = ddlJournalType.SelectedValue; var period = tbAccountingPeriod.Text.AsInteger(); var debugLava = GetAttributeValue("EnableDebug"); var items = sfJournal.GetGLExcelLines(rockContext, _financialBatch, journalCode, period, ref debugLava, GetAttributeValue("JournalDescriptionLava")); if (items.Count > 0) { var excel = sfJournal.GLExcelExport(items); Session["ShelbyFinancialsExcelExport"] = excel; Session["ShelbyFinancialsFileId"] = _financialBatch.Id.ToString(); Session["ShelbyFinancialsDebugLava"] = debugLava; // // vars we need to know // var financialBatch = new FinancialBatchService(rockContext).Get(_batchId); var changes = new History.HistoryChangeList(); // // 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.ShelbyFinancials.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.ShelbyFinancials.DateExported", newDate); financialBatch.SaveAttributeValue("rocks.kfs.ShelbyFinancials.DateExported", rockContext); } } Response.Redirect(Request.RawUrl); }
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); }
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); }
protected void btnExportToFinancialEdge_Click(object sender, EventArgs e) { if (_financialBatch != null) { var rockContext = new RockContext(); var feJournal = new FEJournal(); var items = feJournal.GetGlEntries(rockContext, _financialBatch, GetAttributeValue("JournalType")); if (items.Count > 0) { // // Set session for export file // feJournal.SetFinancialEdgeSessions(items, _financialBatch.Id.ToString()); // // vars we need now // var financialBatch = new FinancialBatchService(rockContext).Get(_batchId); var changes = new History.HistoryChangeList(); // // 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.FinancialEdge.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.FinancialEdge.DateExported", newDate); financialBatch.SaveAttributeValue("rocks.kfs.FinancialEdge.DateExported", rockContext); } } Response.Redirect(Request.RawUrl); }