Exemplo n.º 1
0
        public static SalesInvoiceBuilder WithSalesExternalB2CInvoiceDefaults(this SalesInvoiceBuilder @this, Organisation internalOrganisation)
        {
            var faker = @this.Session.Faker();

            var customer = internalOrganisation.ActiveCustomers.Where(v => v.GetType().Name == typeof(Person).Name).FirstOrDefault();

            var salesInvoiceItem_Default = new SalesInvoiceItemBuilder(@this.Session).WithDefaults().Build();
            var salesInvoiceItem_Product = new SalesInvoiceItemBuilder(@this.Session).WithProductItemDefaults().Build();
            var salesInvoiceItem_Part    = new SalesInvoiceItemBuilder(@this.Session).WithPartItemDefaults().Build();

            var salesInvoiceType = new SalesInvoiceTypes(@this.Session).SalesInvoice;
            var paymentMethod    = faker.Random.ListItem(@this.Session.Extent <PaymentMethod>());

            @this.WithCustomerReference(faker.Random.String(16).ToUpper(CultureInfo.CurrentCulture));
            @this.WithBilledFrom(internalOrganisation);
            @this.WithBilledFromContactPerson(internalOrganisation.CurrentContacts.FirstOrDefault());
            @this.WithDescription(faker.Lorem.Sentence());
            @this.WithComment(faker.Lorem.Sentence());
            @this.WithInternalComment(faker.Lorem.Sentence());
            @this.WithBillToCustomer(customer);
            @this.WithShipToCustomer(customer);
            @this.WithSalesInvoiceType(salesInvoiceType);
            @this.WithTotalListPrice(faker.Random.Decimal());
            @this.WithAssignedPaymentMethod(paymentMethod);
            @this.WithSalesInvoiceItem(salesInvoiceItem_Default);
            @this.WithSalesInvoiceItem(salesInvoiceItem_Product);
            @this.WithSalesInvoiceItem(salesInvoiceItem_Part);
            @this.WithAdvancePayment(faker.Random.Decimal());
            @this.WithSalesTerm(new InvoiceTermBuilder(@this.Session).WithDefaultsForPaymentNetDays().Build());
            @this.WithSalesTerm(new IncoTermBuilder(@this.Session).WithDefaults().Build());
            @this.WithSalesTerm(new InvoiceTermBuilder(@this.Session).WithDefaults().Build());
            @this.WithSalesTerm(new OrderTermBuilder(@this.Session).WithDefaults().Build());

            return(@this);
        }