Exemple #1
0
 protected void ButtonGenerateReport_Click(object sender, EventArgs e)
 {
     QuickPM.Period beginPeriod = new QuickPM.Period(Int32.Parse(DropDownListBeginYear.SelectedValue), QuickPM.Util.ConvertMonthToInt(DropDownListBeginMonth.SelectedValue));
     QuickPM.Period endPeriod = new QuickPM.Period(Int32.Parse(DropDownListEndYear.SelectedValue), QuickPM.Util.ConvertMonthToInt(DropDownListEndMonth.SelectedValue));
     List<string> rentTypes = new List<string>();
     foreach (ListItem item in CheckBoxListRentTypes.Items)
     {
         if (item.Selected)
         {
             rentTypes.Add(item.Text);
         }
     }
     html = GenerateReport(rentTypes, beginPeriod, endPeriod);
 }
Exemple #2
0
 public void AutoAppyCheck()
 {
     decimal checkAmount = 100m;
     QuickPM.Period p = new QuickPM.Period(2008, 1);
     string checkNumber = "2";
     QuickPM.Check c = new QuickPM.Check();
     c.TenantId = tenantId;
     c.Number = checkNumber;
     c.Amount = checkAmount;
     c.ARRecordDate = new DateTime(p.Year, p.Month, 1);
     c.AutoApply(p);
     Assert.AreEqual(1, c.AppliedTo.Count);
     Assert.AreEqual(checkAmount, c.AppliedTo[0].Amount);
     Assert.AreEqual(0, c.AppliedTo[0].RentTypeIndex);
     Assert.AreEqual(c.ARRecordDate, c.AppliedTo[0].Date);
     c.Delete();
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            QuickPMWebsite.DatabaseSettings.UpdateDatabaseConnectionString(HttpContext.Current.Profile, Request);
            long PropertyId = long.Parse(Request["PropertyId"]);
            int year = int.Parse(Request["Year"]);
            int month = int.Parse(Request["Month"]);
            PrintTenantBilling.url = "http://cmd.quickpm.net" + "/Public/Tenant.aspx";
            PDFjet.NET.PDF document = PrintBillings.GetPdf(PropertyId, year, month);
            string filePathName = Request.PhysicalApplicationPath + "/Billings/" + "Billings.pdf";
            document.Save(filePathName);

            byte[] fileBytes = System.IO.File.ReadAllBytes(filePathName);
            QuickPM.Period period = new QuickPM.Period(year, month);
            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=\"#" + PropertyId.ToString() + " " + new QuickPM.Property(PropertyId).Name + " " + period.ToString() + ".pdf\"");
            Response.AddHeader("Content-Length", fileBytes.Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.WriteFile(filePathName);
            Response.End();
        }
    protected void ButtonGenerateChart_Click(object sender, EventArgs e)
    {
        moneyReceived = new List<decimal>();
        tenantPaid = new Dictionary<string, decimal>();
        months = new List<long>();
        int beginYear = Convert.ToInt32(DropDownListBeginYear.SelectedValue);
        int beginMonth = QuickPM.Util.ConvertMonthToInt(DropDownListBeginMonth.SelectedValue);
        int endYear = Convert.ToInt32(DropDownListEndYear.SelectedValue);
        int endMonth = QuickPM.Util.ConvertMonthToInt(DropDownListEndMonth.SelectedValue);
        QuickPM.Period beginPeriod = new QuickPM.Period(beginYear, beginMonth);
        QuickPM.Period endPeriod = new QuickPM.Period(endYear, endMonth);
        if (endMonth == beginMonth && endYear == beginYear)
        {
            endPeriod = endPeriod.AddMonth();
        }
        int property;
        if (Request["PropertyId"] == null)
        {
            string selectedValue = this.PropertyList.SelectedValue;
            string[] tmp = selectedValue.Split(new char[] { ' ' });
            property = Convert.ToInt32(tmp[0]);
        }
        else
        {
            property = Convert.ToInt32(Request["PropertyId"]);
        }
        this.property = new QuickPM.Property(property);

        for (QuickPM.Period p = beginPeriod; p <= endPeriod; p = p.AddMonth())
        {
            months.Add((new DateTime(p.Year, p.Month, 1).Ticks) - (new DateTime(1970, 1, 1).Ticks));
            decimal received = 0;

            List<string> profileIds = new List<string>(QuickPM.Database.GetPropertyTenantIds(this.property.Id, p));
            foreach (string profileId in profileIds)
            {
                QuickPM.Tenant tenant = new QuickPM.Tenant(profileId);
                string shortName = tenant.GetShortName();
                List<QuickPM.Check> checks = QuickPM.Database.GetChecks(profileId, p);
                List<QuickPM.NSFCheck> nsfChecks = QuickPM.Database.GetNSFChecks(profileId, p);
                foreach (QuickPM.Check c in checks)
                {
                    received += c.Amount;
                    if (!tenantPaid.ContainsKey(shortName))
                    {
                        tenantPaid[shortName] = 0m;
                    }
                    tenantPaid[shortName] += c.Amount;
                }
                foreach (QuickPM.NSFCheck n in nsfChecks)
                {
                    received += n.Amount;
                    if (!tenantPaid.ContainsKey(shortName))
                    {
                        tenantPaid[shortName] = 0m;
                    }
                    tenantPaid[shortName] += n.Amount;
                }

            }
            moneyReceived.Add(received);
        }
        CreateTenantList();
    }
Exemple #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        QuickPMWebsite.DatabaseSettings.UpdateDatabaseConnectionString(HttpContext.Current.Profile, Request);

        if (Request["beginyear"] == null || Request["beginmonth"] == null || Request["endyear"] == null || Request["endmonth"] == null ||
            Request["PropertyId"] == null || Request["EBId"] == null)
        {
            eb = new QuickPM.ExpenseList();
            endPeriod = beginPeriod.SubtractMonth();
            return;
        }
        int tmp;
        if (!Int32.TryParse(Request["beginyear"], out tmp) || !Int32.TryParse(Request["beginmonth"], out tmp) ||
            !Int32.TryParse(Request["endyear"], out tmp) || !Int32.TryParse(Request["endmonth"], out tmp) ||
            !Int32.TryParse(Request["PropertyId"], out tmp))
        {
            eb = new QuickPM.ExpenseList();
            endPeriod = beginPeriod.SubtractMonth();
            return;
        }

        beginPeriod.Year = Convert.ToInt32(Request["beginyear"]);
        beginPeriod.Month = Convert.ToInt32(Request["beginmonth"]);
        endPeriod.Year = Convert.ToInt32(Request["endyear"]);
        endPeriod.Month = Convert.ToInt32(Request["endmonth"]);
        PropertyId = Convert.ToInt32(Request["PropertyId"]);
        expenseBudgetId = new Guid(Request["EBId"]);
        ei.ChartOfAccount = 0;
        ei.COADescription = "";
        ei.IsSubCOA = false;
        ei.ParentCOA = 0;

        eb = new QuickPM.ExpenseList(expenseBudgetId);

        for (QuickPM.Period p = beginPeriod; p <= endPeriod; p = p.AddMonth())
        {
            ei.expenses.Add(0m);
            ei.periods.Add(p);
        }
        if (Request["COADescription"] != null)
        {
            QuickPM.ExpenseItem expenseItem = null;
            foreach (QuickPM.ExpenseItem eei in eb.ExpenseItems)
            {
                if (eei.COADescription.Trim() == HttpUtility.UrlDecode(Request["COADescription"].Trim()))
                {
                    expenseItem = eei;
                    break;
                }
            }
            if (expenseItem != null)
            {
                newExpenseItem = false;
                ei = expenseItem;
                if (!IsPostBack)
                {
                    TextBoxCOA.Text = ei.ChartOfAccount.ToString();
                    TextBoxExpenseName.Text = ei.COADescription;
                }
            }
        }

        if (!IsPostBack)
        {
            CheckBoxSubaccount.Checked = ei.IsSubCOA;

            foreach (QuickPM.ExpenseItem i in eb.ExpenseItems)
            {
                if (i.IsSubCOA)
                {
                    continue;
                }
                ListItem li = new ListItem(i.COADescription, i.ChartOfAccount.ToString());
                if (ei.IsSubCOA && ei.ParentCOA == i.ChartOfAccount)
                {
                    li.Selected = true;
                }
                DropDownListAccounts.Items.Add(li);
            }
        }
    }
Exemple #6
0
    protected void ButtonEmail_Click(object sender, EventArgs e)
    {
        QuickPM.Tenant tenant = new QuickPM.Tenant(GetTenantId());
        string html = "<table id=\"email\" cellspacing=\"0px\" cellpadding=\"10px\">" + @"
            <tr>
                <th>Tenant Name/Id</th><th>Email</th><th>Status</th>
            </tr>
        ";
        int year = Int32.Parse(DropDownListYear.SelectedValue);
        int month = QuickPM.Util.ConvertMonthToInt(DropDownListMonth.SelectedValue);
        QuickPM.Period period = new QuickPM.Period(year, month);
        string email = tenant.BillingEmail;

        string status = "";

        if (email.Trim() != "")
        {
            PrintTenantBilling.url = "http://cmd.quickpm.net" + "/Public/Tenant.aspx";
            PDFjet.NET.PDF document = PrintBillings.GetPdf(tenant.TenantId, year, month);
            string filePath = Request.PhysicalApplicationPath + "\\App_Data\\tmpbilling.pdf";
            document.Save(filePath);
            System.IO.Stream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Open);
            QuickPM.RemitInfo remitInfo = new QuickPM.RemitInfo(tenant.Property);
            status = "Sent";
            string questions = remitInfo.Email.Trim() != "" ? "\r\nIf you have a question about your billing statement please email " + remitInfo.Email : "";
            string message = "Please see the attached pdf for your billing statement.\r\nThis is an automated message, do not respond. " + questions;

            try
            {
                SendEmail.Send(email,  period.ToString() + " " + "Billing Statement", message,
                    Request.PhysicalApplicationPath, stream, "BillingStatement.pdf");
            }
            catch (Exception ex)
            {
                if (ex is System.Net.Mail.SmtpFailedRecipientException)
                {
                    status = "Failed to send email";
                }
                else if (ex is System.Net.Mail.SmtpFailedRecipientsException)
                {
                    status = "Failed to send email";
                }
                else
                {
                    status = "Unknown error";
                }

            }
            finally
            {
                stream.Close();
                System.IO.File.Delete(filePath);
            }
        }

        html += "<tr>";
        string billingemail = tenant.BillingEmail.Trim() != "" ? tenant.BillingEmail.Trim() : "No Email";
        html += "<td>" + "<a href=" + QuickPMWebsite.AppCode.Link.LinkTo(tenant, this, HttpContext.Current.Profile.IsAnonymous) + ">" + tenant.Name + " (#" + tenant.TenantId + ")" + "</a>" + "</td>" +
                "<td>" + billingemail + "</td>" +
                "<td>" + status + "</td>";
        html += "</tr>";

        html += "</table>";
        Session["email"] = html;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        QuickPMWebsite.DatabaseSettings.UpdateDatabaseConnectionString(HttpContext.Current.Profile, Request);

        if (QuickPM.Util.GetPropertyIds().Length == 0)
        {
            return;
        }

        long iPropertyId = QuickPM.Util.GetPropertyIds()[0];
        this.PropertyId = iPropertyId;

        if (Request["PropertyId"] != null)
        {
            if(long.TryParse(Request["PropertyId"], out iPropertyId)){
                this.PropertyId = iPropertyId;
            }

        }

        if (!IsPostBack)
        {
            foreach (int PropertyId in QuickPM.Util.GetPropertyIds())
            {
                QuickPM.Property p = new QuickPM.Property(PropertyId);
                ListItem item = new ListItem(p.Name + " (#" + PropertyId + ")", p.Id.ToString());
                if (p.Id == iPropertyId)
                {
                    item.Selected = true;
                }
                DropDownListProperty.Items.Add(item);
            }
        }
        period = null;
        period = GetCurrentPeriod();
            QuickPM.Property pp = new QuickPM.Property(this.PropertyId);
            if (DropDownListTenant.Items.Count == 0 || QuickPM.Util.GetPropertyId(DropDownListTenant.Items[0].Value) != pp.Id)
            {
                DropDownListTenant.Items.Clear();
                foreach (string tenantId in pp.GetTenantIds())
                {
                    QuickPM.Tenant t = new QuickPM.Tenant(tenantId);
                    string PropertyId = QuickPM.Util.GetPropertyId(t.TenantId).ToString();
                    PropertyId = PropertyId.Length < 2 ? "0" + PropertyId : PropertyId;
                    string tenantNumber = t.TenantId.Split(new char[] { '-' })[1];

                    DropDownListTenant.Items.Add(new ListItem(t.GetShortName() + " (#" + PropertyId + "-" + tenantNumber + ")", t.TenantId));
                }
                DropDownListTenant.Items.Add(new ListItem("(" + pp.Name + ")", pp.Id.ToString()));

            }

            if (Request.Form["__EVENTTARGET"] == "DepositDateChanged")
            {
                DepositDateChanged(Request.Form["__EVENTARGUMENT"]);
            }

            if (Request.Form["__EVENTTARGET"] == "AddDepositEntry")
            {
                AddDepositEntry(Request.Form["__EVENTARGUMENT"]);
            }

            if (Request.Form["__EVENTTARGET"] == "DeleteDeposit")
            {
                DeleteDeposit(Request.Form["__EVENTARGUMENT"]);
            }

            if (Request.Form["__EVENTTARGET"] == "DeleteDepositEntry")
            {
                DeleteDepositEntry(Request.Form["__EVENTARGUMENT"]);
            }

            if (Request.Form["__EVENTTARGET"] == "ChangeQuickBooksImported")
            {
                ChangeQuickBooksImported(Request.Form["__EVENTARGUMENT"]);
            }

            deposits = QuickPM.Deposit.GetDeposits(this.PropertyId, period.Year, period.Month);

            if (Request.Form["__EVENTTARGET"] == "FinishDeposit")
            {
                FinishDeposit(Request.Form["__EVENTARGUMENT"]);
            }

        //if(IsPostBack && period != null)
    }
    protected void ParseRequest()
    {
        if (Request["beginyear"] == null || Request["beginmonth"] == null || Request["endyear"] == null || Request["endmonth"] == null ||
               Request["PropertyId"] == null)
        {
            eb = new QuickPM.ExpenseList();
            eb.BeginPeriod = new QuickPM.Period(DateTime.Now.Year, DateTime.Now.Month);
            eb.BeginPeriod = eb.BeginPeriod.AddMonth();
            return;
        }
        int tmp1;
        if (!Int32.TryParse(Request["beginyear"], out tmp1) || !Int32.TryParse(Request["beginmonth"], out tmp1) ||
            !Int32.TryParse(Request["endyear"], out tmp1) || !Int32.TryParse(Request["endmonth"], out tmp1) ||
            !Int32.TryParse(Request["PropertyId"], out tmp1))
        {
            eb = new QuickPM.ExpenseList();
            eb.BeginPeriod = new QuickPM.Period(DateTime.Now.Year, DateTime.Now.Month);
            eb.BeginPeriod = eb.BeginPeriod.AddMonth();
            return;
        }

        QuickPM.Period beginPeriod = new QuickPM.Period();
        QuickPM.Period endPeriod = new QuickPM.Period();
        beginPeriod.Year = Convert.ToInt32(Request["beginyear"]);
        beginPeriod.Month = Convert.ToInt32(Request["beginmonth"]);
        endPeriod.Year = Convert.ToInt32(Request["endyear"]);
        endPeriod.Month = Convert.ToInt32(Request["endmonth"]);
        PropertyId = Convert.ToInt32(Request["PropertyId"]);
        bool isBudget = true;
        if (Request["IsBudget"] != null && (bool.TrueString.ToLower() == Request["IsBudget"].ToLower() || bool.FalseString.ToLower() == Request["IsBudget"].ToLower()))
        {
            isBudget = (bool.TrueString.ToLower() == Request["IsBudget"].ToLower());
        }
        eb = new QuickPM.ExpenseList(PropertyId, beginPeriod, endPeriod, isBudget);
    }
Exemple #9
0
    protected void ButtonImport_Click(object sender, EventArgs e)
    {
        string[] checkData = TextBoxChecks.Text.Split(new char[] { '\n' });
        Dictionary<string, int> columnNames = new Dictionary<string,int>();
        columnNames.Add("TenantNumber", 0);
        columnNames.Add("TenantName", 1);
        columnNames.Add("CheckDate", 2);
        columnNames.Add("ReceivedDate", 3);
        columnNames.Add("CheckNumber", 4);
        columnNames.Add("CheckAmount", 5);
        List<string> skippedLines = new List<string>();
        List<List<string>> importedChecks = new List<List<string>>();
        foreach (string line in checkData)
        {
            string[] columns = line.Split(new char[] { '\t' });
            string tenantNumber = columns[columnNames["TenantNumber"]];
            if (!QuickPM.Util.TryFormatTenantId(tenantNumber, out tenantNumber))
            {
                skippedLines.Add(line);
            }
            string checkDate = columns[columnNames["CheckDate"]];
            string receivedDate = columns[columnNames["ReceivedDate"]];
            string checkNumber = columns[columnNames["CheckNumber"]];
            string checkAmount = columns[columnNames["CheckAmount"]];
            QuickPM.Period period1 = new QuickPM.Period(DateTime.Now.Year, DateTime.Now.Month);
            QuickPM.Period period2 = period1.SubtractMonth();
            List<QuickPM.Check> checks1 = QuickPM.Database.GetChecks(tenantNumber, period1);
            List<QuickPM.Check> checks2 = QuickPM.Database.GetChecks(tenantNumber, period2);
            checks1.AddRange(checks2);
            bool skip = false;
            foreach (QuickPM.Check check in checks1)
            {
                if (check.Number.Trim() == checkNumber.Trim() && check.CheckDate == DateTime.Parse(checkDate))
                {
                    skip = true;
                    break;
                }
            }

            List<string> checkInfo = new List<string>();
            checkInfo.Add(checkNumber.Trim());
            if (skip)
            {
                checkInfo.Add("Yes");
            }
            else
            {
                checkInfo.Add("No");
            }

            if (skip)
            {

                importedChecks.Add(checkInfo);
                continue;
            }

            QuickPM.Check c = new QuickPM.Check();
            c.TenantId = tenantNumber;
            c.Number = checkNumber.Trim();
            c.CheckDate = DateTime.Parse(checkDate);
            c.ReceivedDate = DateTime.Parse(receivedDate);
            c.Amount = Decimal.Parse(checkAmount, System.Globalization.NumberStyles.Any);
            c.ARRecordDate = new DateTime(period1.Year, period1.Month, 1);
            c.AutoApply(period1);
            c.Save();
            importedChecks.Add(checkInfo);
        }
        Session["ImportedChecks"] = importedChecks;
        Session.Add("SkippedLines", skippedLines);
    }
Exemple #10
0
 public void TestCreateBill()
 {
     string tenantId = QuickPM.Util.FormatTenantId(1, 1);
     QuickPM.Period period = new QuickPM.Period(2008, 1);
     QuickPM.Bill b = QuickPM.Bill.GetBill(tenantId, "Rent", period.Year, period.Month);
     Assert.AreEqual(0m, b.Amount);
     Assert.AreEqual(b.RentTypeIndex, 0);
     Assert.AreEqual(b.TenantId, tenantId);
     Assert.AreEqual(b.Year, period.Year);
     Assert.AreEqual(b.Month, period.Month);
     Assert.AreEqual(b.BillingType, QuickPM.TypeOfBill.Monthly);
 }
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        long PropertyId = GetPropertyId();
        int year = Int32.Parse(DropDownListYear.SelectedValue);
        int month = QuickPM.Util.ConvertMonthToInt(DropDownListMonth.SelectedValue);
        PrintTenantBilling.url = "http://cmd.quickpm.net" + "/Public/Tenant.aspx";
        PDFjet.NET.PDF document = PrintBillings.GetPdf(PropertyId, year, month);
        string filePathName = Request.PhysicalApplicationPath + "/Billings/" + "Billings.pdf";
        document.Save(filePathName);

        byte[] fileBytes = System.IO.File.ReadAllBytes(filePathName);
        //Response.Redirect("~/Billings/ViewPrint.aspx");
        QuickPM.Period period = new QuickPM.Period(year, month);
        Response.Clear();
        Response.AddHeader("Content-Disposition", "attachment; filename=\"#" + PropertyId.ToString() + " " + new QuickPM.Property(PropertyId).Name + " " + period.ToString() + ".pdf\"");
        Response.AddHeader("Content-Length", fileBytes.Length.ToString());
        Response.ContentType = "application/octet-stream";
        //byte[] byteBuffer = document.GetData().GetBuffer();
        //char[] charBuffer = System.Text.Encoding.ASCII.GetChars(byteBuffer);
        //Response.Write(charBuffer, 0, charBuffer.Length);
        Response.WriteFile(filePathName);
        Response.End();
    }
Exemple #12
0
        public void TestAddCheck()
        {
            decimal checkAmount = 100m;
            string checkNumber = "1";
            QuickPM.Tenant t = new QuickPM.Tenant(tenantId);
            QuickPM.Period p = new QuickPM.Period(2008, 1);
            QuickPM.Util.AddARRecord(tenantId, p.Year, p.Month);
            QuickPM.Check c = new QuickPM.Check();
            c.TenantId = tenantId;
            c.Amount = checkAmount;
            c.ARRecordDate = new DateTime(p.Year, p.Month, 1);
            c.ReceivedDate = c.ARRecordDate.AddDays(1);
            c.CheckDate = c.ReceivedDate.AddDays(1);
            c.Number = checkNumber;
            c.Save();

            c = new QuickPM.Check(c.Id);

            Assert.AreEqual(checkAmount, c.Amount);
            Assert.AreEqual(checkNumber, c.Number);
            Assert.AreEqual(new DateTime(p.Year, p.Month, 1), c.ARRecordDate);
            Assert.AreEqual((new DateTime(p.Year,p.Month, 1)).AddDays(1), c.ReceivedDate);
            Assert.AreEqual((new DateTime(p.Year, p.Month, 1)).AddDays(2), c.CheckDate);
            Assert.AreEqual(tenantId, c.TenantId);
            c.Delete();
        }
 protected void ButtonGenerateReport_Click(object sender, EventArgs e)
 {
     QuickPM.Period beginPeriod = new QuickPM.Period(GetBeginYear(), GetBeginMonth());
     QuickPM.Period endPeriod = new QuickPM.Period(GetEndYear(), GetEndMonth());
     Session["AppliedReceiptsReportHtml"] = GenerateAgedReport.GenerateHtml(property, GetRentTypes(), beginPeriod, endPeriod);
 }