private FundingLineAccountingRule _getFundingLineAccountingRule(OpenCbsReader reader)
        {
            FundingLineAccountingRule rule = new FundingLineAccountingRule();

            rule.Id           = reader.GetInt("id");
            rule.DebitAccount = new Account {
                Id = reader.GetInt("debit_account_number_id")
            };
            rule.CreditAccount = new Account {
                Id = reader.GetInt("credit_account_number_id")
            };
            rule.BookingDirection = (OBookingDirections)reader.GetSmallInt("booking_direction");

            int?fundingLineId = reader.GetInt("funding_line_id");

            if (fundingLineId.HasValue)
            {
                rule.FundingLine = new FundingLine {
                    Id = fundingLineId.Value
                }
            }
            ;

            return(rule);
        }
    }
Exemple #2
0
        public void Test_SaveFundingLineAccountingRule_When_GenericAccount_Is_Null()
        {
            FundingLineAccountingRule rule = new FundingLineAccountingRule
            {
                CreditAccount = new Account {
                    Id = 2, Number = "1250"
                }
            };

            try
            {
                _accountingRuleServices.SaveAccountingRule(rule);
                Assert.Fail("Accounting Rule shouldn't pass validation test while trying to save (Generic Account is Null).");
            }
            catch (OpenCbsAccountingRuleException exception)
            {
                Assert.AreEqual(OpenCbsAccountingRuleExceptionEnum.GenericAccountIsInvalid, exception.Code);
            }
        }
        public void AddFundingLineRuleForFundingLine()
        {
            Account        genericAccount  = _accountManager.Select(1);
            Account        specificAccount = _accountManager.Select(2);
            FundingLine    fundingLine     = _fundingLineManager.SelectFundingLineById(1, false);
            EventType      eventType       = _eventManager.SelectEventTypeByEventType("RGLE");
            EventAttribute eventAttribute  = _eventManager.SelectEventAttributeByCode("principal");

            FundingLineAccountingRule rule = new FundingLineAccountingRule
            {
                DebitAccount     = genericAccount,
                CreditAccount    = specificAccount,
                FundingLine      = fundingLine,
                BookingDirection = OBookingDirections.Credit,
                EventAttribute   = eventAttribute,
                EventType        = eventType
            };

            rule.Id = _accountingRuleManager.AddAccountingRule(rule);
            Assert.AreNotEqual(0, rule.Id);
        }