protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["LedgerType"] == null)
          {
               Visible = false;
               return;
          }

          TextBox dateStart = BasePage.FindControlR<TextBox>("txbDateFrom");
          TextBox dateEnd = BasePage.FindControlR<TextBox>("txbDateThrough");

          Guid accountId = Guid.Empty;
          Guid.TryParse(Request["AccountId"], out accountId);
          if (accountId != Guid.Empty)
          {
               using (WeavverEntityContainer data = new WeavverEntityContainer())
               {
                    string ledgerType = Request["LedgerType"];
                    DateTime? startAt = null;
                    DateTime startAt2;
                    DateTime? endAt = null;
                    DateTime endAt2;

                    if (DateTime.TryParse(dateStart.Text, out startAt2))
                         startAt = startAt2;

                    if (DateTime.TryParse(dateEnd.Text, out endAt2))
                         endAt = endAt2;

                    string x = data.GetName(Guid.Empty);
                    decimal credits = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, false, false, null, null);
                    decimal debits = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, false, true, false, null, null);
                    decimal balance = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, true, false, null, null);
                    FundsIn.Text = String.Format("{0,10:C}", credits);
                    FundsOut.Text = String.Format("{0,10:C}", debits);
                    Balance.Text = String.Format("{0,10:C}", balance);

                    AvailableBalance.Text = String.Format("{0,10:C}", data.Total_ForLedger(BasePage.SelectedOrganization.OrganizationId, accountId, ledgerType, true, true, true, null, null));

                    if (startAt != null || endAt != null)
                    {
                         FilteredTotals.Visible = true;

                         decimal filteredStartingBalance = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, true, true, null, startAt);
                         decimal filteredCredits = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, false, true, startAt, endAt);
                         decimal filteredDebits = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, false, true, true, startAt, endAt);
                         decimal filteredBalance = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, true, true, startAt, endAt);
                         decimal filteredEndingBalance = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, true, true, null, endAt);

                         VisibleStartingBalance.Text = String.Format("{0,10:C}", filteredStartingBalance);
                         VisibleCredits.Text = String.Format("{0,10:C}", filteredCredits);
                         VisibleDebits.Text = String.Format("{0,10:C}", filteredDebits);
                         VisibleBalance.Text = String.Format("{0,10:C}", filteredBalance);
                         VisibleEndingBalance.Text = String.Format("{0,10:C}", filteredEndingBalance);

                         VisibleAvailableBalance.Text = String.Format("{0,10:C}", data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, true, true, startAt, endAt));
                    }
              }
         }
    }
Example #2
0
        //-------------------------------------------------------------------------------------------
        private void ImportEmails(Communication_EmailAccounts account)
        {
            Console.WriteLine("Importing e-mails for " + account.Id + " -- " + account.Host);
               using (Pop3Client client = new Pop3Client())
               {
                    // connect
                    client.Connect(account.Host, account.Port, (account.Type == "pops"));
                    client.Authenticate(account.Username, account.Password);

                    // iterate over the messages
                    int messageCount = client.GetMessageCount();
                    List<Message> allMessages = new List<Message>(messageCount);
                    for (int i = 1; i <= messageCount; i++)
                    {
                         using (WeavverEntityContainer data = new WeavverEntityContainer())
                         {
                              //data.SearchAllTables("asdf");
                              // save to database
                              Message m = (Message) client.GetMessage(i);
                              if (m.MessagePart.IsText)
                              {
                                   Communication_Emails item = new Communication_Emails();
                                   item.From = m.Headers.From.Raw;
                                   item.Subject = m.Headers.Subject;
                                   item.Raw = System.Text.ASCIIEncoding.ASCII.GetString(m.RawMessage);
                                   data.SaveChanges();

                                   client.DeleteMessage(i);
                              }
                         }
                    }
               }
        }
    //-------------------------------------------------------------------------------------------
    protected void LedgerItemAdd_Click(object sender, EventArgs e)
    {
        //List.ShowFooter = true;
          //List.EditItemIndex = List.Items.Count;
          LedgerType ledgerType = (LedgerType)Enum.Parse(typeof(LedgerType), Request["ledgertype"], true);

          using (WeavverEntityContainer data = new WeavverEntityContainer())
          {
               Accounting_LedgerItems item = new Accounting_LedgerItems();
               item.Id = Guid.NewGuid();
               item.OrganizationId = BasePage.SelectedOrganization.Id;
               item.LedgerType = ledgerType.ToString();
               item.Code = ((CodeType)Enum.Parse(typeof(CodeType), CodeTypeList.SelectedValue, true)).ToString();
               item.PostAt = DateTime.Parse(LedgerItemPostAt.Text).ToUniversalTime();
               item.AccountId = new Guid(Request["AccountId"]);
               item.Memo = LedgerItemName.Text;
               item.Amount = Decimal.Parse(LedgerItemAmount.Text);

               data.Accounting_LedgerItems.AddObject(item);

               try
               {
                    data.SaveChanges();
                    ErrorMsg.Text = "";

                    OnDataSaved(this, EventArgs.Empty);
               }
               catch (IValidatorException ex)
               {
                    ErrorMsg.Text = ex.Message;
               }
          }
    }
Example #4
0
 //-------------------------------------------------------------------------------------------
 public string GetName(Guid nameId)
 {
     using (WeavverEntityContainer data = new WeavverEntityContainer())
       {
            return data.GetName(nameId);
       }
 }
        //-------------------------------------------------------------------------------------------
        public int BillAccount(Guid recurringBillableId)
        {
            using (WeavverEntityContainer data = new WeavverEntityContainer())
               {
                    Accounting_RecurringBillables billable = (from x in data.Accounting_RecurringBillables
                                                              where x.Id == recurringBillableId
                                                              select x).First();

                    if (billable.Status == "Enabled")
                    {
                         int unbilledPeriods = billable.UnbilledPeriods.Value;
                         var billables = billable.ProjectLedgerItems(unbilledPeriods);
                         foreach (var item in billables)
                         {
                              data.Accounting_LedgerItems.Add(item);
                         }
                         // we have to convert it to local time first! or there will have some weird bug where 11/01/11 goes to 11/30/11 instead of 12/01/11
                         billable.Position = billable.Position.ToLocalTime().AddMonths(unbilledPeriods).ToUniversalTime();

                         if (billable.EndAt.HasValue && billable.Position > billable.EndAt.Value)
                              billable.Status = "Disabled";

                         data.SaveChanges();
                         return billables.Count;
                    }
                    else
                    {
                         return 0;
                    }
               }
        }
    //-------------------------------------------------------------------------------------------
    public void UpdateTotals()
    {
        using (WeavverEntityContainer data = new WeavverEntityContainer())
          {
               foreach (DataGridItem dataitem in List.Items)
               {
                    Guid key = (Guid)List.DataKeys[dataitem.ItemIndex];
                    foreach (Sales_ShoppingCartItems item in ShoppingCart.Items)
                    {
                         if (item.Id == key)
                         {
                              int quantity = item.Quantity;
                              TextBox tbQuantity = (TextBox) dataitem.Cells[1].Controls[0];
                              Int32.TryParse(tbQuantity.Text, out quantity);
                              bool changed = false;

                              if (quantity == 0)
                              {
                                   data.Sales_ShoppingCartItems.Attach(item);
                                   ShoppingCart.Items.Remove(item);
                                   data.Sales_ShoppingCartItems.DeleteObject(item);
                                   continue;
                              }
                              else if (quantity != item.Quantity)
                              {
                                   data.Sales_ShoppingCartItems.Attach(item);
                                   item.Quantity = quantity;
                              }
                         }
                    }
               }
               data.SaveChanges();
          }
    }
    //-------------------------------------------------------------------------------------------
    public void UpdatePage()
    {
        using (WeavverEntityContainer data = new WeavverEntityContainer())
          {
               decimal balance = data.Total_ForLedger(SelectedOrganization.Id, LoggedInUser.OrganizationId, LedgerType.Receivable.ToString(), true, true, false, null, null);

               // data.Total_ForLedger(LoggedInUser.OrganizationId);

               var cards = (from items in data.Accounting_CreditCards
                            where items.OrganizationId == SelectedOrganization.Id
                            select items);

               CreditCards.DataSource = cards;
               CreditCards.DataTextField = "CensoredAccountNumber";
               CreditCards.DataValueField = "Id";
               CreditCards.DataBind();

               if (balance < 0)
               {
                    decimal amount = balance * -1;
                    MinimumPaymentDue.Text = "$" + amount.ToString();
                    Balance.Text = "$" + amount.ToString();
                    PayBalanceAmount.Text = "$" + amount.ToString();
               }
          }
    }
Example #8
0
 //-------------------------------------------------------------------------------------------
 public decimal CalculateMonthlyTotal()
 {
     decimal cost = 0;
        foreach (Control ctrl in UpdatePanel1.ContentTemplateContainer.FindControl("OrderFormControls").Controls)
        {
             if (ctrl.GetType() == typeof(DropDownList))
             {
                  DropDownList ddl = (DropDownList)ctrl;
                  //DropDownList ddl = (DropDownList) UpdatePanel1.ContentTemplateContainer.FindControl("OrderForm").FindControl("feature-" + i.ToString());
                  if (ddl != null)
                  {
                       Guid featureOptionId;
                       Guid.TryParse(ddl.SelectedValue, out featureOptionId);
                       using (WeavverEntityContainer data = new WeavverEntityContainer())
                       {
                            Logistics_FeatureOptions option = (from x in data.Logistics_FeatureOptions
                                                              where x.Id == featureOptionId
                                                              select x).First();
                            if (option != null && option.BillingType == FeatureBillingType.Monthly.ToString())
                            {
                                 cost += option.Cost;
                            }
                       }
                  }
             }
        }
        return cost + item.UnitMonthly;
 }
 //-------------------------------------------------------------------------------------------
 public string AgreementText()
 {
     using (WeavverEntityContainer data = new WeavverEntityContainer())
       {
            Legal_Agreements agreement = (from x in data.Legal_Agreements
                                          where x.Id == new Guid("a618950e-db72-46ac-afd9-47693caabb96")
                                          select x).First();
            return agreement.Body;
       }
 }
Example #10
0
        //-------------------------------------------------------------------------------------------
        public void RunCronTasks(CommandLineArguments args)
        {
            Console.WriteLine("Starting to import e-mails..");
               using (WeavverEntityContainer entity = new WeavverEntityContainer())
               {
                    var accounts = from x in entity.Communication_EmailAccounts
                                   select x;

                    accounts.ToList().ForEach(account => ImportEmails(account));
               }
        }
Example #11
0
        //-------------------------------------------------------------------------------------------
        private Accounting_OFXSettings GetOFXSampleObj()
        {
            using (WeavverEntityContainer data = new WeavverEntityContainer())
               {
                    Guid testObjectId = new Guid(Helper.GetAppSetting("accounting_ofxsettings_testobjectid"));
                    var ofxSettings = (from x in data.Accounting_OFXSettings
                                        where x.Id == testObjectId
                                        select x).FirstOrDefault();

                    data.Entry(ofxSettings).State = System.Data.Entity.EntityState.Detached;

                    Assert.IsNotNull(ofxSettings, "could not get the ofx testing object");

                    return ofxSettings;
               }
        }
Example #12
0
        //
        //if (System.IO.File.Exists(filePath))
        //{
        //     html = String.Format("<a href=\"/images/about/{0}.jpg\"><img alt=\"Picture of {1} {2}\" border=\"0\" src=\"/images/about/{0}.jpg\" style=\"float: right; width: 120px; margin-right: 0px; padding: 10px;\" /></a>", emp.Username, emp.FirstName, emp.LastName);
        //}
        //return html;
        //-------------------------------------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        /// <param name="personId"></param>
        /// <returns>An empty Guid of if the person is not punched in. Or the Guid of the TimeLog.</returns>
        public bool IsPunchedIn()
        {
            using (WeavverEntityContainer data = new WeavverEntityContainer())
               {
                    var timeLog = (from x in data.HR_TimeLogs
                                  where (x.OrganizationId == OrganizationId &&
                                  x.PersonId == Id &&
                                  x.End != null)
                                  select x).First();

                    if (timeLog != null)
                    {
                         return true;
                    }
                    return false;
               }
        }
    //-------------------------------------------------------------------------------------------
    protected void Page_Load(object sender, EventArgs e)
    {
        IsPublic = false;
          Master.FormTitle = "Account Payment";
          Master.FormDescription = "Use this tool to make payments or add funds to your account.";
          Master.FixedWidth = true;

          using (WeavverEntityContainer data = new WeavverEntityContainer())
          {

          }

          if (!IsPostBack)
          {
               UpdatePage();
          }
    }
    //-------------------------------------------------------------------------------------------
    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);
    }
Example #15
0
    //-------------------------------------------------------------------------------------------
    public void UpdatePage()
    {
        using (WeavverEntityContainer data = new WeavverEntityContainer())
          {

               List.DataKeyField = "Id";
               List.DataSource = ShoppingCart.Items;
               List.DataBind();

               decimal deposit = ShoppingCart.DepositTotal;
               decimal monthly = ShoppingCart.MonthlyTotal;
               decimal setup = ShoppingCart.SetUpTotal;

               SetUp.Visible = (setup > 0);
               SetUpTotal.Text = String.Format("{0,10:C}", setup);
               Monthly.Visible = (monthly > 0);
               CartMonthly.Text = String.Format("{0,10:C}", monthly);
               Deposits.Visible = (deposit > 0);
               DepositTotal.Text = String.Format("{0,10:C}", deposit);
               CartTotal.Text = String.Format("{0,10:C}", ShoppingCart.Total);

               if (ShoppingCart.Items.Count == 0)
               {
                    btnOrder.ImageUrl = "~/images/sales/checkout-disabled.png";
                    btnOrder.Enabled = false;
                    TotalUpdate.Visible = false;
               }
               else
               {
                    TotalUpdate.Visible = true;
                    btnOrder.ImageUrl = "~/images/sales/checkout.png";
                    btnOrder.Enabled = true;
               }

               var policy = (from x in data.CMS_Pages
                             where x.Title == "Sales/Store Policy" &&
                                   x.OrganizationId == SelectedOrganization.Id
                             select x).FirstOrDefault();

               if (policy != null)
               {
                    StorePolicy.Text = policy.Page;
               }
          }
    }
    //-------------------------------------------------------------------------------------------
    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());
          }
    }
Example #17
0
        //-------------------------------------------------------------------------------------------
        protected void Page_PreInit(object sender, EventArgs e)
        {
            Guid pageId = Guid.Empty;
               if (Guid.TryParse(Request["id"], out pageId))
               {
                    using (WeavverEntityContainer data = new WeavverEntityContainer())
                    {
                         var page = (from x in data.CMS_Pages
                                     where x.Id == pageId
                                     select x).FirstOrDefault();

                         if (File.Exists(Server.MapPath(page.MasterPage)))
                         {
                              this.MasterPageFile = page.MasterPage;
                         }
                    }
               }
        }
Example #18
0
    //-------------------------------------------------------------------------------------------
    protected void Next_Click(object sender, EventArgs e)
    {
        if (Entry.Text == "")
          {
               Directions.ForeColor = System.Drawing.Color.Red;
               return;
          }
          if (Directions.Text.EndsWith(steptwo))
          {
               string userCode = Session["UserCode"].ToString();
               string passcode = Entry.Text;

               WeavverEntityContainer data = new WeavverEntityContainer();
               var user = (from x in data.System_Users
                           where x.OrganizationId == SelectedOrganization.Id &&
                              x.UserCode == userCode &&
                              x.PassCode == passcode
                           select x
                           ).FirstOrDefault();

               if (user != null)
               {
                    //FormsAuthentication.SetAuthCookie(user.Username, true);
                    Response.Redirect("~/kiosk/kiosk2");

                    Directions.Text = "Invalid password, please start again.";
               }
               else
               {
                    ResetForm();
                    Directions.Text = "Your usercode or passcode was incorrect. Please try again.";
                    return;
               }
          }
          PhoneNumber.Style.Add("font-size", "14pt");
          PhoneNumber.Style.Add("font-weight", "bold");
          PhoneNumber.Text = Entry.Text;
          Directions.Text  = steptwo;
          Session["UserCode"] = Entry.Text;
          Directions.ForeColor = System.Drawing.Color.Black;
          Entry.Text = "";
          Entry.TextMode = TextBoxMode.Password;
          Next.Text = "Log In";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        using (WeavverEntityContainer data = new WeavverEntityContainer())
          {
               if (Request["id"] != null)
               {
                    Projection.Visible = true;

                    Guid itemId = new Guid(Request["Id"]);

                    var billable = (from x in data.Accounting_RecurringBillables
                                    where x.Id == itemId
                                    select x).FirstOrDefault();

                    if (billable != null)
                    {
                         var billables = billable.ProjectLedgerItems(24);
                         ProjectionList.ItemDataBound += new DataGridItemEventHandler(ProjectionList_ItemDataBound);
                         ProjectionList.DataSource = billables;
                         ProjectionList.DataBind();
                    }
               }
               else
               {
                    Totals.Visible = true;

                    var recurringRevenue = data.Accounting_RecurringBillables
                                             .Where(x => x.OrganizationId == BasePage.SelectedOrganization.Id)
                                             .Where(x => x.AccountTo == BasePage.SelectedOrganization.Id)
                                             .Sum(x=> (decimal?) x.Amount) ?? 0m;

                    RecurringRevenue.Text = String.Format("{0,10:C}", recurringRevenue);

                    var recurringExpenses = data.Accounting_RecurringBillables
                                             .Where(x => x.OrganizationId == BasePage.SelectedOrganization.Id)
                                             .Where(x => x.AccountFrom == BasePage.SelectedOrganization.Id)
                                             .Sum(x=> (decimal?) x.Amount) ?? 0m;

                    RecurringExpenses.Text = String.Format("{0,10:C}", recurringExpenses);

                    Net.Text = String.Format("{0,10:C}", recurringRevenue - recurringExpenses);
               }
          }
    }
    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();
               }
          }
    }
Example #21
0
        public void OnSave()
        {
            // E-mail the object creator -- Easily accessible via CreatedBy
               // E-mail anyone in the conversation thread // Except the Creator of the Message
               // E-mail person that wrote the message -- NOT

               using (WeavverEntityContainer data = new WeavverEntityContainer())
               {
                    var createdByUser = (from x in data.System_Users
                                         where x.Id == CreatedBy
                                         select x).First();

                    List<Guid> listeners = new List<Guid>();

                    MailMessage msg = new MailMessage("Weavver <*****@*****.**>", createdByUser.EmailAddress);

                    var comments = (from y in data.Communication_Messages
                                    where y.Account == Account
                                    select y);

                    foreach (var comment in comments)
                    {
                         if (!listeners.Contains(comment.CreatedBy))
                         {
                              listeners.Add(comment.CreatedBy);

                              var user = (from x in data.System_Users
                                          where x.Id == comment.CreatedBy
                                          select x).First();
                              msg.To.Add(new MailAddress(user.EmailAddress, user.FullName));
                         }
                    }

                    msg.Subject = createdByUser.FullName + " made a comment"; // on \"" + this.GetType().Name + "\"";
                    string body = "\"" + Body + "\"\r\n\r\n"
                                + "Reply via the following url:\r\n" + HttpContext.Current.Request.Url + "\r\n\r\n"
                                + "------------------------\r\nWeavver, Inc.";
                    msg.Body = body;

                    SmtpClient sClient = new System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings["smtp_address"]);
                    sClient.Send(msg);
               }
        }
        //-------------------------------------------------------------------------------------------
        public void RunCronTasks(Utilities.CommandLineArguments args)
        {
            using (WeavverEntityContainer data = new WeavverEntityContainer())
               {
                    var results = (from billables in data.Accounting_RecurringBillables
                                   where billables.Status == "Enabled" &&
                                         billables.Position <= DateTime.UtcNow
                                   select billables);

                    while (results.Count() > 0)
                    {
                         var set = results.Take<Accounting_RecurringBillables>(10);
                         foreach (Accounting_RecurringBillables billable in set)
                         {
                              billable.PushUnbilledItems();
                         }
                    }
               }
        }
    //-------------------------------------------------------------------------------------------
    protected void Page_Load(object sender, EventArgs e)
    {
        Visible = false;
          return;

          if (!Roles.IsUserInRole("Administrators") ||
              !Roles.IsUserInRole("Accountants"))
          {
               Visible = false;
               return;
          }

          if (!IsPostBack)
          {
               PostAt.Text = DateTime.Now.ToString("MM/dd/yy");

               using (WeavverEntityContainer data = new WeavverEntityContainer())
               {
                    //Guid fromGuid = new Guid(FromAccount.SelectedValue);

                    var fAccounts = (from orgs in data.Accounting_Accounts
                                        where orgs.OrganizationId == BasePage.SelectedOrganization.Id
                                        orderby orgs.Name
                                        select orgs);

                    FromAccount.DataSource = fAccounts;
                    FromAccount.DataTextField = "Name";
                    FromAccount.DataValueField = "Id";
                    FromAccount.DataBind();

                    var cAccounts = (from accounts in data.Accounting_Accounts
                                     where accounts.OrganizationId == BasePage.SelectedOrganization.Id
                                        select accounts);

                    ToAccount.DataSource = cAccounts;
                    ToAccount.DataTextField = "Name";
                    ToAccount.DataValueField = "Id";
                    ToAccount.DataBind();
               }
          }
    }
Example #24
0
    //-------------------------------------------------------------------------------------------
    protected void Page_Load(object sender, EventArgs e)
    {
        using (WeavverEntityContainer data = new WeavverEntityContainer())
          {
               SkeletonPage sPage = (SkeletonPage) Page;

               if (sPage.SelectedOrganization.BillingAddress.HasValue)
               {
                    var orgAddress = (from addy in data.Logistics_Addresses
                                      where addy.OrganizationId == sPage.SelectedOrganization.Id &&
                                      addy.Id == sPage.SelectedOrganization.BillingAddress.Value
                                      select addy).First();

                    OrgAddress.Text = orgAddress.ToString().Replace("\r\n", "<br />");
               }

               if (Request["id"] != null)
               {
                    Guid checkId = new Guid(Request["id"]);

                    var check = (from checks in data.Accounting_Checks
                                 where checks.OrganizationId == sPage.SelectedOrganization.Id &&
                                 checks.Id == checkId
                                 select checks).First();

                    var payeeAccount = (from orgs in data.Logistics_Organizations
                                        where orgs.Id == check.Payee
                                        select orgs).First();

                    if (payeeAccount.BillingAddress.HasValue)
                    {
                         var payeeAddress = (from addy in data.Logistics_Addresses
                                             where addy.OrganizationId == sPage.SelectedOrganization.Id &&
                                             addy.Id == payeeAccount.BillingAddress
                                             select addy).First();

                         PayeeAddress.Text = payeeAddress.ToString().Replace("\r\n", "<br />");
                    }
               }
          }
    }
    //-------------------------------------------------------------------------------------------
    protected void UpdatePage()
    {
        using (WeavverEntityContainer data = new WeavverEntityContainer())
          {
               var accounts = from x in data.Accounting_Accounts
                              where x.OrganizationId == SelectedOrganization.Id
                              orderby x.Name
                              select x;

               Accounts.DataTextField = "Name";
               Accounts.DataValueField = "Id";
               //Accounts.DataSource = accounts;
               //Accounts.DataBind();
          }

          Accounts.Items.Insert(0, "All");

          //BindByDay();
          //BindByWeek();
          //BindByMonth();
    }
Example #26
0
        //-------------------------------------------------------------------------------------------
        public IGatewayResponse Bill(WeavverEntityContainer data, Sales_Orders order, Logistics_Addresses primaryAddress, Logistics_Addresses billingAddress)
        {
            string memo = "WEB PURCHASE";
               // Add the credit to the ledger.
               Accounting_LedgerItems item = new Accounting_LedgerItems();
               item.Id = Guid.NewGuid();
               item.OrganizationId = OrganizationId;
               if (order.Orderee.HasValue)
                    item.AccountId = order.Orderee.Value;
               else
                    item.AccountId = order.Id;
               item.LedgerType = LedgerType.Receivable.ToString();
               item.TransactionId = order.Id;
               item.PostAt = DateTime.UtcNow;
               item.Code = CodeType.Payment.ToString();
               item.Memo = "Payment from Card " + Number.Substring(Number.Length - 4);
               item.Amount = Math.Abs(order.Total.Value);

            //               order.BillingContactEmail

               // Submit to Authorize.Net
               var request = new AuthorizationRequest(Number, ExpirationMonth.ToString("D2") + ExpirationYear.ToString("D2"), order.Total.Value, memo, true);
               request.AddCustomer("", order.PrimaryContactNameFirst, order.PrimaryContactNameLast, primaryAddress.Line1, primaryAddress.State, primaryAddress.ZipCode);
               request.AddMerchantValue("OrderId", order.Id.ToString());
               request.AddMerchantValue("CreatedBy", order.CreatedBy.ToString());
               request.AddMerchantValue("LedgerItemId", item.Id.ToString());
               request.AddShipping("", order.BillingContactNameFirst, order.BillingContactNameLast, billingAddress.Line1, billingAddress.State, billingAddress.ZipCode);
               var gate = new Gateway(ConfigurationManager.AppSettings["authorize.net_loginid"], ConfigurationManager.AppSettings["authorize.net_transactionkey"], (ConfigurationManager.AppSettings["authorize.net_testmode"] == "true"));

               var response = gate.Send(request, memo);
               item.ExternalId = response.TransactionID;
               if (!response.Approved)
               {
                    //item.Voided = true;
                    //item.VoidedBy = Guid.Empty;
                    item.Memo += "\r\nPayment failed: Code " + response.ResponseCode + ", " + response.Message;
               }
               data.Accounting_LedgerItems.Add(item);
               return response;
        }
Example #27
0
    //-------------------------------------------------------------------------------------------
    public void Save_Click(object sender, EventArgs e)
    {
        using (WeavverEntityContainer data = new WeavverEntityContainer())
          {
               //Communication_Messages item = new Communication_Messages();
               //Guid parentId = new Guid(Request["id"].ToString());
               //item.Id = Guid.NewGuid();
               //item.OrganizationId = BasePage.LoggedInUser.OrganizationId;
               //item.Account = parentId;
               //item.Body = CommentUpdate.Text;
               //item.CreatedAt = DateTime.UtcNow;
               //item.CreatedBy = BasePage.LoggedInUser.Id;
               //item.UpdatedAt = DateTime.UtcNow;
               //item.UpdatedBy = BasePage.LoggedInUser.Id;
               //data.Communication_Messages.AddObject(item);
               //data.SaveChanges();

               //CommentUpdate.Text = "";

               //UpdatePage();
          }
    }
Example #28
0
        protected string GetDisplayString()
        {
            object value = FieldValue;

               if (value == null)
               {
                    string fkey = FormatFieldValue(ForeignKeyColumn.GetForeignKeyString(Row));
                    if (fkey.Length == 36)
                    {
                         using (WeavverEntityContainer data = new WeavverEntityContainer())
                         {
                              fkey = data.GetName(new Guid(fkey));
                              requiredCustomLookUp = true;
                         }
                    }
                    return fkey;
               }
               else
               {
                    return FormatFieldValue(ForeignKeyColumn.ParentTable.GetDisplayString(value));
               }
        }
Example #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //CreatePDF(@"W:\Projects\Weavver\Main\Servers\web\c\Inetpub\www\System\Tests\test.pdf");

         if (!IsPostBack)
         {
              WeavverEntityContainer data = new WeavverEntityContainer();
              var orders = from x in data.Sales_Order
                           select x;
              ReportViewer1.ProcessingMode = ProcessingMode.Local;
              ReportViewer1.LocalReport.EnableHyperlinks = true;
              ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Sales_Order", orders));

              List<Sales_OrderReportSettings> settings = new List<Sales_OrderReportSettings>();
              settings.Add(orders.First().ReportSettings);
              ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Sales_OrderReportSettings", settings));

              ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Accounting_LedgerItems", orders.First().LineItems));

              ReportViewer1.LocalReport.ReportPath = @"W:\Projects\Weavver\Main\Projects\WeavverLib\TestReport1.rdlc";
         }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        using (WeavverEntityContainer data = new WeavverEntityContainer())
          {
               var sumQuery = (from balances in data.Accounting_AccountBalances
                               where balances.OrganizationId == BasePage.SelectedOrganization.Id
                               select balances);

               string receivableLedger = LedgerType.Receivable.ToString();
               decimal receivableTotal = 0.0m;
               decimal payableTotal = 0.0m;
               var receivableLedgerItems = sumQuery.Where(x => x.LedgerType == receivableLedger);
               if (receivableLedgerItems.Count() > 0)
               {
                    receivableTotal = receivableLedgerItems.Sum(x => x.Balance);
               }
               ReceivableTotal.Text = String.Format("{0:C}", receivableTotal);

               string payableLedger = LedgerType.Payable.ToString();
               var payableLedgerItems = sumQuery.Where(x => x.LedgerType == payableLedger);
               if (payableLedgerItems.Count() > 0)
               {
                    payableTotal = payableLedgerItems.Sum(x => x.Balance);
               }
               PayableTotal.Text = String.Format("{0:C}", payableTotal);

               Net.Text = String.Format("{0:C}", receivableTotal - payableTotal);

               var sumQuery2 = (from accounts in data.Accounting_Accounts
                                       where accounts.OrganizationId == BasePage.SelectedOrganization.Id
                                       select accounts);

               var balance = sumQuery2.Sum(x => x.Balance);
               Balance.Text = String.Format("{0:C}", balance);

               var projectedBalance = sumQuery2.Sum(x => x.AvailableBalance);
               ProjectedBalance.Text = String.Format("{0:C}", projectedBalance);
          }
    }