@actuarial-ts/data 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ actuarial-ts
2
+ Copyright 2026 Justin Morrey
3
+
4
+ This product includes software developed as part of the actuarial-ts project
5
+ (https://github.com/yerromnitsuj/actng).
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @actuarial-ts/data
2
+
3
+ Data ingestion and ASOP No. 23 data-quality review for the
4
+ [actuarial-ts](../core) SDK. Pure functions, zero runtime dependencies
5
+ (besides `@actuarial-ts/core`), fully typed.
6
+
7
+ - `parseCsv(text)` — minimal RFC 4180-subset CSV parser (quoted fields,
8
+ escaped quotes, embedded commas/newlines, BOM, CRLF/LF).
9
+ - `parseLossRunCsv(text)` — loss-run import to `ClaimSnapshot[]` with
10
+ per-row validation errors (1-based row numbers including the header).
11
+ - `triangleFromLongFormat(rows, { kind })` — pivots long-format
12
+ `(origin, age, value)` rows into a `Triangle`.
13
+ - `reviewClaimData(claims, { asOfDate? })` / `reviewTriangles(paid, incurred)`
14
+ — the ASOP No. 23-oriented review; every check performed is listed in the
15
+ report, pass or fail, so the actuary's disclosure can state what WAS
16
+ reviewed, not just what was found.
17
+
18
+ ## Checks
19
+
20
+ ### `reviewClaimData`
21
+
22
+ | id | status when found | what it finds |
23
+ |----|-------------------|---------------|
24
+ | `negative-paid` | fail | cumulative paid < 0 |
25
+ | `negative-case` | warning | case reserve < 0 (legitimate but rare) |
26
+ | `paid-decreasing` | fail | cumulative paid decreasing across a claim's snapshots ordered by evaluation date |
27
+ | `date-order` | fail | report before accident, or evaluation before report |
28
+ | `duplicate-snapshot` | fail | same claimId + evaluationDate twice |
29
+ | `future-dated` | fail | any claim date after `asOfDate` (not evaluated when `asOfDate` is omitted) |
30
+ | `closed-with-case` | warning | closed claim still carrying case reserve |
31
+
32
+ ### `reviewTriangles`
33
+
34
+ | id | status when found | what it finds |
35
+ |----|-------------------|---------------|
36
+ | `shape-mismatch` | fail | origins/ages differ between paid and incurred (blocks cell-level checks, which stay listed as "not evaluated") |
37
+ | `paid-exceeds-incurred` | fail | paid > incurred in a cell (1e-9 relative tolerance) |
38
+ | `negative-incremental-paid` | warning | cumulative paid decreasing along a row (salvage/subrogation makes this legal but reportable) |
39
+ | `negative-incremental-incurred` | warning | cumulative incurred decreasing along a row |
40
+ | `interior-missing` | warning | a null cell with observed cells both before and after it in the same row |
41
+
42
+ ## Quickstart
43
+
44
+ ```ts
45
+ import { buildTriangles } from "@actuarial-ts/core";
46
+ import { parseLossRunCsv, reviewClaimData, reviewTriangles } from "@actuarial-ts/data";
47
+
48
+ const { claims, errors } = parseLossRunCsv(csvText);
49
+ if (errors.length > 0) console.warn(errors); // caller decides: abort or proceed
50
+
51
+ const claimReview = reviewClaimData(claims, { asOfDate: "2023-12-31" });
52
+
53
+ const { paid, incurred } = buildTriangles(claims, {
54
+ cadence: "annual",
55
+ asOfDate: "2023-12-31",
56
+ });
57
+ const triangleReview = reviewTriangles(paid, incurred);
58
+ ```
59
+
60
+ These utilities are designed to support the actuary's compliance with
61
+ ASOP No. 23; responsibility for compliance remains with the credentialed
62
+ actuary.
63
+
64
+ ## License
65
+
66
+ Apache-2.0. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
package/dist/csv.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Minimal RFC 4180-subset CSV parser.
3
+ *
4
+ * Supported: comma delimiter, quoted fields, doubled quotes ("") as escaped
5
+ * quotes inside quoted fields, commas and newlines inside quoted fields,
6
+ * CRLF and LF row endings, a leading UTF-8 BOM, and a tolerated trailing
7
+ * newline. Lines that are completely empty outside quotes are skipped.
8
+ *
9
+ * Deliberately NOT here: header handling, type coercion, and shape
10
+ * validation. Ragged rows are preserved as-is — validation is the caller's
11
+ * job (see lossRun.ts).
12
+ */
13
+ /** Parses CSV text into a grid of string fields (rows x columns). */
14
+ export declare function parseCsv(text: string): string[][];
15
+ //# sourceMappingURL=csv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../src/csv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,qEAAqE;AACrE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAwEjD"}
package/dist/csv.js ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Minimal RFC 4180-subset CSV parser.
3
+ *
4
+ * Supported: comma delimiter, quoted fields, doubled quotes ("") as escaped
5
+ * quotes inside quoted fields, commas and newlines inside quoted fields,
6
+ * CRLF and LF row endings, a leading UTF-8 BOM, and a tolerated trailing
7
+ * newline. Lines that are completely empty outside quotes are skipped.
8
+ *
9
+ * Deliberately NOT here: header handling, type coercion, and shape
10
+ * validation. Ragged rows are preserved as-is — validation is the caller's
11
+ * job (see lossRun.ts).
12
+ */
13
+ /** Parses CSV text into a grid of string fields (rows x columns). */
14
+ export function parseCsv(text) {
15
+ let s = text;
16
+ if (s.length > 0 && s.charCodeAt(0) === 0xfeff)
17
+ s = s.slice(1);
18
+ const rows = [];
19
+ let row = [];
20
+ let field = "";
21
+ let inQuotes = false;
22
+ let fieldWasQuoted = false;
23
+ const endField = () => {
24
+ row.push(field);
25
+ field = "";
26
+ fieldWasQuoted = false;
27
+ };
28
+ const endRow = () => {
29
+ // A line with zero characters outside quotes is skipped; a line like
30
+ // `""` or `,` still produces a row.
31
+ if (row.length === 0 && field === "" && !fieldWasQuoted)
32
+ return;
33
+ endField();
34
+ rows.push(row);
35
+ row = [];
36
+ };
37
+ let i = 0;
38
+ while (i < s.length) {
39
+ const ch = s[i];
40
+ if (inQuotes) {
41
+ if (ch === '"') {
42
+ if (s[i + 1] === '"') {
43
+ field += '"';
44
+ i += 2;
45
+ continue;
46
+ }
47
+ inQuotes = false;
48
+ i++;
49
+ continue;
50
+ }
51
+ field += ch;
52
+ i++;
53
+ continue;
54
+ }
55
+ if (ch === '"' && field === "" && !fieldWasQuoted) {
56
+ inQuotes = true;
57
+ fieldWasQuoted = true;
58
+ i++;
59
+ continue;
60
+ }
61
+ if (ch === ",") {
62
+ endField();
63
+ i++;
64
+ continue;
65
+ }
66
+ if (ch === "\r") {
67
+ if (s[i + 1] === "\n")
68
+ i++;
69
+ endRow();
70
+ i++;
71
+ continue;
72
+ }
73
+ if (ch === "\n") {
74
+ endRow();
75
+ i++;
76
+ continue;
77
+ }
78
+ field += ch;
79
+ i++;
80
+ }
81
+ // Flush a final row that has no trailing newline. An unterminated quoted
82
+ // field flushes with whatever content it accumulated (lenient by design).
83
+ endRow();
84
+ return rows;
85
+ }
86
+ //# sourceMappingURL=csv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.js","sourceRoot":"","sources":["../src/csv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,qEAAqE;AACrE,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,IAAI,CAAC,GAAG,IAAI,CAAC;IACb,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM;QAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE/D,MAAM,IAAI,GAAe,EAAE,CAAC;IAC5B,IAAI,GAAG,GAAa,EAAE,CAAC;IACvB,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,MAAM,QAAQ,GAAG,GAAS,EAAE;QAC1B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,KAAK,GAAG,EAAE,CAAC;QACX,cAAc,GAAG,KAAK,CAAC;IAC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E,CAAC,EAAE,CAAC;YAC3B,MAAM,EAAE,CAAC;YACT,CAAC,EAAE,CAAC;YACJ,SAAS;QACX,CAAC;QACD,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;YAChB,MAAM,EAAE,CAAC;YACT,CAAC,EAAE,CAAC;YACJ,SAAS;QACX,CAAC;QACD,KAAK,IAAI,EAAE,CAAC;QACZ,CAAC,EAAE,CAAC;IACN,CAAC;IACD,yEAAyE;IACzE,0EAA0E;IAC1E,MAAM,EAAE,CAAC;IACT,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./csv.js";
2
+ export * from "./lossRun.js";
3
+ export * from "./longFormat.js";
4
+ export * from "./review.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./csv.js";
2
+ export * from "./lossRun.js";
3
+ export * from "./longFormat.js";
4
+ export * from "./review.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { Triangle, TriangleKind } from "@actuarial-ts/core";
2
+ /**
3
+ * Long-format ("tidy") triangle assembly: one row per observed
4
+ * (origin, age) cell, pivoted into the origins x ages grid the engine uses.
5
+ *
6
+ * - Origins are sorted lexicographically (matching triangle label order,
7
+ * e.g. "2019" < "2020", "2021Q1" < "2021Q3").
8
+ * - Ages are sorted numerically ascending.
9
+ * - Pairs absent from the input are null (not yet observable / missing).
10
+ * - Duplicate (origin, age) pairs are ambiguous and throw
11
+ * ReservingError("SHAPE", ...), even when the values agree.
12
+ */
13
+ export interface LongFormatRow {
14
+ origin: string;
15
+ /** Development age in months. */
16
+ age: number;
17
+ value: number | null;
18
+ }
19
+ export interface TriangleFromLongFormatOptions {
20
+ kind: TriangleKind;
21
+ }
22
+ /** Pivots long-format rows into a Triangle via core's triangleFromGrid. */
23
+ export declare function triangleFromLongFormat(rows: LongFormatRow[], opts: TriangleFromLongFormatOptions): Triangle;
24
+ //# sourceMappingURL=longFormat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"longFormat.d.ts","sourceRoot":"","sources":["../src/longFormat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGjE;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,2EAA2E;AAC3E,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,aAAa,EAAE,EACrB,IAAI,EAAE,6BAA6B,GAClC,QAAQ,CAoBV"}
Binary file
@@ -0,0 +1 @@
1
+ {"version":3,"file":"longFormat.js","sourceRoot":"","sources":["../src/longFormat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAyBtE,2EAA2E;AAC3E,MAAM,UAAU,sBAAsB,CACpC,IAAqB,EACrB,IAAmC;IAEnC,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,C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,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC;IAC5E,CAAC;IACD,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { ClaimSnapshot } from "@actuarial-ts/core";
2
+ export interface LossRunRowError {
3
+ /** 1-based row number including the header (first data row = 2). */
4
+ row: number;
5
+ message: string;
6
+ }
7
+ export interface LossRunParseResult {
8
+ claims: ClaimSnapshot[];
9
+ errors: LossRunRowError[];
10
+ }
11
+ /** Parses a loss-run CSV into ClaimSnapshots plus per-row validation errors. */
12
+ export declare function parseLossRunCsv(text: string): LossRunParseResult;
13
+ //# sourceMappingURL=lossRun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lossRun.d.ts","sourceRoot":"","sources":["../src/lossRun.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAmCxD,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAkBD,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAkFhE"}
@@ -0,0 +1,122 @@
1
+ import { ReservingError } from "@actuarial-ts/core";
2
+ import { parseCsv } from "./csv.js";
3
+ /**
4
+ * Loss-run CSV import. Mirrors the workbench import contract:
5
+ *
6
+ * Required columns (one row per claim per evaluation snapshot):
7
+ * claim_id, accident_date, report_date, evaluation_date,
8
+ * paid_to_date, case_reserve, status
9
+ *
10
+ * Headers are normalized (trimmed, lower-cased, whitespace -> underscores);
11
+ * extra columns are ignored. Missing required columns make the file
12
+ * unparseable and throw ReservingError("SHAPE", ...). Row-level failures are
13
+ * collected — not thrown — so the caller decides whether to abort or load
14
+ * the clean rows; a row with any error contributes no claim.
15
+ *
16
+ * Row numbers in errors are 1-based INCLUDING the header row, so the first
17
+ * data row is row 2.
18
+ *
19
+ * Unlike the workbench importer, negative paid/case amounts are accepted
20
+ * here: the ASOP 23 review layer (reviewClaimData) flags them, keeping the
21
+ * signal visible instead of silently rejecting salvage/subrogation rows.
22
+ */
23
+ const REQUIRED_COLUMNS = [
24
+ "claim_id",
25
+ "accident_date",
26
+ "report_date",
27
+ "evaluation_date",
28
+ "paid_to_date",
29
+ "case_reserve",
30
+ "status",
31
+ ];
32
+ function normalizeHeader(h) {
33
+ return h.trim().toLowerCase().replace(/\s+/g, "_");
34
+ }
35
+ /** True when the string is a real calendar date in yyyy-mm-dd form. */
36
+ function isValidIsoDate(value) {
37
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
38
+ if (!match)
39
+ return false;
40
+ const y = Number(match[1]);
41
+ const m = Number(match[2]);
42
+ const d = Number(match[3]);
43
+ if (m < 1 || m > 12 || d < 1)
44
+ return false;
45
+ const daysInMonth = new Date(Date.UTC(y, m, 0)).getUTCDate();
46
+ return d <= daysInMonth;
47
+ }
48
+ /** Parses a loss-run CSV into ClaimSnapshots plus per-row validation errors. */
49
+ export function parseLossRunCsv(text) {
50
+ const grid = parseCsv(text);
51
+ const headers = (grid[0] ?? []).map(normalizeHeader);
52
+ const missing = REQUIRED_COLUMNS.filter((c) => !headers.includes(c));
53
+ if (missing.length > 0) {
54
+ throw new ReservingError("SHAPE", `Missing required column(s): ${missing.join(", ")}. Found: ${headers.filter(Boolean).join(", ") || "(none)"}`);
55
+ }
56
+ const columnIndex = new Map();
57
+ headers.forEach((h, idx) => {
58
+ if (!columnIndex.has(h))
59
+ columnIndex.set(h, idx);
60
+ });
61
+ const claims = [];
62
+ const errors = [];
63
+ for (let r = 1; r < grid.length; r++) {
64
+ const rowNumber = r + 1; // 1-based including the header row
65
+ const cells = grid[r];
66
+ const cell = (name) => (cells[columnIndex.get(name)] ?? "").trim();
67
+ const rowErrors = [];
68
+ const claimId = cell("claim_id");
69
+ if (claimId === "")
70
+ rowErrors.push("claim_id is required");
71
+ const date = (name) => {
72
+ const value = cell(name);
73
+ if (!isValidIsoDate(value)) {
74
+ rowErrors.push(`${name} must be a real calendar date in yyyy-mm-dd form (got "${value}")`);
75
+ return null;
76
+ }
77
+ return value;
78
+ };
79
+ const accidentDate = date("accident_date");
80
+ const reportDate = date("report_date");
81
+ const evaluationDate = date("evaluation_date");
82
+ const amount = (name) => {
83
+ const value = cell(name);
84
+ const n = value === "" ? NaN : Number(value);
85
+ if (!Number.isFinite(n)) {
86
+ rowErrors.push(`${name} must be a finite number (got "${value}")`);
87
+ return null;
88
+ }
89
+ return n;
90
+ };
91
+ const paidToDate = amount("paid_to_date");
92
+ const caseReserve = amount("case_reserve");
93
+ const statusRaw = cell("status").toLowerCase();
94
+ const status = statusRaw === "open" || statusRaw === "closed" ? statusRaw : null;
95
+ if (status === null) {
96
+ rowErrors.push(`status must be "open" or "closed" (got "${cell("status")}")`);
97
+ }
98
+ // Cross-field checks need all three dates to be individually valid.
99
+ if (accidentDate !== null && reportDate !== null && evaluationDate !== null) {
100
+ if (reportDate < accidentDate)
101
+ rowErrors.push("report_date precedes accident_date");
102
+ if (evaluationDate < reportDate)
103
+ rowErrors.push("evaluation_date precedes report_date");
104
+ }
105
+ if (rowErrors.length > 0) {
106
+ for (const message of rowErrors)
107
+ errors.push({ row: rowNumber, message });
108
+ continue;
109
+ }
110
+ claims.push({
111
+ claimId,
112
+ accidentDate: accidentDate,
113
+ reportDate: reportDate,
114
+ evaluationDate: evaluationDate,
115
+ paidToDate: paidToDate,
116
+ caseReserve: caseReserve,
117
+ status: status,
118
+ });
119
+ }
120
+ return { claims, errors };
121
+ }
122
+ //# sourceMappingURL=lossRun.js.map
@@ -0,0 +1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C,CAAC,WAAW,EAAE,CAAC;QAC/C,MAAM,MAAM,GACV,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QACpE,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,SAAS,CAAC,IAAI,CAAC,2CAA2C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAChF,CAAC;QAED,oEAAoE;QACpE,IAAI,YAAY,KAAK,IAAI,IAAI,UAAU,KAAK,IAAI,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC5E,IAAI,UAAU,GAAG,YAAY;gBAAE,SAAS,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;YACpF,IAAI,cAAc,GAAG,UAAU;gBAAE,SAAS,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QAC1F,CAAC;QAED,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,KAAK,MAAM,OAAO,IAAI,SAAS;gBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;YAC1E,SAAS;QACX,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,OAAO;YACP,YAAY,EAAE,YAAa;YAC3B,UAAU,EAAE,UAAW;YACvB,cAAc,EAAE,cAAe;YAC/B,UAAU,EAAE,UAAW;YACvB,WAAW,EAAE,WAAY;YACzB,MAAM,EAAE,MAAO;SAChB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { ClaimSnapshot, Triangle } from "@actuarial-ts/core";
2
+ /**
3
+ * ASOP No. 23 (Data Quality)-oriented data review.
4
+ *
5
+ * The report lists every check PERFORMED, not just the ones that found
6
+ * something — the actuary's disclosure needs "what was reviewed" as much as
7
+ * "what was found". A check that could not be evaluated (no as-of date; a
8
+ * triangle shape mismatch blocking cell comparisons) stays in the report
9
+ * with an explicit "not evaluated" detail so the disclosure never overstates
10
+ * the review.
11
+ *
12
+ * Severity philosophy:
13
+ * - "fail" = the data is wrong or internally inconsistent (negative paid,
14
+ * dates out of order, duplicate snapshots, paid > incurred).
15
+ * - "warning" = legitimate but rare/reportable (negative case reserves,
16
+ * salvage-driven negative incremental paid, closed claims
17
+ * still carrying case).
18
+ *
19
+ * These utilities are designed to support the actuary's compliance with
20
+ * ASOP No. 23; responsibility for compliance remains with the credentialed
21
+ * actuary.
22
+ */
23
+ export type DataCheckStatus = "pass" | "warning" | "fail" | "not-evaluated";
24
+ export interface DataCheck {
25
+ id: string;
26
+ description: string;
27
+ status: DataCheckStatus;
28
+ details: string[];
29
+ }
30
+ export interface DataReviewReport {
31
+ checks: DataCheck[];
32
+ summary: {
33
+ pass: number;
34
+ warning: number;
35
+ fail: number;
36
+ notEvaluated: number;
37
+ };
38
+ }
39
+ export interface ReviewClaimDataOptions {
40
+ /** ISO date; when given, any claim date after it fails "future-dated". */
41
+ asOfDate?: string;
42
+ }
43
+ /** Reviews claim-level snapshots against the ASOP 23-oriented check suite. */
44
+ export declare function reviewClaimData(claims: ClaimSnapshot[], opts?: ReviewClaimDataOptions): DataReviewReport;
45
+ /** Reviews a paid/incurred triangle pair for cross-triangle consistency. */
46
+ export declare function reviewTriangles(paid: Triangle, incurred: Triangle): DataReviewReport;
47
+ //# sourceMappingURL=review.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../src/review.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,eAAe,CAAC;AAE5E,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;CAChF;AAED,MAAM,WAAW,sBAAsB;IACrC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAkDD,8EAA8E;AAC9E,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,GAAE,sBAA2B,GAChC,gBAAgB,CAuFlB;AAqDD,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,CAuFpF"}
package/dist/review.js ADDED
@@ -0,0 +1,216 @@
1
+ /** At most this many offending items are listed per check, then "+N more". */
2
+ const MAX_DETAILS = 20;
3
+ function capDetails(items) {
4
+ if (items.length <= MAX_DETAILS)
5
+ return items;
6
+ return [...items.slice(0, MAX_DETAILS), `+${items.length - MAX_DETAILS} more`];
7
+ }
8
+ function makeCheck(id, description, statusWhenFound, findings) {
9
+ return {
10
+ id,
11
+ description,
12
+ status: findings.length > 0 ? statusWhenFound : "pass",
13
+ details: capDetails(findings),
14
+ };
15
+ }
16
+ function notEvaluated(id, description, reason) {
17
+ // A check that could not run is REPORTED as such - counting it as "pass"
18
+ // would overstate the review in the very disclosure this feeds.
19
+ return { id, description, status: "not-evaluated", details: [`not evaluated: ${reason}`] };
20
+ }
21
+ function summarize(checks) {
22
+ const summary = { pass: 0, warning: 0, fail: 0, notEvaluated: 0 };
23
+ for (const c of checks) {
24
+ if (c.status === "not-evaluated")
25
+ summary.notEvaluated++;
26
+ else
27
+ summary[c.status]++;
28
+ }
29
+ return { checks, summary };
30
+ }
31
+ const CLAIM_DESCRIPTIONS = {
32
+ "negative-paid": "Cumulative paid amounts are non-negative",
33
+ "negative-case": "Case reserves are non-negative (negative case is legitimate but rare)",
34
+ "paid-decreasing": "Cumulative paid never decreases across a claim's snapshots ordered by evaluation date",
35
+ "date-order": "accident_date <= report_date <= evaluation_date on every snapshot",
36
+ "duplicate-snapshot": "No claim has two snapshots at the same evaluation date",
37
+ "future-dated": "No claim date exceeds the as-of date",
38
+ "closed-with-case": "Closed claims carry no outstanding case reserve",
39
+ };
40
+ /** Reviews claim-level snapshots against the ASOP 23-oriented check suite. */
41
+ export function reviewClaimData(claims, opts = {}) {
42
+ const negativePaid = [];
43
+ const negativeCase = [];
44
+ const dateOrder = [];
45
+ const futureDated = [];
46
+ const closedWithCase = [];
47
+ claims.forEach((c, idx) => {
48
+ const where = `claim ${c.claimId} row ${idx + 1} (eval ${c.evaluationDate})`;
49
+ if (c.paidToDate < 0) {
50
+ negativePaid.push(`${where}: paid_to_date ${c.paidToDate}`);
51
+ }
52
+ if (c.caseReserve < 0) {
53
+ negativeCase.push(`${where}: case_reserve ${c.caseReserve}`);
54
+ }
55
+ if (c.reportDate < c.accidentDate) {
56
+ dateOrder.push(`${where}: report_date ${c.reportDate} precedes accident_date ${c.accidentDate}`);
57
+ }
58
+ if (c.evaluationDate < c.reportDate) {
59
+ dateOrder.push(`${where}: evaluation_date ${c.evaluationDate} precedes report_date ${c.reportDate}`);
60
+ }
61
+ if (opts.asOfDate !== undefined) {
62
+ const asOf = opts.asOfDate;
63
+ if (c.accidentDate > asOf) {
64
+ futureDated.push(`${where}: accident_date ${c.accidentDate} exceeds as-of ${asOf}`);
65
+ }
66
+ if (c.reportDate > asOf) {
67
+ futureDated.push(`${where}: report_date ${c.reportDate} exceeds as-of ${asOf}`);
68
+ }
69
+ if (c.evaluationDate > asOf) {
70
+ futureDated.push(`${where}: evaluation_date ${c.evaluationDate} exceeds as-of ${asOf}`);
71
+ }
72
+ }
73
+ if (c.status === "closed" && c.caseReserve > 0) {
74
+ closedWithCase.push(`${where}: case_reserve ${c.caseReserve} on a closed claim`);
75
+ }
76
+ });
77
+ // Per-claim timeline checks: duplicates and decreasing cumulative paid.
78
+ const byClaim = new Map();
79
+ for (const c of claims) {
80
+ const list = byClaim.get(c.claimId);
81
+ if (list)
82
+ list.push(c);
83
+ else
84
+ byClaim.set(c.claimId, [c]);
85
+ }
86
+ const paidDecreasing = [];
87
+ const duplicates = [];
88
+ for (const [claimId, snaps] of byClaim) {
89
+ const sorted = [...snaps].sort((a, b) => a.evaluationDate.localeCompare(b.evaluationDate));
90
+ const seenEvals = new Set();
91
+ for (const s of sorted) {
92
+ if (seenEvals.has(s.evaluationDate)) {
93
+ duplicates.push(`claim ${claimId}: duplicate snapshot at ${s.evaluationDate}`);
94
+ }
95
+ seenEvals.add(s.evaluationDate);
96
+ }
97
+ for (let k = 1; k < sorted.length; k++) {
98
+ const prev = sorted[k - 1];
99
+ const cur = sorted[k];
100
+ // Same-date pairs are the duplicate check's finding, not this one's.
101
+ if (cur.evaluationDate === prev.evaluationDate)
102
+ continue;
103
+ if (cur.paidToDate < prev.paidToDate) {
104
+ paidDecreasing.push(`claim ${claimId}: paid_to_date ${prev.paidToDate} -> ${cur.paidToDate} between ${prev.evaluationDate} and ${cur.evaluationDate}`);
105
+ }
106
+ }
107
+ }
108
+ const futureCheck = opts.asOfDate === undefined
109
+ ? notEvaluated("future-dated", CLAIM_DESCRIPTIONS["future-dated"], "no asOfDate provided")
110
+ : makeCheck("future-dated", CLAIM_DESCRIPTIONS["future-dated"], "fail", futureDated);
111
+ return summarize([
112
+ makeCheck("negative-paid", CLAIM_DESCRIPTIONS["negative-paid"], "fail", negativePaid),
113
+ makeCheck("negative-case", CLAIM_DESCRIPTIONS["negative-case"], "warning", negativeCase),
114
+ makeCheck("paid-decreasing", CLAIM_DESCRIPTIONS["paid-decreasing"], "fail", paidDecreasing),
115
+ makeCheck("date-order", CLAIM_DESCRIPTIONS["date-order"], "fail", dateOrder),
116
+ makeCheck("duplicate-snapshot", CLAIM_DESCRIPTIONS["duplicate-snapshot"], "fail", duplicates),
117
+ futureCheck,
118
+ makeCheck("closed-with-case", CLAIM_DESCRIPTIONS["closed-with-case"], "warning", closedWithCase),
119
+ ]);
120
+ }
121
+ const TRIANGLE_DESCRIPTIONS = {
122
+ "shape-mismatch": "Paid and incurred triangles share the same origins and ages",
123
+ "paid-exceeds-incurred": "Paid never exceeds incurred in any cell (1e-9 relative tolerance)",
124
+ "negative-incremental-paid": "Cumulative paid is non-decreasing along each origin row (salvage/subrogation can legitimately violate this)",
125
+ "negative-incremental-incurred": "Cumulative incurred is non-decreasing along each origin row (case takedowns can legitimately violate this)",
126
+ "interior-missing": "No row has a missing cell between observed cells",
127
+ };
128
+ /** Findings where a row's cumulative values decrease between observed cells. */
129
+ function negativeIncrementalFindings(tri) {
130
+ const out = [];
131
+ for (let i = 0; i < tri.values.length; i++) {
132
+ const row = tri.values[i];
133
+ let prev = null;
134
+ let prevAge = null;
135
+ for (let j = 0; j < row.length; j++) {
136
+ const v = row[j];
137
+ if (v === null || v === undefined)
138
+ continue;
139
+ const age = tri.ages[j];
140
+ if (prev !== null && v < prev) {
141
+ out.push(`${tri.kind} ${tri.origins[i]} age ${prevAge} -> ${age}: ${prev} -> ${v}`);
142
+ }
143
+ prev = v;
144
+ prevAge = age;
145
+ }
146
+ }
147
+ return out;
148
+ }
149
+ /** Findings for null cells with observed cells both before and after in the row. */
150
+ function interiorMissingFindings(tri) {
151
+ const out = [];
152
+ for (let i = 0; i < tri.values.length; i++) {
153
+ const row = tri.values[i];
154
+ const observed = row.map((v) => v !== null);
155
+ const first = observed.indexOf(true);
156
+ const last = observed.lastIndexOf(true);
157
+ if (first === -1)
158
+ continue;
159
+ for (let j = first + 1; j < last; j++) {
160
+ if (!observed[j]) {
161
+ out.push(`${tri.kind} ${tri.origins[i]} age ${tri.ages[j]}: interior cell missing`);
162
+ }
163
+ }
164
+ }
165
+ return out;
166
+ }
167
+ /** Reviews a paid/incurred triangle pair for cross-triangle consistency. */
168
+ export function reviewTriangles(paid, incurred) {
169
+ const shapeFindings = [];
170
+ const sameOrigins = paid.origins.length === incurred.origins.length &&
171
+ paid.origins.every((o, i) => o === incurred.origins[i]);
172
+ const sameAges = paid.ages.length === incurred.ages.length &&
173
+ paid.ages.every((a, j) => a === incurred.ages[j]);
174
+ if (!sameOrigins) {
175
+ shapeFindings.push(`origins differ: paid [${paid.origins.join(", ")}] vs incurred [${incurred.origins.join(", ")}]`);
176
+ }
177
+ if (!sameAges) {
178
+ shapeFindings.push(`ages differ: paid [${paid.ages.join(", ")}] vs incurred [${incurred.ages.join(", ")}]`);
179
+ }
180
+ const shapeCheck = makeCheck("shape-mismatch", TRIANGLE_DESCRIPTIONS["shape-mismatch"], "fail", shapeFindings);
181
+ if (shapeFindings.length > 0) {
182
+ // Cell-level comparisons are meaningless across mismatched grids; the
183
+ // remaining checks stay listed (disclosure) but are not evaluated.
184
+ const reason = "triangle shapes differ";
185
+ return summarize([
186
+ shapeCheck,
187
+ notEvaluated("paid-exceeds-incurred", TRIANGLE_DESCRIPTIONS["paid-exceeds-incurred"], reason),
188
+ notEvaluated("negative-incremental-paid", TRIANGLE_DESCRIPTIONS["negative-incremental-paid"], reason),
189
+ notEvaluated("negative-incremental-incurred", TRIANGLE_DESCRIPTIONS["negative-incremental-incurred"], reason),
190
+ notEvaluated("interior-missing", TRIANGLE_DESCRIPTIONS["interior-missing"], reason),
191
+ ]);
192
+ }
193
+ const paidExceeds = [];
194
+ for (let i = 0; i < paid.values.length; i++) {
195
+ const paidRow = paid.values[i];
196
+ const incRow = incurred.values[i];
197
+ for (let j = 0; j < paidRow.length; j++) {
198
+ const p = paidRow[j];
199
+ const inc = incRow[j];
200
+ if (p === null || p === undefined || inc === null || inc === undefined)
201
+ continue;
202
+ const tolerance = 1e-9 * Math.max(1, Math.abs(p), Math.abs(inc));
203
+ if (p - inc > tolerance) {
204
+ paidExceeds.push(`${paid.origins[i]} age ${paid.ages[j]}: paid ${p} > incurred ${inc}`);
205
+ }
206
+ }
207
+ }
208
+ return summarize([
209
+ shapeCheck,
210
+ makeCheck("paid-exceeds-incurred", TRIANGLE_DESCRIPTIONS["paid-exceeds-incurred"], "fail", paidExceeds),
211
+ makeCheck("negative-incremental-paid", TRIANGLE_DESCRIPTIONS["negative-incremental-paid"], "warning", negativeIncrementalFindings(paid)),
212
+ makeCheck("negative-incremental-incurred", TRIANGLE_DESCRIPTIONS["negative-incremental-incurred"], "warning", negativeIncrementalFindings(incurred)),
213
+ makeCheck("interior-missing", TRIANGLE_DESCRIPTIONS["interior-missing"], "warning", [...interiorMissingFindings(paid), ...interiorMissingFindings(incurred)]),
214
+ ]);
215
+ }
216
+ //# sourceMappingURL=review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.js","sourceRoot":"","sources":["../src/review.ts"],"names":[],"mappings":"AA2CA,8EAA8E;AAC9E,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB,SAAS,UAAU,CAAC,KAAe;IACjC,IAAI,KAAK,CAAC,MAAM,IAAI,WAAW;QAAE,OAAO,KAAK,CAAC;IAC9C,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,IAAI,KAAK,CAAC,MAAM,GAAG,WAAW,OAAO,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,SAAS,CAChB,EAAU,EACV,WAAmB,EACnB,eAAmC,EACnC,QAAkB;IAElB,OAAO;QACL,EAAE;QACF,WAAW;QACX,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM;QACtD,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC;KAC9B,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,EAAU,EAAE,WAAmB,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AQ,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;QACf,UAAU;QACV,SAAS,CACP,uBAAuB,EACvB,qBAAqB,CAAC,uBAAuB,CAAC,EAC9C,MAAM,EACN,WAAW,CACZ;QACD,SAAS,CACP,2BAA2B,EAC3B,qBAAqB,CAAC,2BAA2B,CAAC,EAClD,SAAS,EACT,2BAA2B,CAAC,IAAI,CAAC,CAClC;QACD,SAAS,CACP,+BAA+B,EAC/B,qBAAqB,CAAC,+BAA+B,CAAC,EACtD,SAAS,EACT,2BAA2B,CAAC,QAAQ,CAAC,CACtC;QACD,SAAS,CACP,kBAAkB,EAClB,qBAAqB,CAAC,kBAAkB,CAAC,EACzC,SAAS,EACT,CAAC,GAAG,uBAAuB,CAAC,IAAI,CAAC,EAAE,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CACzE;KACF,CAAC,CAAC;AACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@actuarial-ts/data",
3
+ "version": "0.1.0",
4
+ "description": "Data ingestion and ASOP No. 23 data-quality review for the actuarial-ts SDK: RFC 4180 CSV parsing, loss-run import, long-format triangle assembly, and claim/triangle review checks.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE",
20
+ "NOTICE"
21
+ ],
22
+ "sideEffects": false,
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/yerromnitsuj/actng.git",
29
+ "directory": "packages/data"
30
+ },
31
+ "keywords": [
32
+ "actuarial",
33
+ "reserving",
34
+ "loss-run",
35
+ "csv",
36
+ "triangle",
37
+ "data-quality",
38
+ "asop-23",
39
+ "insurance",
40
+ "property-casualty"
41
+ ],
42
+ "scripts": {
43
+ "build": "tsc -p tsconfig.build.json",
44
+ "test": "vitest run",
45
+ "test:watch": "vitest",
46
+ "typecheck": "tsc --noEmit",
47
+ "prepack": "tsc -p tsconfig.build.json"
48
+ },
49
+ "dependencies": {
50
+ "@actuarial-ts/core": "^0.1.0"
51
+ },
52
+ "devDependencies": {
53
+ "typescript": "^5.7.3",
54
+ "vitest": "^3.0.5"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ }
59
+ }