private void RedrawTable()
        {
            clsCSVTable tbl      = new clsCSVTable(clsCashflow.strCashflowPath);
            string      selected = this.TypePopUpButton.TitleOfSelectedItem;

            this.typeChosen = clsCashflow.Type.Unknown;
            foreach (clsCashflow.Type t in Enum.GetValues(typeof(clsCashflow.Type)))
            {
                if (t.ToString() == selected)
                {
                    this.typeChosen = t;
                }
            }
            List <int> IDs = tbl.Matches(clsCashflow.TransactionTypeColumn, ((int)this.typeChosen).ToString());

            this.dataSource.Cashflows.Clear();
            foreach (int id in IDs)
            {
                clsCashflow newCf = new clsCashflow(id);
                if (((this.showExpired) || (newCf.DeleteDate() > System.DateTime.Today.AddYears(50))) && (newCf.LoanID() == -this.entityID))
                {
                    this.dataSource.Cashflows.Add(newCf);
                }
            }
            this.CashflowsTableView.ReloadData();
        }
        partial void CashflowIDEntered(AppKit.NSTextField sender)
        {
            clsCashflow cf = new clsCashflow(this.CashflowIDTextField.IntValue);

            this.DatePicker.DateValue = (NSDate)cf.PayDate().ToUniversalTime();
            this.RecordDateOverridePicker.DateValue = (NSDate)cf.RecordDate().ToUniversalTime();
            this.AmountTextField.DoubleValue        = cf.Amount();

            this.TypePopUpButton.SelectItem(cf.TypeID().ToString());
            if (this.TypePopUpButton.TitleOfSelectedItem == null)
            {
                this.typeChosen = clsCashflow.Type.Unknown;
                this.SystemMessageTextField.StringValue = "INVALID CASHFLOW TYPE (" + cf.TypeID().ToString() + ")";
                this.validIDEntered = false;
            }
            else
            {
                this.validIDEntered = true;
                if (cf.Comment() != null)
                {
                    this.CommentTextField.StringValue = cf.Comment();
                }
                else
                {
                    this.CommentTextField.StringValue = "";
                }
                this.RedrawTable();
            }
            this.ActualTextField.StringValue = "Actual : " + cf.Actual().ToString();
            this.RedrawTable();
        }
 partial void ActualCashflowPressed(NSButton sender)
 {
     if (this.validIDEntered)
     {
         clsCashflow cashflow = new clsCashflow(this.CashflowIDTextField.IntValue);
         if (cashflow.Comment() != null)
         {
             this.CommentTextField.StringValue = cashflow.Comment();
         }
         else
         {
             this.CommentTextField.StringValue = "";
         }
         if (cashflow.Actual())
         {
             this.SystemMessageTextField.StringValue = "CASHFLOW IS ALREADY ACTUAL";
         }
         else if (cashflow.MarkActual(System.DateTime.Today))
         {
             this.SystemMessageTextField.StringValue = "CASHFLOW MADE ACTUAL";
             this.ActualTextField.StringValue        = "Actual : " + true.ToString();
             cashflow.Save();
         }
         else
         {
             this.SystemMessageTextField.StringValue = "CASHFLOW EXPIRED, CAN'T MAKE ACTUAL";
         }
     }
     RedrawTable();
 }
Esempio n. 4
0
 partial void markTrueClicked(AppKit.NSButton sender)
 {
     if (Int32.TryParse(CashflowIDPopUp.SelectedItem.Title, out int i))
     {
         clsCashflow cf = new clsCashflow(Int32.Parse(CashflowIDPopUp.SelectedItem.Title));
         cf.MarkActual(System.DateTime.Today);
         cf.Save();
         loadRehabInfo();
     }
 }
        partial void markTrueClicked(AppKit.NSButton sender)
        {
            int cfID = 0;

            cfID = Int32.Parse(cashflowID.StringValue);

            clsCashflow cf = new clsCashflow(cfID);

            cf.MarkActual(System.DateTime.Today);
            cf.Save();
            loadRehabInfo();
        }
        partial void AddButtonPressed(AppKit.NSButton sender)
        {
            DateTime dtPay    = ((DateTime)this.DatePicker.DateValue).Date;
            DateTime dtRecord = ((DateTime)this.RecordDateOverridePicker.DateValue).Date;
            double   dAmount  = this.AmountTextField.DoubleValue;

            // VALIDATE ENTRIES
            if (this.typeChosen == clsCashflow.Type.Unknown)
            {
                this.SystemMessageTextField.StringValue = "INVALID CASHFLOW TYPE, UNABLE TO ADD";
            }
            else if (this.entityID < 0)
            {
                this.SystemMessageTextField.StringValue = "NO ENTITY SELECTED, UNABLE TO ADD";
            }
            else
            {
                // CREATE NEW CASHFLOW
                clsCashflow cashflow = new clsCashflow(dtPay, dtRecord, System.DateTime.MaxValue, -this.entityID, dAmount,
                                                       false, this.typeChosen, this.CommentTextField.StringValue);
                if (dtPay <= System.DateTime.Today.Date)
                {
                    cashflow.MarkActual(System.DateTime.Today.Date);
                }
                // SAVE TO TABLE
                cashflow.Save();
                this.CashflowIDTextField.IntValue = cashflow.ID();
                // UPDATE COMMENT BOX
                this.SystemMessageTextField.StringValue = "CASHFLOW SAVED.";
                if ((cashflow.TypeID() == clsCashflow.Type.InterestAdditional) && (cashflow.Amount() < 0D))
                {
                    this.SystemMessageTextField.StringValue += "\nCheck Amount.  Additional Interest is usually >= 0.";
                }
                else if ((cashflow.TypeID() == clsCashflow.Type.CapitalCall) && (cashflow.Amount() < 0D))
                {
                    this.SystemMessageTextField.StringValue += "\nCheck Amount.  Capital Calls are usually >= 0.";
                }
                else if ((cashflow.TypeID() == clsCashflow.Type.CatchUp) && (cashflow.Amount() < 0D))
                {
                    this.SystemMessageTextField.StringValue += "\nCheck Amount.  Catchup Payments are usually >= 0.";
                }
                else if (cashflow.Amount() > 0)
                {
                    this.SystemMessageTextField.StringValue += "\nCheck Amount.  Expenses are normally <0.";
                }
            }
            RedrawTable();
        }
 partial void ExpireButtonPressed(AppKit.NSButton sender)
 {
     if (this.validIDEntered)
     {
         clsCashflow cashflow = new clsCashflow(this.CashflowIDTextField.IntValue);
         if (cashflow.Delete(System.DateTime.Now))
         {
             this.SystemMessageTextField.StringValue = "CASHFLOW EXPIRED";
             cashflow.Save();
         }
         else
         {
             this.SystemMessageTextField.StringValue = "CASHFLOW IS ALREADY ACTUAL, EXPIRE FAILED";
         }
     }
     RedrawTable();
 }
Esempio n. 8
0
 partial void deleteButtonClicked(AppKit.NSButton sender)
 {
     if (Int32.TryParse(CashflowIDPopUp.SelectedItem.Title, out int i))
     {
         clsCashflow deletedCashflow = new clsCashflow(Int32.Parse(CashflowIDPopUp.SelectedItem.Title));
         if (deletedCashflow.Actual() == true)
         {
             rehabDrawDisplayFalse.StringValue += "Error: Could not delete cashflow, already payed.";
         }
         else
         {
             deletedCashflow.Delete(System.DateTime.Today);
             deletedCashflow.Save();
         }
         loadRehabInfo();
     }
 }
Esempio n. 9
0
        partial void dateChangeClicked(AppKit.NSButton sender)
        {
            if (Int32.TryParse(CashflowIDPopUp.SelectedItem.Title, out int i))
            {
                clsLoan  loan    = new clsLoan(chosenID);
                DateTime newDate = (DateTime)(dateChanger.DateValue);

                // Delete existing (old) cashflow
                clsCashflow cf = new clsCashflow(Int32.Parse(CashflowIDPopUp.SelectedItem.Title));
                cf.Delete(System.DateTime.Today);
                cf.Save();

                // Create new cashflow with new date
                clsCashflow updatedCF = new clsCashflow(newDate, System.DateTime.Today, System.DateTime.MaxValue, cf.LoanID(), cf.Amount(), false, cf.TypeID());
                loan.AddCashflow(updatedCF);
                updatedCF.Save();
                loadRehabInfo();
            }
        }
        partial void deleteButtonClicked(AppKit.NSButton sender)
        {
            int cfID = 0;

            cfID = Int32.Parse(cashflowID.StringValue);

            clsCashflow deletedCashflow = new clsCashflow(cfID);

            if (deletedCashflow.Actual() == true)
            {
                rehabDrawDisplayFalse.StringValue += "Error: Could not delete cashflow, already payed.";
            }
            else
            {
                deletedCashflow.Delete(System.DateTime.Today);
            }
            deletedCashflow.Save();
            loadRehabInfo();
        }
        partial void dateChangeClicked(AppKit.NSButton sender)
        {
            clsLoan loan = new clsLoan(chosenID);
            int     cfID = 0;

            cfID = Int32.Parse(cashflowID.StringValue);
            DateTime newDate = (DateTime)(dateChanger.DateValue);

            clsCashflow cf = new clsCashflow(cfID);

            cf.Delete(System.DateTime.Today);
            cf.Save();

            clsCashflow updatedCF = new clsCashflow(newDate, System.DateTime.Today, System.DateTime.MaxValue, cf.LoanID(), cf.Amount(), false, cf.TypeID());

            loan.AddCashflow(updatedCF);
            updatedCF.Save();

            loadRehabInfo();
        }
Esempio n. 12
0
        private void _TestCashflow()
        {
            clsCashflow cf = new clsCashflow(47);

            Console.WriteLine(cf.TransactionID() + "," + cf.Amount() + "," + cf.PayDate());

            clsCSVTable testTable = new clsCSVTable(clsCashflow.strCashflowPath);

            testTable.SaveAs("/Users/" + Environment.UserName + "/Documents/Professional/Resilience/tblCashflowTest.csv");

            DateTime pd  = DateTime.Today;
            DateTime rd  = DateTime.Today;
            DateTime dd  = DateTime.MaxValue;
            int      pid = 17;
            double   a   = 100000;
            bool     act = false;

            clsCashflow.Type t      = clsCashflow.Type.RehabDraw;
            clsCashflow      cfTest = new clsCashflow(pd, rd, dd, pid, a, act, t);

            Console.WriteLine(cfTest.Save("/Users/" + Environment.UserName + "/Documents/Professional/Resilience/tblCashflowTest.csv"));
        }
Esempio n. 13
0
        partial void addNewConstruction(AppKit.NSButton sender)
        {
            clsLoan loan = new clsLoan(chosenID);

            DateTime payDate    = (DateTime)(constructionDateNew.DateValue);
            DateTime recordDate = System.DateTime.Today;
            DateTime deleteDate = System.DateTime.MaxValue;
            int      loanID     = chosenID;
            double   amount     = constructionAmountNew.DoubleValue;

            if (amount > 0)
            {
                amount = -amount;
            }

            bool payed = false;

            if (payDate > System.DateTime.Today)
            {
                payed = false;
            }
            else
            {
                payed = true;
            }

            clsCashflow.Type typeID = new clsCashflow.Type();
            typeID = clsCashflow.Type.RehabDraw;

            clsCashflow newCashflow = new clsCashflow(payDate, recordDate, deleteDate, loanID, amount, payed, typeID);

            loan.Cashflows().Add(newCashflow);
            newCashflow.Save();
            loadRehabInfo();
//            if (loan.Save())
//                loadRehabInfo();
//            else
//                rehabDrawDisplayTrue.StringValue += "\nSave Failed, New Cashflow not Saved.";
        }
Esempio n. 14
0
        partial void CashflowIDChosen(NSPopUpButton sender)
        {
            clsCashflow cf = new clsCashflow(Int32.Parse(CashflowIDPopUp.SelectedItem.Title));

            this.dateChanger.DateValue = (NSDate)(cf.PayDate().AddDays(7).ToUniversalTime());
        }
Esempio n. 15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Do any additional setup after loading the view.
            this.ScenarioButton.State      = NSCellStateValue.On;
            this.OutflowsOnlyButton.State  = NSCellStateValue.Off;
            this.ScheduledOnlyButton.State = NSCellStateValue.Off;
            this.showAll           = true;
            this.showScheduledOnly = false;
            this.showExpensesOnly  = false;
            this.showExpired       = false;

            clsCSVTable cfTable = new clsCSVTable(clsCashflow.strCashflowPath);

            for (int i = 0; i < cfTable.Length(); i++)
            {
                DateTime         pd = DateTime.Parse(cfTable.Value(i, clsCashflow.TransactionDateColumn));
                DateTime         rd = DateTime.Parse(cfTable.Value(i, clsCashflow.RecordDateColumn));
                DateTime         dd = DateTime.Parse(cfTable.Value(i, clsCashflow.DeleteDateColumn));
                int              id = Int32.Parse(cfTable.Value(i, clsCashflow.LoanColumn));
                double           a  = Double.Parse(cfTable.Value(i, clsCashflow.AmountColumn));
                bool             b  = Boolean.Parse(cfTable.Value(i, clsCashflow.ActualColumn));
                clsCashflow.Type t  = (clsCashflow.Type)Int32.Parse(cfTable.Value(i, clsCashflow.TransactionTypeColumn));
                string           c  = cfTable.Value(i, clsCashflow.CommentColumn);
                clsCashflow      cf = new clsCashflow(pd, rd, dd, id, a, b, t, c);
                if (DateTime.Parse(cfTable.Value(i, clsCashflow.DeleteDateColumn)) > System.DateTime.Today.AddYears(50))
                {
                    this.activeCashflows.Add(cf);
                    //this.activeCashflows.Add(new clsCashflow(i));
                }
                else
                {
                    this.expiredCashflows.Add(cf);
                }
            }

            this.DateFilterDatePicker.DateValue = (NSDate)System.DateTime.Today;
            this.startDate = System.DateTime.Today.AddYears(-10);
            this.StartDatePicker.DateValue = (NSDate)this.startDate;
            this.endDate = System.DateTime.Today.AddYears(10);
            this.EndDatePicker.DateValue = (NSDate)this.endDate;

            this.ActualFilterComboxBox.RemoveAll();
            this.ActualFilterComboxBox.Add((NSString)"All");
            this.ActualFilterComboxBox.Add((NSString)"True");
            this.ActualFilterComboxBox.Add((NSString)"False");
            this.ActualFilterComboxBox.SelectItem(0);

            this.AddressFilterComboBox.RemoveAll();
            this.AddressFilterComboBox.Add((NSString)"All");
            List <string> addresses = clsProperty.AddressList();

            foreach (string s in addresses)
            {
                this.AddressFilterComboBox.Add((NSString)s);
            }
            this.AddressFilterComboBox.SelectItem(0);

            this.TypeFilterComboBox.RemoveAll();
            this.TypeFilterComboBox.Add((NSString)"All");
            foreach (clsCashflow.Type t in Enum.GetValues(typeof(clsCashflow.Type)))
            {
                this.TypeFilterComboBox.Add((NSString)t.ToString());
            }
            this.TypeFilterComboBox.Remove((NSString)"Unknown");
            this.TypeFilterComboBox.SelectItem(0);

            this.dataSource                   = new CashflowTableDataSource();
            this.dataSourceDelegate           = new CashflowTableDataSourceDelegate(this.dataSource);
            this.CashflowTableView.DataSource = this.dataSource;
            this.CashflowTableView.Delegate   = this.dataSourceDelegate;

            clsCSVTable tblLenders = new clsCSVTable(clsEntity.strEntityPath);
            clsCSVTable tblLoans   = new clsCSVTable(clsLoan.strLoanPath);

            for (int i = 0; i < tblLenders.Length(); i++)
            {
                if (tblLoans.Matches(clsLoan.LenderColumn, i.ToString()).Count > 0)
                {
                    this.LenderPopUp.AddItem(tblLenders.Value(i, clsEntity.NameColumn));
                    this.lenderIndexToID.Add(i);
                }
            }
            for (int i = 0; i < tblLoans.Length(); i++)
            {
                this.lenderLoanIDs.Add(i);
            }

            clsCSVTable tblBorrowers = new clsCSVTable(clsEntity.strEntityPath);

            for (int i = 0; i < tblBorrowers.Length(); i++)
            {
                if (tblLoans.Matches(clsLoan.TitleHolderColumn, i.ToString()).Count > 0)
                {
                    this.BorrowerPopUp.AddItem(tblBorrowers.Value(i, clsEntity.NameColumn));
                    this.borrowerIndexToID.Add(i);
                }
            }
            for (int i = 0; i < tblLoans.Length(); i++)
            {
                this.borrowerLoanIDs.Add(i);
            }
        }