public async Task <TaxRefundResponse> RefundRequest(TaxRefundRequest refundRequest) { var taxRequest = TaxRelayMapper.CreateSovosTaxRequest(refundRequest, _sovosSettings); if (refundRequest.IsRefund) { foreach (var line in taxRequest.LineItems) { line.DebitCreditIndicator = DebitCreditIndicator.Credit; } } try { var response = await _client.GetTaxDeterminationAsync(taxRequest); var taxResponse = TaxRelayMapper.CreateTaxRefundResponseFromSovos(response, refundRequest.SaleDate); return(taxResponse); } catch (Refit.ApiException ex) { var response = new TaxResponse(); return((TaxRefundResponse)response.CreateErrorResponse(ex.Content)); } }
/// <summary> /// Ensure the transactionId and source are provided. This may include the invoice number. /// </summary> /// <param name="taxInformation"></param> /// <returns></returns> public async Task <TaxResponse> GetPendingTaxCalculation(TaxRequest taxInformation) { var taxRequest = TaxRelayMapper.CreateSovosTaxRequest(taxInformation, _sovosSettings); try { var response = await _client.GetTaxDeterminationAsync(taxRequest); var taxResponse = TaxRelayMapper.CreateTaxResponseFromSovos(response, taxInformation.SaleDate); return(taxResponse); } catch (Refit.ApiException ex) { var response = new TaxResponse(); return((TaxResponse)response.CreateErrorResponse(ex.Content)); } }
/// <summary> /// Updates a pending tax request; does not commit/abort it. /// Requires TransactionId, Transaction Source AND Invoice Number. /// Aborts the existing request by TransactionId, then submits a new request with the provided information, providing /// a new transactionId. /// </summary> /// <param name="updateRequest"></param> /// <returns></returns> public async Task <TaxResponse> UpdatePendingTaxCalculation(TaxUpdatePendingTaxRequest updateRequest) { var taxRequest = TaxRelayMapper.CreateSovosTaxRequest(updateRequest, _sovosSettings); taxRequest.TransactionSource = "OVER_" + taxRequest.TransactionSource; try { var response = await _client.GetTaxDeterminationAsync(taxRequest); var taxResponse = TaxRelayMapper.CreateTaxResponseFromSovos(response, updateRequest.SaleDate); return(taxResponse); } catch (Refit.ApiException ex) { var response = new TaxResponse(); return((TaxResponse)response.CreateErrorResponse(ex.Content)); } }