/// <summary>
 /// TransactionBuilder helps you construct a transaction API call correctly with necessary data
 /// </summary>
 /// <param name="client"></param>
 /// <param name="companyCode"></param>
 public TransactionBuilder(AvaTaxClient client, string companyCode, DocumentType type, string customerCode)
 {
     _model = new CreateTransactionModel()
     {
         companyCode  = companyCode,
         customerCode = customerCode,
         date         = DateTime.UtcNow,
         type         = type,
         lines        = new List <LineItemModel>()
     };
     _line_number = 1;
     _client      = client;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AvaTaxOfflineHelper"/> class.
        /// </summary>
        //public AvaTaxOfflineHelper()
        //{
        //    _ratesByZip = new Dictionary<string, TaxRateModel>();
        //}

        /// <summary>
        /// Downloads and stores a ZIP code TaxRateModel object and stores it in the location
        /// designated. Call this method with the Z
        /// </summary>
        /// <param name="client"></param>
        /// <param name="region"></param>
        /// <param name="zip"></param>
        /// <param name="path">The fully qualified path where the file will be stored.</param>
        public static void StoreZipRateContent(AvaTaxClient client, string region, List <string> zips, string path)
        {
            try {
                foreach (string zip in zips)
                {
                    //Call rate by ZIP endpoint.
                    var rateFile = client.TaxRatesByPostalCode(region, zip);

                    //Save the rate by ZIP file in the local ZIP folder.
                    WriteZipRateFile(rateFile, zip, path);
                }
            }
            catch (Exception exc) {
                throw new AvaTaxOfflineHelperException("An error occurred retrieving or storing the rate content. Please see inner exception for details.", exc);
            }
        }