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; }
public void Test_SaveFundingLineAccountingRule_When_SpecificAccount_Is_Null() { FundingLineAccountingRule rule = new FundingLineAccountingRule { DebitAccount = new Account { Id = 1, Number = "1150" } }; 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.SpecificAccountIsInvalid, 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); }