public void WhenToSVSalesOrder_ThenOrderFieldsAreMapped()
        {
            const string discountName         = "FOR NICE PEOPLE ONLY";
            const string discountRate         = "1000%";
            const double discountTotal        = 10.23;
            const double taxTotal             = 3.23;
            const string entityInternalId     = "12";
            const string internalId           = "45";
            const string tranId               = "78";
            var          createdDate          = new DateTime(1000, 1, 1);
            var          lastModifiedDate     = new DateTime(4000, 1, 1);
            const string statusPendingBilling = "Pending Billing";
            const double total             = 203;
            const string sourceWebServices = "Web Services";
            var          order             = new NetSuiteSoapWS.SalesOrder
            {
                entity = new RecordRef
                {
                    internalId = entityInternalId
                },
                internalId       = internalId,
                tranId           = tranId,
                createdDate      = createdDate,
                lastModifiedDate = lastModifiedDate,
                status           = statusPendingBilling,
                total            = total,
                source           = sourceWebServices,
                discountItem     = new RecordRef
                {
                    name = discountName
                },
                discountTotal = discountTotal,
                discountRate  = discountRate,
                taxTotal      = taxTotal
            };

            var result = order.ToSVSalesOrder();

            result.Id.Should().Be(internalId);
            result.DocNumber.Should().Be(tranId);
            result.CreatedDateUtc.Should().Be(createdDate.ToUniversalTime());
            result.ModifiedDateUtc.Should().Be(lastModifiedDate.ToUniversalTime());
            result.Status.Should().Be(NetSuiteSalesOrderStatus.PendingBilling);
            result.Total.Should().Be(( decimal )total);
            result.Source.Should().Be(NetSuiteSalesOrderSource.External);
            result.Customer.Id.ToString().Should().Be(entityInternalId);
            result.DiscountName.Should().Be(discountName);
            result.DiscountTotal.Should().Be(( decimal )discountTotal);
            result.DiscountType.Should().Be(NetSuiteDiscountTypeEnum.Percentage);
            result.TaxTotal.Should().Be(( decimal )taxTotal);
        }
        public void WhenToSVSalesOrder_ThenOrderItemsAreMapped()
        {
            const double quantity       = 3;
            const string itemName       = "testSku";
            const double taxRate1       = 2.5;
            const double taxAmount      = 4.56;
            const double amount         = 11.22;
            var          salesOrderItem = new SalesOrderItem
            {
                quantity = quantity,
                item     = new RecordRef
                {
                    name = itemName
                },
                amountSpecified = true,
                amount          = amount,
                taxRate1        = taxRate1,
                taxAmount       = taxAmount
            };
            var order = new NetSuiteSoapWS.SalesOrder
            {
                entity = new RecordRef {
                    internalId = "12"
                },
                itemList = new SalesOrderItemList
                {
                    item = new []
                    {
                        salesOrderItem,
                        new SalesOrderItem()
                    }
                }
            };

            var result = order.ToSVSalesOrder();

            result.Items.Length.Should().Be(order.itemList.item.Length);
            var resultFirstItem = result.Items [0];

            resultFirstItem.Quantity.Should().Be(( int )salesOrderItem.quantity);
            resultFirstItem.Sku.Should().Be(itemName);
            resultFirstItem.UnitPrice.Should().Be(( decimal )Math.Round(amount / quantity, 2));
            resultFirstItem.TaxRate.Should().Be(( decimal )taxRate1);
            resultFirstItem.TaxAmount.Should().Be(( decimal )taxAmount);
        }
        public void WhenToSVSalesOrder_ThenOrderShippingIsMapped()
        {
            const double  shippingCost   = 12.30;
            const string  addr1          = "123 Some St";
            const string  addr2          = "Apt 2";
            const string  city           = "Mayberry";
            const string  zip            = "12334";
            const Country country        = Country._afghanistan;
            const string  state          = "AZ";
            const string  shippingMethod = "Unladen sparrow";
            var           order          = new NetSuiteSoapWS.SalesOrder
            {
                entity = new RecordRef {
                    internalId = "12"
                },
                shippingCost = shippingCost,
                shipMethod   = new RecordRef
                {
                    name = shippingMethod
                },
                shippingAddress = new Address
                {
                    addr1   = addr1,
                    addr2   = addr2,
                    city    = city,
                    zip     = zip,
                    country = country,
                    state   = state
                }
            };

            var result = order.ToSVSalesOrder();

            result.ShippingInfo.Cost.Should().Be(( decimal )shippingCost);
            result.ShippingInfo.Carrier.Should().Be(shippingMethod);
            var resultShippingAddress = result.ShippingInfo.Address;

            resultShippingAddress.Line1.Should().Be(addr1);
            resultShippingAddress.Line2.Should().Be(addr2);
            resultShippingAddress.City.Should().Be(city);
            resultShippingAddress.PostalCode.Should().Be(zip);
            resultShippingAddress.CountryCode.Should().Be(country.ToString());
            resultShippingAddress.State.Should().Be(state);
        }