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();
        }
        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();
        }
Exemplo n.º 3
0
        public DateTime FindDate(clsCashflow.Type cashflowType, bool firstFound, bool paydate)
        {
            // for a given type of cashflow, this will return either the paydate or the recorddate
            // if firstFound, then it finds the first cashflow of that type
            // if not firstFound, then it finds the latest undeleted cashflow of that type
            DateTime cfDate;
            DateTime dtFound;

            if (firstFound)
            {
                dtFound = DateTime.MaxValue;
            }
            else
            {
                dtFound = DateTime.MinValue;
            }

            if (this.cfCashflows.Count == 0)
            {
                return(dtFound);
            }
            else
            {
                foreach (clsCashflow cf in this.cfCashflows)
                {
                    if ((cf.TypeID() == cashflowType))
                    {
                        if (paydate)
                        {
                            cfDate = cf.PayDate();
                        }
                        else
                        {
                            cfDate = cf.RecordDate();
                        }

                        if (firstFound)
                        {
                            if (cfDate < dtFound)
                            {
                                dtFound = cfDate;
                            }
                        }
                        else
                        {
                            if ((cfDate > dtFound) && (cf.DeleteDate().Year == DateTime.MaxValue.Year))
                            {
                                dtFound = cfDate;
                            }
                        }
                    }
                }
            }
            return(dtFound);
        }
Exemplo n.º 4
0
 public clsCashflow(DateTime payDate, DateTime recordDate, DateTime deleteDate, int loanID,
                    double amount, bool actual, clsCashflow.Type typeID, string comment)
 {
     this.dtPayDate      = payDate;
     this.dtRecordDate   = recordDate;
     this.dtDeleteDate   = deleteDate;
     this.iLoanID        = loanID;
     this.dAmount        = amount;
     this.bActual        = actual;
     this.eTypeID        = typeID;
     this.strComment     = comment;
     this.iTransactionID = -1; // unassigned, will be assigned if saved to DB
 }
Exemplo n.º 5
0
        private double _PastDue(DateTime dt, clsCashflow.Type t)
        {
            double dPastDue = 0D;

            if (this.cfCashflows.Count == 0)
            {
                return(0);
            }
            else
            {
                foreach (clsCashflow cf in this.cfCashflows)
                {
                    if ((cf.PayDate() <= dt) && (cf.DeleteDate() > dt.AddYears(100)) && (cf.TypeID() == t) && (!cf.Actual()))
                    {
                        dPastDue += cf.Amount();
                    }
                }
                return(dPastDue);
            }
        }
Exemplo n.º 6
0
        private double _ProjectedToBePaid(DateTime dt, clsCashflow.Type t)
        {
            double dRemain = 0D;

            if (this.cfCashflows.Count == 0)
            {
                return(0);
            }
            else
            {
                foreach (clsCashflow cf in this.cfCashflows)
                {
                    if ((cf.PayDate() > dt) && (cf.DeleteDate() > dt) && (cf.TypeID() == t))
                    {
                        dRemain += cf.Amount();
                    }
                }
                return(dRemain);
            }
        }
Exemplo n.º 7
0
        private double _Paid(DateTime dt, clsCashflow.Type t)
        {
            double dPaid = 0;

            if (this.cfCashflows.Count == 0)
            {
                return(0);
            }
            else
            {
                foreach (clsCashflow cf in this.cfCashflows)
                {
                    if ((cf.PayDate() <= dt) && (cf.Actual()) && (cf.TypeID() == t))
                    {
                        dPaid += cf.Amount();
                    }
                }
                return(dPaid);
            }
        }
Exemplo n.º 8
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"));
        }
Exemplo n.º 9
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.";
        }
Exemplo n.º 10
0
 private bool _Load(int transactionID, clsCSVTable tbl)
 {
     if (transactionID < tbl.Length())
     {
         this.iTransactionID = transactionID;
         this.dtPayDate      = DateTime.Parse(tbl.Value(transactionID, clsCashflow.TransactionDateColumn));
         this.dtRecordDate   = DateTime.Parse(tbl.Value(transactionID, clsCashflow.RecordDateColumn));
         this.dtDeleteDate   = DateTime.Parse(tbl.Value(transactionID, clsCashflow.DeleteDateColumn));
         if (this.dtDeleteDate > new DateTime(2999, 12, 31))
         {
             this.dtDeleteDate = DateTime.MaxValue;
         }
         this.dAmount    = Double.Parse(tbl.Value(transactionID, clsCashflow.AmountColumn));
         this.iLoanID    = Int32.Parse(tbl.Value(transactionID, clsCashflow.LoanColumn));
         this.eTypeID    = (clsCashflow.Type)Int32.Parse(tbl.Value(transactionID, clsCashflow.TransactionTypeColumn));
         this.bActual    = Boolean.Parse(tbl.Value(transactionID, clsCashflow.ActualColumn));
         this.strComment = tbl.Value(transactionID, clsCashflow.CommentColumn);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 11
0
 partial void TypeFilterSelected(NSComboBox sender)
 {
     this.typeFilter = (clsCashflow.Type)((int)this.TypeFilterComboBox.SelectedIndex);
     this.RefreshTable();
 }
Exemplo n.º 12
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);
            }
        }