コード例 #1
0
        public void TestCurrencyAmount()
        {
            // test to string
            CurrencyAmount amount = new CurrencyAmount(123.45);

            Assert.AreEqual("123.45", amount.ToString());

            // test parse
            amount = CurrencyAmount.Parse("123.45");
            Assert.AreEqual("123.45", amount.ToString());

            // test add
            CurrencyAmount amount2 = new CurrencyAmount(543.21);

            amount = new CurrencyAmount(123.45);
            Assert.AreEqual("666.66", CurrencyAmount.Add(amount, amount2).ToString());

            amount.AddTo(amount2);
            Assert.AreEqual("666.66", amount.ToString());

            // test minus
            amount2 = new CurrencyAmount(543.21);
            amount  = new CurrencyAmount(123.45);
            Assert.AreEqual("-419.76", CurrencyAmount.Minus(amount, amount2).ToString());
            Assert.AreEqual("419.76", CurrencyAmount.Minus(amount2, amount).ToString());
            Assert.AreEqual("0.00", CurrencyAmount.Minus(amount2, amount2).ToString());

            // is zero
            Assert.AreEqual(true, CurrencyAmount.Minus(amount2, amount2).IsZero());
        }
コード例 #2
0
        private void glAccountInitAmountChanged(MasterDataIdentity_GLAccount glAccountId
                                                , CurrencyAmount orgAmount, CurrencyAmount newAmount)
        {
            GLAccountBalanceItem item;

            if (!_items.TryGetValue(glAccountId, out item))
            {
                return;
            }

            // ret += newAmount - orgAmount
            item.AddAmount(_coreDriver.StartMonthId
                           , CurrencyAmount.Minus(newAmount, orgAmount));
        }