Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
TaxDetailsResponse Class
Namespace
Usage
Example
1List<commercetax.TaxDetailsResponse> taxDetailsResponses = new List<commercetax.TaxDetailsResponse>();
2 for(integer i =0;i<1;i++){
3 Integer rate = 1;
4 Double taxableAmount = lineItem.amount;
5 commercetax.TaxDetailsResponse taxDetailsResponse = new commercetax.TaxDetailsResponse();
6 taxDetailsResponse.setRate(Double.valueOf(rate));
7 taxDetailsResponse.setTaxableAmount(taxableAmount);
8 Double tax = taxableAmount*rate;
9 totalLineTax+=tax;
10 taxDetailsResponse.setTax(taxableAmount*rate);
11 taxDetailsResponse.setExemptAmount(0);
12 taxDetailsResponse.setExemptReason('exemptReason');
13 taxDetailsResponse.setTaxRegionId('taxRegionId');
14 taxDetailsResponse.setTaxId(String.valueOf(getRandomInteger(0,2323233)));
15 taxDetailsResponse.setSerCode('serCode');
16 taxDetailsResponse.setTaxAuthorityTypeId('taxAuthorityTypeId');
17 if(request.DocumentCode == 'SetsNullForResponseWithoutException'){
18 taxDetailsResponse.setImposition(null);
19 }else{
20 commercetax.ImpositionResponse imposition = new commercetax.ImpositionResponse();
21 imposition.setSubType('subtype');
22 imposition.setType('type');
23 taxDetailsResponse.setImposition(imposition);
24 }
25
26 if(request.DocumentCode == 'SetsNullForResponseWithoutException'){
27 taxDetailsResponse.setJurisdiction(null);
28 }else{
29 commercetax.JurisdictionResponse jurisdiction = new commercetax.JurisdictionResponse();
30 jurisdiction.setCountry('country');
31 jurisdiction.setRegion('region');
32 jurisdiction.setName('name');
33 jurisdiction.setStateAssignedNumber('stateAssignedNo');
34 jurisdiction.setId('id');
35 jurisdiction.setLevel('level');
36 taxDetailsResponse.setJurisdiction(jurisdiction);
37 }
38
39 taxDetailsResponses.add(taxDetailsResponse);
40 }
41 lineItemResponse.setTaxes(taxDetailsResponses);
42 totalTax +=totalLineTax;
43 totalAmount+=lineItem.amount;TaxDetailsResponse Methods
The TaxDetailsResponse class includes these methods.
setCustomTaxAttributes(customTaxAttributes)
Signature
global void setCustomTaxAttributes(commercetax.CustomTaxAttributesResponse customTaxAttributes)
Parameters
-
customTaxAttributes:
Type: CustomTaxAttributesResponse
Additional
data or custom attributes to include in the tax response.
Return Value
Type: void
setExemptAmount(exemptAmount)
Signature
global void setExemptAmount(Double exemptAmount)
Parameters
-
exemptAmount:
Type: Double
Amount of tax on a line item that is exempt from tax calculation.
Return Value
Type: void
setExemptReason(reason)
Signature
global void setExemptReason(String reason)
Parameters
-
reason:
Type: String
Optional user-defined information on why a tax exemption applies to a line item.
Return Value
Type: void
setImposition(imposition)
Signature
global void setImposition(commercetax.ImpositionResponse imposition)
Parameters
-
imposition:
Type: ImpositionResponse
Contains information about why tax was imposed on a line item.
Return Value
Type: void
setJurisdiction(jurisdiction)
Signature
global void setJurisdiction(commercetax.JurisdictionResponse jurisdiction)
Parameters
-
jurisdiction:
Type: JurisdictionResponse
Contains address information about the tax jurisdiction used in the tax calculation process.
Return Value
Type: void
setRate(rate)
Signature
global void setRate(Double rate)
Parameters
-
rate:
Type: Double
Tax used during tax calculation.
This value is often a decimal amount, such as 0.1 or 0.06, based on the applied tax percentage.
Return Value
Type: void
setSerCode(serCode)
Signature
global void setSerCode(String serCode)
Parameters
-
serCode:
Type: String
Service code used in tax calculation.
Return Value
Type: void
setTax(tax)
Signature
global void setTax(Double tax)
Parameters
-
tax:
Type: Double
Amount of tax
for a line item.
Return Value
Type: void
setTaxAuthorityTypeId(taxAuthorityTypeId)
Signature
global void setTaxAuthorityTypeId(String taxAuthorityTypeId)
Parameters
-
taxAuthorityTypeId:
Type: String
ID of the organization that oversees tax collection.
Return Value
Type: void
setTaxId(taxId)
Signature
global void setTaxId(String taxId)
Parameters
-
taxId:
Type: String
ID value used to determine
the tax for an individual or business.
Return Value
Type: void
setTaxRegionId(taxRegionId)
Signature
global void setTaxRegionId(String taxRegionId)
Parameters
-
taxRegionId:
Type: String
ID of the tax region used in tax calculation. A tax region represents a geographical area where tax is applied.
Return Value
Type: void
setTaxRuleDetails(taxRuleDetails)
Signature
global void setTaxRuleDetails(commercetax.RuleDetailsResponse taxRuleDetails)
Parameters
-
taxRuleDetails:
Type: RuleDetailsResponse
Information about
the Salesforce tax rules used during tax calculation.
Return Value
Type: void
setTaxableAmount(taxableAmount)
Signature
global void setTaxableAmount(Double taxableAmount)
Parameters
-
taxableAmount:
Type: Double
Amount that c
an be taxed on a line item.
Return Value
Type: void