public void SetUp() { _client = TestHelper.GetTestIdoClient(); _builder = FromSyteline.Warehouses.Address1.Address2.Address3.City.State.Zip.Name.Warehouse.Site.Where<WarehousesCriteria>(x => x.Site == "AUS"); }
public void GivenNewGoodCoredOnFinishedGood_WhenDeriving_ThenNonSerializedInventryItemIsCreatedForEveryFinishedGoodAndFacility() { var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); var secondFacility = new WarehouseBuilder(this.DatabaseSession).WithName("second facility").WithOwner(internalOrganisation).Build(); new SupplierRelationshipBuilder(this.DatabaseSession) .WithInternalOrganisation(internalOrganisation) .WithSupplier(supplier) .WithFromDate(DateTime.UtcNow) .Build(); var finishedGood = new FinishedGoodBuilder(this.DatabaseSession) .WithName("part") .Build(); var purchasePrice = new ProductPurchasePriceBuilder(this.DatabaseSession) .WithFromDate(DateTime.UtcNow) .WithCurrency(new Currencies(this.DatabaseSession).FindBy(Currencies.Meta.IsoCode, "EUR")) .WithPrice(1) .WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece) .Build(); var good = new GoodBuilder(this.DatabaseSession) .WithName("Good") .WithSku("10101") .WithFinishedGood(finishedGood) .WithVatRate(new VatRateBuilder(this.DatabaseSession).WithRate(21).Build()) .WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece) .Build(); new SupplierOfferingBuilder(this.DatabaseSession) .WithProduct(good) .WithSupplier(supplier) .WithProductPurchasePrice(purchasePrice) .WithFromDate(DateTime.UtcNow) .Build(); this.DatabaseSession.Derive(true); Assert.AreEqual(2, good.FinishedGood.InventoryItemsWherePart.Count); Assert.AreEqual(1, internalOrganisation.DefaultFacility.InventoryItemsWhereFacility.Count); Assert.AreEqual(1, secondFacility.InventoryItemsWhereFacility.Count); }
public void GivenConfirmedOrderItemForGood_WhenReservedFromInventoryItemChangesValue_ThenQuantitiesAreMovedFromOldToNewInventoryItem() { this.InstantiateObjects(this.DatabaseSession); var secondWarehouse = new WarehouseBuilder(this.DatabaseSession) .WithName("affiliate warehouse") .WithOwner(this.internalOrganisation) .Build(); var item = new SalesOrderItemBuilder(this.DatabaseSession) .WithProduct(this.good) .WithQuantityOrdered(3) .WithActualUnitPrice(5) .Build(); this.order.AddSalesOrderItem(item); this.DatabaseSession.Derive(true); this.order.Confirm(); this.DatabaseSession.Derive(true); Assert.AreEqual(3, item.QuantityOrdered); Assert.AreEqual(0, item.QuantityPicked); Assert.AreEqual(0, item.QuantityShipped); Assert.AreEqual(0, item.QuantityPendingShipment); Assert.AreEqual(0, item.QuantityPendingShipment); Assert.AreEqual(3, item.QuantityReserved); Assert.AreEqual(3, item.QuantityShortFalled); Assert.AreEqual(0, item.QuantityRequestsShipping); Assert.AreEqual(3, item.ReservedFromInventoryItem.QuantityCommittedOut); Assert.AreEqual(0, item.ReservedFromInventoryItem.AvailableToPromise); Assert.AreEqual(0, item.ReservedFromInventoryItem.QuantityOnHand); var previous = item.ReservedFromInventoryItem; var current = new NonSerializedInventoryItemBuilder(this.DatabaseSession).WithFacility(secondWarehouse).WithPart(this.part).Build(); item.ReservedFromInventoryItem = current; this.DatabaseSession.Derive(true); Assert.AreEqual(3, item.QuantityOrdered); Assert.AreEqual(0, item.QuantityPicked); Assert.AreEqual(0, item.QuantityShipped); Assert.AreEqual(3, item.QuantityReserved); Assert.AreEqual(3, item.QuantityShortFalled); Assert.AreEqual(0, item.QuantityRequestsShipping); Assert.AreEqual(0, previous.QuantityCommittedOut); Assert.AreEqual(0, previous.AvailableToPromise); Assert.AreEqual(3, current.QuantityCommittedOut); Assert.AreEqual(0, current.AvailableToPromise); }
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(); } } } }
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); }