//------------------------------------------------------------------------------------------- protected void TransferFunds_Click(object sender, EventArgs e) { using (WeavverEntityContainer data = new WeavverEntityContainer()) { DateTime postAtDate = DateTime.UtcNow; if (DateTime.TryParse(PostAt.Text, out postAtDate)) { postAtDate = postAtDate.ToUniversalTime(); } Accounting_Accounts accountFrom = (from accounts in data.Accounting_Accounts where accounts.Id == new Guid(FromAccount.SelectedValue) select accounts).FirstOrDefault(); Accounting_Accounts accountTo = (from toAccounts in data.Accounting_Accounts where toAccounts.Id == new Guid(ToAccount.SelectedValue) select toAccounts).FirstOrDefault(); Guid transactionId = Guid.NewGuid(); Accounting_LedgerItems debitAccount1 = new Accounting_LedgerItems(); debitAccount1.OrganizationId = BasePage.SelectedOrganization.Id; debitAccount1.TransactionId = transactionId; debitAccount1.PostAt = postAtDate; debitAccount1.AccountId = accountFrom.Id; debitAccount1.LedgerType = accountFrom.LedgerType; debitAccount1.Code = CodeType.Withdrawal.ToString(); debitAccount1.Memo = String.Format("Transfer to {0}", accountTo.Name); debitAccount1.Amount = Decimal.Parse(Amount.Text) * -1.0m; data.Accounting_LedgerItems.AddObject(debitAccount1); Accounting_LedgerItems creditAccount2 = new Accounting_LedgerItems(); creditAccount2.OrganizationId = BasePage.SelectedOrganization.Id; creditAccount2.TransactionId = transactionId; creditAccount2.PostAt = postAtDate; creditAccount2.AccountId = new Guid(ToAccount.SelectedValue); creditAccount2.LedgerType = accountTo.LedgerType; creditAccount2.Code = CodeType.Deposit.ToString(); creditAccount2.Memo = String.Format("Transfer from {0}", accountFrom.Name); creditAccount2.Amount = Decimal.Parse(Amount.Text); data.Accounting_LedgerItems.AddObject(creditAccount2); data.SaveChanges(); // Response.Redirect("~/Accounting_LedgerItems/List.aspx?TransactionId=" + transactionId.ToString()); } OnDataSaved(this, EventArgs.Empty); }
//------------------------------------------------------------------------------------------- protected void MakePayment_Click(object sender, EventArgs e) { using (WeavverEntityContainer data = new WeavverEntityContainer()) { DateTime postAtDate = DateTime.UtcNow; if (DateTime.TryParse(PostAt.Text, out postAtDate)) { postAtDate = postAtDate.ToUniversalTime(); } Logistics_Organizations accountFrom = (from accounts in data.Logistics_Organizations where accounts.Id == new Guid(FromAccount.SelectedValue) select accounts).FirstOrDefault(); Accounting_Accounts accountTo = (from toAccounts in data.Accounting_Accounts where toAccounts.Id == new Guid(ToAccount.SelectedValue) select toAccounts).FirstOrDefault(); Guid transactionId = Guid.NewGuid(); Accounting_LedgerItems creditFinancialAccount = new Accounting_LedgerItems(); creditFinancialAccount.OrganizationId = SelectedOrganization.Id; creditFinancialAccount.TransactionId = transactionId; creditFinancialAccount.PostAt = postAtDate; creditFinancialAccount.AccountId = accountFrom.Id; creditFinancialAccount.LedgerType = LedgerType.Receivable.ToString(); creditFinancialAccount.Code = CodeType.Deposit.ToString(); creditFinancialAccount.Memo = String.Format("Check {0} to {1}", CheckNum.Text, accountTo.Name); creditFinancialAccount.Amount = Decimal.Parse(Amount.Text); data.Accounting_LedgerItems.AddObject(creditFinancialAccount); Accounting_LedgerItems creditReceivableAccount = new Accounting_LedgerItems(); creditReceivableAccount.OrganizationId = SelectedOrganization.Id; creditReceivableAccount.TransactionId = transactionId; creditReceivableAccount.PostAt = postAtDate; creditReceivableAccount.LedgerType = accountTo.LedgerType; creditReceivableAccount.AccountId = new Guid(ToAccount.SelectedValue); creditReceivableAccount.Code = CodeType.Payment.ToString(); creditReceivableAccount.Memo = String.Format("Check {0} from {1}", CheckNum.Text, accountFrom.Name); creditReceivableAccount.Amount = Decimal.Parse(Amount.Text); data.Accounting_LedgerItems.AddObject(creditReceivableAccount); data.SaveChanges(); Response.Redirect("~/Accounting_LedgerItems/List.aspx?TransactionId=" + transactionId.ToString()); } }
//------------------------------------------------------------------------------------------- public void OFXPreview_Click(object sender, EventArgs e) { ClearError(); using (WeavverEntityContainer data = new WeavverEntityContainer()) { Accounting_OFXSettings ofxSettings = (from x in data.Accounting_OFXSettings where x.AccountId == new Guid(OFXAccounts.SelectedValue) select x).FirstOrDefault(); if (ofxSettings != null) { Accounting_Accounts acct = (from x in data.Accounting_Accounts where x.Id == new Guid(OFXAccounts.SelectedValue) select x).FirstOrDefault(); List <Accounting_OFXLedgerItem> items = ofxSettings.GetRemoteLedgerItems(DateTime.Parse(OFXStartDate.Text), DateTime.Parse(OFXEndDate.Text)); Session["Import_Transactions"] = items; List <Accounting_LedgerItems> LedgerItemsData = new List <Accounting_LedgerItems>(); foreach (var item in items) { LedgerItemsData.Add(item.LedgerItem); } var sortedItems = LedgerItemsData.OrderByDescending(x => x.PostAt); TransactionsDetected.DataSource = sortedItems; TransactionsDetected.DataBind(); LedgerItems.Visible = true; // totals var credits = items.Where(x => x.LedgerItem.Amount > 0).Sum(x => x.LedgerItem.Amount); var debits = items.Where(x => x.LedgerItem.Amount < 0).Sum(x => x.LedgerItem.Amount); DetectedTotal.Text = items.Count.ToString(); if (credits.HasValue) { TotalCredits.Text = String.Format("{0,10:C}", credits.Value); } if (debits.HasValue) { TotalDebits.Text = String.Format("{0,10:C}", debits.Value); } } } }
protected void Page_Load(object sender, EventArgs e) { ScheduledPayments.ItemDataBound += new DataGridItemEventHandler(ScheduledPayments_ItemDataBound); WeavverMaster.FormTitle = "OFX Bill Pay"; Guid accountId = new Guid(Request["id"]); using (WeavverEntityContainer data = new WeavverEntityContainer()) { Accounting_Accounts financialAccount = (from x in data.Accounting_Accounts where x.Id == accountId select x).FirstOrDefault(); if (financialAccount.OrganizationId == LoggedInUser.OrganizationId) { Accounting_OFXSettings ofxBank = financialAccount.GetOFXSettings(); Logistics_Addresses address = null; billPayment.OFXAppId = "QWIN"; billPayment.OFXAppVersion = "1700"; billPayment.FIUrl = ofxBank.Url; billPayment.FIId = ofxBank.FinancialInstitutionId.ToString(); billPayment.FIOrganization = ofxBank.FinancialInstitutionName; billPayment.OFXUser = ofxBank.Username; billPayment.OFXPassword = ofxBank.Password; billPayment.Payment.FromBankId = ofxBank.BankId; billPayment.Payment.FromAccountId = financialAccount.AccountNumber; LedgerType lType = (LedgerType)Enum.Parse(typeof(LedgerType), financialAccount.LedgerType); billPayment.Payment.FromAccountType = Accounting_OFXSettings.ConvertWeavverLedgerTypeToEbankingAccountType(lType); billPayment.SynchronizePayments("REFRESH"); billPayment.SynchronizePayees("REFRESH"); // do these together so we can poll the info in ItemDataBound var items = from x in billPayment.SyncPayments orderby x.DateDue descending select x; ScheduledPayments.DataSource = items; ScheduledPayments.DataBind(); Payees.DataSource = billPayment.SyncPayees; Payees.DataBind(); } } }