@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
188 lines • 8.69 kB
TypeScript
import { RatesRequestParams, TaxCalculationResult } from '../schemas';
import type { AvalaraClient } from '../client';
type ExecuteRequest = AvalaraClient['executeRequest'];
/**
* Creates the rates resource methods
* OpenAPI Path: /rates → rates.*
* @description Tax calculation and rate computation for transaction lines and addresses
*/
export declare function createRatesResource(executeRequest: ExecuteRequest): {
/**
* Calculate tax rates for transaction lines
*
* @fullPath api.avalara.rates.create
* @service avalara
* @domain tax-calculation
* @dataMethod ratesData.create - returns only the tax calculation data without metadata
* @discoverable true
* @searchTerms ["tax", "rates", "calculate", "avalara", "sales tax", "vat", "compliance", "transaction", "create"]
* @relatedEndpoints ["api.commerce.orders.create", "api.commerce.cartHeaders.checkout", "api.items.pricing.calculate", "api.customers.addresses.validate"]
* @commonPatterns ["Calculate sales tax", "Get tax rates", "Tax compliance", "E-commerce tax calculation", "Multi-jurisdiction tax"]
* @workflow ["e-commerce-checkout", "order-processing", "tax-compliance", "invoice-generation", "financial-reporting"]
* @prerequisites ["Valid transaction data", "Public bearer token", "x-site-id header", "Valid addresses", "Product/service lines"]
* @nextSteps ["Apply calculated tax to order", "Store tax calculation results", "Generate compliant invoice", "Submit tax returns"]
* @businessRules ["Requires valid addresses", "Supports multiple tax jurisdictions", "Real-time calculation", "Compliance with local tax laws", "Handles exemptions and special rates"]
* @functionalArea "tax-and-compliance"
* @crossSite "Multi-site tax calculation support"
* @caching "Cache for 1 hour for identical requests, tax rates change infrequently"
* @performance "Optimize by batching multiple line items, use address validation for accuracy"
*
* @param params Tax calculation request parameters including lines, addresses, and transaction details
* @returns Promise<RatesResponse> Complete tax calculation results with rates, amounts, and jurisdiction details
*
* @example
* ```typescript
* // Calculate tax for a simple sale
* const taxRequest = {
* lines: [{
* amount: 100.00,
* description: 'Widget',
* quantity: 1
* }],
* addresses: {
* shipTo: {
* line1: '123 Main St',
* city: 'Irvine',
* region: 'CA',
* country: 'US',
* postalCode: '92602'
* }
* },
* type: 'SalesOrder',
* date: '2024-01-15',
* companyCode: 'DEFAULT'
* };
*
* const response = await client.rates.create(taxRequest);
* console.log(response.data.totalTax); // Total tax amount
* console.log(response.data.lines); // Tax details per line
*
* // Get just the calculation result
* const taxResult = await client.ratesData.create(taxRequest);
* console.log(taxResult.totalTax); // Direct access to tax amount
*
* // Multi-line transaction with shipping
* const complexRequest = {
* lines: [
* { amount: 50.00, description: 'Product A', taxCode: 'P0000000' },
* { amount: 30.00, description: 'Product B', taxCode: 'P0000000' },
* { amount: 10.00, description: 'Shipping', taxCode: 'FR010000' }
* ],
* addresses: {
* shipFrom: {
* line1: '100 Warehouse Blvd',
* city: 'Los Angeles',
* region: 'CA',
* country: 'US',
* postalCode: '90210'
* },
* shipTo: {
* line1: '456 Customer Ave',
* city: 'New York',
* region: 'NY',
* country: 'US',
* postalCode: '10001'
* }
* },
* type: 'SalesInvoice',
* customerCode: 'CUST001',
* commit: true
* };
*
* const complexResult = await client.ratesData.create(complexRequest);
* ```
*/
create: (params: RatesRequestParams) => Promise<{
params: Record<string, unknown> | unknown[];
data: {
lines?: import("zod").objectInputType<{
lineNumber: import("zod").ZodOptional<import("zod").ZodString>;
taxableAmount: import("zod").ZodOptional<import("zod").ZodNumber>;
tax: import("zod").ZodOptional<import("zod").ZodNumber>;
taxCalculated: import("zod").ZodOptional<import("zod").ZodNumber>;
rate: import("zod").ZodOptional<import("zod").ZodNumber>;
exemptAmount: import("zod").ZodOptional<import("zod").ZodNumber>;
details: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
jurisdictionName: import("zod").ZodOptional<import("zod").ZodString>;
rate: import("zod").ZodOptional<import("zod").ZodNumber>;
tax: import("zod").ZodOptional<import("zod").ZodNumber>;
taxableAmount: import("zod").ZodOptional<import("zod").ZodNumber>;
taxType: import("zod").ZodOptional<import("zod").ZodString>;
jurisdictionType: import("zod").ZodOptional<import("zod").ZodString>;
}, "strip", import("zod").ZodTypeAny, {
taxableAmount?: number | undefined;
tax?: number | undefined;
rate?: number | undefined;
jurisdictionName?: string | undefined;
taxType?: string | undefined;
jurisdictionType?: string | undefined;
}, {
taxableAmount?: number | undefined;
tax?: number | undefined;
rate?: number | undefined;
jurisdictionName?: string | undefined;
taxType?: string | undefined;
jurisdictionType?: string | undefined;
}>, "many">>;
}, import("zod").ZodTypeAny, "passthrough">[] | undefined;
addresses?: {
postalCode?: string | undefined;
city?: string | undefined;
country?: string | undefined;
line1?: string | undefined;
region?: string | undefined;
addressType?: string | undefined;
latitude?: number | undefined;
longitude?: number | undefined;
}[] | undefined;
totalAmount?: number | undefined;
totalExempt?: number | undefined;
totalTaxable?: number | undefined;
totalTax?: number | undefined;
totalTaxCalculated?: number | undefined;
taxDate?: string | undefined;
summary?: {
country?: string | undefined;
region?: string | undefined;
tax?: number | undefined;
taxCalculated?: number | undefined;
rate?: number | undefined;
taxType?: string | undefined;
jurisType?: string | undefined;
jurisCode?: string | undefined;
jurisName?: string | undefined;
taxAuthorityType?: number | undefined;
stateAssignedNo?: string | undefined;
taxName?: string | undefined;
taxGroup?: string | undefined;
rateType?: string | undefined;
taxable?: number | undefined;
nonTaxable?: number | undefined;
exemption?: number | undefined;
}[] | undefined;
} & {
[k: string]: unknown;
};
options: Record<string, unknown> | unknown[];
status: number;
message: string;
count: number;
total: number;
totalResults: number;
}>;
};
/**
* Creates the ratesData resource methods (data-only versions)
*/
export declare function createRatesDataResource(rates: ReturnType<typeof createRatesResource>): {
/**
* Calculate tax rates and return calculation result data only
* @param params Tax calculation request parameters
* @returns Promise<TaxCalculationResult> Tax calculation result with rates and amounts
*/
create: (params: RatesRequestParams) => Promise<TaxCalculationResult>;
};
export type RatesResource = ReturnType<typeof createRatesResource>;
export type RatesDataResource = ReturnType<typeof createRatesDataResource>;
export {};
//# sourceMappingURL=rates.d.ts.map