示例#1
0
        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);
        }
示例#2
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);
        }
        public void GivenSupplierRelationship_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            this.InstantiateObjects(this.Session);

            var builder = new SupplierRelationshipBuilder(this.Session);

            builder.Build();

            Assert.True(this.Session.Derive(false).HasErrors);

            this.Session.Rollback();

            builder.WithSupplier(this.supplier);
            builder.Build();

            Assert.False(this.Session.Derive(false).HasErrors);
        }
        public void GivenSupplierRelationshipBuilder_WhenBuild_ThenSubAccountNumerIsValidElevenTestNumber()
        {
            this.InternalOrganisation.SubAccountCounter.Value = 1000;

            this.Session.Commit();

            var supplier1             = new OrganisationBuilder(this.Session).WithName("supplier1").Build();
            var supplierRelationship1 = new SupplierRelationshipBuilder(this.Session).WithSupplier(supplier1).Build();

            this.Session.Derive();

            var partyFinancial1 = supplier1.PartyFinancialRelationshipsWhereParty.First(v => Equals(v.InternalOrganisation, supplierRelationship1.InternalOrganisation));

            this.Session.Derive();

            Assert.Equal(1007, partyFinancial1.SubAccountNumber);

            var supplier2             = new OrganisationBuilder(this.Session).WithName("supplier2").Build();
            var supplierRelationship2 = new SupplierRelationshipBuilder(this.Session).WithSupplier(supplier2).Build();

            this.Session.Derive();

            var partyFinancial2 = supplier2.PartyFinancialRelationshipsWhereParty.First(v => Equals(v.InternalOrganisation, supplierRelationship2.InternalOrganisation));

            this.Session.Derive();

            Assert.Equal(1015, partyFinancial2.SubAccountNumber);

            var supplier3             = new OrganisationBuilder(this.Session).WithName("supplier3").Build();
            var supplierRelationship3 = new SupplierRelationshipBuilder(this.Session).WithSupplier(supplier3).Build();

            this.Session.Derive();

            var partyFinancial3 = supplier3.PartyFinancialRelationshipsWhereParty.First(v => Equals(v.InternalOrganisation, supplierRelationship3.InternalOrganisation));

            this.Session.Derive();

            Assert.Equal(1023, partyFinancial3.SubAccountNumber);
        }
        public void GivenSupplierRelationship_WhenDeriving_ThenSubAccountNumberMustBeUniqueWithinInternalOrganisation()
        {
            var supplier2 = new OrganisationBuilder(this.Session).WithName("supplier").Build();

            this.Session.Derive();

            var belgium = new Countries(this.Session).CountryByIsoCode["BE"];
            var euro    = belgium.Currency;

            var bank = new BankBuilder(this.Session).WithCountry(belgium).WithName("ING België").WithBic("BBRUBEBB").Build();

            var ownBankAccount = new OwnBankAccountBuilder(this.Session)
                                 .WithDescription("BE23 3300 6167 6391")
                                 .WithBankAccount(new BankAccountBuilder(this.Session).WithBank(bank).WithCurrency(euro).WithIban("BE23 3300 6167 6391").WithNameOnAccount("Koen").Build())
                                 .Build();

            var internalOrganisation2 = new OrganisationBuilder(this.Session)
                                        .WithIsInternalOrganisation(true)
                                        .WithName("internalOrganisation2")
                                        .WithDefaultCollectionMethod(ownBankAccount)
                                        .Build();

            this.Session.Derive();

            var supplierRelationship2 = new SupplierRelationshipBuilder(this.Session)
                                        .WithSupplier(supplier2)
                                        .WithInternalOrganisation(internalOrganisation2)
                                        .WithFromDate(DateTime.UtcNow)
                                        .Build();

            this.Session.Derive();

            var partyFinancial2 = supplier2.PartyFinancialRelationshipsWhereParty.First(v => Equals(v.InternalOrganisation, supplierRelationship2.InternalOrganisation));

            partyFinancial2.SubAccountNumber = 19;

            Assert.False(this.Session.Derive(false).HasErrors);
        }
示例#6
0
        public void GivenOrganisationContactRelationship_WhenRelationshipPeriodIsNotValid_ThenContactIsNotInCustomerContactUserGroup()
        {
            var party = new OrganisationBuilder(this.Session).WithName("customer").Build();

            this.Session.Derive();

            var customerRelationship = new CustomerRelationshipBuilder(this.Session)
                                       .WithInternalOrganisation(this.InternalOrganisation)
                                       .WithCustomer(party)
                                       .WithFromDate(DateTime.UtcNow.AddYears(-1))
                                       .Build();

            this.Session.Derive();

            Assert.Contains(customerRelationship, party.CurrentPartyRelationships);
            Assert.Empty(party.InactivePartyRelationships);

            var supplierRelationship = new SupplierRelationshipBuilder(this.Session)
                                       .WithInternalOrganisation(this.InternalOrganisation)
                                       .WithSupplier(party)
                                       .WithFromDate(DateTime.UtcNow.AddYears(-1))
                                       .Build();

            this.Session.Derive();

            Assert.Contains(customerRelationship, party.CurrentPartyRelationships);
            Assert.Contains(supplierRelationship, party.CurrentPartyRelationships);
            Assert.Empty(party.InactivePartyRelationships);

            customerRelationship.ThroughDate = DateTime.UtcNow.AddDays(-1);

            this.Session.Derive();

            Assert.Contains(supplierRelationship, party.CurrentPartyRelationships);
            Assert.Contains(customerRelationship, party.InactivePartyRelationships);
        }
示例#7
0
        public void GivenSupplierRelationship_WhenDeriving_ThenSubAccountNumberMustBeUniqueWithinInternalOrganisation()
        {
            var supplier2 = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build();

            var belgium = new Countries(this.DatabaseSession).CountryByIsoCode["BE"];
            var euro = belgium.Currency;

            var bank = new BankBuilder(this.DatabaseSession).WithCountry(belgium).WithName("ING België").WithBic("BBRUBEBB").Build();

            var ownBankAccount = new OwnBankAccountBuilder(this.DatabaseSession)
                .WithDescription("BE23 3300 6167 6391")
                .WithBankAccount(new BankAccountBuilder(this.DatabaseSession).WithBank(bank).WithCurrency(euro).WithIban("BE23 3300 6167 6391").WithNameOnAccount("Koen").Build())
                .Build();

            var billingAddress = new PartyContactMechanismBuilder(this.DatabaseSession)
                .WithContactMechanism(new WebAddressBuilder(this.DatabaseSession).WithElectronicAddressString("billfrom").Build())
                .WithContactPurpose(new ContactMechanismPurposes(this.DatabaseSession).BillingAddress)
                .WithUseAsDefault(true)
                .Build();

            var internalOrganisation2 = new InternalOrganisationBuilder(this.DatabaseSession)
                .WithName("internalOrganisation2")
                .WithLocale(new Locales(this.DatabaseSession).EnglishGreatBritain)
                .WithEmployeeRole(new Roles(this.DatabaseSession).Administrator)
                .WithPartyContactMechanism(billingAddress)
                .WithDefaultPaymentMethod(ownBankAccount)
                .WithPreferredCurrency(euro)
                .Build();

            var supplierRelationship2 = new SupplierRelationshipBuilder(this.DatabaseSession)
                .WithSupplier(supplier2)
                .WithInternalOrganisation(internalOrganisation2)
                .WithFromDate(DateTime.UtcNow)
                .Build();

            supplierRelationship2.SubAccountNumber = 19;

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
        }
示例#8
0
        public void GivenSupplierRelationship_WhenDeriving_ThenSameSubAccountNumberIsAllowedAtInternalOrganisation()
        {
            var supplier1 = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build();

            var supplierRelationship1 = new SupplierRelationshipBuilder(this.DatabaseSession)
                .WithSupplier(supplier1)
                .WithInternalOrganisation(Singleton.Instance(this.DatabaseSession).DefaultInternalOrganisation)
                .Build();

            this.DatabaseSession.Derive(true);

            supplierRelationship1.SubAccountNumber = this.supplier.SupplierRelationshipsWhereSupplier.First.SubAccountNumber;

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);
        }
示例#9
0
        public void GivenSupplierRelationship_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            this.InstantiateObjects(this.DatabaseSession);

            var builder = new SupplierRelationshipBuilder(this.DatabaseSession);
            var supplier = builder.Build();

            this.DatabaseSession.Derive();
            Assert.IsTrue(supplier.Strategy.IsDeleted);

            this.DatabaseSession.Rollback();

            builder.WithSupplier(this.supplier);
            builder.Build();

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
        }
示例#10
0
        public void GivenSupplierRelationshipBuilder_WhenBuild_ThenSubAccountNumerIsValidElevenTestNumber()
        {
            this.internalOrganisation.SubAccountCounter.Value = 1000;

            this.DatabaseSession.Commit();

            var supplier1 = new OrganisationBuilder(this.DatabaseSession).WithName("supplier1").Build();
            var supplierRelationship1 = new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier1).Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(1007, supplierRelationship1.SubAccountNumber);

            var supplier2 = new OrganisationBuilder(this.DatabaseSession).WithName("supplier2").Build();
            var supplierRelationship2 = new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier2).Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(1015, supplierRelationship2.SubAccountNumber);

            var supplier3 = new OrganisationBuilder(this.DatabaseSession).WithName("supplier3").Build();
            var supplierRelationship3 = new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier3).Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(1023, supplierRelationship3.SubAccountNumber);
        }