コード例 #1
0
        public void GivenSubContractorRelationship_WhenDeriving_ThenSubAccountNumberMustBeUniqueWithinInternalOrganisation()
        {
            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 subcontractor2 = internalOrganisation2.CreateSubContractor(this.Session.Faker());

            this.Session.Derive();

            var subContractorRelationship2 = subcontractor2.SubContractorRelationshipsWhereSubContractor.First();

            this.Session.Derive();

            var partyFinancial2 = subcontractor2.PartyFinancialRelationshipsWhereParty.First(v => Equals(v.InternalOrganisation, internalOrganisation2));

            partyFinancial2.SubAccountNumber = 19;

            Assert.False(this.Session.Derive(false).HasErrors);
        }
コード例 #2
0
        public Bank GetByIdSingle()
        {
            Bank bank   = BankBuilder.FromDatabase().Build();
            Bank result = dao.GetByIdSingle <Bank, int>(bank.Id);

            return(result);
        }
コード例 #3
0
        public Bank Delete()
        {
            Bank bank = BankBuilder.FromDatabase().Build();

            dao.Delete(bank);
            return(bank);
        }
コード例 #4
0
ファイル: BankTests.cs プロジェクト: Allors/apps
        public void GivenBank_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var netherlands = new Countries(this.DatabaseSession).CountryByIsoCode["NL"];

            var builder = new BankBuilder(this.DatabaseSession);
            builder.Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            this.DatabaseSession.Rollback();

            builder.WithCountry(netherlands);
            builder.Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            this.DatabaseSession.Rollback();

            builder.WithBic("RABONL2U");
            builder.Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            this.DatabaseSession.Rollback();

            builder.WithName("Rabo");
            builder.Build();

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
        }
コード例 #5
0
        public void GivenOwnBankAccount_WhenDeriving_ThenBankAccountMustBeValidated()
        {
            var netherlands = new Countries(this.Session).CountryByIsoCode["NL"];
            var euro        = netherlands.Currency;

            var builder     = new BankAccountBuilder(this.Session).WithCurrency(euro).WithIban("NL50RABO0109546784").WithNameOnAccount("Martien");
            var bankAccount = builder.Build();

            new OwnBankAccountBuilder(this.Session)
            .WithDescription("own account")
            .WithBankAccount(bankAccount).Build();

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

            this.Session.Rollback();

            var bank = new BankBuilder(this.Session).WithCountry(netherlands).WithName("RABOBANK GROEP").WithBic("RABONL2U").Build();

            builder.WithBank(bank);
            bankAccount = builder.Build();

            new OwnBankAccountBuilder(this.Session)
            .WithDescription("own account")
            .WithBankAccount(bankAccount).Build();

            Assert.False(this.Session.Derive(false).HasErrors);
        }
コード例 #6
0
        public void GivenAccountingPeriod_WhenMonthInSameQuarterIsAdded_ThenOnlyPeriodForMonthIsAdded()
        {
            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("own account")
                                 .WithBankAccount(new BankAccountBuilder(this.Session).WithBank(bank).WithCurrency(euro).WithIban("BE23 3300 6167 6391").WithNameOnAccount("Koen").Build())
                                 .Build();

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

            this.Session.Derive();

            organisation.StartNewFiscalYear();

            Assert.Equal(4, this.Session.Extent <AccountingPeriod>().Count);

            var nextMonth = organisation.ActualAccountingPeriod.AddNextMonth();

            Assert.Equal(5, this.Session.Extent <AccountingPeriod>().Count);

            Assert.Equal(organisation.ActualAccountingPeriod.PeriodNumber + 1, nextMonth.PeriodNumber);
            Assert.Equal(new TimeFrequencies(this.Session).Month, nextMonth.Frequency);
            Assert.Equal(organisation.ActualAccountingPeriod.FromDate.AddMonths(1).Date, nextMonth.FromDate);
            Assert.Equal(organisation.ActualAccountingPeriod.FromDate.AddMonths(2).AddSeconds(-1).Date, nextMonth.ThroughDate);
            Assert.True(nextMonth.ExistParent);
        }
コード例 #7
0
ファイル: StoreTests.cs プロジェクト: Allors/apps
        public void GivenStoreWithoutDefaultPaymentMethod_WhenSinglePaymentMethodIsAdded_ThenDefaultPaymentMethodIsSet()
        {
            Singleton.Instance(this.DatabaseSession).RemoveDefaultInternalOrganisation();
            this.DatabaseSession.Commit();

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

            var bank = new BankBuilder(this.DatabaseSession).WithCountry(netherlands).WithName("RABOBANK GROEP").WithBic("RABONL2U").Build();

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

            var store = new StoreBuilder(this.DatabaseSession)
                .WithName("Organisation store")
                .WithDefaultCarrier(new Carriers(this.DatabaseSession).Fedex)
                .WithDefaultShipmentMethod(new ShipmentMethods(this.DatabaseSession).Ground)
                .WithPaymentMethod(ownBankAccount)
                .Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(ownBankAccount, store.DefaultPaymentMethod);
        }
コード例 #8
0
        public void GivenStore_WhenDefaultPaymentMethodIsSet_ThenPaymentMethodIsAddedToCollectionPaymentMethods()
        {
            this.Session.Commit();

            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 ownBankAccount = new OwnBankAccountBuilder(this.Session)
                                 .WithDescription("BE23 3300 6167 6391")
                                 .WithBankAccount(new BankAccountBuilder(this.Session).WithBank(bank).WithCurrency(euro).WithIban("NL50RABO0109546784").WithNameOnAccount("Martien").Build())
                                 .Build();

            var store = new StoreBuilder(this.Session)
                        .WithName("Organisation store")
                        .WithDefaultCarrier(new Carriers(this.Session).Fedex)
                        .WithDefaultShipmentMethod(new ShipmentMethods(this.Session).Ground)
                        .WithDefaultCollectionMethod(ownBankAccount)
                        .Build();

            this.Session.Derive();

            Assert.Single(store.CollectionMethods);
            Assert.Equal(ownBankAccount, store.CollectionMethods.First);
        }
コード例 #9
0
ファイル: BankTests.cs プロジェクト: lulzzz/allors2
        public void GivenBank_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var netherlands = new Countries(this.Session).CountryByIsoCode["NL"];

            var builder = new BankBuilder(this.Session);

            builder.Build();

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

            this.Session.Rollback();

            builder.WithCountry(netherlands);
            builder.Build();

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

            this.Session.Rollback();

            builder.WithBic("RABONL2U");
            builder.Build();

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

            this.Session.Rollback();

            builder.WithName("Rabo");
            builder.Build();

            Assert.False(this.Session.Derive(false).HasErrors);
        }
        public async Task <BankContract> Handle(AddBankCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var contract = request.BankContract;
                var bank     = new BankBuilder()
                               .WithCode(contract.Code)
                               .WithIspb(contract.ISPB)
                               .WithName(contract.Name)
                               .WithDocument(contract.Document)
                               .Build();

                await _repository.AddBank(bank);

                await _uow.CommitAsync(cancellationToken);

                contract.Id = bank.Id.Value;
                return(contract);
            }
            catch (Exception e)
            {
                Log.Error(new { details = "Error on save bank", exception = new { e.Message, e.InnerException } });
                throw;
            }
        }
コード例 #11
0
        public IQueryable <Bank> GetById()
        {
            Bank bank = BankBuilder.FromDatabase().Build();
            IQueryable <Bank> result = dao.GetById <Bank, int>(bank.Id);

            return(result);
        }
コード例 #12
0
        public void CreateBank_DataSaved()
        {
            // Arrange context
            DbContextOptions <NeudesicInsuranceDataContext> options = new DbContextOptionsBuilder <NeudesicInsuranceDataContext>()
                                                                      .UseInMemoryDatabase("NeudesicInsurance")
                                                                      .Options;

            var context = new NeudesicInsuranceDataContext(options);

            // Arrange repository
            EfRepository <Bank> bankRepository = new EfRepository <Bank>(context);

            // Act
            Bank bank = new BankBuilder().WithId(0).Build();
            SaveResult <Bank> result = bankRepository.Create(bank);

            Task <Bank> findTask = context.Banks.FirstAsync();

            findTask.Wait();
            Bank savedBank = findTask.Result;

            // Assert
            Assert.IsTrue(result.IsSuccess);
            Assert.IsTrue(savedBank.Id > 0);
            Assert.AreEqual(bank.Name, savedBank.Name);
        }
コード例 #13
0
        public Bank Update()
        {
            Bank bank = BankBuilder.FromDatabase().Build();

            bank.No = Randomize.String();
            Bank result = dao.Update(bank);

            return(result);
        }
コード例 #14
0
ファイル: BankTests.cs プロジェクト: Allors/apps
        public void GivenBankWithBic_WhenDeriving_ThenFirstfourCharactersMustBeAlphabetic()
        {
            var netherlands = new Countries(this.DatabaseSession).CountryByIsoCode["NL"];

            var bank = new BankBuilder(this.DatabaseSession).WithCountry(netherlands).WithName("RABOBANK GROEP").WithBic("RABONL2U").Build();

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);

            bank.Bic = "RAB1NL2U";

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);
        }
コード例 #15
0
ファイル: BankTests.cs プロジェクト: lulzzz/allors2
        public void GivenBankWithBic_WhenDeriving_ThenCharacters5And6MustBeValidCountryCode()
        {
            var netherlands = new Countries(this.Session).CountryByIsoCode["NL"];

            var bank = new BankBuilder(this.Session).WithCountry(netherlands).WithName("RABOBANK GROEP").WithBic("RABONL2U").Build();

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

            bank.Bic = "RABONN2U";

            Assert.True(this.Session.Derive(false).HasErrors);
        }
コード例 #16
0
ファイル: BankAccountTests.cs プロジェクト: Allors/apps
        public void GivenBankAccount_WhenDeriving_ThenIbanMustBeUnique()
        {
            var netherlands = new Countries(this.DatabaseSession).CountryByIsoCode["NL"];
            var euro = netherlands.Currency;

            var bank = new BankBuilder(this.DatabaseSession).WithCountry(netherlands).WithName("RABOBANK GROEP").WithBic("RABONL2U").Build();
            new BankAccountBuilder(this.DatabaseSession).WithBank(bank).WithCurrency(euro).WithIban("NL50RABO0109546784").Build();

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);

            new BankAccountBuilder(this.DatabaseSession).WithBank(bank).WithCurrency(euro).WithIban("NL50RABO0109546784").Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);
        }
コード例 #17
0
        public IQueryable <Bank> FromDto_Basic_Simple()
        {
            Bank    model = BankBuilder.FromDatabase().Evict().Build();
            BankDto sampleDto = mapper.Map <BankDto>(model);
            IQueryable <BankDto> dtoList = new List <BankDto> {
                sampleDto
            }.AsQueryable();

            IQueryable <Bank> result =
                from dto in dtoList
                select mapper.Map <Bank>(dto);

            return(result);
        }
コード例 #18
0
        public void GivenBankAccount_WhenDeriving_ThenIbanMustBeUnique()
        {
            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();

            new BankAccountBuilder(this.Session).WithBank(bank).WithCurrency(euro).WithIban("NL50RABO0109546784").Build();

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

            new BankAccountBuilder(this.Session).WithBank(bank).WithCurrency(euro).WithIban("NL50RABO0109546784").Build();

            Assert.True(this.Session.Derive(false).HasErrors);
        }
コード例 #19
0
ファイル: BankTests.cs プロジェクト: Allors/apps
        public void GivenBankWithBic_WhenDeriving_ThenStringLengthMustBeEightOrEleven()
        {
            var netherlands = new Countries(this.DatabaseSession).CountryByIsoCode["NL"];

            var bank = new BankBuilder(this.DatabaseSession).WithCountry(netherlands).WithName("RABOBANK GROEP").WithBic("RABONL2").Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            bank.Bic = "RABONL2UAAAA";

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            bank.Bic = "RABONL2UAAA";

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
        }
コード例 #20
0
ファイル: BankTests.cs プロジェクト: lulzzz/allors2
        public void GivenBankWithBic_WhenDeriving_ThenStringLengthMustBeEightOrEleven()
        {
            var netherlands = new Countries(this.Session).CountryByIsoCode["NL"];

            var bank = new BankBuilder(this.Session).WithCountry(netherlands).WithName("RABOBANK GROEP").WithBic("RABONL2").Build();

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

            bank.Bic = "RABONL2UAAAA";

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

            bank.Bic = "RABONL2UAAA";

            Assert.False(this.Session.Derive(false).HasErrors);
        }
コード例 #21
0
        public void GivenOwnBankAccount_WhenBuild_ThenPostBuildRelationsMustExist()
        {
            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)
                                .Build();

            this.Session.Derive();

            Assert.True(paymentMethod.IsActive);
            Assert.True(paymentMethod.ExistDescription);
        }
コード例 #22
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);
        }
コード例 #23
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);
        }
コード例 #24
0
ファイル: BankAccountTests.cs プロジェクト: Allors/apps
        public void GivenBankAccount_WhenOwnBankAccount_ThenRequiredRelationsMustExist()
        {
            var netherlands = new Countries(this.DatabaseSession).CountryByIsoCode["NL"];
            var euro = netherlands.Currency;
            var bank = new BankBuilder(this.DatabaseSession).WithCountry(netherlands).WithName("RABOBANK GROEP").WithBic("RABONL2U").Build();

            this.DatabaseSession.Commit();

            var builder = new BankAccountBuilder(this.DatabaseSession).WithIban("NL50RABO0109546784");
            var bankAccount = builder.Build();

            new OwnBankAccountBuilder(this.DatabaseSession).WithBankAccount(bankAccount).Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            this.DatabaseSession.Rollback();

            builder.WithBank(bank);
            bankAccount = builder.Build();

            new OwnBankAccountBuilder(this.DatabaseSession).WithBankAccount(bankAccount).Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            this.DatabaseSession.Rollback();

            builder.WithCurrency(euro);
            bankAccount = builder.Build();

            new OwnBankAccountBuilder(this.DatabaseSession).WithBankAccount(bankAccount).Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            this.DatabaseSession.Rollback();

            builder.WithNameOnAccount("name");
            bankAccount = builder.Build();

            new OwnBankAccountBuilder(this.DatabaseSession).WithBankAccount(bankAccount).WithDescription("description").Build();

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
        }
コード例 #25
0
        public void GivenBankAccount_WhenOwnBankAccount_ThenRequiredRelationsMustExist()
        {
            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();

            this.Session.Commit();

            var builder     = new BankAccountBuilder(this.Session).WithIban("NL50RABO0109546784");
            var bankAccount = builder.Build();

            new OwnBankAccountBuilder(this.Session).WithBankAccount(bankAccount).Build();

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

            this.Session.Rollback();

            builder.WithBank(bank);
            bankAccount = builder.Build();

            new OwnBankAccountBuilder(this.Session).WithBankAccount(bankAccount).Build();

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

            this.Session.Rollback();

            builder.WithCurrency(euro);
            bankAccount = builder.Build();

            new OwnBankAccountBuilder(this.Session).WithBankAccount(bankAccount).Build();

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

            this.Session.Rollback();

            builder.WithNameOnAccount("name");
            bankAccount = builder.Build();

            new OwnBankAccountBuilder(this.Session).WithBankAccount(bankAccount).WithDescription("description").Build();

            Assert.False(this.Session.Derive(false).HasErrors);
        }
コード例 #26
0
        public void GivenCustomerRelationship_WhenDeriving_ThenSubAccountNumberMustBeUniqueWithinSingleton()
        {
            var customer2 = new OrganisationBuilder(this.Session).WithName("customer").Build();

            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 mechelen = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var address1 = new PostalAddressBuilder(this.Session).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();

            var internalOrganisation2 = new OrganisationBuilder(this.Session)
                                        .WithIsInternalOrganisation(true)
                                        .WithDoAccounting(true)
                                        .WithName("internalOrganisation2")
                                        .WithDefaultCollectionMethod(ownBankAccount)
                                        .WithSubAccountCounter(new CounterBuilder(this.Session).WithUniqueId(Guid.NewGuid()).WithValue(0).Build())
                                        .Build();

            var customerRelationship2 = new CustomerRelationshipBuilder(this.Session)
                                        .WithCustomer(customer2)
                                        .WithInternalOrganisation(internalOrganisation2)
                                        .WithFromDate(DateTime.UtcNow)
                                        .Build();

            Session.Derive();

            var partyFinancial = customer2.PartyFinancialRelationshipsWhereParty.First(v => Equals(v.InternalOrganisation, customerRelationship2.InternalOrganisation));

            partyFinancial.SubAccountNumber = 19;

            Assert.False(this.Session.Derive(false).HasErrors);
        }
コード例 #27
0
ファイル: CustomerShipmentTests.cs プロジェクト: Allors/apps
        public void GivenCustomerShipment_WhenDeriving_ThenBillFromContactMechanismMustExist()
        {
            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("own account")
                .WithBankAccount(new BankAccountBuilder(this.DatabaseSession).WithBank(bank).WithCurrency(euro).WithIban("BE23 3300 6167 6391").WithNameOnAccount("Koen").Build())
                .Build();

            var mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build();
            var customer = new PersonBuilder(this.DatabaseSession).WithLastName("customer").Build();
            var address1 = new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();

            var billingAddress = new PartyContactMechanismBuilder(this.DatabaseSession)
                .WithContactMechanism(address1)
                .WithContactPurpose(new ContactMechanismPurposes(this.DatabaseSession).BillingAddress)
                .WithUseAsDefault(true)
                .Build();

            var internalOrganisation = new InternalOrganisationBuilder(this.DatabaseSession)
                .WithLocale(new Locales(this.DatabaseSession).EnglishGreatBritain)
                .WithName("internalOrganisation")
                .WithPreferredCurrency(euro)
                .WithDefaultPaymentMethod(ownBankAccount)
                .Build();

            internalOrganisation.AddPartyContactMechanism(billingAddress);

            this.DatabaseSession.Derive(true);

            var shipment1 = new CustomerShipmentBuilder(this.DatabaseSession)
                .WithBillFromInternalOrganisation(internalOrganisation)
                .WithShipToParty(customer)
                .WithShipToAddress(new PostalAddresses(this.DatabaseSession).Extent().First)
                .WithShipmentMethod(new ShipmentMethods(this.DatabaseSession).Boat)
                .Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(address1, shipment1.BillFromContactMechanism);
        }
コード例 #28
0
ファイル: Organisations.cs プロジェクト: Allors/allors2
        public static Organisation CreateInternalOrganisation(
            ISession session,
            string name,
            string address,
            string postalCode,
            string locality,
            Country country,
            string phone1CountryCode,
            string phone1,
            ContactMechanismPurpose phone1Purpose,
            string phone2CountryCode,
            string phone2,
            ContactMechanismPurpose phone2Purpose,
            string emailAddress,
            string websiteAddress,
            string taxNumber,
            string bankName,
            string facilityName,
            string bic,
            string iban,
            Currency currency,
            string logo,
            string storeName,
            BillingProcess billingProcess,
            string outgoingShipmentNumberPrefix,
            string salesInvoiceNumberPrefix,
            string salesOrderNumberPrefix,
            string purchaseOrderNumberPrefix,
            string purchaseInvoiceNumberPrefix,
            string requestNumberPrefix,
            string quoteNumberPrefix,
            string productNumberPrefix,
            string workEffortPrefix,
            string creditNoteNumberPrefix,
            bool isImmediatelyPicked,
            bool autoGenerateShipmentPackage,
            bool isImmediatelyPacked,
            bool isAutomaticallyShipped,
            bool autoGenerateCustomerShipment,
            bool isAutomaticallyReceived,
            bool autoGeneratePurchaseShipment,
            bool useCreditNoteSequence,
            int?requestCounterValue,
            int?quoteCounterValue,
            int?orderCounterValue,
            int?purchaseOrderCounterValue,
            int?invoiceCounterValue,
            int?purchaseInvoiceCounterValue,
            bool purchaseOrderNeedsApproval,
            decimal?purchaseOrderApprovalThresholdLevel1,
            decimal?purchaseOrderApprovalThresholdLevel2,
            SerialisedItemSoldOn[] serialisedItemSoldOns,
            bool collectiveWorkEffortInvoice,
            InvoiceSequence invoiceSequence,
            RequestSequence requestSequence,
            QuoteSequence quoteSequence,
            CustomerShipmentSequence customerShipmentSequence,
            PurchaseShipmentSequence purchaseShipmentSequence,
            WorkEffortSequence workEffortSequence)
        {
            var postalAddress1 = new PostalAddressBuilder(session)
                                 .WithAddress1(address)
                                 .WithPostalCode(postalCode)
                                 .WithLocality(locality)
                                 .WithCountry(country)
                                 .Build();

            var webSite = new WebAddressBuilder(session)
                          .WithElectronicAddressString(websiteAddress)
                          .Build();

            BankAccount bankAccount = null;

            if (!string.IsNullOrEmpty(bic) && !string.IsNullOrEmpty(iban))
            {
                var bank = new BankBuilder(session).WithName(bankName).WithBic(bic).WithCountry(country).Build();
                bankAccount = new BankAccountBuilder(session)
                              .WithBank(bank)
                              .WithIban(iban)
                              .WithNameOnAccount(name)
                              .WithCurrency(currency)
                              .Build();
            }

            var internalOrganisation = new OrganisationBuilder(session)
                                       .WithIsInternalOrganisation(true)
                                       .WithTaxNumber(taxNumber)
                                       .WithName(name)
                                       .WithPreferredCurrency(new Currencies(session).FindBy(M.Currency.IsoCode, "EUR"))
                                       .WithInvoiceSequence(invoiceSequence)
                                       .WithRequestSequence(requestSequence)
                                       .WithQuoteSequence(quoteSequence)
                                       .WithCustomerShipmentSequence(customerShipmentSequence)
                                       .WithPurchaseShipmentSequence(purchaseShipmentSequence)
                                       .WithWorkEffortSequence(workEffortSequence)
                                       .WithFiscalYearStartMonth(01)
                                       .WithFiscalYearStartDay(01)
                                       .WithDoAccounting(false)
                                       .WithPurchaseOrderNeedsApproval(purchaseOrderNeedsApproval)
                                       .WithPurchaseOrderApprovalThresholdLevel1(purchaseOrderApprovalThresholdLevel1)
                                       .WithPurchaseOrderApprovalThresholdLevel2(purchaseOrderApprovalThresholdLevel2)
                                       .WithAutoGeneratePurchaseShipment(autoGeneratePurchaseShipment)
                                       .WithIsAutomaticallyReceived(isAutomaticallyReceived)
                                       .WithCollectiveWorkEffortInvoice(collectiveWorkEffortInvoice)
                                       .WithCountry(country)
                                       .Build();

            internalOrganisation.SerialisedItemSoldOns = serialisedItemSoldOns;

            if (invoiceSequence == new InvoiceSequences(session).RestartOnFiscalYear)
            {
                var sequenceNumbers = internalOrganisation.FiscalYearsInternalOrganisationSequenceNumbers.FirstOrDefault(v => v.FiscalYear == session.Now().Year);
                if (sequenceNumbers == null)
                {
                    sequenceNumbers = new FiscalYearInternalOrganisationSequenceNumbersBuilder(session).WithFiscalYear(session.Now().Year).Build();
                    internalOrganisation.AddFiscalYearsInternalOrganisationSequenceNumber(sequenceNumbers);
                }

                sequenceNumbers.PurchaseOrderNumberPrefix   = purchaseOrderNumberPrefix;
                sequenceNumbers.PurchaseInvoiceNumberPrefix = purchaseInvoiceNumberPrefix;

                if (purchaseOrderCounterValue != null)
                {
                    sequenceNumbers.PurchaseOrderNumberCounter = new CounterBuilder(session).WithValue(purchaseOrderCounterValue).Build();
                }

                if (purchaseInvoiceCounterValue != null)
                {
                    sequenceNumbers.PurchaseInvoiceNumberCounter = new CounterBuilder(session).WithValue(purchaseInvoiceCounterValue).Build();
                }
            }
            else
            {
                internalOrganisation.PurchaseOrderNumberPrefix   = purchaseOrderNumberPrefix;
                internalOrganisation.PurchaseInvoiceNumberPrefix = purchaseInvoiceNumberPrefix;

                if (purchaseOrderCounterValue != null)
                {
                    internalOrganisation.PurchaseOrderNumberCounter = new CounterBuilder(session).WithValue(purchaseOrderCounterValue).Build();
                }

                if (purchaseInvoiceCounterValue != null)
                {
                    internalOrganisation.PurchaseInvoiceNumberCounter = new CounterBuilder(session).WithValue(purchaseInvoiceCounterValue).Build();
                }
            }

            if (requestSequence == new RequestSequences(session).RestartOnFiscalYear)
            {
                var sequenceNumbers = internalOrganisation.FiscalYearsInternalOrganisationSequenceNumbers.FirstOrDefault(v => v.FiscalYear == session.Now().Year);
                if (sequenceNumbers == null)
                {
                    sequenceNumbers = new FiscalYearInternalOrganisationSequenceNumbersBuilder(session).WithFiscalYear(session.Now().Year).Build();
                    internalOrganisation.AddFiscalYearsInternalOrganisationSequenceNumber(sequenceNumbers);
                }

                sequenceNumbers.RequestNumberPrefix = requestNumberPrefix;

                if (requestCounterValue != null)
                {
                    sequenceNumbers.RequestNumberCounter = new CounterBuilder(session).WithValue(requestCounterValue).Build();
                }
            }
            else
            {
                internalOrganisation.RequestNumberPrefix = requestNumberPrefix;

                if (requestCounterValue != null)
                {
                    internalOrganisation.RequestNumberCounter = new CounterBuilder(session).WithValue(requestCounterValue).Build();
                }
            }

            if (quoteSequence == new QuoteSequences(session).RestartOnFiscalYear)
            {
                var sequenceNumbers = internalOrganisation.FiscalYearsInternalOrganisationSequenceNumbers.FirstOrDefault(v => v.FiscalYear == session.Now().Year);
                if (sequenceNumbers == null)
                {
                    sequenceNumbers = new FiscalYearInternalOrganisationSequenceNumbersBuilder(session).WithFiscalYear(session.Now().Year).Build();
                    internalOrganisation.AddFiscalYearsInternalOrganisationSequenceNumber(sequenceNumbers);
                }

                sequenceNumbers.QuoteNumberPrefix = quoteNumberPrefix;

                if (quoteCounterValue != null)
                {
                    sequenceNumbers.QuoteNumberCounter = new CounterBuilder(session).WithValue(quoteCounterValue).Build();
                }
            }
            else
            {
                internalOrganisation.QuoteNumberPrefix = quoteNumberPrefix;

                if (quoteCounterValue != null)
                {
                    internalOrganisation.QuoteNumberCounter = new CounterBuilder(session).WithValue(quoteCounterValue).Build();
                }
            }

            if (workEffortSequence == new WorkEffortSequences(session).RestartOnFiscalYear)
            {
                var sequenceNumbers = internalOrganisation.FiscalYearsInternalOrganisationSequenceNumbers.FirstOrDefault(v => v.FiscalYear == session.Now().Year);
                if (sequenceNumbers == null)
                {
                    sequenceNumbers = new FiscalYearInternalOrganisationSequenceNumbersBuilder(session).WithFiscalYear(session.Now().Year).Build();
                    internalOrganisation.AddFiscalYearsInternalOrganisationSequenceNumber(sequenceNumbers);
                }

                sequenceNumbers.WorkEffortNumberPrefix = workEffortPrefix;
            }
            else
            {
                internalOrganisation.WorkEffortNumberPrefix = workEffortPrefix;
            }

            OwnBankAccount defaultCollectionMethod = null;

            if (bankAccount != null)
            {
                internalOrganisation.AddBankAccount(bankAccount);
                defaultCollectionMethod = new OwnBankAccountBuilder(session).WithBankAccount(bankAccount).WithDescription("Huisbank").Build();
                internalOrganisation.DefaultCollectionMethod = defaultCollectionMethod;
            }

            if (!string.IsNullOrEmpty(emailAddress))
            {
                var email = new EmailAddressBuilder(session)
                            .WithElectronicAddressString(emailAddress)
                            .Build();

                internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                              .WithUseAsDefault(true)
                                                              .WithContactMechanism(email)
                                                              .WithContactPurpose(new ContactMechanismPurposes(session).GeneralEmail)
                                                              .Build());
            }

            internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                          .WithUseAsDefault(true)
                                                          .WithContactMechanism(postalAddress1)
                                                          .WithContactPurpose(new ContactMechanismPurposes(session).RegisteredOffice)
                                                          .WithContactPurpose(new ContactMechanismPurposes(session).GeneralCorrespondence)
                                                          .WithContactPurpose(new ContactMechanismPurposes(session).BillingAddress)
                                                          .WithContactPurpose(new ContactMechanismPurposes(session).ShippingAddress)
                                                          .Build());

            internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                          .WithUseAsDefault(true)
                                                          .WithContactMechanism(webSite)
                                                          .WithContactPurpose(new ContactMechanismPurposes(session).InternetAddress)
                                                          .Build());

            TelecommunicationsNumber phoneNumber1 = null;

            if (!string.IsNullOrEmpty(phone1))
            {
                phoneNumber1 = new TelecommunicationsNumberBuilder(session).WithContactNumber(phone1).Build();
                if (!string.IsNullOrEmpty(phone1CountryCode))
                {
                    phoneNumber1.CountryCode = phone1CountryCode;
                }
            }

            if (phoneNumber1 != null)
            {
                internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                              .WithUseAsDefault(true)
                                                              .WithContactMechanism(phoneNumber1)
                                                              .WithContactPurpose(phone1Purpose)
                                                              .Build());
            }

            TelecommunicationsNumber phoneNumber2 = null;

            if (!string.IsNullOrEmpty(phone2))
            {
                phoneNumber2 = new TelecommunicationsNumberBuilder(session).WithContactNumber(phone2).Build();
                if (!string.IsNullOrEmpty(phone2CountryCode))
                {
                    phoneNumber2.CountryCode = phone2CountryCode;
                }
            }

            if (phoneNumber2 != null)
            {
                internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                              .WithUseAsDefault(true)
                                                              .WithContactMechanism(phoneNumber2)
                                                              .WithContactPurpose(phone2Purpose)
                                                              .Build());
            }

            if (!string.IsNullOrWhiteSpace(logo))
            {
                var singleton = session.GetSingleton();
                internalOrganisation.LogoImage = new MediaBuilder(session).WithInFileName(logo).WithInData(singleton.GetResourceBytes(logo)).Build();
            }

            Facility facility = null;

            if (facilityName != null)
            {
                facility = new FacilityBuilder(session)
                           .WithName(facilityName)
                           .WithFacilityType(new FacilityTypes(session).Warehouse)
                           .WithOwner(internalOrganisation)
                           .Build();
            }

            var store = new StoreBuilder(session)
                        .WithName(storeName)
                        .WithDefaultCollectionMethod(defaultCollectionMethod)
                        .WithDefaultShipmentMethod(new ShipmentMethods(session).Ground)
                        .WithDefaultCarrier(new Carriers(session).Fedex)
                        .WithBillingProcess(billingProcess)
                        .WithIsImmediatelyPicked(isImmediatelyPicked)
                        .WithAutoGenerateShipmentPackage(autoGenerateShipmentPackage)
                        .WithIsImmediatelyPacked(isImmediatelyPacked)
                        .WithIsAutomaticallyShipped(isAutomaticallyShipped)
                        .WithAutoGenerateCustomerShipment(autoGenerateCustomerShipment)
                        .WithUseCreditNoteSequence(useCreditNoteSequence)
                        .WithInternalOrganisation(internalOrganisation)
                        .Build();

            if (defaultCollectionMethod == null)
            {
                store.DefaultCollectionMethod = new CashBuilder(session).Build();
            }
            else
            {
                store.DefaultCollectionMethod = defaultCollectionMethod;
            }

            if (facility != null)
            {
                store.DefaultFacility = facility;
            }

            if (invoiceSequence == new InvoiceSequences(session).RestartOnFiscalYear)
            {
                var sequenceNumbers = new FiscalYearStoreSequenceNumbersBuilder(session).WithFiscalYear(session.Now().Year).Build();

                sequenceNumbers.CreditNoteNumberPrefix       = creditNoteNumberPrefix;
                sequenceNumbers.OutgoingShipmentNumberPrefix = outgoingShipmentNumberPrefix;
                sequenceNumbers.SalesInvoiceNumberPrefix     = salesInvoiceNumberPrefix;
                sequenceNumbers.SalesOrderNumberPrefix       = salesOrderNumberPrefix;

                if (orderCounterValue != null)
                {
                    sequenceNumbers.SalesOrderNumberCounter = new CounterBuilder(session).WithValue(orderCounterValue).Build();
                }

                if (invoiceCounterValue != null)
                {
                    sequenceNumbers.SalesInvoiceNumberCounter = new CounterBuilder(session).WithValue(invoiceCounterValue).Build();
                }

                store.AddFiscalYearsStoreSequenceNumber(sequenceNumbers);
            }
            else
            {
                store.CreditNoteNumberPrefix       = creditNoteNumberPrefix;
                store.OutgoingShipmentNumberPrefix = outgoingShipmentNumberPrefix;
                store.SalesInvoiceNumberPrefix     = salesInvoiceNumberPrefix;
                store.SalesOrderNumberPrefix       = salesOrderNumberPrefix;

                if (orderCounterValue != null)
                {
                    store.SalesOrderNumberCounter = new CounterBuilder(session).WithValue(orderCounterValue).Build();
                }

                if (invoiceCounterValue != null)
                {
                    store.SalesInvoiceNumberCounter = new CounterBuilder(session).WithValue(invoiceCounterValue).Build();
                }
            }

            return(internalOrganisation);
        }
コード例 #29
0
ファイル: AccountingPeriodTests.cs プロジェクト: Allors/apps
        public void GivenAccountingPeriod_WhenMonthInNextQuarterIsAdded_ThenPeriodsForMonthAndForQuarterAreAdded()
        {
            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("own account")
                .WithBankAccount(new BankAccountBuilder(this.DatabaseSession).WithBank(bank).WithCurrency(euro).WithIban("BE23 3300 6167 6391").WithNameOnAccount("Koen").Build())
                .Build();

            var organisation = new InternalOrganisationBuilder(this.DatabaseSession)
                .WithName("Internal")
                .WithLocale(new Locales(this.DatabaseSession).EnglishGreatBritain)
                .WithPreferredCurrency(euro)
                .WithDefaultPaymentMethod(ownBankAccount)
                .Build();

            organisation.AppsStartNewFiscalYear();

            Assert.AreEqual(4, this.DatabaseSession.Extent<AccountingPeriod>().Count);

            organisation.ActualAccountingPeriod.AddNextMonth();

            Assert.AreEqual(5, this.DatabaseSession.Extent<AccountingPeriod>().Count);

            organisation.ActualAccountingPeriod.AddNextMonth();

            Assert.AreEqual(6, this.DatabaseSession.Extent<AccountingPeriod>().Count);

            var fourthMonth = organisation.ActualAccountingPeriod.AddNextMonth();

            Assert.AreEqual(8, this.DatabaseSession.Extent<AccountingPeriod>().Count);

            Assert.AreEqual(organisation.ActualAccountingPeriod.PeriodNumber + 3, fourthMonth.PeriodNumber);
            Assert.AreEqual(new TimeFrequencies(this.DatabaseSession).Month, fourthMonth.TimeFrequency);
            Assert.AreEqual(organisation.ActualAccountingPeriod.FromDate.AddMonths(3).Date, fourthMonth.FromDate);
            Assert.AreEqual(organisation.ActualAccountingPeriod.FromDate.AddMonths(4).AddSeconds(-1).Date, fourthMonth.ThroughDate);
            Assert.IsTrue(fourthMonth.ExistParent);
            Assert.Contains(fourthMonth, organisation.AccountingPeriods);

            var secondQuarter = fourthMonth.Parent;

            Assert.AreEqual(organisation.ActualAccountingPeriod.Parent.PeriodNumber + 1, secondQuarter.PeriodNumber);
            Assert.AreEqual(new TimeFrequencies(this.DatabaseSession).Trimester, secondQuarter.TimeFrequency);
            Assert.AreEqual(organisation.ActualAccountingPeriod.Parent.FromDate.AddMonths(3).Date, secondQuarter.FromDate);
            Assert.AreEqual(organisation.ActualAccountingPeriod.Parent.FromDate.AddMonths(6).AddSeconds(-1).Date, secondQuarter.ThroughDate);
            Assert.AreEqual(organisation.ActualAccountingPeriod.Parent.Parent, secondQuarter.Parent);
            Assert.Contains(secondQuarter, organisation.AccountingPeriods);
        }
コード例 #30
0
ファイル: Fixture.cs プロジェクト: lulzzz/allors2
        public static void Setup(IDatabase database)
        {
            CultureInfo.CurrentCulture   = new CultureInfo("en-GB");
            CultureInfo.CurrentUICulture = new CultureInfo("en-GB");

            using (var session = database.CreateSession())
            {
                new Setup(session, null).Apply();

                var administrator = new Users(session).GetUser("administrator");
                session.SetUser(administrator);

                var singleton = session.GetSingleton();

                new UserGroups(session).Administrators.AddMember(administrator);

                singleton.Guest = new PersonBuilder(session).WithUserName("guest").WithLastName("guest").Build();

                session.Derive();
                session.Commit();

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

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

                var ownBankAccount = new OwnBankAccountBuilder(session)
                                     .WithBankAccount(new BankAccountBuilder(session).WithBank(bank)
                                                      .WithCurrency(euro)
                                                      .WithIban("BE68539007547034")
                                                      .WithNameOnAccount("Koen")
                                                      .Build())
                                     .WithDescription("Main bank account")
                                     .Build();

                var postalBoundary = new PostalBoundaryBuilder(session).WithLocality("Mechelen").WithCountry(belgium).Build();
                var postalAddress  = new PostalAddressBuilder(session).WithAddress1("Kleine Nieuwedijkstraat 2").WithPostalBoundary(postalBoundary).Build();

                var internalOrganisation = new OrganisationBuilder(session)
                                           .WithIsInternalOrganisation(true)
                                           .WithDoAccounting(false)
                                           .WithName("internalOrganisation")
                                           .WithPreferredCurrency(new Currencies(session).CurrencyByCode["EUR"])
                                           .WithIncomingShipmentNumberPrefix("incoming shipmentno: ")
                                           .WithPurchaseInvoiceNumberPrefix("incoming invoiceno: ")
                                           .WithPurchaseOrderNumberPrefix("purchase orderno: ")
                                           .WithDefaultCollectionMethod(ownBankAccount)
                                           .WithSubAccountCounter(new CounterBuilder(session).WithUniqueId(Guid.NewGuid()).WithValue(0).Build())
                                           .Build();

                internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                              .WithUseAsDefault(true)
                                                              .WithContactMechanism(postalAddress)
                                                              .WithContactPurpose(new ContactMechanismPurposes(session).GeneralCorrespondence)
                                                              .WithContactPurpose(new ContactMechanismPurposes(session).BillingAddress)
                                                              .Build());

                var facility = new FacilityBuilder(session)
                               .WithFacilityType(new FacilityTypes(session).Warehouse)
                               .WithName("facility")
                               .WithOwner(internalOrganisation)
                               .Build();

                singleton.Settings.DefaultFacility = facility;

                var collectionMethod = new PaymentMethods(session).Extent().First;

                new StoreBuilder(session)
                .WithName("store")
                .WithBillingProcess(new BillingProcesses(session).BillingForShipmentItems)
                .WithInternalOrganisation(internalOrganisation)
                .WithOutgoingShipmentNumberPrefix("shipmentno: ")
                .WithSalesInvoiceNumberPrefix("invoiceno: ")
                .WithSalesOrderNumberPrefix("orderno: ")
                .WithDefaultShipmentMethod(new ShipmentMethods(session).Ground)
                .WithDefaultCarrier(new Carriers(session).Fedex)
                .WithCreditLimit(500)
                .WithPaymentGracePeriod(10)
                .WithDefaultCollectionMethod(collectionMethod)
                .WithIsImmediatelyPicked(false)
                .Build();

                new ProductCategoryBuilder(session).WithName("Primary Category").Build();

                var customer       = new OrganisationBuilder(session).WithName("customer").WithLocale(singleton.DefaultLocale).Build();
                var supplier       = new OrganisationBuilder(session).WithName("supplier").WithLocale(singleton.DefaultLocale).Build();
                var purchaser      = new PersonBuilder(session).WithLastName("purchaser").WithUserName("purchaser").Build();
                var salesrep       = new PersonBuilder(session).WithLastName("salesRep").WithUserName("salesRep").Build();
                var orderProcessor = new PersonBuilder(session).WithLastName("orderProcessor").WithUserName("orderProcessor").Build();

                new CustomerRelationshipBuilder(session).WithCustomer(customer).WithInternalOrganisation(internalOrganisation).WithFromDate(DateTime.UtcNow).Build();

                new SupplierRelationshipBuilder(session).WithSupplier(supplier).WithInternalOrganisation(internalOrganisation).WithFromDate(DateTime.UtcNow).Build();

                new EmploymentBuilder(session).WithFromDate(DateTime.UtcNow).WithEmployee(purchaser).WithEmployer(internalOrganisation).Build();

                new EmploymentBuilder(session).WithFromDate(DateTime.UtcNow).WithEmployee(salesrep).WithEmployer(internalOrganisation).Build();

                new EmploymentBuilder(session).WithFromDate(DateTime.UtcNow).WithEmployee(orderProcessor).WithEmployer(internalOrganisation).Build();

                new SalesRepRelationshipBuilder(session).WithFromDate(DateTime.UtcNow).WithCustomer(customer).WithSalesRepresentative(salesrep).Build();

                var vatRate21 = new VatRateBuilder(session).WithRate(21).Build();

                var good1 = new NonUnifiedGoodBuilder(session)
                            .WithProductIdentification(new ProductNumberBuilder(session)
                                                       .WithIdentification("1")
                                                       .WithProductIdentificationType(new ProductIdentificationTypes(session).Good).Build())
                            .WithVatRate(vatRate21)
                            .WithName("good1")
                            .WithUnitOfMeasure(new UnitsOfMeasure(session).Piece)
                            .WithPart(new NonUnifiedPartBuilder(session)
                                      .WithProductIdentification(new PartNumberBuilder(session)
                                                                 .WithIdentification("1")
                                                                 .WithProductIdentificationType(new ProductIdentificationTypes(session).Part).Build())
                                      .WithInventoryItemKind(new InventoryItemKinds(session).NonSerialised).Build())
                            .Build();

                var good2 = new NonUnifiedGoodBuilder(session)
                            .WithProductIdentification(new ProductNumberBuilder(session)
                                                       .WithIdentification("2")
                                                       .WithProductIdentificationType(new ProductIdentificationTypes(session).Good).Build())
                            .WithVatRate(vatRate21)
                            .WithName("good2")
                            .WithUnitOfMeasure(new UnitsOfMeasure(session).Piece)
                            .WithPart(new NonUnifiedPartBuilder(session)
                                      .WithProductIdentification(new PartNumberBuilder(session)
                                                                 .WithIdentification("2")
                                                                 .WithProductIdentificationType(new ProductIdentificationTypes(session).Part).Build())
                                      .WithInventoryItemKind(new InventoryItemKinds(session).NonSerialised).Build())
                            .Build();

                var good3 = new NonUnifiedGoodBuilder(session)
                            .WithProductIdentification(new ProductNumberBuilder(session)
                                                       .WithIdentification("3")
                                                       .WithProductIdentificationType(new ProductIdentificationTypes(session).Good).Build())
                            .WithVatRate(vatRate21)
                            .WithName("good3")
                            .WithUnitOfMeasure(new UnitsOfMeasure(session).Piece)
                            .WithPart(new NonUnifiedPartBuilder(session)
                                      .WithProductIdentification(new PartNumberBuilder(session)
                                                                 .WithIdentification("3")
                                                                 .WithProductIdentificationType(new ProductIdentificationTypes(session).Part).Build())
                                      .WithInventoryItemKind(new InventoryItemKinds(session).NonSerialised).Build())
                            .Build();

                var catMain = new ProductCategoryBuilder(session).WithName("main cat").Build();

                var cat1 = new ProductCategoryBuilder(session)
                           .WithName("cat for good1")
                           .WithParent(catMain)
                           .WithProduct(good1)
                           .Build();

                var cat2 = new ProductCategoryBuilder(session)
                           .WithName("cat for good2")
                           .WithParent(catMain)
                           .WithProduct(good2)
                           .WithProduct(good3)
                           .Build();

                session.Derive();
                session.Commit();
            }
        }
コード例 #31
0
ファイル: PickListTests.cs プロジェクト: Allors/apps
        public void GivenPickListCreatedByOrderProcessor_WhenCurrentUserInAnotherOrderProcessorUserGroup_ThenAccessIsDenied()
        {
            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("own account")
                .WithBankAccount(new BankAccountBuilder(this.DatabaseSession).WithBank(bank).WithCurrency(euro).WithIban("BE23 3300 6167 6391").WithNameOnAccount("Koen").Build())
                .Build();

            var mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build();
            var address1 = new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();

            var billingAddress = new PartyContactMechanismBuilder(this.DatabaseSession)
                .WithContactMechanism(address1)
                .WithContactPurpose(new ContactMechanismPurposes(this.DatabaseSession).BillingAddress)
                .WithUseAsDefault(true)
                .Build();

            var orderProcessor2 = new PersonBuilder(this.DatabaseSession).WithLastName("orderProcessor2").WithUserName("orderProcessor2").Build();
            var internalOrganisation = new InternalOrganisationBuilder(this.DatabaseSession)
                .WithName("employer2")
                .WithLocale(new Locales(this.DatabaseSession).EnglishGreatBritain)
                .WithEmployeeRole(new Roles(this.DatabaseSession).Administrator)
                .WithEmployeeRole(new Roles(this.DatabaseSession).Operations)
                .WithDefaultPaymentMethod(ownBankAccount)
                .WithPreferredCurrency(euro)
                .WithPartyContactMechanism(billingAddress)
                .Build();

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            var usergroups = internalOrganisation.UserGroupsWhereParty;
            usergroups.Filter.AddEquals(UserGroups.Meta.Parent, new Roles(this.DatabaseSession).Operations.UserGroupWhereRole);
            var orderProcessorUserGroup = usergroups.First;

            new EmploymentBuilder(this.DatabaseSession)
                .WithFromDate(DateTime.UtcNow)
                .WithEmployee(orderProcessor2)
                .WithEmployer(internalOrganisation)
                .Build();

            orderProcessorUserGroup.AddMember(orderProcessor2);

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("orderProcessor", "Forms"), new string[0]);
            var pickList = new PickListBuilder(this.DatabaseSession).Build();

            this.DatabaseSession.Derive(true);

            var acl = new AccessControlList(pickList, new Users(this.DatabaseSession).GetCurrentUser());

            Assert.IsTrue(acl.CanWrite(PickLists.Meta.Picker));
            Assert.IsTrue(acl.CanRead(PickLists.Meta.Picker));
            Assert.IsTrue(acl.CanExecute(PickLists.Meta.Cancel));

            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("orderProcessor2", "Forms"), new string[0]);
            acl = new AccessControlList(pickList, new Users(this.DatabaseSession).GetCurrentUser());

            Assert.IsFalse(acl.HasReadOperation);
        }
コード例 #32
0
        public override void Init()
        {
            base.Init();

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

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

            this.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();

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

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();
        }
コード例 #33
0
 public Bank BuildByComplex(BankBuilder builder, BankBuilderDirector director)
 {
     builder = new SberBankBuilder();
     director.Construct(builder);
     return(builder.Bank);
 }
コード例 #34
0
        public void GivenAccountingPeriod_WhenMonthInNextSemesterIsAdded_ThenPeriodsForMonthForQuarterAndForSemesterAreAdded()
        {
            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("own account")
                                 .WithBankAccount(new BankAccountBuilder(this.Session).WithBank(bank).WithCurrency(euro).WithIban("BE23 3300 6167 6391").WithNameOnAccount("Koen").Build())
                                 .Build();

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

            this.Session.Derive();

            organisation.StartNewFiscalYear();

            Assert.Equal(4, this.Session.Extent <AccountingPeriod>().Count);

            organisation.ActualAccountingPeriod.AddNextMonth();

            Assert.Equal(5, this.Session.Extent <AccountingPeriod>().Count);

            organisation.ActualAccountingPeriod.AddNextMonth();

            Assert.Equal(6, this.Session.Extent <AccountingPeriod>().Count);

            organisation.ActualAccountingPeriod.AddNextMonth();

            Assert.Equal(8, this.Session.Extent <AccountingPeriod>().Count);

            organisation.ActualAccountingPeriod.AddNextMonth();

            Assert.Equal(9, this.Session.Extent <AccountingPeriod>().Count);

            organisation.ActualAccountingPeriod.AddNextMonth();

            Assert.Equal(10, this.Session.Extent <AccountingPeriod>().Count);

            var seventhMonth = organisation.ActualAccountingPeriod.AddNextMonth();

            Assert.Equal(13, this.Session.Extent <AccountingPeriod>().Count);

            var thirdQuarter = seventhMonth.Parent;

            Assert.Equal(organisation.ActualAccountingPeriod.Parent.PeriodNumber + 2, thirdQuarter.PeriodNumber);
            Assert.Equal(new TimeFrequencies(this.Session).Trimester, thirdQuarter.Frequency);
            Assert.Equal(organisation.ActualAccountingPeriod.Parent.FromDate.AddMonths(6).Date, thirdQuarter.FromDate);
            Assert.Equal(organisation.ActualAccountingPeriod.Parent.FromDate.AddMonths(9).AddSeconds(-1).Date, thirdQuarter.ThroughDate);

            var secondSemester = thirdQuarter.Parent;

            Assert.Equal(organisation.ActualAccountingPeriod.Parent.Parent.PeriodNumber + 1, secondSemester.PeriodNumber);
            Assert.Equal(new TimeFrequencies(this.Session).Semester, secondSemester.Frequency);
            Assert.Equal(organisation.ActualAccountingPeriod.Parent.Parent.FromDate.AddMonths(6).Date, secondSemester.FromDate);
            Assert.Equal(organisation.ActualAccountingPeriod.Parent.Parent.FromDate.AddMonths(12).AddSeconds(-1).Date, secondSemester.ThroughDate);
            Assert.Equal(organisation.ActualAccountingPeriod.Parent.Parent.Parent, secondSemester.Parent);
        }
コード例 #35
0
ファイル: SalesInvoiceTests.cs プロジェクト: Allors/apps
        public void GivenSalesInvoiceCreatedBySalesRep_WhenCurrentUserInAnotherSalesRepUserGroup_ThenAccessIsDenied()
        {
            var salesRep2 = new PersonBuilder(this.DatabaseSession).WithUserName("salesRep2").WithLastName("salesRep2").Build();
            var customer2 = new OrganisationBuilder(this.DatabaseSession).WithName("customer").Build();
            var contactMechanism = new PostalAddressBuilder(this.DatabaseSession)
                .WithAddress1("Haverwerf 15")
                .WithPostalBoundary(new PostalBoundaryBuilder(this.DatabaseSession)
                                        .WithLocality("Mechelen")
                                        .WithCountry(new Countries(this.DatabaseSession).FindBy(Countries.Meta.IsoCode, "BE"))
                                        .Build())

                .Build();

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

            var mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build();
            var mechelenAddress = new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();

            var billToMechelen = new PartyContactMechanismBuilder(this.DatabaseSession)
                .WithContactMechanism(mechelenAddress)
                .WithContactPurpose(new ContactMechanismPurposes(this.DatabaseSession).BillingAddress)
                .WithUseAsDefault(true)
                .Build();

            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 internalOrganisation2 = new InternalOrganisationBuilder(this.DatabaseSession)
                .WithName("internalOrganisation2")
                .WithLocale(new Locales(this.DatabaseSession).EnglishGreatBritain)
                .WithEmployeeRole(new Roles(this.DatabaseSession).Administrator)
                .WithEmployeeRole(new Roles(this.DatabaseSession).Sales)
                .WithDefaultPaymentMethod(ownBankAccount)
                .WithPreferredCurrency(euro)
                .WithPartyContactMechanism(billToMechelen)
                .Build();

            var facility = new WarehouseBuilder(this.DatabaseSession).WithName("facility").WithOwner(internalOrganisation2).Build();
            internalOrganisation2.DefaultFacility = facility;

            new StoreBuilder(this.DatabaseSession)
                .WithName("store")
                .WithDefaultFacility(facility)
                .WithOwner(internalOrganisation2)
                .WithDefaultShipmentMethod(new ShipmentMethods(this.DatabaseSession).Ground)
                .WithDefaultCarrier(new Carriers(this.DatabaseSession).Fedex)
                .WithCreditLimit(500)
                .WithPaymentGracePeriod(10)
                .Build();

            new EmploymentBuilder(this.DatabaseSession).WithEmployee(salesRep2).WithEmployer(internalOrganisation2).WithFromDate(DateTime.UtcNow).Build();

            new CustomerRelationshipBuilder(this.DatabaseSession)
                .WithCustomer(customer2)
                .WithInternalOrganisation(internalOrganisation2)
                .WithFromDate(DateTime.UtcNow)
                .Build();

            new SalesRepRelationshipBuilder(this.DatabaseSession)
                .WithSalesRepresentative(salesRep2)
                .WithCustomer(customer2)
                .WithInternalOrganisation(internalOrganisation2)
                .WithFromDate(DateTime.UtcNow)
                .Build();

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("salesRep2", "Forms"), new string[0]);

            var invoice = new SalesInvoiceBuilder(this.DatabaseSession)
                .WithBilledFromInternalOrganisation(internalOrganisation2)
                .WithBillToCustomer(customer2)
                .WithBillToContactMechanism(contactMechanism)
                .Build();

            this.DatabaseSession.Derive(true);

            var acl = new AccessControlList(invoice, new Users(this.DatabaseSession).GetCurrentUser());

            Assert.IsTrue(acl.CanWrite(SalesInvoices.Meta.Comment));
            Assert.IsTrue(acl.CanRead(SalesInvoices.Meta.Comment));
            Assert.IsTrue(acl.CanExecute(SalesInvoices.Meta.Send));

            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("salesRep", "Forms"), new string[0]);
            acl = new AccessControlList(invoice, new Users(this.DatabaseSession).GetCurrentUser());

            Assert.IsFalse(acl.HasReadOperation);
        }
コード例 #36
0
        public void GivenCustomerRelationship_WhenDeriving_ThenSubAccountNumberMustBeUniqueWithinInternalOrganisation()
        {
            var customer2 = new OrganisationBuilder(this.DatabaseSession).WithName("customer").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 mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build();
            var address1 = new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();

            var billingAddress = new PartyContactMechanismBuilder(this.DatabaseSession)
                .WithContactMechanism(address1)
                .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 customerRelationship2 = new CustomerRelationshipBuilder(this.DatabaseSession)
                .WithCustomer(customer2)
                .WithInternalOrganisation(internalOrganisation2)
                .WithFromDate(DateTime.UtcNow)
                .Build();

            customerRelationship2.SubAccountNumber = 19;

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
        }
コード例 #37
0
ファイル: PurchaseOrderTests.cs プロジェクト: Allors/apps
        public void GivenPurchaseOrderCreatedByProcurementLevel1Role_WhenCurrentUserInAnotherProcurementLevel1RoleUserGroup_ThenAccessIsDenied()
        {
            var belgium = new Countries(this.DatabaseSession).CountryByIsoCode["BE"];
            var euro = belgium.Currency;

            var mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build();
            var mechelenAddress = new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();

            var billToMechelen = new PartyContactMechanismBuilder(this.DatabaseSession)
                .WithContactMechanism(mechelenAddress)
                .WithContactPurpose(new ContactMechanismPurposes(this.DatabaseSession).BillingAddress)
                .WithUseAsDefault(true)
                .Build();

            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 purchaser2 = new PersonBuilder(this.DatabaseSession).WithLastName("purchaser2").WithUserName("purchaser2").Build();

            var internalOrganisation = new InternalOrganisationBuilder(this.DatabaseSession)
                .WithName("new internalOrganisation")
                .WithLocale(Singleton.Instance(this.DatabaseSession).DefaultLocale)
                .WithEmployeeRole(new Roles(this.DatabaseSession).Administrator)
                .WithDefaultPaymentMethod(ownBankAccount)
                .WithPreferredCurrency(euro)
                .WithPartyContactMechanism(billToMechelen)
                .Build();

            var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build();
            new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier).WithInternalOrganisation(internalOrganisation).Build();

            new EmploymentBuilder(this.DatabaseSession)
                .WithFromDate(DateTime.UtcNow)
                .WithEmployee(purchaser2)
                .WithEmployer(internalOrganisation)
                .Build();

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("purchaser", "Forms"), new string[0]);
            var order = new PurchaseOrderBuilder(this.DatabaseSession).WithTakenViaSupplier(supplier).WithShipToBuyer(internalOrganisation).Build();

            this.DatabaseSession.Derive(true);

            var acl = new AccessControlList(order, new Users(this.DatabaseSession).GetCurrentUser());

            Assert.IsTrue(acl.CanWrite(PurchaseOrders.Meta.Comment));
            Assert.IsTrue(acl.CanRead(PurchaseOrders.Meta.Comment));
            Assert.IsTrue(acl.CanExecute(PurchaseOrders.Meta.Confirm));

            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("purchaser2", "Forms"), new string[0]);
            acl = new AccessControlList(order, new Users(this.DatabaseSession).GetCurrentUser());

            Assert.IsFalse(acl.HasReadOperation);
        }
コード例 #38
0
ファイル: PurchaseInvoiceTests.cs プロジェクト: Allors/apps
        public void GivenPurchaseInvoice_WhenGettingInvoiceNumberWithoutFormat_ThenInvoiceNumberShouldBeReturned()
        {
            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 internalOrganisation = new InternalOrganisationBuilder(this.DatabaseSession)
                .WithName("org")
                .WithLocale(new Locales(this.DatabaseSession).EnglishGreatBritain)
                .WithDefaultPaymentMethod(ownBankAccount)
                .WithPreferredCurrency(euro)
                .Build();

            var invoice1 = new PurchaseInvoiceBuilder(this.DatabaseSession)
                .WithPurchaseInvoiceType(new PurchaseInvoiceTypes(this.DatabaseSession).PurchaseInvoice)
                .WithBilledToInternalOrganisation(internalOrganisation)
                .Build();

            Assert.AreEqual("1", invoice1.InvoiceNumber);

            var invoice2 = new PurchaseInvoiceBuilder(this.DatabaseSession)
                .WithPurchaseInvoiceType(new PurchaseInvoiceTypes(this.DatabaseSession).PurchaseInvoice)
                .WithBilledToInternalOrganisation(internalOrganisation)
                .Build();

            Assert.AreEqual("2", invoice2.InvoiceNumber);
        }
コード例 #39
0
        public static Organisation CreateInternalOrganisation(
            ISession session,
            string name,
            string address,
            string postalCode,
            string locality,
            Country country,
            string phone1CountryCode,
            string phone1,
            ContactMechanismPurpose phone1Purpose,
            string phone2CountryCode,
            string phone2,
            ContactMechanismPurpose phone2Purpose,
            string emailAddress,
            string websiteAddress,
            string taxNumber,
            string bankName,
            string facilityName,
            string bic,
            string iban,
            Currency currency,
            string logo,
            string storeName,
            BillingProcess billingProcess,
            string outgoingShipmentNumberPrefix,
            string salesInvoiceNumberPrefix,
            string salesOrderNumberPrefix,
            string requestNumberPrefix,
            string quoteNumberPrefix,
            string productNumberPrefix,
            int?requestCounterValue,
            int?quoteCounterValue,
            int?orderCounterValue,
            int?invoiceCounterValue)
        {
            var postalAddress1 = new PostalAddressBuilder(session)
                                 .WithAddress1(address)
                                 .WithPostalBoundary(new PostalBoundaryBuilder(session).WithPostalCode(postalCode).WithLocality(locality).WithCountry(country).Build())
                                 .Build();

            var email = new EmailAddressBuilder(session)
                        .WithElectronicAddressString(emailAddress)
                        .Build();

            var webSite = new WebAddressBuilder(session)
                          .WithElectronicAddressString(websiteAddress)
                          .Build();

            var bank        = new BankBuilder(session).WithName(bankName).WithBic(bic).WithCountry(country).Build();
            var bankaccount = new BankAccountBuilder(session)
                              .WithBank(bank)
                              .WithIban(iban)
                              .WithNameOnAccount(name)
                              .WithCurrency(currency)
                              .Build();

            var organisation = new OrganisationBuilder(session)
                               .WithIsInternalOrganisation(true)
                               .WithTaxNumber(taxNumber)
                               .WithName(name)
                               .WithBankAccount(bankaccount)
                               .WithDefaultCollectionMethod(new OwnBankAccountBuilder(session).WithBankAccount(bankaccount).WithDescription("Huisbank").Build())
                               .WithPreferredCurrency(new Currencies(session).FindBy(M.Currency.IsoCode, "EUR"))
                               .WithInvoiceSequence(new InvoiceSequences(session).EnforcedSequence)
                               .WithFiscalYearStartMonth(01)
                               .WithFiscalYearStartDay(01)
                               .WithDoAccounting(false)
                               .WithRequestNumberPrefix(requestNumberPrefix)
                               .WithQuoteNumberPrefix(quoteNumberPrefix)
                               .Build();

            if (requestCounterValue != null)
            {
                organisation.RequestCounter = new CounterBuilder(session).WithValue(requestCounterValue).Build();
            }

            if (quoteCounterValue != null)
            {
                organisation.QuoteCounter = new CounterBuilder(session).WithValue(quoteCounterValue).Build();
            }

            organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                  .WithUseAsDefault(true)
                                                  .WithContactMechanism(email)
                                                  .WithContactPurpose(new ContactMechanismPurposes(session).GeneralEmail)
                                                  .Build());
            organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                  .WithUseAsDefault(true)
                                                  .WithContactMechanism(postalAddress1)
                                                  .WithContactPurpose(new ContactMechanismPurposes(session).GeneralCorrespondence)
                                                  .Build());
            organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                  .WithUseAsDefault(true)
                                                  .WithContactMechanism(webSite)
                                                  .WithContactPurpose(new ContactMechanismPurposes(session).InternetAddress)
                                                  .Build());

            TelecommunicationsNumber phoneNumber1 = null;

            if (!string.IsNullOrEmpty(phone1))
            {
                phoneNumber1 = new TelecommunicationsNumberBuilder(session).WithContactNumber(phone1).Build();
                if (!string.IsNullOrEmpty(phone1CountryCode))
                {
                    phoneNumber1.CountryCode = phone1CountryCode;
                }
            }

            if (phoneNumber1 != null)
            {
                organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                      .WithUseAsDefault(true)
                                                      .WithContactMechanism(phoneNumber1)
                                                      .WithContactPurpose(phone1Purpose)
                                                      .Build());
            }

            TelecommunicationsNumber phoneNumber2 = null;

            if (!string.IsNullOrEmpty(phone2))
            {
                phoneNumber2 = new TelecommunicationsNumberBuilder(session).WithContactNumber(phone2).Build();
                if (!string.IsNullOrEmpty(phone2CountryCode))
                {
                    phoneNumber2.CountryCode = phone2CountryCode;
                }
            }

            if (phoneNumber2 != null)
            {
                organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session)
                                                      .WithUseAsDefault(true)
                                                      .WithContactMechanism(phoneNumber2)
                                                      .WithContactPurpose(phone2Purpose)
                                                      .Build());
            }

            if (File.Exists(logo))
            {
                var fileInfo = new FileInfo(logo);

                var fileName = System.IO.Path.GetFileNameWithoutExtension(fileInfo.FullName).ToLowerInvariant();
                var content  = File.ReadAllBytes(fileInfo.FullName);
                var image    = new MediaBuilder(session).WithFileName(fileName).WithInData(content).Build();
                organisation.LogoImage = image;
            }

            Facility facility = null;

            if (facilityName != null)
            {
                facility = new FacilityBuilder(session)
                           .WithName(facilityName)
                           .WithFacilityType(new FacilityTypes(session).Warehouse)
                           .WithOwner(organisation)
                           .Build();
            }

            var paymentMethod = new OwnBankAccountBuilder(session).WithBankAccount(bankaccount).WithDescription("Hoofdbank").Build();

            var store = new StoreBuilder(session)
                        .WithName(storeName)
                        .WithOutgoingShipmentNumberPrefix(outgoingShipmentNumberPrefix)
                        .WithSalesInvoiceNumberPrefix(salesInvoiceNumberPrefix)
                        .WithSalesOrderNumberPrefix(salesOrderNumberPrefix)
                        .WithDefaultCollectionMethod(paymentMethod)
                        .WithDefaultShipmentMethod(new ShipmentMethods(session).Ground)
                        .WithDefaultCarrier(new Carriers(session).Fedex)
                        .WithBillingProcess(billingProcess)
                        .WithSalesInvoiceCounter(new CounterBuilder(session).WithUniqueId(Guid.NewGuid()).WithValue(0).Build())
                        .WithIsImmediatelyPicked(true)
                        .WithIsAutomaticallyShipped(true)
                        .WithInternalOrganisation(organisation)
                        .Build();

            if (facility != null)
            {
                store.DefaultFacility = facility;
            }

            if (orderCounterValue != null)
            {
                store.SalesOrderCounter = new CounterBuilder(session).WithValue(orderCounterValue).Build();
            }

            if (invoiceCounterValue != null)
            {
                store.SalesInvoiceCounter = new CounterBuilder(session).WithValue(invoiceCounterValue).Build();
            }

            return(organisation);
        }
コード例 #40
0
ファイル: Fixture.cs プロジェクト: Allors/apps
        private static void SetupFull()
        {
            var configuration = new Adapters.Memory.IntegerId.Configuration { ObjectFactory = Config.ObjectFactory };
            Config.Default = new Adapters.Memory.IntegerId.Database(configuration);

            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-GB");
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-GB");

            var database = Config.Default;
            database.Init();

            using (var session = database.CreateSession())
            {
                new Setup(session, null).Apply();
                new Security(session).Apply();

                session.Derive(true);
                session.Commit();

                using (var stringWriter = new StringWriter())
                {
                    using (var writer = new XmlTextWriter(stringWriter))
                    {
                        database.Save(writer);
                        basicXml = stringWriter.ToString();
                    }
                }

                var singleton = Singleton.Instance(session);
                singleton.Guest = new PersonBuilder(session).WithUserName("guest").WithLastName("guest").Build();

                var administrator = new PersonBuilder(session).WithUserName("administrator").WithLastName("Administrator").Build();

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

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

                var ownBankAccount = new OwnBankAccountBuilder(session)
                    .WithBankAccount(new BankAccountBuilder(session).WithBank(bank)
                                        .WithCurrency(euro)
                                        .WithIban("BE68539007547034")
                                        .WithNameOnAccount("Koen")
                                        .Build())
                    .WithDescription("Main bank account")
                    .Build();

                var postalBoundary = new PostalBoundaryBuilder(session).WithLocality("Mechelen").WithCountry(belgium).Build();
                var postalAddress = new PostalAddressBuilder(session).WithAddress1("Kleine Nieuwedijkstraat 2").WithPostalBoundary(postalBoundary).Build();

                var billingAddress =
                    new PartyContactMechanismBuilder(session).WithContactMechanism(postalAddress).WithContactPurpose(
                        new ContactMechanismPurposes(session).BillingAddress).WithUseAsDefault(true).Build();

                var shippingAddress =
                    new PartyContactMechanismBuilder(session).WithContactMechanism(postalAddress).WithContactPurpose(
                        new ContactMechanismPurposes(session).ShippingAddress).WithUseAsDefault(true).Build();

                var internalOrganisation = new InternalOrganisationBuilder(session)
                    .WithLocale(new Locales(session).EnglishGreatBritain)
                    .WithName("internalOrganisation")
                    .WithPreferredCurrency(euro)
                    .WithIncomingShipmentNumberPrefix("incoming shipmentno: ")
                    .WithPurchaseInvoiceNumberPrefix("incoming invoiceno: ")
                    .WithPurchaseOrderNumberPrefix("purchase orderno: ")
                    .WithPartyContactMechanism(billingAddress)
                    .WithPartyContactMechanism(shippingAddress)
                    .WithEmployeeRole(new Roles(session).Administrator)
                    .WithEmployeeRole(new Roles(session).Procurement)
                    .WithEmployeeRole(new Roles(session).Sales)
                    .WithEmployeeRole(new Roles(session).Operations)
                    .WithEmployeeRole(new Roles(session).Administrator)
                    .WithDefaultPaymentMethod(ownBankAccount)
                    .Build();

                Singleton.Instance(session).DefaultInternalOrganisation = internalOrganisation;

                var facility = new WarehouseBuilder(session).WithName("facility").WithOwner(internalOrganisation).Build();
                internalOrganisation.DefaultFacility = facility;

                new StoreBuilder(session)
                    .WithName("store")
                    .WithDefaultFacility(facility)
                    .WithOwner(internalOrganisation)
                    .WithOutgoingShipmentNumberPrefix("shipmentno: ")
                    .WithSalesInvoiceNumberPrefix("invoiceno: ")
                    .WithSalesOrderNumberPrefix("orderno: ")
                    .WithDefaultShipmentMethod(new ShipmentMethods(session).Ground)
                    .WithDefaultCarrier(new Carriers(session).Fedex)
                    .WithCreditLimit(500)
                    .WithPaymentGracePeriod(10)
                    .Build();

                var customer = new OrganisationBuilder(session).WithName("customer").WithLocale(singleton.DefaultLocale).Build();
                var supplier = new OrganisationBuilder(session).WithName("supplier").WithLocale(singleton.DefaultLocale).Build();
                var purchaser = new PersonBuilder(session).WithLastName("purchaser").WithUserName("purchaser").Build();
                var salesrep = new PersonBuilder(session).WithLastName("salesRep").WithUserName("salesRep").Build();
                var orderProcessor =
                    new PersonBuilder(session).WithLastName("orderProcessor").WithUserName("orderProcessor").Build();

                new CustomerRelationshipBuilder(session).WithCustomer(customer).WithInternalOrganisation(internalOrganisation).WithFromDate(DateTime.UtcNow).Build();

                new SupplierRelationshipBuilder(session).WithSupplier(supplier).WithInternalOrganisation(internalOrganisation).WithFromDate(DateTime.UtcNow).Build();

                new EmploymentBuilder(session).WithFromDate(DateTime.UtcNow).WithEmployee(purchaser).WithEmployer(internalOrganisation).Build();

                new EmploymentBuilder(session).WithFromDate(DateTime.UtcNow).WithEmployee(salesrep).WithEmployer(internalOrganisation).Build();

                new EmploymentBuilder(session).WithFromDate(DateTime.UtcNow).WithEmployee(orderProcessor).WithEmployer(internalOrganisation).Build();

                new SalesRepRelationshipBuilder(session).WithFromDate(DateTime.UtcNow).WithCustomer(customer).WithSalesRepresentative(salesrep).Build();

                session.Derive(true);

                var administrators = new UserGroups(session).Administrators;
                administrators.AddMember(administrator);

                var usergroups = internalOrganisation.UserGroupsWhereParty;
                usergroups = internalOrganisation.UserGroupsWhereParty;
                usergroups.Filter.AddEquals(UserGroups.Meta.Parent, new Roles(session).Operations.UserGroupWhereRole);
                var userGroup = usergroups.First;

                userGroup.AddMember(orderProcessor);

                usergroups = internalOrganisation.UserGroupsWhereParty;
                usergroups.Filter.AddEquals(UserGroups.Meta.Parent, new Roles(session).Procurement.UserGroupWhereRole);
                userGroup = usergroups.First;

                userGroup.AddMember(purchaser);

                session.Derive(true);
                session.Commit();

                using (var stringWriter = new StringWriter())
                {
                    using (var writer = new XmlTextWriter(stringWriter))
                    {
                        database.Save(writer);
                        fullXml = stringWriter.ToString();
                    }
                }
            }
        }