示例#1
0
        /// <summary>
        /// Add a line to this transaction
        /// </summary>
        /// <param name="amount">Value of the item.</param>
        /// <param name="type">Address Type. Can be ShipFrom, ShipTo, PointOfOrderAcceptance, PointOfOrderOrigin, SingleLocation.</param>
        /// <param name="line1">Street address, attention line, or business name of the location.</param>
        /// <param name="line2">Street address, business name, or apartment/unit number of the location.</param>
        /// <param name="line3">Street address or apartment/unit number of the location.</param>
        /// <param name="city">City of the location.</param>
        /// <param name="region">State or Region of the location.</param>
        /// <param name="postalCode">Postal/zip code of the location.</param>
        /// <param name="country">Two-letter country code of the location.</param>
        /// <returns></returns>
        public TransactionBuilder WithSeparateAddressLine(decimal amount, TransactionAddressType type, string line1, string line2, string line3, string city, string region, string postalCode, string country)
        {
            var l = new LineItemModel
            {
                number    = _line_number.ToString(),
                quantity  = 1,
                amount    = amount,
                addresses = new AddressesModel()
            };

            // Add this address
            var ai = new AddressLocationInfo
            {
                line1      = line1,
                line2      = line2,
                line3      = line3,
                city       = city,
                region     = region,
                postalCode = postalCode,
                country    = country
            };

            SetAddress(l.addresses, type, ai);

            // Put this line in the model
            _model.lines.Add(l);
            _line_number++;

            // Continue building
            return(this);
        }
示例#2
0
        /// <summary>
        /// Add an address to this transaction using an existing company location code.
        ///
        /// AvaTax will search for a company location whose code matches the `locationCode` parameter and use the address
        /// of that location.
        /// </summary>
        /// <param name="type">Address Type. Can be ShipFrom, ShipTo, PointOfOrderAcceptance, PointOfOrderOrigin, SingleLocation.</param>
        /// <param name="locationCode">The location code of the location to use as this address.</param>
        /// <returns></returns>
        public TransactionBuilder WithAddress(TransactionAddressType type, string locationCode)
        {
            if (_model.addresses == null)
            {
                _model.addresses = new AddressesModel();
            }
            var ai = new AddressLocationInfo
            {
                locationCode = locationCode
            };

            SetAddress(_model.addresses, type, ai);
            return(this);
        }
示例#3
0
        /// <summary>
        /// Add a geocoded location address to this transaction
        /// </summary>
        /// <param name="type"></param>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <returns></returns>
        public TransactionBuilder WithLatLong(TransactionAddressType type, decimal latitude, decimal longitude)
        {
            if (_model.addresses == null)
            {
                _model.addresses = new AddressesModel();
            }
            var ai = new AddressLocationInfo
            {
                latitude  = latitude,
                longitude = longitude
            };

            SetAddress(_model.addresses, type, ai);
            return(this);
        }
示例#4
0
        /// <summary>
        /// Add an address to this line using an existing company location code.
        ///
        /// AvaTax will search for a company location whose code matches the `locationCode` parameter and use the address
        /// of that location.
        /// </summary>
        /// <param name="type">Address Type. Can be ShipFrom, ShipTo, PointOfOrderAcceptance, PointOfOrderOrigin, SingleLocation.</param>
        /// <param name="locationCode">The location code of the location to use as this address.</param>
        /// <returns></returns>
        public TransactionBuilder WithLineAddress(TransactionAddressType type, string locationCode)
        {
            var line = GetMostRecentLine("WithLineAddress");

            if (line.addresses == null)
            {
                line.addresses = new AddressesModel();
            }
            var ai = new AddressLocationInfo
            {
                locationCode = locationCode
            };

            SetAddress(line.addresses, type, ai);
            return(this);
        }
示例#5
0
        /// <summary>
        /// Add an address to this transaction
        /// </summary>
        /// <param name="type">Address Type. Can be ShipFrom, ShipTo, PointOfOrderAcceptance, PointOfOrderOrigin, SingleLocation.</param>
        /// <param name="line1">The street address, attention line, or business name of the location.</param>
        /// <param name="line2">The street address, business name, or apartment/unit number of the location.</param>
        /// <param name="line3">The street address or apartment/unit number of the location.</param>
        /// <param name="city">City of the location.</param>
        /// <param name="region">State or Region of the location.</param>
        /// <param name="postalCode">Postal/zip code of the location.</param>
        /// <param name="country">The two-letter country code of the location.</param>
        /// <returns></returns>
        public TransactionBuilder WithAddress(TransactionAddressType type, string line1, string line2, string line3, string city, string region, string postalCode, string country)
        {
            if (_model.addresses == null)
            {
                _model.addresses = new AddressesModel();
            }
            var ai = new AddressLocationInfo
            {
                line1      = line1,
                line2      = line2,
                line3      = line3,
                city       = city,
                region     = region,
                postalCode = postalCode,
                country    = country
            };

            SetAddress(_model.addresses, type, ai);
            return(this);
        }
示例#6
0
        /// <summary>
        /// Add an address to this line
        /// </summary>
        /// <param name="type">Address Type. Can be ShipFrom, ShipTo, PointOfOrderAcceptance, PointOfOrderOrigin, SingleLocation.</param>
        /// <param name="line1">Street address, attention line, or business name of the location.</param>
        /// <param name="line2">Street address, business name, or apartment/unit number of the location.</param>
        /// <param name="line3">Street address or apartment/unit number of the location.</param>
        /// <param name="city">City of the location.</param>
        /// <param name="region">State or Region of the location.</param>
        /// <param name="postalCode">Postal/zip code of the location.</param>
        /// <param name="country">Two-letter country code of the location.</param>
        /// <returns></returns>
        public TransactionBuilder WithLineAddress(TransactionAddressType type, string line1, string line2, string line3, string city, string region, string postalCode, string country)
        {
            var line = GetMostRecentLine("WithLineAddress");

            if (line.addresses == null)
            {
                line.addresses = new AddressesModel();
            }
            var ai = new AddressLocationInfo
            {
                line1      = line1,
                line2      = line2,
                line3      = line3,
                city       = city,
                region     = region,
                postalCode = postalCode,
                country    = country
            };

            SetAddress(line.addresses, type, ai);
            return(this);
        }
示例#7
0
        /// <summary>
        /// Set a specific address type for an address object
        /// </summary>
        /// <param name="addresses"></param>
        /// <param name="type"></param>
        /// <param name="ai"></param>
        public static void SetAddress(AddressesModel addresses, TransactionAddressType type, AddressLocationInfo ai)
        {
            switch (type)
            {
            case TransactionAddressType.PointOfOrderAcceptance:
                addresses.pointOfOrderAcceptance = ai;
                break;

            case TransactionAddressType.PointOfOrderOrigin:
                addresses.pointOfOrderOrigin = ai;
                break;

            case TransactionAddressType.ShipFrom:
                addresses.shipFrom = ai;
                break;

            case TransactionAddressType.ShipTo:
                addresses.shipTo = ai;
                break;

            case TransactionAddressType.SingleLocation:
                addresses.singleLocation = ai;
                break;
            }
        }