public void Edit() { var customOrganisationClassification = new CustomOrganisationClassificationBuilder(this.Session).WithName("Gold").Build(); var industryClassification = new IndustryClassificationBuilder(this.Session).WithName("Retail").Build(); var legalForm = new LegalForms(this.Session).FindBy(M.LegalForm.Description, "BE - BVBA / SPRL"); this.Session.Derive(); this.Session.Commit(); var before = new Organisations(this.Session).Extent().ToArray(); var organisation = before.First(v => v.PartyName.Equals("Acme0")); var id = organisation.Id; var organisationOverviewPage = this.organisationListPage.Select(organisation); var page = organisationOverviewPage.Edit(); page.Name.Set("new organisation") .TaxNumber.Set("BE 123 456 789 01") .LegalForm.Set(legalForm.Description) .Locale.Set(this.Session.GetSingleton().AdditionalLocales.First.Name) .IndustryClassifications.Toggle(industryClassification.Name) .CustomClassifications.Toggle(customOrganisationClassification.Name) .IsManufacturer.Set(true) .IsInternalOrganisation.Set(true) .Comment.Set("comment") .Save.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new Organisations(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length); organisation = after.First(v => v.Id.Equals(id)); Assert.Equal("new organisation", organisation.Name); Assert.Equal("BE 123 456 789 01", organisation.TaxNumber); Assert.Equal(legalForm, organisation.LegalForm); Assert.Equal(this.Session.GetSingleton().AdditionalLocales.First, organisation.Locale); Assert.Contains(industryClassification, organisation.IndustryClassifications); Assert.Contains(customOrganisationClassification, organisation.CustomClassifications); Assert.True(organisation.IsManufacturer); Assert.True(organisation.IsInternalOrganisation); Assert.Equal("comment", organisation.Comment); }
public void Edit() { var customOrganisationClassification = new CustomOrganisationClassificationBuilder(this.Session).WithName("Gold").Build(); var industryClassification = new IndustryClassificationBuilder(this.Session).WithName("Retail").Build(); var legalForm = new LegalForms(this.Session).FindBy(M.LegalForm.Description, "BE - BVBA / SPRL"); this.Session.Derive(); this.Session.Commit(); var before = new Organisations(this.Session).Extent().ToArray(); var organisation = before.Last(); var id = organisation.Id; this.organisationListPage.Table.DefaultAction(organisation); var organisationOverview = new OrganisationOverviewComponent(this.organisationListPage.Driver); var organisationOverviewDetail = organisationOverview.OrganisationOverviewDetail.Click(); organisationOverviewDetail .Name.Set("new organisation") .TaxNumber.Set("BE 123 456 789 01") .LegalForm.Select(legalForm) .Locale.Select(this.Session.GetSingleton().AdditionalLocales.First) .IndustryClassifications.Toggle(industryClassification) .CustomClassifications.Toggle(customOrganisationClassification) .IsManufacturer.Set(true) .Comment.Set("comment") .SAVE.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new Organisations(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length); organisation = after.First(v => v.Id.Equals(id)); }
public void GivenInvoiceItemWithDiscountPercentageForPartyClassification_WhenDeriving_ThenUseDiscountComponentsForPartyClassification() { const decimal quantity = 3; const decimal percentage = 5; var classification = new IndustryClassificationBuilder(this.DatabaseSession).WithName("gold customer").Build(); new DiscountComponentBuilder(this.DatabaseSession) .WithSpecifiedFor(this.internalOrganisation) .WithDescription("discount good for party classification") .WithPartyClassification(classification) .WithProduct(this.good) .WithPercentage(percentage) .WithFromDate(DateTime.UtcNow.AddMinutes(-1)) .WithThroughDate(DateTime.UtcNow.AddYears(1).AddDays(-1)) .Build(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); this.InstantiateObjects(this.DatabaseSession); this.billToCustomer.AddPartyClassification(classification); this.invoice.ShipToCustomer = this.shipToCustomer; var item1 = new SalesInvoiceItemBuilder(this.DatabaseSession).WithProduct(this.good).WithSalesInvoiceItemType(new SalesInvoiceItemTypes(this.DatabaseSession).ProductItem).WithQuantity(quantity).Build(); this.invoice.AddSalesInvoiceItem(item1); this.DatabaseSession.Derive(true); var amount = decimal.Round((this.currentGood1BasePrice.Price * percentage) / 100, 2); Assert.AreEqual(this.currentGood1BasePrice.Price, item1.UnitBasePrice); Assert.AreEqual(amount, item1.UnitDiscount); Assert.AreEqual(0, item1.UnitSurcharge); Assert.AreEqual(this.currentGood1BasePrice.Price - amount, item1.CalculatedUnitPrice); Assert.AreEqual(this.goodPurchasePrice.Price, item1.UnitPurchasePrice); Assert.AreEqual(decimal.Round(((item1.UnitBasePrice / this.goodPurchasePrice.Price) - 1) * 100, 2), item1.InitialMarkupPercentage); Assert.AreEqual(decimal.Round(((item1.CalculatedUnitPrice / this.goodPurchasePrice.Price) - 1) * 100, 2), item1.MaintainedMarkupPercentage); Assert.AreEqual(decimal.Round(((item1.UnitBasePrice - this.goodPurchasePrice.Price) / item1.UnitBasePrice) * 100, 2), item1.InitialProfitMargin); Assert.AreEqual(decimal.Round(((item1.CalculatedUnitPrice - this.goodPurchasePrice.Price) / item1.CalculatedUnitPrice) * 100, 2), item1.MaintainedProfitMargin); }