コード例 #1
0
ファイル: JournalTests.cs プロジェクト: Allors/apps
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: OwnCreditCardTests.cs プロジェクト: Allors/apps
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: CashTests.cs プロジェクト: Allors/apps
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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());
        }
コード例 #18
0
        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);
        }
コード例 #19
0
ファイル: JournalTests.cs プロジェクト: Allors/apps
        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);
        }
コード例 #20
0
ファイル: JournalTests.cs プロジェクト: Allors/apps
        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);
        }
コード例 #21
0
ファイル: JournalTests.cs プロジェクト: Allors/apps
        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);
        }
コード例 #22
0
        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());
        }