Esempio n. 1
0
        public static void UpdateAccountCcyAmt(BankStmt obj, decimal fromAmt, Currency fromCcy)
        {
            if (obj.Account == null)
            {
                return;
            }
            var session = obj.Session;

            if (obj.Account.Currency == null)
            {
                throw new UserFriendlyException("No currency for account " + obj.Account.Name);
            }
            if (obj.Account.Currency.Oid == fromCcy.Oid)
            {
                obj.TranAmount = fromAmt;
            }
            else if (obj.TranDate != default(DateTime))
            {
                var rateObj = GetForexRateObject(session, fromCcy, obj.Account.Currency, (DateTime)obj.TranDate);
                if (rateObj != null)
                {
                    var value = fromAmt * (decimal)rateObj.ConversionRate;
                    obj.SetPropertyValue("TranAmount", ref obj._TranAmount, Math.Round(value, 2));
                }
            }
        }
Esempio n. 2
0
        public static void UpdateCounterCcyAmt(BankStmt obj, decimal fromAmt, Currency fromCcy)
        {
            if (obj.CounterCcy == null)
            {
                return;
            }
            var session = obj.Session;

            if (obj.CounterCcy.Oid == fromCcy.Oid)
            {
                obj.CounterCcyAmt = fromAmt;
            }
            else if (obj.TranDate != default(DateTime))
            {
                var rateObj = GetForexRateObject(session, fromCcy, obj.CounterCcy, (DateTime)obj.TranDate);
                if (rateObj != null)
                {
                    // TODO: do not assume that Local Currency is 'AUD'
                    var value = Math.Round(fromAmt * (decimal)rateObj.ConversionRate, 2);
                    obj.SetPropertyValue("CounterCcyAmt", ref obj._CounterCcyAmt, value);
                }
            }
        }
Esempio n. 3
0
        public static void UpdateFunctionalCcyAmt(BankStmt obj, decimal fromAmt, Currency fromCcy)
        {
            var session = obj.Session;

            if (fromCcy == null)
            {
                return;
            }
            if (SetOfBooks.CachedInstance.FunctionalCurrency.Oid == fromCcy.Oid)
            {
                obj.FunctionalCcyAmt = fromAmt;
            }
            else if (obj.TranDate != default(DateTime))
            {
                var rateObj = GetForexRateObject(session, fromCcy, SetOfBooks.GetInstance(obj.Session).FunctionalCurrency, (DateTime)obj.TranDate);
                if (rateObj != null)
                {
                    // TODO: do not assume that Functional Currency is 'AUD'
                    var value = fromAmt * (decimal)rateObj.ConversionRate;
                    obj.SetPropertyValue("FunctionalCcyAmt", ref obj._FunctionalCcyAmt, Math.Round(value, 2));
                }
            }
        }