kempo-tax 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -20,9 +20,17 @@ import { formatPercent, parsePercent } from '../tax/percent.js';
|
|
|
20
20
|
has no jurisdiction and a rate of "7.0", and it must land on the same report row as the "VT" / "7"
|
|
21
21
|
that the same sale would produce today, or one place appears twice.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
/*
|
|
24
|
+
The entry itself records where the sale went, so a jurisdiction row with no place in it at all —
|
|
25
|
+
the earliest Stripe entries — still lands on the right one rather than on a blank.
|
|
26
|
+
*/
|
|
27
|
+
const stateOf = (part, entry) => part.state || entry.state || '';
|
|
28
|
+
|
|
29
|
+
const countryOf = (part, entry) => part.country || entry.country || '';
|
|
30
|
+
|
|
31
|
+
const placeOf = (part, entry) => part.jurisdiction || stateOf(part, entry) || countryOf(part, entry) || '—';
|
|
24
32
|
|
|
25
|
-
const levelOf = part => part.level || (part
|
|
33
|
+
const levelOf = (part, entry) => part.level || (stateOf(part, entry) ? 'state' : countryOf(part, entry) ? 'country' : '');
|
|
26
34
|
|
|
27
35
|
const rateOf = part => {
|
|
28
36
|
const micro = parsePercent(String(part.rate ?? ''));
|
|
@@ -80,14 +88,16 @@ export const buildReport = (entries, { from = null, to = null } = {}) => {
|
|
|
80
88
|
apply(bucket.months.get(month));
|
|
81
89
|
|
|
82
90
|
for(const part of entry.jurisdictions || []){
|
|
83
|
-
const jurisdiction = placeOf(part);
|
|
84
|
-
const level = levelOf(part);
|
|
91
|
+
const jurisdiction = placeOf(part, entry);
|
|
92
|
+
const level = levelOf(part, entry);
|
|
85
93
|
const rate = rateOf(part);
|
|
86
|
-
const
|
|
94
|
+
const country = countryOf(part, entry);
|
|
95
|
+
const state = stateOf(part, entry);
|
|
96
|
+
const key = [country, state, level, jurisdiction, rate].join('|');
|
|
87
97
|
if(!bucket.jurisdictions.has(key)){
|
|
88
98
|
bucket.jurisdictions.set(key, {
|
|
89
|
-
country
|
|
90
|
-
state
|
|
99
|
+
country,
|
|
100
|
+
state,
|
|
91
101
|
level,
|
|
92
102
|
jurisdiction,
|
|
93
103
|
rate,
|