Example #1
0
        private void SetupUser(Organisation organisation, string email, string firstName, string lastName, string password)
        {
            var userEmail = new EmailAddressBuilder(this.Session).WithElectronicAddressString(email).Build();

            var person = new PersonBuilder(this.Session)
                         .WithUserName(email)
                         .WithFirstName(firstName)
                         .WithLastName(lastName)
                         .WithUserEmail(userEmail.ElectronicAddressString)
                         .WithUserEmailConfirmed(true)
                         .Build();

            person.AddPartyContactMechanism(
                new PartyContactMechanismBuilder(this.Session)
                .WithContactMechanism(userEmail)
                .WithContactPurpose(new ContactMechanismPurposes(this.Session).PersonalEmailAddress)
                .WithUseAsDefault(true)
                .Build());

            new EmploymentBuilder(this.Session).WithEmployee(person).WithEmployer(organisation).Build();

            new UserGroups(this.Session).Administrators.AddMember(person);
            new UserGroups(this.Session).Creators.AddMember(person);

            person.SetPassword(password);
        }
Example #2
0
        private void SetupUser(Organisation organisation, string email, string firstName, string lastName, string password)
        {
            var userEmail = new EmailAddressBuilder(this.Session).WithElectronicAddressString(email).Build();

            var be = new Countries(this.Session).FindBy(M.Country.IsoCode, "BE");

            var postalAddress = new PostalAddressBuilder(this.Session)
                                .WithAddress1($"{firstName} address")
                                .WithPostalBoundary(new PostalBoundaryBuilder(this.Session).WithLocality($"Mechelen").WithPostalCode("2800").WithCountry(be).Build())
                                .Build();

            var generalCorrespondence = new PartyContactMechanismBuilder(this.Session)
                                        .WithContactMechanism(postalAddress)
                                        .WithContactPurpose(new ContactMechanismPurposes(this.Session).GeneralCorrespondence)
                                        .WithUseAsDefault(true)
                                        .Build();

            var person = new PersonBuilder(this.Session)
                         .WithUserName(email)
                         .WithFirstName(firstName)
                         .WithLastName(lastName)
                         .WithUserEmail(userEmail.ElectronicAddressString)
                         .WithUserEmailConfirmed(true)
                         .WithPartyContactMechanism(generalCorrespondence)
                         .Build();

            person.AddPartyContactMechanism(
                new PartyContactMechanismBuilder(this.Session)
                .WithContactMechanism(userEmail)
                .WithContactPurpose(new ContactMechanismPurposes(this.Session).PersonalEmailAddress)
                .WithUseAsDefault(true)
                .Build());

            new EmploymentBuilder(this.Session).WithEmployee(person).WithEmployer(organisation).Build();

            new UserGroups(this.Session).Administrators.AddMember(person);
            new UserGroups(this.Session).Creators.AddMember(person);

            person.SetPassword(password);
        }
Example #3
0
        public void GivenWorkEffortPrintDocument_WhenPrinting_ThenMediaCreated()
        {
            // Arrange
            var frequencies = new TimeFrequencies(this.Session);
            var purposes    = new ContactMechanismPurposes(this.Session);

            //// Customer Contact and Address Data
            var customer         = new OrganisationBuilder(this.Session).WithName("Customer").Build();
            var customerContact  = new PersonBuilder(this.Session).WithFirstName("Customer").WithLastName("Contact").Build();
            var organisation     = new Organisations(this.Session).Extent().First(o => o.IsInternalOrganisation);
            var customerRelation = new CustomerRelationshipBuilder(this.Session).WithCustomer(customer).WithInternalOrganisation(organisation).Build();

            var usa             = new Countries(this.Session).Extent().First(c => c.IsoCode.Equals("US"));
            var michigan        = new StateBuilder(this.Session).WithName("Michigan").WithCountry(usa).Build();
            var northville      = new CityBuilder(this.Session).WithName("Northville").WithState(michigan).Build();
            var postalCode      = new PostalCodeBuilder(this.Session).WithCode("48167").Build();
            var billingAddress  = this.CreatePostalAddress("Billing Address", "123 Street", "Suite S1", northville, postalCode);
            var shippingAddress = this.CreatePostalAddress("Shipping Address", "123 Street", "Dock D1", northville, postalCode);
            var phone           = new TelecommunicationsNumberBuilder(this.Session).WithCountryCode("1").WithAreaCode("616").WithContactNumber("774-2000").Build();

            customer.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.BillingAddress, billingAddress));
            customer.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.ShippingAddress, shippingAddress));
            customerContact.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.GeneralPhoneNumber, phone));

            //// Work Effort Data
            var salesPerson      = new PersonBuilder(this.Session).WithFirstName("Sales").WithLastName("Person").Build();
            var salesRepRelation = new SalesRepRelationshipBuilder(this.Session).WithCustomer(customer).WithSalesRepresentative(salesPerson).Build();
            var salesOrder       = this.CreateSalesOrder(customer, organisation);
            var workOrder        = this.CreateWorkEffort(organisation, customer, customerContact, salesOrder.SalesOrderItems.First);
            var employee         = new PersonBuilder(this.Session).WithFirstName("Good").WithLastName("Worker").Build();
            var employment       = new EmploymentBuilder(this.Session).WithEmployee(employee).WithEmployer(organisation).Build();

            var salesOrderItem = salesOrder.SalesOrderItems.First;

            salesOrder.AddValidOrderItem(salesOrderItem);

            //// Work Effort Inventory Assignmets
            var part1 = this.CreatePart("P1");
            var part2 = this.CreatePart("P2");
            var part3 = this.CreatePart("P3");

            this.Session.Derive(true);

            var inventoryAssignment1 = this.CreateInventoryAssignment(workOrder, part1, 11);
            var inventoryAssignment2 = this.CreateInventoryAssignment(workOrder, part2, 12);
            var inventoryAssignment3 = this.CreateInventoryAssignment(workOrder, part3, 13);

            //// Work Effort Time Entries
            var yesterday      = DateTimeFactory.CreateDateTime(this.Session.Now().AddDays(-1));
            var laterYesterday = DateTimeFactory.CreateDateTime(yesterday.AddHours(3));

            var today      = DateTimeFactory.CreateDateTime(this.Session.Now());
            var laterToday = DateTimeFactory.CreateDateTime(today.AddHours(4));

            var tomorrow      = DateTimeFactory.CreateDateTime(this.Session.Now().AddDays(1));
            var laterTomorrow = DateTimeFactory.CreateDateTime(tomorrow.AddHours(6));

            var timeEntryYesterday = this.CreateTimeEntry(yesterday, laterYesterday, frequencies.Day, workOrder);
            var timeEntryToday     = this.CreateTimeEntry(today, laterToday, frequencies.Hour, workOrder);
            var timeEntryTomorrow  = this.CreateTimeEntry(tomorrow, laterTomorrow, frequencies.Minute, workOrder);

            employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryYesterday);
            employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryToday);
            employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryTomorrow);

            this.Session.Derive(true);

            // Act
            workOrder.Print();

            this.Session.Derive();
            this.Session.Commit();

            // Assert
            Assert.True(workOrder.PrintDocument.ExistMedia);

            var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            var outputFile = System.IO.File.Create(System.IO.Path.Combine(desktopDir, "workTask.odt"));
            var stream     = new System.IO.MemoryStream(workOrder.PrintDocument.Media.MediaContent.Data);

            stream.CopyTo(outputFile);
            stream.Close();
        }
Example #4
0
        public void GivenWorkEffort_WhenCreatingModel_ThenValuesAreSet()
        {
            // Arrange
            var frequencies = new TimeFrequencies(this.Session);
            var purposes    = new ContactMechanismPurposes(this.Session);

            //// Customer Contact and Address Data
            var customer         = new OrganisationBuilder(this.Session).WithName("Customer").Build();
            var customerContact  = new PersonBuilder(this.Session).WithFirstName("Customer").WithLastName("Contact").Build();
            var organisation     = new Organisations(this.Session).Extent().First(o => o.IsInternalOrganisation);
            var customerRelation = new CustomerRelationshipBuilder(this.Session).WithCustomer(customer).WithInternalOrganisation(organisation).Build();

            var usa             = new Countries(this.Session).Extent().First(c => c.IsoCode.Equals("US"));
            var michigan        = new StateBuilder(this.Session).WithName("Michigan").WithCountry(usa).Build();
            var northville      = new CityBuilder(this.Session).WithName("Northville").WithState(michigan).Build();
            var postalCode      = new PostalCodeBuilder(this.Session).WithCode("48167").Build();
            var billingAddress  = this.CreatePostalAddress("Billing Address", "123 Street", "Suite S1", northville, postalCode);
            var shippingAddress = this.CreatePostalAddress("Shipping Address", "123 Street", "Dock D1", northville, postalCode);
            var phone           = new TelecommunicationsNumberBuilder(this.Session).WithCountryCode("1").WithAreaCode("616").WithContactNumber("774-2000").Build();

            customer.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.BillingAddress, billingAddress));
            customer.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.ShippingAddress, shippingAddress));
            customerContact.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.GeneralPhoneNumber, phone));

            //// Work Effort Data
            var salesPerson = new PersonBuilder(this.Session).WithFirstName("Sales").WithLastName("Person").Build();
            var salesOrder  = this.CreateSalesOrder(customer, organisation);
            var workOrder   = this.CreateWorkEffort(organisation, customer, customerContact, salesOrder.SalesOrderItems.First);
            var employee    = new PersonBuilder(this.Session).WithFirstName("Good").WithLastName("Worker").Build();
            var employment  = new EmploymentBuilder(this.Session).WithEmployee(employee).WithEmployer(organisation).Build();

            var salesOrderItem = salesOrder.SalesOrderItems.First;

            ((SalesOrderDerivedRoles)salesOrder).AddValidOrderItem(salesOrderItem);

            //// Work Effort Inventory Assignmets
            var part1 = this.CreatePart("P1");
            var part2 = this.CreatePart("P2");
            var part3 = this.CreatePart("P3");

            this.Session.Derive(true);

            var inventoryAssignment1 = this.CreateInventoryAssignment(workOrder, part1, 11);
            var inventoryAssignment2 = this.CreateInventoryAssignment(workOrder, part2, 12);
            var inventoryAssignment3 = this.CreateInventoryAssignment(workOrder, part3, 13);

            //// Work Effort Time Entries
            var yesterday      = DateTimeFactory.CreateDateTime(this.Session.Now().AddDays(-1));
            var laterYesterday = DateTimeFactory.CreateDateTime(yesterday.AddHours(3));

            var today      = DateTimeFactory.CreateDateTime(this.Session.Now());
            var laterToday = DateTimeFactory.CreateDateTime(today.AddHours(4));

            var tomorrow      = DateTimeFactory.CreateDateTime(this.Session.Now().AddDays(1));
            var laterTomorrow = DateTimeFactory.CreateDateTime(tomorrow.AddHours(6));

            var standardRate = new RateTypes(this.Session).StandardRate;
            var overtimeRate = new RateTypes(this.Session).OvertimeRate;

            var timeEntryYesterday = this.CreateTimeEntry(yesterday, laterYesterday, frequencies.Day, workOrder, standardRate);
            var timeEntryToday     = this.CreateTimeEntry(today, laterToday, frequencies.Hour, workOrder, standardRate);
            var timeEntryTomorrow  = this.CreateTimeEntry(tomorrow, laterTomorrow, frequencies.Minute, workOrder, overtimeRate);

            employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryYesterday);
            employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryToday);
            employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryTomorrow);

            this.Session.Derive(true);

            // Act
            var model = new WorkTaskModel.Model(workOrder);

            // Assert
            Assert.Equal(3, model.TimeEntries.Length);
            Assert.Single(model.TimeEntriesByBillingRate);
        }