Beispiel #1
0
        public void GivenEmailCommunication_WhenOriginatorIsDeleted_ThenCommunicationEventIsDeleted()
        {
            var personalEmailAddress = new ContactMechanismPurposes(this.Session).PersonalEmailAddress;

            var originatorEmail   = new EmailAddressBuilder(this.Session).WithElectronicAddressString("*****@*****.**").Build();
            var originatorContact = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(originatorEmail).WithContactPurpose(personalEmailAddress).WithUseAsDefault(true).Build();
            var originator        = new PersonBuilder(this.Session).WithLastName("originator").WithPartyContactMechanism(originatorContact).Build();

            var addresseeEmail   = new EmailAddressBuilder(this.Session).WithElectronicAddressString("*****@*****.**").Build();
            var addresseeContact = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(addresseeEmail).WithContactPurpose(personalEmailAddress).WithUseAsDefault(true).Build();
            var addressee        = new PersonBuilder(this.Session).WithLastName("addressee").WithPartyContactMechanism(addresseeContact).Build();

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

            var communication = new EmailCommunicationBuilder(this.Session)
                                .WithSubject("Hello")
                                .WithDescription("Hello world!")
                                .WithFromParty(originator)
                                .WithToParty(addressee)
                                .WithFromEmail(originatorEmail)
                                .WithToEmail(addresseeEmail)
                                .Build();

            this.Session.Derive();

            Assert.Single(this.Session.Extent <EmailCommunication>());

            originator.Delete();
            this.Session.Derive();

            Assert.Equal(0, this.Session.Extent <EmailCommunication>().Count);
        }
Beispiel #2
0
        public void GivenEmailCommunication_WhenDeriving_ThenInvolvedPartiesAreDerived()
        {
            var owner = new PersonBuilder(this.Session).WithLastName("owner").Build();

            var personalEmailAddress = new ContactMechanismPurposes(this.Session).PersonalEmailAddress;

            var originatorEmail   = new EmailAddressBuilder(this.Session).WithElectronicAddressString("*****@*****.**").Build();
            var originatorContact = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(originatorEmail).WithContactPurpose(personalEmailAddress).WithUseAsDefault(true).Build();
            var originator        = new PersonBuilder(this.Session).WithLastName("originator").WithPartyContactMechanism(originatorContact).Build();

            var addresseeEmail   = new EmailAddressBuilder(this.Session).WithElectronicAddressString("*****@*****.**").Build();
            var addresseeContact = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(addresseeEmail).WithContactPurpose(personalEmailAddress).WithUseAsDefault(true).Build();
            var addressee        = new PersonBuilder(this.Session).WithLastName("addressee").WithPartyContactMechanism(addresseeContact).Build();

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

            var communication = new EmailCommunicationBuilder(this.Session)
                                .WithSubject("Hello")
                                .WithDescription("Hello world!")
                                .WithOwner(owner)
                                .WithFromParty(originator)
                                .WithToParty(addressee)
                                .WithFromEmail(originatorEmail)
                                .WithToEmail(addresseeEmail)
                                .Build();

            this.Session.Derive();

            Assert.Equal(3, communication.InvolvedParties.Count);
            Assert.Contains(owner, communication.InvolvedParties);
            Assert.Contains(originator, communication.InvolvedParties);
            Assert.Contains(addressee, communication.InvolvedParties);
        }
Beispiel #3
0
        public void GivenEmailCommunicationIsBuild_WhenDeriving_ThenStatusIsSet()
        {
            var personalEmailAddress = new ContactMechanismPurposes(this.Session).PersonalEmailAddress;

            var originatorEmail   = new EmailAddressBuilder(this.Session).WithElectronicAddressString("*****@*****.**").Build();
            var originatorContact = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(originatorEmail).WithContactPurpose(personalEmailAddress).WithUseAsDefault(true).Build();
            var originator        = new PersonBuilder(this.Session).WithLastName("originator").WithPartyContactMechanism(originatorContact).Build();

            var addresseeEmail   = new EmailAddressBuilder(this.Session).WithElectronicAddressString("*****@*****.**").Build();
            var addresseeContact = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(addresseeEmail).WithContactPurpose(personalEmailAddress).WithUseAsDefault(true).Build();
            var addressee        = new PersonBuilder(this.Session).WithLastName("addressee").WithPartyContactMechanism(addresseeContact).Build();

            var communication = new EmailCommunicationBuilder(this.Session)
                                .WithOwner(this.Administrator)
                                .WithSubject("Hello")
                                .WithDescription("Hello world!")
                                .WithFromParty(originator)
                                .WithToParty(addressee)
                                .WithFromEmail(originatorEmail)
                                .WithToEmail(addresseeEmail)
                                .Build();

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

            Assert.Equal(communication.CommunicationEventState, new CommunicationEventStates(this.Session).Scheduled);
            Assert.Equal(communication.CommunicationEventState, communication.LastCommunicationEventState);
        }
        public void GivenInventoryItem_WhenQuantityOnHandIsDecreased_ThenSalesOrderItemsWithQuantityRequestsShippingAreUpdated()
        {
            // Arrange
            var inventoryItemKinds = new InventoryItemKinds(this.Session);
            var unitsOfMeasure     = new UnitsOfMeasure(this.Session);
            var varianceReasons    = new InventoryTransactionReasons(this.Session);
            var contactMechanisms  = new ContactMechanismPurposes(this.Session);

            var vatRate21    = new VatRateBuilder(this.Session).WithRate(21).Build();
            var category     = new ProductCategoryBuilder(this.Session).WithName("category").Build();
            var finishedGood = CreatePart("1", inventoryItemKinds.NonSerialised);
            var good         = CreateGood("10101", vatRate21, "good1", unitsOfMeasure.Piece, category, finishedGood);

            CreateInventoryTransaction(5, varianceReasons.Unknown, finishedGood);

            this.Session.Derive(true);

            var mechelen             = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var mechelenAddress      = new PostalAddressBuilder(this.Session).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();
            var shipToMechelen       = CreateShipTo(mechelenAddress, contactMechanisms.ShippingAddress, true);
            var customer             = new PersonBuilder(this.Session).WithLastName("customer").WithPartyContactMechanism(shipToMechelen).Build();
            var internalOrganisation = this.InternalOrganisation;

            new CustomerRelationshipBuilder(this.Session).WithFromDate(DateTime.UtcNow).WithCustomer(customer).Build();

            this.Session.Derive(true);

            var order     = CreateSalesOrder(customer, customer, DateTime.UtcNow, false);
            var salesItem = CreateSalesOrderItem("item1", good, 10, 15);

            // Act
            order.AddSalesOrderItem(salesItem);
            this.Session.Derive(true);

            order.Confirm();
            this.Session.Derive(true);

            // Assert
            Assert.Equal(5, salesItem.QuantityRequestsShipping);
            Assert.Equal(0, salesItem.QuantityPendingShipment);
            Assert.Equal(10, salesItem.QuantityReserved);
            Assert.Equal(5, salesItem.QuantityShortFalled);

            // Rearrange
            CreateInventoryTransaction(-2, varianceReasons.Unknown, finishedGood);

            // Act
            this.Session.Derive();

            // Assert
            Assert.Equal(3, salesItem.QuantityRequestsShipping);
            Assert.Equal(0, salesItem.QuantityPendingShipment);
            Assert.Equal(10, salesItem.QuantityReserved);
            Assert.Equal(7, salesItem.QuantityShortFalled);
        }
Beispiel #5
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();
        }
Beispiel #6
0
        public void GivenInventoryItem_WhenQuantityOnHandIsRaised_ThenSalesOrderItemsWithQuantityShortFalledAreUpdated()
        {
            // Arrange
            var inventoryItemKinds = new InventoryItemKinds(this.Session);
            var unitsOfMeasure     = new UnitsOfMeasure(this.Session);
            var varianceReasons    = new InventoryTransactionReasons(this.Session);
            var contactMechanisms  = new ContactMechanismPurposes(this.Session);

            var store = this.Session.Extent <Store>().First;

            store.IsImmediatelyPicked = false;

            var vatRate21    = new VatRateBuilder(this.Session).WithRate(21).Build();
            var category     = new ProductCategoryBuilder(this.Session).WithName("category").Build();
            var finishedGood = this.CreatePart("1", inventoryItemKinds.NonSerialised);
            var good         = this.CreateGood("10101", vatRate21, "good1", unitsOfMeasure.Piece, category, finishedGood);

            this.Session.Derive();

            this.CreateInventoryTransaction(5, varianceReasons.Unknown, finishedGood);

            this.Session.Derive();

            var mechelen        = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var mechelenAddress = new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen).WithAddress1("Haverwerf 15").Build();
            var shipToMechelen  = this.CreateShipTo(mechelenAddress, contactMechanisms.ShippingAddress, true);
            var customer        = new PersonBuilder(this.Session).WithLastName("customer").WithPartyContactMechanism(shipToMechelen).Build();

            new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer).Build();

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

            var order1     = this.CreateSalesOrder(customer, customer, this.Session.Now());
            var salesItem1 = this.CreateSalesOrderItem("item1", good, 10, 15);
            var salesItem2 = this.CreateSalesOrderItem("item2", good, 20, 15);

            order1.AddSalesOrderItem(salesItem1);
            order1.AddSalesOrderItem(salesItem2);

            var order2     = this.CreateSalesOrder(customer, customer, this.Session.Now().AddDays(1));
            var salesItem3 = this.CreateSalesOrderItem("item3", good, 10, 15);
            var salesItem4 = this.CreateSalesOrderItem("item4", good, 20, 15);

            order2.AddSalesOrderItem(salesItem3);
            order2.AddSalesOrderItem(salesItem4);

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

            // Act
            order1.SetReadyForPosting();
            this.Session.Derive(true);

            order1.Post();
            this.Session.Derive();

            order1.Accept();
            this.Session.Derive();

            Assert.Equal(0, salesItem1.ReservedFromNonSerialisedInventoryItem.AvailableToPromise);
            Assert.Equal(5, salesItem1.ReservedFromNonSerialisedInventoryItem.QuantityOnHand);

            order2.SetReadyForPosting();

            this.Session.Derive(true);

            order2.Post();
            this.Session.Derive();

            order2.Accept();
            this.Session.Derive();

            // Assert
            Assert.Equal(0, salesItem1.QuantityRequestsShipping);
            Assert.Equal(5, salesItem1.QuantityPendingShipment);
            Assert.Equal(10, salesItem1.QuantityReserved);
            Assert.Equal(5, salesItem1.QuantityShortFalled);

            Assert.Equal(0, salesItem2.QuantityRequestsShipping);
            Assert.Equal(0, salesItem2.QuantityPendingShipment);
            Assert.Equal(20, salesItem2.QuantityReserved);
            Assert.Equal(20, salesItem2.QuantityShortFalled);

            Assert.Equal(0, salesItem3.QuantityRequestsShipping);
            Assert.Equal(0, salesItem3.QuantityPendingShipment);
            Assert.Equal(10, salesItem3.QuantityReserved);
            Assert.Equal(10, salesItem3.QuantityShortFalled);

            Assert.Equal(0, salesItem4.QuantityRequestsShipping);
            Assert.Equal(0, salesItem4.QuantityPendingShipment);
            Assert.Equal(20, salesItem4.QuantityReserved);
            Assert.Equal(20, salesItem4.QuantityShortFalled);

            Assert.Equal(0, salesItem1.ReservedFromNonSerialisedInventoryItem.AvailableToPromise);
            Assert.Equal(5, salesItem1.ReservedFromNonSerialisedInventoryItem.QuantityOnHand);

            // Re-arrange
            this.CreateInventoryTransaction(15, varianceReasons.Unknown, finishedGood);

            // Act
            this.Session.Derive(true);
            this.Session.Commit();

            // Assert
            // Orderitems are sorted as follows: item1, item2, item3, item4
            Assert.Equal(0, salesItem1.QuantityRequestsShipping);
            Assert.Equal(10, salesItem1.QuantityPendingShipment);
            Assert.Equal(10, salesItem1.QuantityReserved);
            Assert.Equal(0, salesItem1.QuantityShortFalled);

            Assert.Equal(0, salesItem2.QuantityRequestsShipping);
            Assert.Equal(10, salesItem2.QuantityPendingShipment);
            Assert.Equal(20, salesItem2.QuantityReserved);
            Assert.Equal(10, salesItem2.QuantityShortFalled);

            Assert.Equal(0, salesItem3.QuantityRequestsShipping);
            Assert.Equal(0, salesItem3.QuantityPendingShipment);
            Assert.Equal(10, salesItem3.QuantityReserved);
            Assert.Equal(10, salesItem3.QuantityShortFalled);

            Assert.Equal(0, salesItem4.QuantityRequestsShipping);
            Assert.Equal(0, salesItem4.QuantityPendingShipment);
            Assert.Equal(20, salesItem4.QuantityReserved);
            Assert.Equal(20, salesItem4.QuantityShortFalled);

            Assert.Equal(0, salesItem1.ReservedFromNonSerialisedInventoryItem.AvailableToPromise);
            Assert.Equal(20, salesItem1.ReservedFromNonSerialisedInventoryItem.QuantityOnHand);

            // Re-arrange
            this.CreateInventoryTransaction(85, varianceReasons.Unknown, finishedGood);

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

            // Assert
            // Orderitems are sorted as follows: item2, item1, item4, item 3
            Assert.Equal(0, salesItem1.QuantityRequestsShipping);
            Assert.Equal(10, salesItem1.QuantityPendingShipment);
            Assert.Equal(10, salesItem1.QuantityReserved);
            Assert.Equal(0, salesItem1.QuantityShortFalled);

            Assert.Equal(0, salesItem2.QuantityRequestsShipping);
            Assert.Equal(20, salesItem2.QuantityPendingShipment);
            Assert.Equal(20, salesItem2.QuantityReserved);
            Assert.Equal(0, salesItem2.QuantityShortFalled);

            Assert.Equal(0, salesItem3.QuantityRequestsShipping);
            Assert.Equal(10, salesItem3.QuantityPendingShipment);
            Assert.Equal(10, salesItem3.QuantityReserved);
            Assert.Equal(0, salesItem3.QuantityShortFalled);

            Assert.Equal(0, salesItem4.QuantityRequestsShipping);
            Assert.Equal(20, salesItem4.QuantityPendingShipment);
            Assert.Equal(20, salesItem4.QuantityReserved);
            Assert.Equal(0, salesItem4.QuantityShortFalled);

            Assert.Equal(45, salesItem1.ReservedFromNonSerialisedInventoryItem.AvailableToPromise);
            Assert.Equal(105, salesItem1.ReservedFromNonSerialisedInventoryItem.QuantityOnHand);
        }