コード例 #1
0
        public static ShippingAndHandlingChargeBuilder WithPercentageDefaults(this ShippingAndHandlingChargeBuilder @this)
        {
            var faker = @this.Session.Faker();

            @this.WithPercentage(decimal.Round(faker.Random.Decimal(1, 5), 2));
            @this.WithDescription(faker.Lorem.Sentence());

            return(@this);
        }
コード例 #2
0
        public void EditForSalesOrder()
        {
            this.salesOrderListPage = this.Sidenav.NavigateToSalesOrders();

            var salesOrder = new SalesOrders(this.Session).Extent().First;

            salesOrder.AddOrderAdjustment(new ShippingAndHandlingChargeBuilder(this.Session).WithAmountDefaults().Build());

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

            var before = new OrderAdjustments(this.Session).Extent().ToArray();

            var expected = new ShippingAndHandlingChargeBuilder(this.Session).WithAmountDefaults().Build();

            var shippingAndHandlingCharge = salesOrder.OrderAdjustments.First();
            var id = shippingAndHandlingCharge.Id;

            this.Session.Derive();

            var expectedAmount      = expected.Amount;
            var expectedDescription = expected.Description;

            this.salesOrderListPage.Table.DefaultAction(salesOrder);
            var salesOrderOverview      = new SalesOrderOverviewComponent(this.salesOrderListPage.Driver);
            var adjustmentOverviewPanel = salesOrderOverview.OrderadjustmentOverviewPanel.Click();

            adjustmentOverviewPanel.Table.DefaultAction(shippingAndHandlingCharge);

            var adjustmentEdit = new OrderAdjustmentEditComponent(this.Driver);

            adjustmentEdit.Amount.Set(expected.Amount.ToString());
            adjustmentEdit.Description.Set(expected.Description);

            this.Session.Rollback();
            adjustmentEdit.SAVE.Click();

            this.Driver.WaitForAngular();
            this.Session.Rollback();

            var after = new OrderAdjustments(this.Session).Extent().ToArray();

            var actual = (ShippingAndHandlingCharge)this.Session.Instantiate(id);

            Assert.Equal(after.Length, before.Length);

            Assert.Equal(expectedAmount, actual.Amount);
            Assert.Equal(expectedDescription, actual.Description);
        }
コード例 #3
0
        public void GivenShippingAndHandlingCharge_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var builder = new ShippingAndHandlingChargeBuilder(this.DatabaseSession);
            builder.Build();

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

            this.DatabaseSession.Rollback();

            builder.WithAmount(1);
            builder.Build();

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

            builder.WithPercentage(1);
            builder.Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);
        }
コード例 #4
0
        public void CreatePercentageForProductQuote()
        {
            this.quoteListPage = this.Sidenav.NavigateToProductQuotes();

            var quote = new ProductQuotes(this.Session).Extent().First;

            var before = new ShippingAndHandlingCharges(this.Session).Extent().ToArray();

            var expected = new ShippingAndHandlingChargeBuilder(this.Session).WithPercentageDefaults().Build();

            quote.AddOrderAdjustment(expected);

            this.Session.Derive();

            Assert.True(expected.ExistPercentage);
            Assert.True(expected.ExistDescription);

            var expectedPercentage  = expected.Percentage;
            var expectedDescription = expected.Description;

            this.quoteListPage.Table.DefaultAction(quote);
            var shippingAndHandlingChargeCreate = new ProductQuoteOverviewComponent(this.quoteListPage.Driver).OrderadjustmentOverviewPanel.Click().CreateShippingAndHandlingCharge();

            shippingAndHandlingChargeCreate
            .Percentage.Set(expectedPercentage.ToString())
            .Description.Set(expectedDescription);

            this.Session.Rollback();
            shippingAndHandlingChargeCreate.SAVE.Click();

            this.Driver.WaitForAngular();
            this.Session.Rollback();

            var after = new ShippingAndHandlingCharges(this.Session).Extent().ToArray();

            Assert.Equal(after.Length, before.Length + 1);

            var actual = after.Except(before).First();

            Assert.Equal(expectedPercentage, actual.Percentage);
            Assert.Equal(expectedDescription, actual.Description);
        }
コード例 #5
0
        public void CreateAmountForPurchaseInvoice()
        {
            this.purchaseInvoiceListPage = this.Sidenav.NavigateToPurchaseInvoices();

            var purchaseInvoice = new PurchaseInvoices(this.Session).Extent().First;

            var before = new ShippingAndHandlingCharges(this.Session).Extent().ToArray();

            var expected = new ShippingAndHandlingChargeBuilder(this.Session).WithAmountDefaults().Build();

            purchaseInvoice.AddOrderAdjustment(expected);

            this.Session.Derive();

            Assert.True(expected.ExistAmount);
            Assert.True(expected.ExistDescription);

            var expectedAmount      = expected.Amount;
            var expectedDescription = expected.Description;

            this.purchaseInvoiceListPage.Table.DefaultAction(purchaseInvoice);
            var shippingAndHandlingChargeCreate = new PurchaseInvoiceOverviewComponent(this.purchaseInvoiceListPage.Driver).OrderadjustmentOverviewPanel.Click().CreateShippingAndHandlingCharge();

            shippingAndHandlingChargeCreate
            .Amount.Set(expectedAmount.ToString())
            .Description.Set(expectedDescription);

            this.Session.Rollback();
            shippingAndHandlingChargeCreate.SAVE.Click();

            this.Driver.WaitForAngular();
            this.Session.Rollback();

            var after = new ShippingAndHandlingCharges(this.Session).Extent().ToArray();

            Assert.Equal(after.Length, before.Length + 1);

            var actual = after.Except(before).First();

            Assert.Equal(expectedAmount, actual.Amount);
            Assert.Equal(expectedDescription, actual.Description);
        }
コード例 #6
0
        public void GivenShippingAndHandlingCharge_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var builder = new ShippingAndHandlingChargeBuilder(this.Session);

            builder.Build();

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

            this.Session.Rollback();

            builder.WithAmount(1);
            builder.Build();

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

            builder.WithPercentage(1);
            builder.Build();

            Assert.True(this.Session.Derive(false).HasErrors);
        }
コード例 #7
0
        public void BaseInvoice(CustomerShipmentInvoice method)
        {
            if (this.ShipmentState.Equals(new ShipmentStates(this.Strategy.Session).Shipped) &&
                Equals(this.Store.BillingProcess, new BillingProcesses(this.Strategy.Session).BillingForShipmentItems))
            {
                var invoiceByOrder = new Dictionary <SalesOrder, SalesInvoice>();
                var costsInvoiced  = false;

                foreach (ShipmentItem shipmentItem in this.ShipmentItems)
                {
                    foreach (OrderShipment orderShipment in shipmentItem.OrderShipmentsWhereShipmentItem)
                    {
                        var salesOrder = orderShipment.OrderItem.OrderWhereValidOrderItem as SalesOrder;

                        if (!invoiceByOrder.TryGetValue(salesOrder, out var salesInvoice))
                        {
                            salesInvoice = new SalesInvoiceBuilder(this.Strategy.Session)
                                           .WithStore(salesOrder.Store)
                                           .WithBilledFrom(salesOrder.TakenBy)
                                           .WithAssignedBilledFromContactMechanism(salesOrder.DerivedTakenByContactMechanism)
                                           .WithBilledFromContactPerson(salesOrder.TakenByContactPerson)
                                           .WithBillToCustomer(salesOrder.BillToCustomer)
                                           .WithAssignedBillToContactMechanism(salesOrder.DerivedBillToContactMechanism)
                                           .WithBillToContactPerson(salesOrder.BillToContactPerson)
                                           .WithBillToEndCustomer(salesOrder.BillToEndCustomer)
                                           .WithAssignedBillToEndCustomerContactMechanism(salesOrder.DerivedBillToEndCustomerContactMechanism)
                                           .WithBillToEndCustomerContactPerson(salesOrder.BillToEndCustomerContactPerson)
                                           .WithShipToCustomer(salesOrder.ShipToCustomer)
                                           .WithAssignedShipToAddress(salesOrder.DerivedShipToAddress)
                                           .WithShipToContactPerson(salesOrder.ShipToContactPerson)
                                           .WithShipToEndCustomer(salesOrder.ShipToEndCustomer)
                                           .WithAssignedShipToEndCustomerAddress(salesOrder.DerivedShipToEndCustomerAddress)
                                           .WithShipToEndCustomerContactPerson(salesOrder.ShipToEndCustomerContactPerson)
                                           .WithInvoiceDate(this.Session().Now())
                                           .WithSalesChannel(salesOrder.SalesChannel)
                                           .WithSalesInvoiceType(new SalesInvoiceTypes(this.Strategy.Session).SalesInvoice)
                                           .WithAssignedVatRegime(salesOrder.DerivedVatRegime)
                                           .WithAssignedIrpfRegime(salesOrder.DerivedIrpfRegime)
                                           .WithCustomerReference(salesOrder.CustomerReference)
                                           .WithAssignedPaymentMethod(this.PaymentMethod)
                                           .Build();

                            invoiceByOrder.Add(salesOrder, salesInvoice);

                            foreach (OrderAdjustment orderAdjustment in salesOrder.OrderAdjustments)
                            {
                                OrderAdjustment newAdjustment = null;
                                if (orderAdjustment.GetType().Name.Equals(typeof(DiscountAdjustment).Name))
                                {
                                    newAdjustment = new DiscountAdjustmentBuilder(this.Session()).Build();
                                }

                                if (orderAdjustment.GetType().Name.Equals(typeof(SurchargeAdjustment).Name))
                                {
                                    newAdjustment = new SurchargeAdjustmentBuilder(this.Session()).Build();
                                }

                                if (orderAdjustment.GetType().Name.Equals(typeof(Fee).Name))
                                {
                                    newAdjustment = new FeeBuilder(this.Session()).Build();
                                }

                                if (orderAdjustment.GetType().Name.Equals(typeof(ShippingAndHandlingCharge).Name))
                                {
                                    newAdjustment = new ShippingAndHandlingChargeBuilder(this.Session()).Build();
                                }

                                if (orderAdjustment.GetType().Name.Equals(typeof(MiscellaneousCharge).Name))
                                {
                                    newAdjustment = new MiscellaneousChargeBuilder(this.Session()).Build();
                                }

                                newAdjustment.Amount ??= orderAdjustment.Amount;
                                newAdjustment.Percentage ??= orderAdjustment.Percentage;
                                salesInvoice.AddOrderAdjustment(newAdjustment);
                            }

                            if (!costsInvoiced)
                            {
                                var costs = this.BaseOnDeriveShippingAndHandlingCharges();
                                if (costs > 0)
                                {
                                    salesInvoice.AddOrderAdjustment(new ShippingAndHandlingChargeBuilder(this.Strategy.Session).WithAmount(costs).Build());
                                    costsInvoiced = true;
                                }
                            }

                            foreach (SalesTerm salesTerm in salesOrder.SalesTerms)
                            {
                                if (salesTerm.GetType().Name == typeof(IncoTerm).Name)
                                {
                                    salesInvoice.AddSalesTerm(new IncoTermBuilder(this.Strategy.Session)
                                                              .WithTermType(salesTerm.TermType)
                                                              .WithTermValue(salesTerm.TermValue)
                                                              .WithDescription(salesTerm.Description)
                                                              .Build());
                                }

                                if (salesTerm.GetType().Name == typeof(InvoiceTerm).Name)
                                {
                                    salesInvoice.AddSalesTerm(new InvoiceTermBuilder(this.Strategy.Session)
                                                              .WithTermType(salesTerm.TermType)
                                                              .WithTermValue(salesTerm.TermValue)
                                                              .WithDescription(salesTerm.Description)
                                                              .Build());
                                }

                                if (salesTerm.GetType().Name == typeof(OrderTerm).Name)
                                {
                                    salesInvoice.AddSalesTerm(new OrderTermBuilder(this.Strategy.Session)
                                                              .WithTermType(salesTerm.TermType)
                                                              .WithTermValue(salesTerm.TermValue)
                                                              .WithDescription(salesTerm.Description)
                                                              .Build());
                                }
                            }
                        }

                        var amountAlreadyInvoiced = shipmentItem.ShipmentItemBillingsWhereShipmentItem.Sum(v => v.Amount);
                        var leftToInvoice         = (orderShipment.OrderItem.QuantityOrdered * orderShipment.OrderItem.AssignedUnitPrice) - amountAlreadyInvoiced;

                        if (leftToInvoice > 0)
                        {
                            if (orderShipment.OrderItem is SalesOrderItem salesOrderItem)
                            {
                                var invoiceItem = new SalesInvoiceItemBuilder(this.Strategy.Session)
                                                  .WithInvoiceItemType(new InvoiceItemTypes(this.Strategy.Session).ProductItem)
                                                  .WithProduct(salesOrderItem.Product)
                                                  .WithQuantity(orderShipment.Quantity)
                                                  .WithAssignedUnitPrice(salesOrderItem.UnitPrice)
                                                  .WithAssignedVatRegime(salesOrderItem.AssignedVatRegime)
                                                  .WithDescription(salesOrderItem.Description)
                                                  .WithInternalComment(salesOrderItem.InternalComment)
                                                  .WithMessage(salesOrderItem.Message)
                                                  .Build();

                                salesInvoice.AddSalesInvoiceItem(invoiceItem);

                                new ShipmentItemBillingBuilder(this.Strategy.Session)
                                .WithQuantity(shipmentItem.Quantity)
                                .WithAmount(leftToInvoice)
                                .WithShipmentItem(shipmentItem)
                                .WithInvoiceItem(invoiceItem)
                                .Build();
                            }
                        }
                    }
                }
            }
        }
コード例 #8
0
ファイル: SalesOrderTests.cs プロジェクト: Allors/apps
        public void GivenSalesOrderWithShippingAndHandlingPercentage_WhenDeriving_ThenOrderTotalsMustIncludeShippingAndHandlingAmount()
        {
            var billToCustomer = new PersonBuilder(this.DatabaseSession).WithLastName("person1").Build();
            var shipToCustomer = new PersonBuilder(this.DatabaseSession).WithLastName("person2").Build();
            var internalOrganisation = Singleton.Instance(this.DatabaseSession).DefaultInternalOrganisation;

            new CustomerRelationshipBuilder(this.DatabaseSession).WithFromDate(DateTime.UtcNow).WithCustomer(billToCustomer).WithInternalOrganisation(internalOrganisation).Build();
            new CustomerRelationshipBuilder(this.DatabaseSession).WithFromDate(DateTime.UtcNow).WithCustomer(shipToCustomer).WithInternalOrganisation(internalOrganisation).Build();

            var mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build();
            var euro = new Currencies(this.DatabaseSession).FindBy(Currencies.Meta.IsoCode, "EUR");
            var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build();
            var vatRate21 = new VatRateBuilder(this.DatabaseSession).WithRate(21).Build();
            var adjustment = new ShippingAndHandlingChargeBuilder(this.DatabaseSession).WithPercentage(5).WithVatRate(vatRate21).Build();

            var good = new GoodBuilder(this.DatabaseSession)
                .WithSku("10101")
                .WithVatRate(vatRate21)
                .WithName("good")
                .WithInventoryItemKind(new InventoryItemKinds(this.DatabaseSession).NonSerialized)
                .WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece)
                .Build();

            var goodPurchasePrice = new ProductPurchasePriceBuilder(this.DatabaseSession)
                .WithCurrency(euro)
                .WithFromDate(DateTime.UtcNow)
                .WithPrice(7)
                .WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece)
                .Build();

            new SupplierOfferingBuilder(this.DatabaseSession)
                .WithProduct(good)
                .WithSupplier(supplier)
                .WithFromDate(DateTime.UtcNow)
                .WithProductPurchasePrice(goodPurchasePrice)
                .Build();

            this.DatabaseSession.Derive(true);

            var order = new SalesOrderBuilder(this.DatabaseSession)
                .WithBillToCustomer(billToCustomer)
                .WithShipToCustomer(shipToCustomer)
                .WithShipToAddress(new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build())
                .WithShippingAndHandlingCharge(adjustment)
                .Build();

            const decimal quantityOrdered = 3;
            var item1 = new SalesOrderItemBuilder(this.DatabaseSession).WithProduct(good).WithQuantityOrdered(quantityOrdered).WithActualUnitPrice(15).Build();
            order.AddSalesOrderItem(item1);

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(45, order.TotalBasePrice);
            Assert.AreEqual(0, order.TotalDiscount);
            Assert.AreEqual(0, order.TotalSurcharge);
            Assert.AreEqual(2.25, order.TotalShippingAndHandling);
            Assert.AreEqual(0, order.TotalFee);
            Assert.AreEqual(47.25, order.TotalExVat);
            Assert.AreEqual(9.92, order.TotalVat);
            Assert.AreEqual(57.17, order.TotalIncVat);
            Assert.AreEqual(goodPurchasePrice.Price, order.TotalPurchasePrice);
        }
コード例 #9
0
        public void BaseCreateSalesInvoice(PurchaseInvoiceCreateSalesInvoice method)
        {
            var salesInvoice = new SalesInvoiceBuilder(this.Strategy.Session)
                               .WithPurchaseInvoice(this)
                               .WithBilledFrom(this.BilledTo)
                               .WithBilledFromContactPerson(this.BilledToContactPerson)
                               .WithBillToCustomer(this.BillToEndCustomer)
                               .WithAssignedBillToContactMechanism(this.DerivedBillToEndCustomerContactMechanism)
                               .WithBillToContactPerson(this.BillToEndCustomerContactPerson)
                               .WithShipToCustomer(this.ShipToEndCustomer)
                               .WithAssignedShipToAddress(this.DerivedShipToEndCustomerAddress)
                               .WithShipToContactPerson(this.ShipToEndCustomerContactPerson)
                               .WithDescription(this.Description)
                               .WithInvoiceDate(this.Session().Now())
                               .WithSalesInvoiceType(new SalesInvoiceTypes(this.Strategy.Session).SalesInvoice)
                               .WithCustomerReference(this.CustomerReference)
                               .WithAssignedPaymentMethod(this.DerivedBillToCustomerPaymentMethod)
                               .WithComment(this.Comment)
                               .WithInternalComment(this.InternalComment)
                               .Build();

            foreach (OrderAdjustment orderAdjustment in this.OrderAdjustments)
            {
                OrderAdjustment newAdjustment = null;
                if (orderAdjustment.GetType().Name.Equals(typeof(DiscountAdjustment).Name))
                {
                    newAdjustment = new DiscountAdjustmentBuilder(this.Session()).Build();
                }

                if (orderAdjustment.GetType().Name.Equals(typeof(SurchargeAdjustment).Name))
                {
                    newAdjustment = new SurchargeAdjustmentBuilder(this.Session()).Build();
                }

                if (orderAdjustment.GetType().Name.Equals(typeof(Fee).Name))
                {
                    newAdjustment = new FeeBuilder(this.Session()).Build();
                }

                if (orderAdjustment.GetType().Name.Equals(typeof(ShippingAndHandlingCharge).Name))
                {
                    newAdjustment = new ShippingAndHandlingChargeBuilder(this.Session()).Build();
                }

                if (orderAdjustment.GetType().Name.Equals(typeof(MiscellaneousCharge).Name))
                {
                    newAdjustment = new MiscellaneousChargeBuilder(this.Session()).Build();
                }

                newAdjustment.Amount ??= orderAdjustment.Amount;
                newAdjustment.Percentage ??= orderAdjustment.Percentage;
                salesInvoice.AddOrderAdjustment(newAdjustment);
            }

            foreach (PurchaseInvoiceItem purchaseInvoiceItem in this.PurchaseInvoiceItems)
            {
                var invoiceItem = new SalesInvoiceItemBuilder(this.Strategy.Session)
                                  .WithInvoiceItemType(purchaseInvoiceItem.InvoiceItemType)
                                  .WithAssignedUnitPrice(purchaseInvoiceItem.AssignedUnitPrice)
                                  .WithProduct(purchaseInvoiceItem.Part as UnifiedGood)
                                  .WithSerialisedItem(purchaseInvoiceItem.SerialisedItem)
                                  .WithNextSerialisedItemAvailability(new SerialisedItemAvailabilities(this.Session()).Sold)
                                  .WithQuantity(purchaseInvoiceItem.Quantity)
                                  .WithComment(purchaseInvoiceItem.Comment)
                                  .WithInternalComment(purchaseInvoiceItem.InternalComment)
                                  .Build();

                salesInvoice.AddSalesInvoiceItem(invoiceItem);
            }

            var internalOrganisation = (InternalOrganisation)salesInvoice.BilledFrom;

            if (!internalOrganisation.ActiveCustomers.Contains(salesInvoice.BillToCustomer))
            {
                new CustomerRelationshipBuilder(this.Strategy.Session)
                .WithCustomer(salesInvoice.BillToCustomer)
                .WithInternalOrganisation(internalOrganisation)
                .Build();
            }

            this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.CreateSalesInvoice, Operations.Execute));
        }
コード例 #10
0
ファイル: PurchaseOrder.cs プロジェクト: Allors/allors2
        public void BaseInvoice(PurchaseOrderInvoice method)
        {
            if (this.CanInvoice)
            {
                var purchaseInvoice = new PurchaseInvoiceBuilder(this.Strategy.Session)
                                      .WithBilledFrom(this.TakenViaSupplier)
                                      .WithAssignedBilledFromContactMechanism(this.DerivedTakenViaContactMechanism)
                                      .WithBilledFromContactPerson(this.TakenViaContactPerson)
                                      .WithBilledTo(this.OrderedBy)
                                      .WithBilledToContactPerson(this.BillToContactPerson)
                                      .WithDescription(this.Description)
                                      .WithInvoiceDate(this.Session().Now())
                                      .WithAssignedVatRegime(this.DerivedVatRegime)
                                      .WithAssignedIrpfRegime(this.DerivedIrpfRegime)
                                      .WithCustomerReference(this.CustomerReference)
                                      .WithPurchaseInvoiceType(new PurchaseInvoiceTypes(this.Session()).PurchaseInvoice)
                                      .Build();

                foreach (OrderAdjustment orderAdjustment in this.OrderAdjustments)
                {
                    OrderAdjustment newAdjustment = null;
                    if (orderAdjustment.GetType().Name.Equals(typeof(DiscountAdjustment).Name))
                    {
                        newAdjustment = new DiscountAdjustmentBuilder(this.Session()).Build();
                    }

                    if (orderAdjustment.GetType().Name.Equals(typeof(SurchargeAdjustment).Name))
                    {
                        newAdjustment = new SurchargeAdjustmentBuilder(this.Session()).Build();
                    }

                    if (orderAdjustment.GetType().Name.Equals(typeof(Fee).Name))
                    {
                        newAdjustment = new FeeBuilder(this.Session()).Build();
                    }

                    if (orderAdjustment.GetType().Name.Equals(typeof(ShippingAndHandlingCharge).Name))
                    {
                        newAdjustment = new ShippingAndHandlingChargeBuilder(this.Session()).Build();
                    }

                    if (orderAdjustment.GetType().Name.Equals(typeof(MiscellaneousCharge).Name))
                    {
                        newAdjustment = new MiscellaneousChargeBuilder(this.Session()).Build();
                    }

                    newAdjustment.Amount ??= orderAdjustment.Amount;
                    newAdjustment.Percentage ??= orderAdjustment.Percentage;
                    purchaseInvoice.AddOrderAdjustment(newAdjustment);
                }

                foreach (PurchaseOrderItem orderItem in this.ValidOrderItems)
                {
                    if (orderItem.CanInvoice)
                    {
                        var invoiceItem = new PurchaseInvoiceItemBuilder(this.Strategy.Session)
                                          .WithAssignedUnitPrice(orderItem.UnitPrice)
                                          .WithInvoiceItemType(orderItem.InvoiceItemType)
                                          .WithPart(orderItem.Part)
                                          .WithQuantity(orderItem.QuantityOrdered)
                                          .WithAssignedVatRegime(orderItem.AssignedVatRegime)
                                          .WithAssignedIrpfRegime(orderItem.AssignedIrpfRegime)
                                          .WithDescription(orderItem.Description)
                                          .WithInternalComment(orderItem.InternalComment)
                                          .WithMessage(orderItem.Message)
                                          .Build();

                        purchaseInvoice.AddPurchaseInvoiceItem(invoiceItem);

                        new OrderItemBillingBuilder(this.Strategy.Session)
                        .WithQuantity(orderItem.QuantityOrdered)
                        .WithAmount(orderItem.TotalBasePrice)
                        .WithOrderItem(orderItem)
                        .WithInvoiceItem(invoiceItem)
                        .Build();
                    }
                }
            }
        }
コード例 #11
0
ファイル: SalesInvoiceTests.cs プロジェクト: Allors/apps
        public void GivenSalesInvoiceWithShippingAndHandlingPercentage_WhenDeriving_ThenSalesInvoiceTotalsMustIncludeShippingAndHandlingAmount()
        {
            var euro = new Currencies(this.DatabaseSession).FindBy(Currencies.Meta.IsoCode, "EUR");
            var vatRate21 = new VatRateBuilder(this.DatabaseSession).WithRate(21).Build();
            var adjustment = new ShippingAndHandlingChargeBuilder(this.DatabaseSession).WithPercentage(5).WithVatRate(vatRate21).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 good = new GoodBuilder(this.DatabaseSession)
                .WithSku("10101")
                .WithVatRate(vatRate21)
                .WithName("good")
                .WithInventoryItemKind(new InventoryItemKinds(this.DatabaseSession).NonSerialized)
                .WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece)
                .Build();

            var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation");
            internalOrganisation.PreferredCurrency = euro;

            var invoice = new SalesInvoiceBuilder(this.DatabaseSession)
                .WithInvoiceNumber("1")
                .WithBillToCustomer(new OrganisationBuilder(this.DatabaseSession).WithName("customer").Build())
                .WithBillToContactMechanism(contactMechanism)
                .WithSalesInvoiceType(new SalesInvoiceTypes(this.DatabaseSession).SalesInvoice)
                .WithShippingAndHandlingCharge(adjustment)
                .Build();

            new CustomerRelationshipBuilder(this.DatabaseSession).WithFromDate(DateTime.UtcNow).WithCustomer(invoice.BillToCustomer).WithInternalOrganisation(Singleton.Instance(this.DatabaseSession).DefaultInternalOrganisation).Build();

            var item1 = new SalesInvoiceItemBuilder(this.DatabaseSession).WithProduct(good).WithQuantity(3).WithActualUnitPrice(15).WithSalesInvoiceItemType(new SalesInvoiceItemTypes(this.DatabaseSession).ProductItem).Build();
            invoice.AddSalesInvoiceItem(item1);

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(45, invoice.TotalBasePrice);
            Assert.AreEqual(0, invoice.TotalDiscount);
            Assert.AreEqual(0, invoice.TotalSurcharge);
            Assert.AreEqual(2.25, invoice.TotalShippingAndHandling);
            Assert.AreEqual(0, invoice.TotalFee);
            Assert.AreEqual(47.25, invoice.TotalExVat);
            Assert.AreEqual(9.92, invoice.TotalVat);
            Assert.AreEqual(57.17, invoice.TotalIncVat);
        }