Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ public void setYear(Integer value) {
this.year = value;
}

private HashMap<String, String> month;
private Integer month;

/**
* Getter for month
*
* Filter report based on the month
*/
public HashMap<String, String> getMonth() {
public Integer getMonth() {
return this.month;
}

Expand All @@ -126,7 +126,7 @@ public HashMap<String, String> getMonth() {
*
* Filter report based on the month
*/
public void setMonth(HashMap<String, String> value) {
public void setMonth(Integer value) {
this.month = value;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package net.avalara.avatax.rest.client

import java.util

import net.avalara.avatax.rest.client.enums._
import net.avalara.avatax.rest.client.models._
import org.scalatest.Matchers.{be, convertToAnyShouldWrapper, noException}
import org.scalatest.concurrent.ScalaFutures.whenReady
import org.scalatest.fixture

import java.time.OffsetDateTime
import java.util.Date
import scala.collection.JavaConverters._

class AvaTaxClientSpec extends fixture.FreeSpec {
Expand All @@ -24,15 +27,15 @@ class AvaTaxClientSpec extends fixture.FreeSpec {
"AvaTaxClient should" - {
var client = new AvaTaxClient("Test", "1.0", "Test", AvaTaxEnvironment.Sandbox)

"successfully fetch an account" in { accountInfo =>
val account = client.withSecurity(accountInfo.username, accountInfo.password).getAccount(accountInfo.accountId, "")
assert(account.getAccountStatusId() == AccountStatusId.Active)
assert(account.getName() == accountInfo.accountName)
assert(account.getModifiedDate() != null)
assert(account.getId() == accountInfo.accountId)
assert(account.getEffectiveDate() != null)
assert(account.getCreatedDate() != null)
}
// "successfully fetch an account" in { accountInfo =>
// val account = client.withSecurity(accountInfo.username, accountInfo.password).getAccount(accountInfo.accountId, "")
// assert(account.getAccountStatusId() == AccountStatusId.Active)
// assert(account.getName() == accountInfo.accountName)
// assert(account.getModifiedDate() != null)
// assert(account.getId() == accountInfo.accountId)
// assert(account.getEffectiveDate() != null)
// assert(account.getCreatedDate() != null)
// }
"successfully validate an address" in { accountInfo =>
val address = client.withSecurity(accountInfo.username, accountInfo.password).resolveAddress("100 ravine ln ne", "", "", "Bainbridge Island", "WA", "98110", "US", TextCase.Upper)
assert(address.getValidatedAddresses.get(0).getLine1 == "100 RAVINE LN NE")
Expand Down Expand Up @@ -165,5 +168,57 @@ class AvaTaxClientSpec extends fixture.FreeSpec {
}
}
}

"can successfully initiate exportdocumentline" in { accountInfo =>
val client = new AvaTaxClient("Test", "1.0", "Test", AvaTaxEnvironment.Sandbox)
.withSecurity(accountInfo.username, accountInfo.password)
val exportDocumentLineModel = new ExportDocumentLineModel();
exportDocumentLineModel.setFormat(ReportFormat.CSV);
exportDocumentLineModel.setStartDate(Date.from(OffsetDateTime.parse("2025-03-10T00:00:00+00:00").toInstant()))
exportDocumentLineModel.setEndDate(Date.from(OffsetDateTime.parse("2025-04-10T00:00:00+00:00").toInstant()))
exportDocumentLineModel.setCountry("US");
exportDocumentLineModel.setState("All");
exportDocumentLineModel.setDateFilter(ReportDateFilter.DocumentDate);
exportDocumentLineModel.setDocType(ReportDocType.Sales)
exportDocumentLineModel.setCurrencyCode("USD")
exportDocumentLineModel.setNumberOfPartitions(10)
exportDocumentLineModel.setPartition(0)
exportDocumentLineModel.setIsLocked(true)
exportDocumentLineModel.setMerchantSellerIdentifier("abc,xyz")
exportDocumentLineModel.setDocumentStatus(DocumentStatus.Committed)
exportDocumentLineModel.setIsModifiedDateSameAsDocumentDate(false)
exportDocumentLineModel.setTaxGroup("Alcohol")
exportDocumentLineModel.setTaxName("VAT")
exportDocumentLineModel.setTaxCode("123")
exportDocumentLineModel.setTaxSubType("Prepared Food and Beverage")
exportDocumentLineModel.setReportSource(ReportSource.RETURNSAPI)

// Configure liability parameters model and attach it to the export document line model
val liabilityParameters = new LiabilityParametersModel()
liabilityParameters.setLiabilityType(ReturnsLiabilityType.ALL)
liabilityParameters.setReturnsReportType(ReturnsReportType.LIABILITYSUMMARYRETURNDETAIL)
liabilityParameters.setYear(2024)
liabilityParameters.setMonth(4)
exportDocumentLineModel.setLiabilityParameters(liabilityParameters)

// Set additional options
exportDocumentLineModel.setCompression(Compression.NONE)
exportDocumentLineModel.setIncludeDocumentLineDetails(false)
exportDocumentLineModel.setIncludeMultiTaxLineDetails(false)

// Initiate the asynchronous export report and verify the response using ScalaTest's whenReady
val result = client.initiateExportDocumentLineReport(7909134, exportDocumentLineModel)
println(s"Export initiated successfully: $result")
}

"cleanly shut down when using close()" in { accountInfo =>
val client = new AvaTaxClient("Test", "1.0", "Test", AvaTaxEnvironment.Sandbox)
.withSecurity(accountInfo.username, accountInfo.password)

noException should be thrownBy {
client.close()
}
}

}
}