public void GivenJournal_WhenBuildWithout_ThenCloseWhenInBalanceIsFalse() { var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.DatabaseSession) .WithInternalOrganisation(internalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.DatabaseSession) .WithInternalOrganisation(internalOrganisation) .WithJournalType(new JournalTypes(this.DatabaseSession).Bank) .WithContraAccount(internalOrganisationGlAccount) .WithDescription("journal") .Build(); this.DatabaseSession.Derive(); Assert.IsFalse(journal.CloseWhenInBalance); }
public void GivenJournal_WhenBuildWithout_ThenUseAsDefaultIsFalse() { this.InternalOrganisation.DoAccounting = true; this.Session.Derive(); var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.Session) .WithJournalType(new JournalTypes(this.Session).Bank) .WithContraAccount(internalOrganisationGlAccount) .WithDescription("journal") .Build(); this.Session.Derive(false); Assert.False(journal.UseAsDefault); }
public void GivenJournal_WhenDeriving_ThenSingletonMustExist() { this.InternalOrganisation.DoAccounting = true; this.Session.Derive(); var glAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.Session).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.Session).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.Session).WithDescription("accountGroup").Build()) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithFromDate(this.Session.Now()) .WithGeneralLedgerAccount(glAccount) .Build(); this.Session.Commit(); var builder = new JournalBuilder(this.Session); builder.WithDescription("description"); builder.WithJournalType(new JournalTypes(this.Session).Bank); builder.WithContraAccount(internalOrganisationGlAccount); builder.Build(); Assert.False(this.Session.Derive(false).HasErrors); }
public void GivenOrganisationGlAccount_WhenDeriving_ThenRequiredRelationsMustExist() { var builder = new OrganisationGlAccountBuilder(this.DatabaseSession); builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder.WithInternalOrganisation(new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation")); builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder.WithGeneralLedgerAccount(new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.DatabaseSession).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.DatabaseSession).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.DatabaseSession).WithDescription("accountGroup").Build()) .Build()); builder.Build(); Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); }
public void GivenOwnCreditCardForInternalOrganisationThatDoesAccounting_WhenDeriving_ThenEitherGeneralLedgerAccountOrJournalMustExist() { var supplier = new OrganisationBuilder(this.DatabaseSession) .WithName("supplier") .WithLocale(new Locales(this.DatabaseSession).EnglishGreatBritain) .Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); var supplierRelationship = new SupplierRelationshipBuilder(this.DatabaseSession) .WithSupplier(supplier) .WithInternalOrganisation(internalOrganisation) .WithFromDate(DateTime.UtcNow) .Build(); var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.DatabaseSession) .WithInternalOrganisation(internalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.DatabaseSession).WithDescription("journal").Build(); var creditCard = new CreditCardBuilder(this.DatabaseSession) .WithCardNumber("4012888888881881") .WithExpirationYear(2016) .WithExpirationMonth(03) .WithNameOnCard("M.E. van Knippenberg") .WithCreditCardCompany(new CreditCardCompanyBuilder(this.DatabaseSession).WithName("Visa").Build()) .Build(); var paymentMethod = new OwnCreditCardBuilder(this.DatabaseSession) .WithCreditCard(creditCard) .WithCreditor(supplierRelationship) .Build(); this.DatabaseSession.Commit(); internalOrganisation.RemovePaymentMethods(); internalOrganisation.AddPaymentMethod(paymentMethod); internalOrganisation.DoAccounting = true; Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); paymentMethod.Journal = journal; Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); paymentMethod.RemoveJournal(); paymentMethod.GeneralLedgerAccount = internalOrganisationGlAccount; Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); }
public void GivenJournal_WhenDeriving_ThenContraAccountCanNotBeChangedWhenJournalEntriesArePresent() { this.InternalOrganisation.DoAccounting = true; this.Session.Derive(); var generalLedgerAccount1 = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("bankAccount 1") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.Session).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.Session).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.Session).WithDescription("accountGroup").Build()) .Build(); var internalOrganisationGlAccount1 = new OrganisationGlAccountBuilder(this.Session) .WithFromDate(this.Session.Now()) .WithGeneralLedgerAccount(generalLedgerAccount1) .Build(); var generalLedgerAccount2 = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0002") .WithName("bankAccount 2") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.Session).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.Session).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.Session).WithDescription("accountGroup").Build()) .Build(); var internalOrganisationGlAccount2 = new OrganisationGlAccountBuilder(this.Session) .WithFromDate(this.Session.Now()) .WithGeneralLedgerAccount(generalLedgerAccount2) .Build(); var journal = new JournalBuilder(this.Session) .WithDescription("description") .WithContraAccount(internalOrganisationGlAccount1) .WithJournalType(new JournalTypes(this.Session).Bank) .Build(); this.Session.Derive(); Assert.Equal(generalLedgerAccount1, journal.PreviousContraAccount.GeneralLedgerAccount); journal.AddJournalEntry(new JournalEntryBuilder(this.Session) .WithJournalEntryDetail(new JournalEntryDetailBuilder(this.Session) .WithAmount(1) .WithDebit(true) .WithGeneralLedgerAccount(internalOrganisationGlAccount1) .Build()) .Build()); journal.ContraAccount = internalOrganisationGlAccount2; Assert.Equal("Journal.ContraAccount, Journal.PreviousContraAccount are not equal", this.Session.Derive(false).Errors[0].Message); }
public void GivenOwnCreditCard_WhenDeriving_ThenGeneralLedgerAccountAndJournalAtMostOne() { this.InternalOrganisation.DoAccounting = true; this.Session.Derive(); var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.Session).WithDescription("journal").Build(); var creditCard = new CreditCardBuilder(this.Session) .WithCardNumber("4012888888881881") .WithExpirationYear(this.Session.Now().Year + 1) .WithExpirationMonth(03) .WithNameOnCard("M.E. van Knippenberg") .WithCreditCardCompany(new CreditCardCompanyBuilder(this.Session).WithName("Visa").Build()) .Build(); var collectionMethod = new OwnCreditCardBuilder(this.Session) .WithCreditCard(creditCard) .WithGeneralLedgerAccount(internalOrganisationGlAccount) .Build(); ((OrganisationDerivedRoles)this.InternalOrganisation).AddActiveCollectionMethod(collectionMethod); this.Session.Commit(); var internalOrganisation = this.InternalOrganisation; internalOrganisation.DoAccounting = true; internalOrganisation.DefaultCollectionMethod = collectionMethod; Assert.False(this.Session.Derive(false).HasErrors); collectionMethod.Journal = journal; Assert.True(this.Session.Derive(false).HasErrors); collectionMethod.RemoveGeneralLedgerAccount(); Assert.False(this.Session.Derive(false).HasErrors); }
public void GivenCashPaymentMethodForInternalOrganisationThatDoesAccounting_WhenDeriving_ThenEitherGeneralLedgerAccountOrJournalMustExist() { var supplier = new OrganisationBuilder(this.DatabaseSession) .WithName("supplier") .WithLocale(new Locales(this.DatabaseSession).EnglishGreatBritain) .Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); var supplierRelationship = new SupplierRelationshipBuilder(this.DatabaseSession) .WithSupplier(supplier) .WithInternalOrganisation(internalOrganisation) .WithFromDate(DateTime.UtcNow) .Build(); var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.DatabaseSession) .WithInternalOrganisation(internalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.DatabaseSession).WithDescription("journal").Build(); this.DatabaseSession.Commit(); var cash = new CashBuilder(this.DatabaseSession) .WithDescription("description") .WithCreditor(supplierRelationship) .Build(); internalOrganisation.RemovePaymentMethods(); internalOrganisation.AddPaymentMethod(cash); internalOrganisation.DoAccounting = true; Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); cash.Journal = journal; Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); cash.RemoveJournal(); cash.GeneralLedgerAccount = internalOrganisationGlAccount; Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); }
public void GivenJournal_WhenDeriving_ThenContraAccountCanBeChangedWhenNotUsedYet() { this.InternalOrganisation.DoAccounting = true; this.Session.Derive(); var generalLedgerAccount1 = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("bankAccount 1") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.Session).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.Session).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.Session).WithDescription("accountGroup").Build()) .Build(); var internalOrganisationGlAccount1 = new OrganisationGlAccountBuilder(this.Session) .WithFromDate(this.Session.Now()) .WithGeneralLedgerAccount(generalLedgerAccount1) .Build(); var generalLedgerAccount2 = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0002") .WithName("bankAccount 2") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.Session).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.Session).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.Session).WithDescription("accountGroup").Build()) .Build(); var internalOrganisationGlAccount2 = new OrganisationGlAccountBuilder(this.Session) .WithFromDate(this.Session.Now()) .WithGeneralLedgerAccount(generalLedgerAccount2) .Build(); var journal = new JournalBuilder(this.Session) .WithDescription("description") .WithContraAccount(internalOrganisationGlAccount1) .WithJournalType(new JournalTypes(this.Session).Bank) .Build(); this.Session.Derive(); Assert.Equal(generalLedgerAccount1, journal.PreviousContraAccount.GeneralLedgerAccount); journal.ContraAccount = internalOrganisationGlAccount2; this.Session.Derive(); Assert.Equal(generalLedgerAccount2, journal.PreviousContraAccount.GeneralLedgerAccount); }
public void GivenOwnBankAccountForSingletonThatDoesAccounting_WhenDeriving_ThenEitherGeneralLedgerAccountOrJournalMustExist() { var internalOrganisation = this.InternalOrganisation; var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.Session).WithDescription("journal").Build(); var netherlands = new Countries(this.Session).CountryByIsoCode["NL"]; var euro = netherlands.Currency; var bank = new BankBuilder(this.Session).WithCountry(netherlands).WithName("RABOBANK GROEP").WithBic("RABONL2U").Build(); var bankAccount = new BankAccountBuilder(this.Session).WithBank(bank).WithCurrency(euro).WithIban("NL50RABO0109546784").WithNameOnAccount("Martien").Build(); var collectionMethod = new OwnBankAccountBuilder(this.Session) .WithDescription("own account") .WithBankAccount(bankAccount) .Build(); this.Session.Commit(); internalOrganisation.DoAccounting = true; ((OrganisationDerivedRoles)internalOrganisation).AddActiveCollectionMethod(collectionMethod); Assert.True(this.Session.Derive(false).HasErrors); collectionMethod.Journal = journal; Assert.False(this.Session.Derive(false).HasErrors); collectionMethod.RemoveJournal(); collectionMethod.GeneralLedgerAccount = internalOrganisationGlAccount; Assert.False(this.Session.Derive(false).HasErrors); }
public void GivenOwnCreditCardForSingletonThatDoesAccounting_WhenDeriving_ThenEitherGeneralLedgerAccountOrJournalMustExist() { this.InternalOrganisation.DoAccounting = true; this.Session.Derive(); var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.Session).WithDescription("journal").Build(); var creditCard = new CreditCardBuilder(this.Session) .WithCardNumber("4012888888881881") .WithExpirationYear(this.Session.Now().Year + 1) .WithExpirationMonth(03) .WithNameOnCard("M.E. van Knippenberg") .WithCreditCardCompany(new CreditCardCompanyBuilder(this.Session).WithName("Visa").Build()) .Build(); var paymentMethod = new OwnCreditCardBuilder(this.Session) .WithCreditCard(creditCard) .Build(); this.InternalOrganisation.AddPaymentMethod(paymentMethod); Assert.True(this.Session.Derive(false).HasErrors); paymentMethod.Journal = journal; Assert.False(this.Session.Derive(false).HasErrors); paymentMethod.RemoveJournal(); paymentMethod.GeneralLedgerAccount = internalOrganisationGlAccount; Assert.False(this.Session.Derive(false).HasErrors); }
public void GivenOrganisationGlAccount_WhenBuild_ThenHasBankStatementTransactionsIsAlwaysFalse() { var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.Session).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.Session).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.Session).WithDescription("accountGroup").Build()) .Build(); var organisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); this.Session.Derive(); Assert.False(organisationGlAccount.HasBankStatementTransactions); }
public void GivenOwnBankAccount_WhenDeriving_ThenGeneralLedgerAccountAndJournalAtMostOne() { var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.Session).WithDescription("journal").Build(); var netherlands = new Countries(this.Session).CountryByIsoCode["NL"]; var euro = netherlands.Currency; var bank = new BankBuilder(this.Session).WithCountry(netherlands).WithName("RABOBANK GROEP").WithBic("RABONL2U").Build(); var bankAccount = new BankAccountBuilder(this.Session).WithBank(bank).WithCurrency(euro).WithIban("NL50RABO0109546784").WithNameOnAccount("Martien").Build(); var paymentMethod = new OwnBankAccountBuilder(this.Session) .WithDescription("own account") .WithBankAccount(bankAccount) .WithGeneralLedgerAccount(internalOrganisationGlAccount) .Build(); this.Session.Commit(); var internalOrganisation = this.InternalOrganisation; internalOrganisation.DoAccounting = true; internalOrganisation.DefaultCollectionMethod = paymentMethod; Assert.False(this.Session.Derive(false).HasErrors); paymentMethod.Journal = journal; Assert.True(this.Session.Derive(false).HasErrors); paymentMethod.RemoveGeneralLedgerAccount(); Assert.False(this.Session.Derive(false).HasErrors); }
public void GivenCashPaymentMethodForSingletonThatDoesAccounting_WhenDeriving_ThenEitherGeneralLedgerAccountOrJournalMustExist() { var internalOrganisation = this.InternalOrganisation; var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithInternalOrganisation(this.InternalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.Session) .WithDescription("journal") .Build(); this.Session.Commit(); var cash = new CashBuilder(this.Session) .WithDescription("description") .Build(); internalOrganisation.DoAccounting = true; ((OrganisationDerivedRoles)internalOrganisation).AddActiveCollectionMethod(cash); Assert.True(this.Session.Derive(false).HasErrors); cash.Journal = journal; Assert.False(this.Session.Derive(false).HasErrors); cash.RemoveJournal(); cash.GeneralLedgerAccount = internalOrganisationGlAccount; Assert.False(this.Session.Derive(false).HasErrors); }
public void GivenOrganisationGlAccount_WhenDeriving_ThenRequiredRelationsMustExist() { var builder = new OrganisationGlAccountBuilder(this.Session); builder.Build(); Assert.True(this.Session.Derive(false).HasErrors); this.Session.Rollback(); builder.WithGeneralLedgerAccount(new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.Session).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.Session).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.Session).WithDescription("accountGroup").Build()) .Build()); builder.Build(); Assert.False(this.Session.Derive(false).HasErrors); }
public void GivenOrganisationGlAccount_WhenBuild_ThenHasBankStatementTransactionsIsAlwaysFalse() { var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.DatabaseSession).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.DatabaseSession).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.DatabaseSession).WithDescription("accountGroup").Build()) .Build(); var organisationGlAccount = new OrganisationGlAccountBuilder(this.DatabaseSession) .WithInternalOrganisation(internalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); this.DatabaseSession.Derive(); Assert.IsFalse(organisationGlAccount.HasBankStatementTransactions); }
public void GivenOrganisationGlAccount_WhenNotReferenced_ThenAccountIsNeutral() { var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.Session).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.Session).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.Session).WithDescription("accountGroup").Build()) .Build(); var organisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); Assert.True(organisationGlAccount.IsNeutralAccount()); Assert.False(organisationGlAccount.IsBankAccount()); Assert.False(organisationGlAccount.IsCashAccount()); Assert.False(organisationGlAccount.IsCostAccount()); Assert.False(organisationGlAccount.IsCreditorAccount()); Assert.False(organisationGlAccount.IsDebtorAccount()); Assert.False(organisationGlAccount.IsInventoryAccount()); Assert.False(organisationGlAccount.IsTurnOverAccount()); }
public void GivenCashPaymentMethod_WhenDeriving_ThenGeneralLedgerAccountAndJournalAtMostOne() { var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.Session).WithDescription("journal").Build(); this.Session.Commit(); var cash = new CashBuilder(this.Session) .WithDescription("description") .WithGeneralLedgerAccount(internalOrganisationGlAccount) .Build(); var internalOrganisation = this.InternalOrganisation; internalOrganisation.DoAccounting = true; internalOrganisation.DefaultCollectionMethod = cash; Assert.False(this.Session.Derive(false).HasErrors); cash.Journal = journal; Assert.True(this.Session.Derive(false).HasErrors); cash.RemoveGeneralLedgerAccount(); Assert.False(this.Session.Derive(false).HasErrors); }
public void GivenJournal_WhenDeriving_ThenJournalTypeCanNotBeChangedWhenJournalEntriesArePresent() { var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); var generalLedgerAccount1 = new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0001") .WithName("bankAccount 1") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.DatabaseSession).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.DatabaseSession).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.DatabaseSession).WithDescription("accountGroup").Build()) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.DatabaseSession) .WithFromDate(DateTime.UtcNow) .WithInternalOrganisation(internalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount1) .Build(); var journal = new JournalBuilder(this.DatabaseSession) .WithDescription("description") .WithContraAccount(internalOrganisationGlAccount) .WithJournalType(new JournalTypes(this.DatabaseSession).Bank) .Build(); this.DatabaseSession.Derive(true); Assert.AreEqual(generalLedgerAccount1, journal.PreviousContraAccount.GeneralLedgerAccount); journal.AddJournalEntry(new JournalEntryBuilder(this.DatabaseSession) .WithJournalEntryDetail(new JournalEntryDetailBuilder(this.DatabaseSession) .WithAmount(1) .WithDebit(true) .WithGeneralLedgerAccount(internalOrganisationGlAccount) .Build()) .Build()); journal.JournalType = new JournalTypes(this.DatabaseSession).Cash; Assert.AreEqual("Journal.JournalType, Journal.PreviousJournalType are not equal", this.DatabaseSession.Derive().Errors[0].Message); }
public void GivenJournal_WhenDeriving_ThenJournalTypeMustExist() { var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); var glAccount = new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.DatabaseSession).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.DatabaseSession).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.DatabaseSession).WithDescription("accountGroup").Build()) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.DatabaseSession) .WithFromDate(DateTime.UtcNow) .WithInternalOrganisation(internalOrganisation) .WithGeneralLedgerAccount(glAccount) .Build(); this.DatabaseSession.Commit(); var builder = new JournalBuilder(this.DatabaseSession); builder.WithDescription("description"); builder.WithContraAccount(internalOrganisationGlAccount); builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder.WithJournalType(new JournalTypes(this.DatabaseSession).Bank); builder.Build(); Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); }
public void GivenJournal_WhenDeriving_ThenContraAccountCanBeChangedWhenNotUsedYet() { var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); var generalLedgerAccount1 = new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0001") .WithName("bankAccount 1") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.DatabaseSession).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.DatabaseSession).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.DatabaseSession).WithDescription("accountGroup").Build()) .Build(); var internalOrganisationGlAccount1 = new OrganisationGlAccountBuilder(this.DatabaseSession) .WithFromDate(DateTime.UtcNow) .WithInternalOrganisation(internalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount1) .Build(); var generalLedgerAccount2 = new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0002") .WithName("bankAccount 2") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.DatabaseSession).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.DatabaseSession).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.DatabaseSession).WithDescription("accountGroup").Build()) .Build(); var internalOrganisationGlAccount2 = new OrganisationGlAccountBuilder(this.DatabaseSession) .WithFromDate(DateTime.UtcNow) .WithInternalOrganisation(internalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount2) .Build(); var journal = new JournalBuilder(this.DatabaseSession) .WithDescription("description") .WithContraAccount(internalOrganisationGlAccount1) .WithJournalType(new JournalTypes(this.DatabaseSession).Bank) .Build(); this.DatabaseSession.Derive(true); Assert.AreEqual(generalLedgerAccount1, journal.PreviousContraAccount.GeneralLedgerAccount); journal.ContraAccount = internalOrganisationGlAccount2; this.DatabaseSession.Derive(true); Assert.AreEqual(generalLedgerAccount2, journal.PreviousContraAccount.GeneralLedgerAccount); }
public void GivenOrganisationGlAccount_WhenNotReferenced_ThenAccountIsNeutral() { var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .WithSide(new DebitCreditConstants(this.DatabaseSession).Debit) .WithGeneralLedgerAccountType(new GeneralLedgerAccountTypeBuilder(this.DatabaseSession).WithDescription("accountType").Build()) .WithGeneralLedgerAccountGroup(new GeneralLedgerAccountGroupBuilder(this.DatabaseSession).WithDescription("accountGroup").Build()) .Build(); var organisationGlAccount = new OrganisationGlAccountBuilder(this.DatabaseSession) .WithInternalOrganisation(internalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); Assert.IsTrue(organisationGlAccount.IsNeutralAccount()); Assert.IsFalse(organisationGlAccount.IsBankAccount()); Assert.IsFalse(organisationGlAccount.IsCashAccount()); Assert.IsFalse(organisationGlAccount.IsCostAccount()); Assert.IsFalse(organisationGlAccount.IsCreditorAccount()); Assert.IsFalse(organisationGlAccount.IsDebtorAccount()); Assert.IsFalse(organisationGlAccount.IsInventoryAccount()); Assert.IsFalse(organisationGlAccount.IsTurnOverAccount()); }