示例#1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dividendDetails">The details of the cash dividend (date, price)</param>
        /// <param name="units">The total number of units over which dividend is paid</param>
        public ForeignExchange(IJournalEntryLine line)
            : base((ICustomerAccount)line.GiroAccount, line.Parent, getDescription(line))
        {
            if (!(line.Status == JournalEntryLineStati.Booked && line.BookComponent == null &&
                (line.GLAccount.CashTransferType == CashTransferTypes.ForexBaseCurrency ||
                line.GLAccount.CashTransferType == CashTransferTypes.ForexNonBaseCurrency)))
                throw new ApplicationException("This journal entry line is not a valid Foreign Exchange.");

            BookingComponentTypes bookingComponentType = BookingComponentTypes.ForexBaseCurrency;
            switch (line.GLAccount.CashTransferType)
            {
                case CashTransferTypes.ForexNonBaseCurrency:
                    bookingComponentType = BookingComponentTypes.ForexNonBaseCurrency;
                    break;
                case CashTransferTypes.ForexBaseCurrency:
                    bookingComponentType = BookingComponentTypes.ForexBaseCurrency;
                    break;
            }

            IForeignExchangeComponent newComponent = new ForeignExchangeComponent(this, bookingComponentType, this.CreationDate);
            line.BookComponent = newComponent.Component;
            newComponent.JournalLines.Add(line);
            line.BookComponent.MainLine = line;
            newComponent.Component.SetDescription(this.Description);
            this.Components.Add(newComponent);
        }
示例#2
0
 /// <summary>
 /// Creates the first ValuationCashMutation for a n instrument
 /// </summary>
 /// <param name="line">The first JournalEntryLine that creates this Valuation Mutation</param>
 internal ValuationCashMutation(IJournalEntryLine line)
 {
     this.Account = line.GiroAccount;
     this.Instrument = line.BookingRelatedInstrument;
     this.ValuationCashType = line.GLAccount.ValuationCashType;
     this.Date = line.BookDate;
 }
示例#3
0
 //public CashDetailLine(string type, DateTime txDate, DateTime creationdate, string cashComponent, string ledgerCode, Money amount)
 //{
 //    this.Type = type;
 //    this.Transactiondate = txDate;
 //    this.CreationDate = creationdate;
 //    this.CashComponent = cashComponent;
 //    this.LedgerCode = ledgerCode;
 //    this.Amount = amount;
 //}
 public CashDetailLine(IJournalEntryLine line)
 {
     this.Type = line.GLAccount.Description;
     this.Transactiondate = line.Parent.TransactionDate;
     this.CreationDate = line.CreationDate;
     this.CashComponent = line.GLAccount.Description; ;
     this.LedgerCode = line.GLAccount.GLAccountNumber;
     this.Amount = line.Balance.Negate();
     this.Side = "";
     this.Fund = "";
 }
示例#4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dividendDetails">The details of the cash dividend (date, price)</param>
        /// <param name="units">The total number of units over which dividend is paid</param>
        public CashTransfer(IJournalEntryLine line)
            : base((ICustomerAccount)line.GiroAccount, line.Parent, getDescription(line))
        {
            if (!(line.Status == JournalEntryLineStati.Booked && line.BookComponent == null &&
                (line.GLAccount.CashTransferType == CashTransferTypes.Deposit || line.GLAccount.CashTransferType == CashTransferTypes.Withdrawal)))
                throw new ApplicationException("This journal entry line is not a valid cashmutation.");

            ICashTransferComponent newComponent = new CashTransferComponent(this, BookingComponentTypes.CashTransfer, this.CreationDate);
            line.BookComponent = newComponent.Component;
            newComponent.JournalLines.Add(line);
            line.BookComponent.MainLine = line;
            newComponent.Component.SetDescription(this.Description);
            this.Components.Add(newComponent);
        }
示例#5
0
        public CashDetailLine(IJournalEntryLine line, bool IsFirstLine)
        {
            if (IsFirstLine)
            {
                ITransactionOrder tx = (ITransactionOrder)((ITransactionComponent)line.BookComponent.Parent).ParentTransaction;
                this.TradeID = tx.Key;
                this.Type = tx.TransactionTypeDisplay;
                if (tx.TxSide == B4F.TotalGiro.Orders.Side.Buy)
                    this.Side = "Aankoop";
                else
                    this.Side = "Verkoop";

                this.Size = tx.ValueSize.Quantity;
                this.Fund = tx.TradedInstrument.Name;
                this.Price = tx.Price;
                this.Transactiondate = line.Parent.TransactionDate;
                this.CreationDate = line.CreationDate;
            }

            this.CashComponent = line.GLAccount.Description; ;
            this.LedgerCode = line.GLAccount.GLAccountNumber;
            this.Amount = line.Balance.Negate();
        }
示例#6
0
        private IValuationCashMutation getNearestMutation(ref IValuationCashMutation[] mutationsToSave, IJournalEntryLine line, int matchlevel)
        {
            IValuationCashMutation mut = null;
            TimeSpan days = TimeSpan.MaxValue;
            string lineKey;
            string mutKey;
            switch (matchlevel)
            {
                case 1:
                    lineKey = string.Format("{0}",
                        line.Currency.Key.ToString());
                    break;
                case 2:
                    lineKey = string.Format("{0}-{1}",
                        line.Currency.Key.ToString(),
                        (line.BookingRelatedInstrument != null ? line.BookingRelatedInstrument.Key.ToString() : "0"));
                    break;
                default: // 3
                    lineKey = string.Format("{0}-{1}-{2}",
                        line.Currency.Key.ToString(),
                        (line.BookingRelatedInstrument != null ? line.BookingRelatedInstrument.Key.ToString() : "0"),
                        line.GLAccount.ValuationCashType.ToString());
                    break;
            }

            foreach (IValuationCashMutation mutation in mutationsToSave)
            {
                switch (matchlevel)
                {
                    case 1:
                        mutKey = string.Format("{0}",
                            mutation.Amount.Underlying.Key.ToString());
                        break;
                    case 2:
                        mutKey = string.Format("{0}-{1}",
                            mutation.Amount.Underlying.Key.ToString(),
                            (mutation.Instrument != null ? mutation.Instrument.Key.ToString() : "0"));
                        break;
                    default: // 3
                        mutKey = string.Format("{0}-{1}-{2}",
                            mutation.Amount.Underlying.Key.ToString(),
                            (mutation.Instrument != null ? mutation.Instrument.Key.ToString() : "0"),
                            mutation.ValuationCashType.ToString());
                        break;
                }

                if (lineKey.Equals(mutKey))
                {
                    //if (mut != null && ((TimeSpan)(mutation.Date - posTx.TransactionDate)).Days > 0)
                    //    return mut;

                    if (mut == null || (days < (mutation.Date - line.BookDate)))
                    {
                        mut = mutation;
                        days = mut.Date - line.BookDate;
                    }

                    if (days.Days >= 0)
                        return mut;
                }
            }
            return mut;
        }
示例#7
0
        private IMonetaryValuationMutation getNearestMutation(ref List<IValuationMutation> mutationsToSave, IJournalEntryLine line)
        {
            IMonetaryValuationMutation mut = null;
            TimeSpan days = TimeSpan.MaxValue;

            foreach (IValuationMutation mutation in mutationsToSave)
            {
                if (line.Currency.Equals(mutation.Instrument))
                {
                    //if (mut != null && ((TimeSpan)(mutation.Date - line.TransactionDate)).Days > 0)
                    //    return mut;

                    if (mut == null || (days < (mutation.Date - line.BookDate)))
                    {
                        mut = (IMonetaryValuationMutation)mutation;
                        days = mut.Date - line.BookDate;
                    }

                    if (days.Days >= 0)
                        return mut;
                }
            }
            if (mut == null)
            {
                // if no match, just take the first the first one
                mut = (IMonetaryValuationMutation)mutationsToSave[0];
            }
            return mut;
        }
示例#8
0
 protected static string getDescription(IJournalEntryLine line)
 {
     string description = "";
     if (!string.IsNullOrEmpty(line.Description))
         description = line.Description;
     else
         description = line.GLAccount.CashTransferType.ToString();
     return description;
 }
 internal JournalEntryLineValuationMapping(IJournalEntryLine line, IValuationMutation mutation)
 {
     this.key = line.Key;
     this.ValuationMutation = mutation;
     this.IsRelevant = line.IsRelevant;
 }
示例#10
0
 public bool ContainsLine(IJournalEntryLine line)
 {
     if (Mappings.Count > 0)
     {
         foreach (JournalEntryLineValuationCashMapping mapping in Mappings)
         {
             if (mapping.Key.Equals(line.Key))
                 return true;
         }
     }
     return false;
 }
示例#11
0
 public void AddNotRelevantLine(IJournalEntryLine notRelevantLine)
 {
     Mappings.Add(new JournalEntryLineValuationCashMapping(notRelevantLine, this));
 }
示例#12
0
        public void AddLine(IJournalEntryLine line)
        {
            if (!Account.Equals(line.ParentSubPosition.ParentPosition.Account))
                throw new ApplicationException("It is not possible to create Valuations when multiple positions exists for one instrument.");

            if (Instrument != null && line.BookingRelatedInstrument != null)
            {
                if (!Instrument.Equals(line.BookingRelatedInstrument))
                    throw new ApplicationException("The cash generating instrument does not equal the cash generating instrument on the cash valuation mutation.");
            }
            else if ((Instrument != null && line.BookingRelatedInstrument == null) || (Instrument == null && line.BookingRelatedInstrument != null))
                throw new ApplicationException("The cash generating instrument does not equal the cash generating instrument on the cash valuation mutation.");

            if (!ValuationCashType.Equals(line.GLAccount.ValuationCashType))
                throw new ApplicationException("The cash type does not equal the cash type on the cash valuation mutation.");

            if (line.GLAccount.ValuationCashTypeDetails.IsSettled != line.ParentSubPosition.IsSettled)
                throw new ApplicationException("The settled flag of the cash type does not equal the settled flag on journal entry line.");

            Money amount;
            if (Instrument != null)
                amount = line.Balance.Negate();
            else
                amount = line.BaseBalance.Negate();
            Money baseAmount = line.BaseBalance.Negate();

            Amount += amount;
            amountToDate += amount;
            BaseAmount += baseAmount;
            baseAmountToDate += baseAmount;

            Mappings.Add(new JournalEntryLineValuationCashMapping(line, this));
        }
示例#13
0
        private static void deleteLine(IDalSession session, IJournalEntryLine line)
        {
            IJournalEntry journalEntry = line.Parent;
            int removedLineNumber = line.LineNumber;
            bool glAccountIsFixed = line.GLAccountIsFixed;

            journalEntry.Lines.Remove(line);
            session.Delete(line);

            if (!glAccountIsFixed)
                journalEntry.Lines.ShiftLineNumbers(removedLineNumber, -1);

            JournalEntryMapper.Update(session, journalEntry);
        }
示例#14
0
        private static void assignProperties(IDalSession session, IJournalEntryLine updatingLine, JournalEntryLineEditView lineEditView,
                                             ICurrency defaultCurrency)
        {
            if (updatingLine.GLAccount == null || lineEditView.GLAccountId != updatingLine.GLAccount.Key)
            {
                IGLAccount glAccount = GLAccountMapper.GetGLAccount(session, lineEditView.GLAccountId);
                if (glAccount != null)
                    updatingLine.GLAccount = glAccount;
                else
                    throw new ApplicationException("Journal Entry Line must have a valid GLAccount.");
            }

            ICurrency currency = null;
            if (lineEditView.CurrencyId != 0)
            {
                if (updatingLine.Balance == null || lineEditView.CurrencyId != updatingLine.Balance.Underlying.Key)
                {
                    currency = InstrumentMapper.GetCurrency(session, lineEditView.CurrencyId);
                    if (currency == null)
                        throw new ApplicationException("Journal Entry Line must have a valid Currency.");
                }
                else
                    currency = (ICurrency)updatingLine.Balance.Underlying;
            }
            else
                currency = defaultCurrency;

            if ((lineEditView.DebitQuantity != 0m && lineEditView.CreditQuantity == 0m) ||
                (lineEditView.DebitQuantity == 0m && lineEditView.CreditQuantity != 0m))
                updatingLine.Balance = new Money(lineEditView.DebitQuantity - lineEditView.CreditQuantity, currency, currency.BaseCurrency, lineEditView.ExchangeRate);
            else
                throw new ApplicationException("Either Debit or Credit (but not both) on Journal Entry Line must be non-zero.");

            if (updatingLine.GLAccount.RequiresGiroAccount)
            {
                if (lineEditView.GiroAccountNumber == string.Empty)
                    throw new ApplicationException(
                        string.Format("Journal Entry Line is required by its GL Account ('{0}') to have a non-empty Giro Account.",
                                      updatingLine.GLAccount.FullDescription));

                if (updatingLine.GiroAccount == null || lineEditView.GiroAccountNumber != updatingLine.GiroAccount.Number)
                {
                    IAccountTypeCustomer giroAccount = AccountMapper.GetAccountByNumber(session, lineEditView.GiroAccountNumber) as IAccountTypeCustomer;
                    if (giroAccount != null)
                        updatingLine.GiroAccount = giroAccount;
                    else
                        throw new ApplicationException("Journal Entry Line must have a valid Giro Account (Customer or Nostro).");
                }
            }
            else
            {
                if (lineEditView.GiroAccountNumber != string.Empty)
                    throw new ApplicationException(
                        string.Format("Journal Entry Line is prohibited by its GL Account ('{0}') to have a Giro Account.",
                                      updatingLine.GLAccount.FullDescription));

                updatingLine.GiroAccount = null;
            }

            updatingLine.Description = lineEditView.Description;
        }
示例#15
0
 internal void clientSettle(IJournalEntry clientSettleJournal, IJournalEntryLine newLine, IGLAccount account, Money balance, IBookingComponent bookingComponent, IAccountTypeInternal giroAccount)
 {
     newLine.GLAccount = account;
     newLine.Balance = balance;
     newLine.BookComponent = bookingComponent;
     newLine.GiroAccount = giroAccount;
     newLine.IsSettledStatus = true;
     clientSettleJournal.Lines.AddJournalEntryLine(newLine);
     newLine.BookLine();
 }