@novha/calc-engines 6.3.0 → 8.0.0

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.
Files changed (278) hide show
  1. package/dist/capital-gains/brazil/BrazilCapitalGainsService.js +3 -0
  2. package/dist/capital-gains/brazil/BrazilCapitalGainsServiceImpl.js +56 -0
  3. package/dist/capital-gains/brazil/domain/types.js +3 -0
  4. package/dist/capital-gains/canada/CanadaCapitalGainsServiceImpl.js +29 -17
  5. package/dist/capital-gains/index.js +14 -2
  6. package/dist/capital-gains/india/IndiaCapitalGainsService.js +3 -0
  7. package/dist/capital-gains/india/IndiaCapitalGainsServiceImpl.js +58 -0
  8. package/dist/capital-gains/india/domain/types.js +3 -0
  9. package/dist/capital-gains/japan/JapanCapitalGainsService.js +3 -0
  10. package/dist/capital-gains/japan/JapanCapitalGainsServiceImpl.js +41 -0
  11. package/dist/capital-gains/japan/domain/types.js +3 -0
  12. package/dist/capital-gains/spain/SpainCapitalGainsService.js +3 -0
  13. package/dist/capital-gains/spain/SpainCapitalGainsServiceImpl.js +56 -0
  14. package/dist/capital-gains/spain/domain/types.js +3 -0
  15. package/dist/corporate/brazil/BrazilCorporateTaxService.js +3 -0
  16. package/dist/corporate/brazil/BrazilCorporateTaxServiceImpl.js +33 -0
  17. package/dist/corporate/brazil/domain/types.js +3 -0
  18. package/dist/corporate/index.js +10 -2
  19. package/dist/corporate/india/IndiaCorporateTaxService.js +3 -0
  20. package/dist/corporate/india/IndiaCorporateTaxServiceImpl.js +29 -0
  21. package/dist/corporate/india/domain/types.js +3 -0
  22. package/dist/corporate/japan/JapanCorporateTaxService.js +3 -0
  23. package/dist/corporate/japan/JapanCorporateTaxServiceImpl.js +29 -0
  24. package/dist/corporate/japan/domain/types.js +3 -0
  25. package/dist/corporate/spain/SpainCorporateTaxService.js +3 -0
  26. package/dist/corporate/spain/SpainCorporateTaxServiceImpl.js +29 -0
  27. package/dist/corporate/spain/domain/types.js +3 -0
  28. package/dist/income-tax/brazil/BrazilIncomeTaxService.js +3 -0
  29. package/dist/income-tax/brazil/BrazilIncomeTaxServiceImpl.js +78 -0
  30. package/dist/income-tax/brazil/domain/types.js +3 -0
  31. package/dist/income-tax/index.js +14 -2
  32. package/dist/income-tax/india/IndiaIncomeTaxService.js +3 -0
  33. package/dist/income-tax/india/IndiaIncomeTaxServiceImpl.js +75 -0
  34. package/dist/income-tax/india/domain/types.js +3 -0
  35. package/dist/income-tax/japan/JapanIncomeTaxService.js +3 -0
  36. package/dist/income-tax/japan/JapanIncomeTaxServiceImpl.js +75 -0
  37. package/dist/income-tax/japan/domain/types.js +3 -0
  38. package/dist/income-tax/spain/SpainIncomeTaxService.js +3 -0
  39. package/dist/income-tax/spain/SpainIncomeTaxServiceImpl.js +62 -0
  40. package/dist/income-tax/spain/domain/types.js +3 -0
  41. package/dist/index.js +3 -2
  42. package/dist/inheritance-tax/australia/AustraliaInheritanceTaxService.js +3 -0
  43. package/dist/inheritance-tax/australia/AustraliaInheritanceTaxServiceImpl.js +19 -0
  44. package/dist/inheritance-tax/australia/domain/types.js +3 -0
  45. package/dist/inheritance-tax/canada/CanadaInheritanceTaxService.js +3 -0
  46. package/dist/inheritance-tax/canada/CanadaInheritanceTaxServiceImpl.js +51 -0
  47. package/dist/inheritance-tax/canada/domain/types.js +3 -0
  48. package/dist/inheritance-tax/domain/types.js +3 -0
  49. package/dist/inheritance-tax/france/FranceInheritanceTaxService.js +3 -0
  50. package/dist/inheritance-tax/france/FranceInheritanceTaxServiceImpl.js +52 -0
  51. package/dist/inheritance-tax/france/domain/types.js +3 -0
  52. package/dist/inheritance-tax/germany/GermanyInheritanceTaxService.js +3 -0
  53. package/dist/inheritance-tax/germany/GermanyInheritanceTaxServiceImpl.js +52 -0
  54. package/dist/inheritance-tax/germany/domain/types.js +3 -0
  55. package/dist/inheritance-tax/index.js +31 -0
  56. package/dist/inheritance-tax/japan/JapanInheritanceTaxService.js +3 -0
  57. package/dist/inheritance-tax/japan/JapanInheritanceTaxServiceImpl.js +53 -0
  58. package/dist/inheritance-tax/japan/domain/types.js +3 -0
  59. package/dist/inheritance-tax/south-africa/SouthAfricaInheritanceTaxService.js +3 -0
  60. package/dist/inheritance-tax/south-africa/SouthAfricaInheritanceTaxServiceImpl.js +52 -0
  61. package/dist/inheritance-tax/south-africa/domain/types.js +3 -0
  62. package/dist/inheritance-tax/spain/SpainInheritanceTaxService.js +3 -0
  63. package/dist/inheritance-tax/spain/SpainInheritanceTaxServiceImpl.js +51 -0
  64. package/dist/inheritance-tax/spain/domain/types.js +3 -0
  65. package/dist/inheritance-tax/uk/UKInheritanceTaxService.js +3 -0
  66. package/dist/inheritance-tax/uk/UKInheritanceTaxServiceImpl.js +39 -0
  67. package/dist/inheritance-tax/uk/domain/types.js +3 -0
  68. package/dist/inheritance-tax/usa/USAInheritanceTaxService.js +3 -0
  69. package/dist/inheritance-tax/usa/USAInheritanceTaxServiceImpl.js +51 -0
  70. package/dist/inheritance-tax/usa/domain/types.js +3 -0
  71. package/dist/mortgage/brazil/BrazilMortgageService.js +3 -0
  72. package/dist/mortgage/brazil/BrazilMortgageServiceImpl.js +76 -0
  73. package/dist/mortgage/brazil/domain/types.js +3 -0
  74. package/dist/mortgage/index.js +14 -2
  75. package/dist/mortgage/india/IndiaMortgageService.js +3 -0
  76. package/dist/mortgage/india/IndiaMortgageServiceImpl.js +76 -0
  77. package/dist/mortgage/india/domain/types.js +3 -0
  78. package/dist/mortgage/japan/JapanMortgageService.js +3 -0
  79. package/dist/mortgage/japan/JapanMortgageServiceImpl.js +76 -0
  80. package/dist/mortgage/japan/domain/types.js +3 -0
  81. package/dist/mortgage/spain/SpainMortgageService.js +3 -0
  82. package/dist/mortgage/spain/SpainMortgageServiceImpl.js +96 -0
  83. package/dist/mortgage/spain/domain/types.js +3 -0
  84. package/dist/shared/domain/types.js +2 -1
  85. package/dist/types/capital-gains/brazil/BrazilCapitalGainsService.d.ts +4 -0
  86. package/dist/types/capital-gains/brazil/BrazilCapitalGainsServiceImpl.d.ts +10 -0
  87. package/dist/types/capital-gains/brazil/domain/types.d.ts +11 -0
  88. package/dist/types/capital-gains/canada/CanadaCapitalGainsServiceImpl.d.ts +1 -1
  89. package/dist/types/capital-gains/index.d.ts +9 -1
  90. package/dist/types/capital-gains/india/IndiaCapitalGainsService.d.ts +4 -0
  91. package/dist/types/capital-gains/india/IndiaCapitalGainsServiceImpl.d.ts +9 -0
  92. package/dist/types/capital-gains/india/domain/types.d.ts +9 -0
  93. package/dist/types/capital-gains/japan/JapanCapitalGainsService.d.ts +4 -0
  94. package/dist/types/capital-gains/japan/JapanCapitalGainsServiceImpl.d.ts +9 -0
  95. package/dist/types/capital-gains/japan/domain/types.d.ts +6 -0
  96. package/dist/types/capital-gains/spain/SpainCapitalGainsService.d.ts +4 -0
  97. package/dist/types/capital-gains/spain/SpainCapitalGainsServiceImpl.d.ts +10 -0
  98. package/dist/types/capital-gains/spain/domain/types.d.ts +11 -0
  99. package/dist/types/corporate/brazil/BrazilCorporateTaxService.d.ts +4 -0
  100. package/dist/types/corporate/brazil/BrazilCorporateTaxServiceImpl.d.ts +8 -0
  101. package/dist/types/corporate/brazil/domain/types.d.ts +19 -0
  102. package/dist/types/corporate/index.d.ts +9 -1
  103. package/dist/types/corporate/india/IndiaCorporateTaxService.d.ts +4 -0
  104. package/dist/types/corporate/india/IndiaCorporateTaxServiceImpl.d.ts +8 -0
  105. package/dist/types/corporate/india/domain/types.d.ts +15 -0
  106. package/dist/types/corporate/japan/JapanCorporateTaxService.d.ts +4 -0
  107. package/dist/types/corporate/japan/JapanCorporateTaxServiceImpl.d.ts +8 -0
  108. package/dist/types/corporate/japan/domain/types.d.ts +15 -0
  109. package/dist/types/corporate/spain/SpainCorporateTaxService.d.ts +4 -0
  110. package/dist/types/corporate/spain/SpainCorporateTaxServiceImpl.d.ts +8 -0
  111. package/dist/types/corporate/spain/domain/types.d.ts +15 -0
  112. package/dist/types/income-tax/brazil/BrazilIncomeTaxService.d.ts +4 -0
  113. package/dist/types/income-tax/brazil/BrazilIncomeTaxServiceImpl.d.ts +11 -0
  114. package/dist/types/income-tax/brazil/domain/types.d.ts +18 -0
  115. package/dist/types/income-tax/index.d.ts +9 -1
  116. package/dist/types/income-tax/india/IndiaIncomeTaxService.d.ts +4 -0
  117. package/dist/types/income-tax/india/IndiaIncomeTaxServiceImpl.d.ts +10 -0
  118. package/dist/types/income-tax/india/domain/types.d.ts +16 -0
  119. package/dist/types/income-tax/japan/JapanIncomeTaxService.d.ts +4 -0
  120. package/dist/types/income-tax/japan/JapanIncomeTaxServiceImpl.d.ts +10 -0
  121. package/dist/types/income-tax/japan/domain/types.d.ts +16 -0
  122. package/dist/types/income-tax/spain/SpainIncomeTaxService.d.ts +4 -0
  123. package/dist/types/income-tax/spain/SpainIncomeTaxServiceImpl.d.ts +10 -0
  124. package/dist/types/income-tax/spain/domain/types.d.ts +16 -0
  125. package/dist/types/index.d.ts +1 -0
  126. package/dist/types/inheritance-tax/australia/AustraliaInheritanceTaxService.d.ts +4 -0
  127. package/dist/types/inheritance-tax/australia/AustraliaInheritanceTaxServiceImpl.d.ts +8 -0
  128. package/dist/types/inheritance-tax/australia/domain/types.d.ts +13 -0
  129. package/dist/types/inheritance-tax/canada/CanadaInheritanceTaxService.d.ts +4 -0
  130. package/dist/types/inheritance-tax/canada/CanadaInheritanceTaxServiceImpl.d.ts +9 -0
  131. package/dist/types/inheritance-tax/canada/domain/types.d.ts +20 -0
  132. package/dist/types/inheritance-tax/domain/types.d.ts +17 -0
  133. package/dist/types/inheritance-tax/france/FranceInheritanceTaxService.d.ts +4 -0
  134. package/dist/types/inheritance-tax/france/FranceInheritanceTaxServiceImpl.d.ts +9 -0
  135. package/dist/types/inheritance-tax/france/domain/types.d.ts +29 -0
  136. package/dist/types/inheritance-tax/germany/GermanyInheritanceTaxService.d.ts +4 -0
  137. package/dist/types/inheritance-tax/germany/GermanyInheritanceTaxServiceImpl.d.ts +9 -0
  138. package/dist/types/inheritance-tax/germany/domain/types.d.ts +28 -0
  139. package/dist/types/inheritance-tax/index.d.ts +19 -0
  140. package/dist/types/inheritance-tax/japan/JapanInheritanceTaxService.d.ts +4 -0
  141. package/dist/types/inheritance-tax/japan/JapanInheritanceTaxServiceImpl.d.ts +9 -0
  142. package/dist/types/inheritance-tax/japan/domain/types.d.ts +21 -0
  143. package/dist/types/inheritance-tax/south-africa/SouthAfricaInheritanceTaxService.d.ts +4 -0
  144. package/dist/types/inheritance-tax/south-africa/SouthAfricaInheritanceTaxServiceImpl.d.ts +9 -0
  145. package/dist/types/inheritance-tax/south-africa/domain/types.d.ts +20 -0
  146. package/dist/types/inheritance-tax/spain/SpainInheritanceTaxService.d.ts +4 -0
  147. package/dist/types/inheritance-tax/spain/SpainInheritanceTaxServiceImpl.d.ts +9 -0
  148. package/dist/types/inheritance-tax/spain/domain/types.d.ts +19 -0
  149. package/dist/types/inheritance-tax/uk/UKInheritanceTaxService.d.ts +4 -0
  150. package/dist/types/inheritance-tax/uk/UKInheritanceTaxServiceImpl.d.ts +8 -0
  151. package/dist/types/inheritance-tax/uk/domain/types.d.ts +17 -0
  152. package/dist/types/inheritance-tax/usa/USAInheritanceTaxService.d.ts +4 -0
  153. package/dist/types/inheritance-tax/usa/USAInheritanceTaxServiceImpl.d.ts +9 -0
  154. package/dist/types/inheritance-tax/usa/domain/types.d.ts +19 -0
  155. package/dist/types/mortgage/brazil/BrazilMortgageService.d.ts +4 -0
  156. package/dist/types/mortgage/brazil/BrazilMortgageServiceImpl.d.ts +7 -0
  157. package/dist/types/mortgage/brazil/domain/types.d.ts +39 -0
  158. package/dist/types/mortgage/index.d.ts +9 -1
  159. package/dist/types/mortgage/india/IndiaMortgageService.d.ts +4 -0
  160. package/dist/types/mortgage/india/IndiaMortgageServiceImpl.d.ts +7 -0
  161. package/dist/types/mortgage/india/domain/types.d.ts +39 -0
  162. package/dist/types/mortgage/japan/JapanMortgageService.d.ts +4 -0
  163. package/dist/types/mortgage/japan/JapanMortgageServiceImpl.d.ts +7 -0
  164. package/dist/types/mortgage/japan/domain/types.d.ts +39 -0
  165. package/dist/types/mortgage/spain/SpainMortgageService.d.ts +4 -0
  166. package/dist/types/mortgage/spain/SpainMortgageServiceImpl.d.ts +8 -0
  167. package/dist/types/mortgage/spain/domain/types.d.ts +44 -0
  168. package/dist/types/shared/domain/types.d.ts +2 -1
  169. package/package.json +1 -1
  170. package/src/capital-gains/brazil/BrazilCapitalGainsService.ts +5 -0
  171. package/src/capital-gains/brazil/BrazilCapitalGainsServiceImpl.ts +69 -0
  172. package/src/capital-gains/brazil/domain/types.ts +15 -0
  173. package/src/capital-gains/canada/CanadaCapitalGainsServiceImpl.ts +34 -21
  174. package/src/capital-gains/index.ts +40 -0
  175. package/src/capital-gains/india/IndiaCapitalGainsService.ts +5 -0
  176. package/src/capital-gains/india/IndiaCapitalGainsServiceImpl.ts +64 -0
  177. package/src/capital-gains/india/domain/types.ts +12 -0
  178. package/src/capital-gains/japan/JapanCapitalGainsService.ts +5 -0
  179. package/src/capital-gains/japan/JapanCapitalGainsServiceImpl.ts +47 -0
  180. package/src/capital-gains/japan/domain/types.ts +9 -0
  181. package/src/capital-gains/spain/SpainCapitalGainsService.ts +5 -0
  182. package/src/capital-gains/spain/SpainCapitalGainsServiceImpl.ts +69 -0
  183. package/src/capital-gains/spain/domain/types.ts +15 -0
  184. package/src/corporate/brazil/BrazilCorporateTaxService.ts +5 -0
  185. package/src/corporate/brazil/BrazilCorporateTaxServiceImpl.ts +40 -0
  186. package/src/corporate/brazil/domain/types.ts +16 -0
  187. package/src/corporate/index.ts +45 -1
  188. package/src/corporate/india/IndiaCorporateTaxService.ts +5 -0
  189. package/src/corporate/india/IndiaCorporateTaxServiceImpl.ts +35 -0
  190. package/src/corporate/india/domain/types.ts +15 -0
  191. package/src/corporate/japan/JapanCorporateTaxService.ts +5 -0
  192. package/src/corporate/japan/JapanCorporateTaxServiceImpl.ts +35 -0
  193. package/src/corporate/japan/domain/types.ts +15 -0
  194. package/src/corporate/spain/SpainCorporateTaxService.ts +5 -0
  195. package/src/corporate/spain/SpainCorporateTaxServiceImpl.ts +35 -0
  196. package/src/corporate/spain/domain/types.ts +15 -0
  197. package/src/income-tax/brazil/BrazilIncomeTaxService.ts +5 -0
  198. package/src/income-tax/brazil/BrazilIncomeTaxServiceImpl.ts +91 -0
  199. package/src/income-tax/brazil/domain/types.ts +21 -0
  200. package/src/income-tax/index.ts +40 -0
  201. package/src/income-tax/india/IndiaIncomeTaxService.ts +5 -0
  202. package/src/income-tax/india/IndiaIncomeTaxServiceImpl.ts +87 -0
  203. package/src/income-tax/india/domain/types.ts +16 -0
  204. package/src/income-tax/japan/JapanIncomeTaxService.ts +5 -0
  205. package/src/income-tax/japan/JapanIncomeTaxServiceImpl.ts +87 -0
  206. package/src/income-tax/japan/domain/types.ts +16 -0
  207. package/src/income-tax/spain/SpainIncomeTaxService.ts +5 -0
  208. package/src/income-tax/spain/SpainIncomeTaxServiceImpl.ts +75 -0
  209. package/src/income-tax/spain/domain/types.ts +16 -0
  210. package/src/index.ts +1 -0
  211. package/src/inheritance-tax/australia/AustraliaInheritanceTaxService.ts +5 -0
  212. package/src/inheritance-tax/australia/AustraliaInheritanceTaxServiceImpl.ts +21 -0
  213. package/src/inheritance-tax/australia/domain/types.ts +16 -0
  214. package/src/inheritance-tax/canada/CanadaInheritanceTaxService.ts +5 -0
  215. package/src/inheritance-tax/canada/CanadaInheritanceTaxServiceImpl.ts +65 -0
  216. package/src/inheritance-tax/canada/domain/types.ts +24 -0
  217. package/src/inheritance-tax/domain/types.ts +19 -0
  218. package/src/inheritance-tax/france/FranceInheritanceTaxService.ts +5 -0
  219. package/src/inheritance-tax/france/FranceInheritanceTaxServiceImpl.ts +66 -0
  220. package/src/inheritance-tax/france/domain/types.ts +35 -0
  221. package/src/inheritance-tax/germany/GermanyInheritanceTaxService.ts +5 -0
  222. package/src/inheritance-tax/germany/GermanyInheritanceTaxServiceImpl.ts +66 -0
  223. package/src/inheritance-tax/germany/domain/types.ts +34 -0
  224. package/src/inheritance-tax/index.ts +110 -0
  225. package/src/inheritance-tax/japan/JapanInheritanceTaxService.ts +5 -0
  226. package/src/inheritance-tax/japan/JapanInheritanceTaxServiceImpl.ts +67 -0
  227. package/src/inheritance-tax/japan/domain/types.ts +25 -0
  228. package/src/inheritance-tax/south-africa/SouthAfricaInheritanceTaxService.ts +5 -0
  229. package/src/inheritance-tax/south-africa/SouthAfricaInheritanceTaxServiceImpl.ts +66 -0
  230. package/src/inheritance-tax/south-africa/domain/types.ts +24 -0
  231. package/src/inheritance-tax/spain/SpainInheritanceTaxService.ts +5 -0
  232. package/src/inheritance-tax/spain/SpainInheritanceTaxServiceImpl.ts +65 -0
  233. package/src/inheritance-tax/spain/domain/types.ts +23 -0
  234. package/src/inheritance-tax/uk/UKInheritanceTaxService.ts +5 -0
  235. package/src/inheritance-tax/uk/UKInheritanceTaxServiceImpl.ts +46 -0
  236. package/src/inheritance-tax/uk/domain/types.ts +20 -0
  237. package/src/inheritance-tax/usa/USAInheritanceTaxService.ts +5 -0
  238. package/src/inheritance-tax/usa/USAInheritanceTaxServiceImpl.ts +65 -0
  239. package/src/inheritance-tax/usa/domain/types.ts +23 -0
  240. package/src/mortgage/brazil/BrazilMortgageService.ts +5 -0
  241. package/src/mortgage/brazil/BrazilMortgageServiceImpl.ts +101 -0
  242. package/src/mortgage/brazil/domain/types.ts +46 -0
  243. package/src/mortgage/index.ts +49 -1
  244. package/src/mortgage/india/IndiaMortgageService.ts +5 -0
  245. package/src/mortgage/india/IndiaMortgageServiceImpl.ts +101 -0
  246. package/src/mortgage/india/domain/types.ts +46 -0
  247. package/src/mortgage/japan/JapanMortgageService.ts +5 -0
  248. package/src/mortgage/japan/JapanMortgageServiceImpl.ts +101 -0
  249. package/src/mortgage/japan/domain/types.ts +46 -0
  250. package/src/mortgage/spain/SpainMortgageService.ts +5 -0
  251. package/src/mortgage/spain/SpainMortgageServiceImpl.ts +130 -0
  252. package/src/mortgage/spain/domain/types.ts +52 -0
  253. package/src/shared/domain/types.ts +1 -0
  254. package/test/australia-inheritance-tax.test.ts +35 -0
  255. package/test/brazil-capital-gains.test.ts +65 -0
  256. package/test/brazil-corporate-tax.test.ts +63 -0
  257. package/test/brazil-income-tax.test.ts +85 -0
  258. package/test/brazil-mortgage.test.ts +70 -0
  259. package/test/canada-inheritance-tax.test.ts +62 -0
  260. package/test/france-inheritance-tax.test.ts +101 -0
  261. package/test/germany-inheritance-tax.test.ts +100 -0
  262. package/test/india-capital-gains.test.ts +71 -0
  263. package/test/india-corporate-tax.test.ts +54 -0
  264. package/test/india-income-tax.test.ts +78 -0
  265. package/test/india-mortgage.test.ts +70 -0
  266. package/test/japan-capital-gains.test.ts +55 -0
  267. package/test/japan-corporate-tax.test.ts +54 -0
  268. package/test/japan-income-tax.test.ts +76 -0
  269. package/test/japan-inheritance-tax.test.ts +74 -0
  270. package/test/japan-mortgage.test.ts +69 -0
  271. package/test/south-africa-inheritance-tax.test.ts +81 -0
  272. package/test/spain-capital-gains.test.ts +66 -0
  273. package/test/spain-corporate-tax.test.ts +54 -0
  274. package/test/spain-income-tax.test.ts +84 -0
  275. package/test/spain-inheritance-tax.test.ts +78 -0
  276. package/test/spain-mortgage.test.ts +70 -0
  277. package/test/uk-inheritance-tax.test.ts +72 -0
  278. package/test/usa-inheritance-tax.test.ts +90 -0
@@ -0,0 +1,81 @@
1
+ import { SouthAfricaInheritanceTaxServiceImpl } from '../src/inheritance-tax/south-africa/SouthAfricaInheritanceTaxServiceImpl';
2
+ import { Input, Rules } from '../src/inheritance-tax/south-africa/domain/types';
3
+
4
+ const southAfricaRules: Rules = {
5
+ primaryAbatement: 3500000,
6
+ taxBrackets: [
7
+ { from: 0, to: 30000000, rate: 0.20 },
8
+ { from: 30000000, to: null, rate: 0.25 },
9
+ ],
10
+ };
11
+
12
+ describe('SouthAfricaInheritanceTaxServiceImpl', () => {
13
+ it('returns zero tax for estate below primary abatement', () => {
14
+ const input: Input = { estateValue: 3000000, deductions: 0 };
15
+ const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
16
+ const result = service.calculate();
17
+
18
+ expect(result.inheritanceTax).toBe(0);
19
+ expect(result.taxableEstate).toBe(0);
20
+ });
21
+
22
+ it('returns zero tax for estate at primary abatement', () => {
23
+ const input: Input = { estateValue: 3500000, deductions: 0 };
24
+ const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
25
+ const result = service.calculate();
26
+
27
+ expect(result.inheritanceTax).toBe(0);
28
+ });
29
+
30
+ it('applies 20% rate for estate above abatement within first bracket', () => {
31
+ const input: Input = { estateValue: 13500000, deductions: 0 };
32
+ const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
33
+ const result = service.calculate();
34
+
35
+ // Taxable = 13500000 - 3500000 = 10000000
36
+ // 10000000 * 0.20 = 2000000
37
+ expect(result.taxableEstate).toBe(10000000);
38
+ expect(result.inheritanceTax).toBe(2000000);
39
+ });
40
+
41
+ it('applies 25% rate for amounts above R30M bracket', () => {
42
+ const input: Input = { estateValue: 43500000, deductions: 0 };
43
+ const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
44
+ const result = service.calculate();
45
+
46
+ // Taxable = 43500000 - 3500000 = 40000000
47
+ // 30000000 * 0.20 = 6000000
48
+ // 10000000 * 0.25 = 2500000
49
+ // Total = 8500000
50
+ expect(result.taxableEstate).toBe(40000000);
51
+ expect(result.inheritanceTax).toBe(8500000);
52
+ });
53
+
54
+ it('deductions reduce taxable estate', () => {
55
+ const input: Input = { estateValue: 13500000, deductions: 5000000 };
56
+ const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
57
+ const result = service.calculate();
58
+
59
+ // Net estate = 13500000 - 5000000 = 8500000
60
+ // Taxable = 8500000 - 3500000 = 5000000
61
+ // 5000000 * 0.20 = 1000000
62
+ expect(result.taxableEstate).toBe(5000000);
63
+ expect(result.inheritanceTax).toBe(1000000);
64
+ });
65
+
66
+ it('returns zero for zero estate', () => {
67
+ const input: Input = { estateValue: 0, deductions: 0 };
68
+ const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
69
+ const result = service.calculate();
70
+
71
+ expect(result.inheritanceTax).toBe(0);
72
+ });
73
+
74
+ it('calculates effective rate correctly', () => {
75
+ const input: Input = { estateValue: 13500000, deductions: 0 };
76
+ const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
77
+ const result = service.calculate();
78
+
79
+ expect(result.effectiveRate).toBe((result.inheritanceTax / 13500000) * 100);
80
+ });
81
+ });
@@ -0,0 +1,66 @@
1
+ import { SpainCapitalGainsServiceImpl } from '../src/capital-gains/spain/SpainCapitalGainsServiceImpl';
2
+ import { Input, Rules } from '../src/capital-gains/spain/domain/types';
3
+
4
+ const spainRules: Rules = {
5
+ brackets: [
6
+ { from: 0, to: 6000, rate: 0.19 },
7
+ { from: 6000, to: 50000, rate: 0.21 },
8
+ { from: 50000, to: 200000, rate: 0.23 },
9
+ { from: 200000, to: 300000, rate: 0.27 },
10
+ { from: 300000, to: null, rate: 0.30 },
11
+ ],
12
+ };
13
+
14
+ describe('SpainCapitalGainsServiceImpl', () => {
15
+ it('returns zero tax for zero gain', () => {
16
+ const input: Input = { capitalGain: 0 };
17
+ const service = new SpainCapitalGainsServiceImpl(input, spainRules);
18
+ const result = service.calculate();
19
+
20
+ expect(result.taxableGain).toBe(0);
21
+ expect(result.capitalGainTax).toBe(0);
22
+ expect(result.totalTax).toBe(0);
23
+ expect(result.effectiveRate).toBe(0);
24
+ expect(result.breakdowns).toHaveLength(0);
25
+ });
26
+
27
+ it('correctly calculates tax for gain in first bracket', () => {
28
+ const input: Input = { capitalGain: 3000 };
29
+ const service = new SpainCapitalGainsServiceImpl(input, spainRules);
30
+ const result = service.calculate();
31
+
32
+ // 0-3000: 3000 * 0.19 = 570
33
+ expect(result.capitalGainTax).toBe(570);
34
+ expect(result.totalTax).toBe(570);
35
+ expect(result.effectiveRate).toBeCloseTo(19, 2);
36
+ });
37
+
38
+ it('correctly calculates tax spanning multiple brackets', () => {
39
+ const input: Input = { capitalGain: 100000 };
40
+ const service = new SpainCapitalGainsServiceImpl(input, spainRules);
41
+ const result = service.calculate();
42
+
43
+ // 0-6000: 6000 * 0.19 = 1140
44
+ // 6000-50000: 44000 * 0.21 = 9240
45
+ // 50000-100000: 50000 * 0.23 = 11500
46
+ // Total = 21880
47
+ expect(result.capitalGainTax).toBeCloseTo(21880, 2);
48
+ expect(result.totalTax).toBeCloseTo(21880, 2);
49
+ });
50
+
51
+ it('taxable gain equals input capital gain', () => {
52
+ const input: Input = { capitalGain: 50000 };
53
+ const service = new SpainCapitalGainsServiceImpl(input, spainRules);
54
+ const result = service.calculate();
55
+
56
+ expect(result.taxableGain).toBe(50000);
57
+ });
58
+
59
+ it('effective rate equals total tax divided by gain times 100', () => {
60
+ const input: Input = { capitalGain: 100000 };
61
+ const service = new SpainCapitalGainsServiceImpl(input, spainRules);
62
+ const result = service.calculate();
63
+
64
+ expect(result.effectiveRate).toBeCloseTo((result.capitalGainTax / 100000) * 100, 2);
65
+ });
66
+ });
@@ -0,0 +1,54 @@
1
+ import { SpainCorporateTaxServiceImpl } from '../src/corporate/spain/SpainCorporateTaxServiceImpl';
2
+ import { Input, Rules } from '../src/corporate/spain/domain/types';
3
+
4
+ const spainRules: Rules = {
5
+ regime: { type: 'flat', rate: 0.25 },
6
+ };
7
+
8
+ describe('SpainCorporateTaxServiceImpl', () => {
9
+ it('returns zero tax for zero income', () => {
10
+ const input: Input = { taxableIncome: 0 };
11
+ const service = new SpainCorporateTaxServiceImpl(input, spainRules);
12
+ const result = service.calculate();
13
+
14
+ expect(result.corporateTax).toBe(0);
15
+ expect(result.effectiveTaxRate).toBe(0);
16
+ expect(result.breakdowns).toHaveLength(0);
17
+ });
18
+
19
+ it('correctly applies the flat 25% rate', () => {
20
+ const input: Input = { taxableIncome: 100000 };
21
+ const service = new SpainCorporateTaxServiceImpl(input, spainRules);
22
+ const result = service.calculate();
23
+
24
+ // 100000 * 0.25 = 25000
25
+ expect(result.corporateTax).toBe(25000);
26
+ });
27
+
28
+ it('calculates effective tax rate as percentage', () => {
29
+ const input: Input = { taxableIncome: 100000 };
30
+ const service = new SpainCorporateTaxServiceImpl(input, spainRules);
31
+ const result = service.calculate();
32
+
33
+ expect(result.effectiveTaxRate).toBe(25);
34
+ });
35
+
36
+ it('returns one breakdown entry for flat rate calculation', () => {
37
+ const input: Input = { taxableIncome: 100000 };
38
+ const service = new SpainCorporateTaxServiceImpl(input, spainRules);
39
+ const result = service.calculate();
40
+
41
+ expect(result.breakdowns).toHaveLength(1);
42
+ expect(result.breakdowns[0].rate).toBe(0.25);
43
+ expect(result.breakdowns[0].amount).toBe(25000);
44
+ });
45
+
46
+ it('scales linearly with taxable income', () => {
47
+ const input: Input = { taxableIncome: 500000 };
48
+ const service = new SpainCorporateTaxServiceImpl(input, spainRules);
49
+ const result = service.calculate();
50
+
51
+ expect(result.corporateTax).toBe(125000);
52
+ expect(result.effectiveTaxRate).toBe(25);
53
+ });
54
+ });
@@ -0,0 +1,84 @@
1
+ import { SpainIncomeTaxServiceImpl } from '../src/income-tax/spain/SpainIncomeTaxServiceImpl';
2
+ import { IncomeTaxRules } from '../src/income-tax/spain/domain/types';
3
+
4
+ const spainRules: IncomeTaxRules = {
5
+ taxBrackets: [
6
+ { from: 0, to: 12450, rate: 0.19 },
7
+ { from: 12450, to: 20200, rate: 0.24 },
8
+ { from: 20200, to: 35200, rate: 0.30 },
9
+ { from: 35200, to: 60000, rate: 0.37 },
10
+ { from: 60000, to: 300000, rate: 0.45 },
11
+ { from: 300000, to: null, rate: 0.47 },
12
+ ],
13
+ socialContributions: { rate: 0.0635 },
14
+ };
15
+
16
+ describe('SpainIncomeTaxServiceImpl', () => {
17
+ it('returns zero tax for zero income', () => {
18
+ const service = new SpainIncomeTaxServiceImpl(0, spainRules);
19
+ const result = service.calculateNetIncome();
20
+
21
+ expect(result.incomeTax).toBe(0);
22
+ expect(result.socialContributions).toBe(0);
23
+ expect(result.totalDeductions).toBe(0);
24
+ expect(result.effectiveTaxRate).toBe(0);
25
+ });
26
+
27
+ it('correctly calculates income tax for income in first bracket', () => {
28
+ const service = new SpainIncomeTaxServiceImpl(10000, spainRules);
29
+ const result = service.calculateNetIncome();
30
+
31
+ // 0-10000: 10000 * 0.19 = 1900
32
+ expect(result.incomeTax).toBeCloseTo(1900, 2);
33
+ expect(result.grossIncome).toBe(10000);
34
+ });
35
+
36
+ it('correctly calculates social contributions', () => {
37
+ const service = new SpainIncomeTaxServiceImpl(10000, spainRules);
38
+ const result = service.calculateNetIncome();
39
+
40
+ // 10000 * 0.0635 = 635
41
+ expect(result.socialContributions).toBeCloseTo(635, 2);
42
+ });
43
+
44
+ it('correctly calculates income tax spanning multiple brackets', () => {
45
+ const service = new SpainIncomeTaxServiceImpl(25000, spainRules);
46
+ const result = service.calculateNetIncome();
47
+
48
+ // 0-12450: 12450 * 0.19 = 2365.5
49
+ // 12450-20200: 7750 * 0.24 = 1860
50
+ // 20200-25000: 4800 * 0.30 = 1440
51
+ // Total = 5665.5
52
+ expect(result.incomeTax).toBeCloseTo(5665.5, 1);
53
+ });
54
+
55
+ it('calculates effective tax rate as income tax divided by gross income', () => {
56
+ const service = new SpainIncomeTaxServiceImpl(25000, spainRules);
57
+ const result = service.calculateNetIncome();
58
+
59
+ expect(result.effectiveTaxRate).toBeCloseTo(result.incomeTax / result.grossIncome, 4);
60
+ });
61
+
62
+ it('net income equals gross income minus total deductions', () => {
63
+ const service = new SpainIncomeTaxServiceImpl(25000, spainRules);
64
+ const result = service.calculateNetIncome();
65
+
66
+ expect(result.netIncome).toBeCloseTo(result.grossIncome - result.totalDeductions, 2);
67
+ });
68
+
69
+ it('total deductions equals income tax plus social contributions', () => {
70
+ const service = new SpainIncomeTaxServiceImpl(25000, spainRules);
71
+ const result = service.calculateNetIncome();
72
+
73
+ expect(result.totalDeductions).toBeCloseTo(result.incomeTax + result.socialContributions, 2);
74
+ });
75
+
76
+ it('applies highest bracket rate to income above 300000', () => {
77
+ const service = new SpainIncomeTaxServiceImpl(350000, spainRules);
78
+ const result = service.calculateNetIncome();
79
+
80
+ expect(result.incomeTax).toBeGreaterThan(0);
81
+ const lastBreakdown = result.taxBracketBreakdown[result.taxBracketBreakdown.length - 1];
82
+ expect(lastBreakdown.rate).toBe(0.47);
83
+ });
84
+ });
@@ -0,0 +1,78 @@
1
+ import { SpainInheritanceTaxServiceImpl } from '../src/inheritance-tax/spain/SpainInheritanceTaxServiceImpl';
2
+ import { Input, Rules } from '../src/inheritance-tax/spain/domain/types';
3
+
4
+ const spainRules: Rules = {
5
+ exemption: 0,
6
+ taxBrackets: [
7
+ { from: 0, to: 7993.46, rate: 0.0765 },
8
+ { from: 7993.46, to: 31956.34, rate: 0.102 },
9
+ { from: 31956.34, to: 79881.68, rate: 0.153 },
10
+ { from: 79881.68, to: 239389.13, rate: 0.2125 },
11
+ { from: 239389.13, to: 398777.54, rate: 0.255 },
12
+ { from: 398777.54, to: 797555.08, rate: 0.2975 },
13
+ { from: 797555.08, to: null, rate: 0.34 },
14
+ ],
15
+ };
16
+
17
+ describe('SpainInheritanceTaxServiceImpl', () => {
18
+ it('returns zero tax for zero estate', () => {
19
+ const input: Input = { estateValue: 0 };
20
+ const service = new SpainInheritanceTaxServiceImpl(input, spainRules);
21
+ const result = service.calculate();
22
+
23
+ expect(result.inheritanceTax).toBe(0);
24
+ expect(result.taxableEstate).toBe(0);
25
+ expect(result.effectiveRate).toBe(0);
26
+ });
27
+
28
+ it('returns zero tax when estate is at or below the exemption', () => {
29
+ const rulesWithExemption: Rules = { ...spainRules, exemption: 100000 };
30
+ const input: Input = { estateValue: 80000 };
31
+ const service = new SpainInheritanceTaxServiceImpl(input, rulesWithExemption);
32
+ const result = service.calculate();
33
+
34
+ expect(result.inheritanceTax).toBe(0);
35
+ expect(result.taxableEstate).toBe(0);
36
+ });
37
+
38
+ it('correctly calculates tax for estate in first bracket', () => {
39
+ const input: Input = { estateValue: 5000 };
40
+ const service = new SpainInheritanceTaxServiceImpl(input, spainRules);
41
+ const result = service.calculate();
42
+
43
+ // 0-5000: 5000 * 0.0765 = 382.5
44
+ expect(result.taxableEstate).toBe(5000);
45
+ expect(result.inheritanceTax).toBeCloseTo(382.5, 2);
46
+ });
47
+
48
+ it('correctly calculates tax for estate spanning multiple brackets', () => {
49
+ const input: Input = { estateValue: 100000 };
50
+ const service = new SpainInheritanceTaxServiceImpl(input, spainRules);
51
+ const result = service.calculate();
52
+
53
+ // 0-7993.46: 7993.46 * 0.0765 ≈ 611.50
54
+ // 7993.46-31956.34: 23962.88 * 0.102 ≈ 2444.21
55
+ // 31956.34-79881.68: 47925.34 * 0.153 ≈ 7332.58
56
+ // 79881.68-100000: 20118.32 * 0.2125 ≈ 4275.14
57
+ // Total ≈ 14663.43
58
+ expect(result.taxableEstate).toBe(100000);
59
+ expect(result.inheritanceTax).toBeCloseTo(14663.43, 0);
60
+ });
61
+
62
+ it('effective rate equals inheritance tax divided by estate times 100', () => {
63
+ const input: Input = { estateValue: 100000 };
64
+ const service = new SpainInheritanceTaxServiceImpl(input, spainRules);
65
+ const result = service.calculate();
66
+
67
+ expect(result.effectiveRate).toBeCloseTo((result.inheritanceTax / 100000) * 100, 2);
68
+ });
69
+
70
+ it('taxable estate is reduced by the exemption amount', () => {
71
+ const rulesWithExemption: Rules = { ...spainRules, exemption: 20000 };
72
+ const input: Input = { estateValue: 50000 };
73
+ const service = new SpainInheritanceTaxServiceImpl(input, rulesWithExemption);
74
+ const result = service.calculate();
75
+
76
+ expect(result.taxableEstate).toBe(30000);
77
+ });
78
+ });
@@ -0,0 +1,70 @@
1
+ import { SpainMortgageServiceImpl } from '../src/mortgage/spain/SpainMortgageServiceImpl';
2
+ import { MortgageInput, MortgageRules } from '../src/mortgage/spain/domain/types';
3
+
4
+ const spainRules: MortgageRules = {
5
+ loanConstraints: { maxLtvPercent: 0.80, maxAmortizationYears: 30 },
6
+ interest: { compounding: 'MONTHLY' },
7
+ transferTax: { brackets: [{ above: 0, rate: 0.07 }] },
8
+ };
9
+
10
+ const input: MortgageInput = {
11
+ propertyPrice: 300000,
12
+ downPayment: 60000,
13
+ annualInterestRate: 3.5,
14
+ amortizationYears: 25,
15
+ isFirstTimeBuyer: false,
16
+ };
17
+
18
+ describe('SpainMortgageServiceImpl', () => {
19
+ it('correctly calculates the loan amount', () => {
20
+ const service = new SpainMortgageServiceImpl();
21
+ const result = service.calculate(input, spainRules);
22
+
23
+ // loanAmount = 300000 - 60000 = 240000
24
+ expect(result.loanAmount).toBe(240000);
25
+ });
26
+
27
+ it('correctly calculates transfer tax', () => {
28
+ const service = new SpainMortgageServiceImpl();
29
+ const result = service.calculate(input, spainRules);
30
+
31
+ // transferTax = (300000 - 0) * 0.07 = 21000
32
+ expect(result.transferTax).toBeCloseTo(21000, 2);
33
+ });
34
+
35
+ it('calculates a positive monthly payment', () => {
36
+ const service = new SpainMortgageServiceImpl();
37
+ const result = service.calculate(input, spainRules);
38
+
39
+ expect(result.monthlyPayment).toBeGreaterThan(0);
40
+ });
41
+
42
+ it('total paid is greater than the loan amount', () => {
43
+ const service = new SpainMortgageServiceImpl();
44
+ const result = service.calculate(input, spainRules);
45
+
46
+ expect(result.totalPaid).toBeGreaterThan(result.loanAmount);
47
+ });
48
+
49
+ it('total paid equals monthly payment multiplied by total payments', () => {
50
+ const service = new SpainMortgageServiceImpl();
51
+ const result = service.calculate(input, spainRules);
52
+
53
+ const expectedTotal = result.monthlyPayment * (input.amortizationYears * 12);
54
+ expect(result.totalPaid).toBeCloseTo(expectedTotal, 2);
55
+ });
56
+
57
+ it('amortization schedule has the correct number of years', () => {
58
+ const service = new SpainMortgageServiceImpl();
59
+ const result = service.calculate(input, spainRules);
60
+
61
+ expect(result.amortizationSchedule).toHaveLength(25);
62
+ });
63
+
64
+ it('throws an error when down payment equals or exceeds property price', () => {
65
+ const service = new SpainMortgageServiceImpl();
66
+ const badInput: MortgageInput = { ...input, downPayment: 300000 };
67
+
68
+ expect(() => service.calculate(badInput, spainRules)).toThrow();
69
+ });
70
+ });
@@ -0,0 +1,72 @@
1
+ import { UKInheritanceTaxServiceImpl } from '../src/inheritance-tax/uk/UKInheritanceTaxServiceImpl';
2
+ import { Input, Rules } from '../src/inheritance-tax/uk/domain/types';
3
+
4
+ const ukRules: Rules = {
5
+ nilRateBand: 325000,
6
+ standardRate: 0.40,
7
+ charityRate: 0.36,
8
+ charityThreshold: 10,
9
+ };
10
+
11
+ describe('UKInheritanceTaxServiceImpl', () => {
12
+ it('returns zero tax for estate below nil-rate band', () => {
13
+ const input: Input = { estateValue: 200000, charitableGivingPercent: 0 };
14
+ const service = new UKInheritanceTaxServiceImpl(input, ukRules);
15
+ const result = service.calculate();
16
+
17
+ expect(result.inheritanceTax).toBe(0);
18
+ expect(result.taxableEstate).toBe(0);
19
+ });
20
+
21
+ it('returns zero tax for estate at nil-rate band', () => {
22
+ const input: Input = { estateValue: 325000, charitableGivingPercent: 0 };
23
+ const service = new UKInheritanceTaxServiceImpl(input, ukRules);
24
+ const result = service.calculate();
25
+
26
+ expect(result.inheritanceTax).toBe(0);
27
+ });
28
+
29
+ it('applies 40% rate for estate above nil-rate band', () => {
30
+ const input: Input = { estateValue: 500000, charitableGivingPercent: 0 };
31
+ const service = new UKInheritanceTaxServiceImpl(input, ukRules);
32
+ const result = service.calculate();
33
+
34
+ // (500000 - 325000) * 0.40 = 70000
35
+ expect(result.taxableEstate).toBe(175000);
36
+ expect(result.inheritanceTax).toBe(70000);
37
+ });
38
+
39
+ it('applies 36% charity rate when charitable giving >= 10%', () => {
40
+ const input: Input = { estateValue: 500000, charitableGivingPercent: 10 };
41
+ const service = new UKInheritanceTaxServiceImpl(input, ukRules);
42
+ const result = service.calculate();
43
+
44
+ // (500000 - 325000) * 0.36 = 63000
45
+ expect(result.taxableEstate).toBe(175000);
46
+ expect(result.inheritanceTax).toBe(63000);
47
+ });
48
+
49
+ it('applies standard rate when charitable giving < 10%', () => {
50
+ const input: Input = { estateValue: 500000, charitableGivingPercent: 9 };
51
+ const service = new UKInheritanceTaxServiceImpl(input, ukRules);
52
+ const result = service.calculate();
53
+
54
+ expect(result.inheritanceTax).toBe(70000);
55
+ });
56
+
57
+ it('returns zero for zero estate', () => {
58
+ const input: Input = { estateValue: 0, charitableGivingPercent: 0 };
59
+ const service = new UKInheritanceTaxServiceImpl(input, ukRules);
60
+ const result = service.calculate();
61
+
62
+ expect(result.inheritanceTax).toBe(0);
63
+ });
64
+
65
+ it('calculates effective rate correctly', () => {
66
+ const input: Input = { estateValue: 1000000, charitableGivingPercent: 0 };
67
+ const service = new UKInheritanceTaxServiceImpl(input, ukRules);
68
+ const result = service.calculate();
69
+
70
+ expect(result.effectiveRate).toBe((result.inheritanceTax / 1000000) * 100);
71
+ });
72
+ });
@@ -0,0 +1,90 @@
1
+ import { USAInheritanceTaxServiceImpl } from '../src/inheritance-tax/usa/USAInheritanceTaxServiceImpl';
2
+ import { Input, Rules } from '../src/inheritance-tax/usa/domain/types';
3
+
4
+ const usaRules: Rules = {
5
+ exemption: 13610000,
6
+ taxBrackets: [
7
+ { from: 0, to: 10000, rate: 0.18 },
8
+ { from: 10000, to: 20000, rate: 0.20 },
9
+ { from: 20000, to: 40000, rate: 0.22 },
10
+ { from: 40000, to: 60000, rate: 0.24 },
11
+ { from: 60000, to: 80000, rate: 0.26 },
12
+ { from: 80000, to: 100000, rate: 0.28 },
13
+ { from: 100000, to: 150000, rate: 0.30 },
14
+ { from: 150000, to: 250000, rate: 0.32 },
15
+ { from: 250000, to: 500000, rate: 0.34 },
16
+ { from: 500000, to: 750000, rate: 0.36 },
17
+ { from: 750000, to: 1000000, rate: 0.38 },
18
+ { from: 1000000, to: null, rate: 0.40 },
19
+ ],
20
+ };
21
+
22
+ describe('USAInheritanceTaxServiceImpl', () => {
23
+ it('returns zero tax for estate below exemption', () => {
24
+ const input: Input = { estateValue: 10000000 };
25
+ const service = new USAInheritanceTaxServiceImpl(input, usaRules);
26
+ const result = service.calculate();
27
+
28
+ expect(result.inheritanceTax).toBe(0);
29
+ expect(result.taxableEstate).toBe(0);
30
+ expect(result.breakdowns).toHaveLength(0);
31
+ });
32
+
33
+ it('returns zero tax for estate at exactly the exemption', () => {
34
+ const input: Input = { estateValue: 13610000 };
35
+ const service = new USAInheritanceTaxServiceImpl(input, usaRules);
36
+ const result = service.calculate();
37
+
38
+ expect(result.inheritanceTax).toBe(0);
39
+ expect(result.taxableEstate).toBe(0);
40
+ });
41
+
42
+ it('correctly calculates tax for estate just above exemption', () => {
43
+ const input: Input = { estateValue: 13620000 }; // 10000 above exemption
44
+ const service = new USAInheritanceTaxServiceImpl(input, usaRules);
45
+ const result = service.calculate();
46
+
47
+ // 10000 * 0.18 = 1800
48
+ expect(result.taxableEstate).toBe(10000);
49
+ expect(result.inheritanceTax).toBe(1800);
50
+ });
51
+
52
+ it('correctly calculates tax with multiple brackets', () => {
53
+ const input: Input = { estateValue: 13660000 }; // 50000 above exemption
54
+ const service = new USAInheritanceTaxServiceImpl(input, usaRules);
55
+ const result = service.calculate();
56
+
57
+ // 10000 * 0.18 = 1800
58
+ // 10000 * 0.20 = 2000
59
+ // 20000 * 0.22 = 4400
60
+ // 10000 * 0.24 = 2400
61
+ // Total = 10600
62
+ expect(result.taxableEstate).toBe(50000);
63
+ expect(result.inheritanceTax).toBe(10600);
64
+ });
65
+
66
+ it('returns zero for zero estate', () => {
67
+ const input: Input = { estateValue: 0 };
68
+ const service = new USAInheritanceTaxServiceImpl(input, usaRules);
69
+ const result = service.calculate();
70
+
71
+ expect(result.inheritanceTax).toBe(0);
72
+ expect(result.effectiveRate).toBe(0);
73
+ });
74
+
75
+ it('returns zero for negative estate', () => {
76
+ const input: Input = { estateValue: -100000 };
77
+ const service = new USAInheritanceTaxServiceImpl(input, usaRules);
78
+ const result = service.calculate();
79
+
80
+ expect(result.inheritanceTax).toBe(0);
81
+ });
82
+
83
+ it('calculates effective rate correctly', () => {
84
+ const input: Input = { estateValue: 14610000 }; // 1,000,000 above exemption
85
+ const service = new USAInheritanceTaxServiceImpl(input, usaRules);
86
+ const result = service.calculate();
87
+
88
+ expect(result.effectiveRate).toBe((result.inheritanceTax / 14610000) * 100);
89
+ });
90
+ });