-
Notifications
You must be signed in to change notification settings - Fork 2
/
ITaxCalculator.ts
129 lines (122 loc) · 3.73 KB
/
ITaxCalculator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { Address } from "ordercloud-javascript-sdk";
import { OCIntegrationConfig } from "../OCIntegrationConfig";
/**
* @desc An interface to define expected responses from tax calculation. Meant to be used in OrderCloud ecommerce checkout.
*/
export interface ITaxCalculator {
/**
* @desc Calculates tax for an order without creating any records. Use this to display tax amount to user prior to order submit.
*/
calculateEstimateAsync(order: OrderSummaryForTax, overrideConfig?: OCIntegrationConfig) : Promise<OrderTaxCalculation>;
/**
* @desc Creates a tax transaction record in the calculating system. Use this once per order - on order submit, payment capture, or fulfillment.
*/
commitTransactionAsync(order: OrderSummaryForTax, overrideConfig?: OCIntegrationConfig) : Promise<OrderTaxCalculation>;
}
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
export interface OrderTaxCalculation {
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
orderID: string;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
externalTransactionID: string;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
totalTax: number;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
lineItems: LineItemTaxCalculation[];
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
orderLevelTaxes: TaxDetails;
}
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
export interface LineItemTaxCalculation {
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
lineItemID: string;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
lineItemTotalTax: number;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
lineItemLevelTaxes: TaxDetails[];
}
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
export interface TaxDetails {
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
tax: number;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
taxable: number;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
exempt: number;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
taxDescription: string;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
jurisdictionLevel: string;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
jurisdictionValue: string;
/**
* @desc Represents the details of the tax costs calculated for one Order
*/
shipEstimateID: string;
}
export interface OrderSummaryForTax {
orderID: string;
customerCode: string;
promotionDiscount: number;
lineItems: LineItemSummaryForTax[];
shippingCosts: ShipEstimateSummaryForTax[]
}
export interface LineItemSummaryForTax {
lineItemID: string;
productID: string;
productName: string;
quantity: number;
unitPrice: number;
promotionDiscount: number;
/**
* @desc (UnitPrice * Quantity) - PromotionDiscount
*/
lineItemTotal: number;
taxCode: string;
shipTo: Address;
shipFrom: Address;
}
export interface ShipEstimateSummaryForTax {
shipEstimateID: string;
/**
* @desc E.G. "Fedex 2-day priority"
*/
description: string;
cost: number;
shipTo: Address;
shipFrom: Address;
}