Exemplo n.º 1
0
        public TransactionLine(FFDataSet.LineItemRow lineRow)
        {
            if (lineRow == null)
            {
                throw new Exception("Null Line Item Row.");
            }

            FFDataSet.TransactionRow tRow;
            tRow = DataSetModel.Instance.getTransactionRowWithID(lineRow.transactionID);

            if (tRow == null)
            {
                throw new Exception("Orphan Line Item Row.");
            }

            this.Transaction = new TransactionModel(tRow);

            foreach (LineItemModel line in Transaction.LineItems)
            {
                if (line.LineID == lineRow.id)
                {
                    this.LineItem = line;
                }
            }

            if (this.LineItem == null)
            {
                throw new Exception("No line with matching ID.");
            }
        }
Exemplo n.º 2
0
        public LineItemModel[] getLineItemModels()
        {
            FFDataSet.LineItemRow[] rawLines   = this.transactionRow.GetLineItemRows();
            LineItemModel[]         modelLines = new LineItemModel[rawLines.Length];

            for (int i = 0; i < rawLines.Length; i++)
            {
                modelLines[i] = new LineItemModel(rawLines[i]);
            }

            return(modelLines);
        }
Exemplo n.º 3
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        //  Public Functions
        ///////////////////////////////////////////////////////////////////////////////////////////
        public RegistryLineModel()
        {
            this.lineItem           = new LineItemModel();
            this.lineItem.AccountID = RegistryLineModel.CurrentAccountID;
            this.lineItem.Polarity  = PolarityCON.CREDIT;

            this.oppositeLine          = new LineItemModel();
            this.oppositeLine.Polarity = PolarityCON.DEBIT;

            this.transaction = new TransactionModel();
            this.transaction.LineItems.Add(this.lineItem);
            this.transaction.LineItems.Add(this.oppositeLine);
        }
Exemplo n.º 4
0
        public RegistryLineModel(TransactionLine tLine)
        {
            this.transaction = tLine.Transaction;
            this.lineItem    = tLine.LineItem;


            if (this.getOppositeLineCount == 1)
            {
                foreach (LineItemModel line in this.transaction.LineItems)
                {
                    if (line.Polarity != this.lineItem.Polarity)
                    {
                        this.oppositeLine = line;
                    }
                }
            }
        }
Exemplo n.º 5
0
        private decimal suggestedAmount(LineItemModel newLine)
        {
            decimal suggested = 0;

            if (newLine.Polarity == PolarityCON.DEBIT)
            {
                suggested = this.CreditSum - this.DebitSum;
            }
            else
            {
                suggested = this.DebitSum - this.CreditSum;
            }

            if (suggested < 0)
            {
                suggested = 0;
            }

            return(suggested);
        }