@happyvertical/smrt-expenses 0.61.3 → 0.61.5
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/dist/chunks/{ExpenseReceiptCollection-CaVPOnIl.js → ExpenseReceiptCollection-B-ESJn1g.js} +8 -3
- package/dist/chunks/ExpenseReceiptCollection-B-ESJn1g.js.map +1 -0
- package/dist/chunks/{expense-actions-B6A8fu37.js → expense-actions-C_Y7CrnB.js} +2 -2
- package/dist/chunks/{expense-actions-B6A8fu37.js.map → expense-actions-C_Y7CrnB.js.map} +1 -1
- package/dist/expense-allocation.d.ts.map +1 -1
- package/dist/index.js +21 -16
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +2607 -2275
- package/dist/models/ExpenseAllocation.d.ts +2 -2
- package/dist/models/ExpenseAllocation.d.ts.map +1 -1
- package/dist/models/ExpenseReceipt.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +1032 -1030
- package/package.json +9 -9
- package/dist/chunks/ExpenseReceiptCollection-CaVPOnIl.js.map +0 -1
package/dist/chunks/{ExpenseReceiptCollection-CaVPOnIl.js → ExpenseReceiptCollection-B-ESJn1g.js}
RENAMED
|
@@ -183,16 +183,21 @@ __publicField$1(ExpenseReceipt, "__smrtPackage__", "@happyvertical/smrt-expenses
|
|
|
183
183
|
__decorateClass$1([tenantId({ nullable: true })], ExpenseReceipt.prototype, "tenantId", 2);
|
|
184
184
|
__decorateClass$1([foreignKey(Expense, {
|
|
185
185
|
required: true,
|
|
186
|
+
requiredFor: "identity",
|
|
186
187
|
onDelete: "CASCADE"
|
|
187
188
|
})], ExpenseReceipt.prototype, "expenseId", 2);
|
|
188
|
-
__decorateClass$1([crossPackageRef("@happyvertical/smrt-assets:Asset", {
|
|
189
|
+
__decorateClass$1([crossPackageRef("@happyvertical/smrt-assets:Asset", {
|
|
190
|
+
required: true,
|
|
191
|
+
requiredFor: "identity"
|
|
192
|
+
})], ExpenseReceipt.prototype, "assetId", 2);
|
|
189
193
|
__decorateClass$1([crossPackageRef("@happyvertical/smrt-profiles:Profile")], ExpenseReceipt.prototype, "uploadedByProfileId", 2);
|
|
190
194
|
__decorateClass$1([field({ type: "text" })], ExpenseReceipt.prototype, "filename", 2);
|
|
191
195
|
__decorateClass$1([field({ type: "text" })], ExpenseReceipt.prototype, "mimeType", 2);
|
|
192
196
|
__decorateClass$1([field({ type: "integer" })], ExpenseReceipt.prototype, "byteCount", 2);
|
|
193
197
|
__decorateClass$1([field({
|
|
194
198
|
type: "text",
|
|
195
|
-
required: true
|
|
199
|
+
required: true,
|
|
200
|
+
requiredFor: "identity"
|
|
196
201
|
})], ExpenseReceipt.prototype, "contentSha256", 2);
|
|
197
202
|
ExpenseReceipt = __decorateClass$1([TenantScoped({ mode: "optional" }), smrt({
|
|
198
203
|
tableName: "expense_receipts",
|
|
@@ -335,4 +340,4 @@ ExpenseReceiptCollection = __decorateClass([smrt({
|
|
|
335
340
|
//#endregion
|
|
336
341
|
export { ExpenseReceipt as n, __exportAll as r, ExpenseReceiptCollection as t };
|
|
337
342
|
|
|
338
|
-
//# sourceMappingURL=ExpenseReceiptCollection-
|
|
343
|
+
//# sourceMappingURL=ExpenseReceiptCollection-B-ESJn1g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpenseReceiptCollection-B-ESJn1g.js","names":[],"sources":["../../src/models/ExpenseReceipt.ts","../../src/collections/ExpenseReceiptCollection.ts"],"sourcesContent":["/**\n * ExpenseReceipt — the expense-owned join between an {@link Expense} and the\n * smrt-assets `Asset` that proves it.\n *\n * @packageDocumentation\n */\n\nimport { AssetCollection } from '@happyvertical/smrt-assets';\nimport {\n classifyDatabaseError,\n crossPackageRef,\n field,\n foreignKey,\n isPostgresDatabase,\n isUniqueViolationError,\n SmrtObject,\n type SmrtSaveOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport {\n DuplicateReceiptError,\n ExpenseError,\n type ExpenseReceiptOptions,\n} from '../types.js';\nimport {\n assertMinorUnits,\n effectiveTenant,\n identityConflict,\n normalizeSha256,\n normalizeTenantId,\n pinNaturalKey,\n} from '../validation.js';\nimport { Expense } from './Expense.js';\n\n/**\n * The unique index that refuses a second copy of a file on one expense. Kept\n * in step with the literal in the `@smrt()` indexes below (the scanner reads\n * that literal); the PostgreSQL schema test asserts the name.\n */\nconst RECEIPT_FILE_KEY = 'expense_receipts_expense_sha256_key';\n\n/** The columns of {@link RECEIPT_FILE_KEY}; no other unique key uses them. */\nconst RECEIPT_FILE_COLUMNS = new Set(['expense_id', 'content_sha256']);\n\n/**\n * The columns a unique violation reports. Core's typed write error carries\n * them in `details.fieldName` (recovered from PostgreSQL's\n * `Key (expense_id, content_sha256)=…` detail, or SQLite's column list) but\n * not the driver error itself, so this is where the violated key is named.\n */\nfunction violatedColumns(error: unknown): string[] {\n const details = (error as { details?: { fieldName?: unknown } } | null)\n ?.details;\n const fieldName =\n typeof details?.fieldName === 'string' ? details.fieldName : '';\n return fieldName\n .split(',')\n .map((column) => column.trim())\n .filter(Boolean);\n}\n\n/**\n * Columns a receipt keeps for life: it is evidence, not a draft. The tenant\n * is among them because it is derived from the expense on insert; letting a\n * later save (e.g. one without tenant context) change it would split the\n * receipt from its expense's tenant.\n */\nconst IMMUTABLE = [\n ['tenantId', 'tenant_id'],\n ['expenseId', 'expense_id'],\n ['assetId', 'asset_id'],\n ['contentSha256', 'content_sha256'],\n] as const;\n\n/**\n * A receipt file attached to an expense.\n *\n * Asset ownership uses a noun-specific join (`expense_receipts`), not the\n * generic `AssetAssociation`. The file's SHA-256 is stored so:\n *\n * - the same file attached twice to one expense is refused — a unique index\n * on `(expense_id, content_sha256)` plus a pre-insert check that raises\n * {@link DuplicateReceiptError}. The index leaves `tenant_id` out on\n * purpose: an expense belongs to exactly one tenant, so the key is already\n * tenant-scoped, and a NULL tenant would otherwise make every global row\n * distinct and the index unenforced;\n * - the same file on two different expenses is allowed, and surfaced for a\n * person to look at by `ExpenseReceiptCollection.findDuplicateReceipts()`.\n *\n * Attaching a receipt never changes the expense's review state. The receipt\n * takes its tenant from the expense, and its asset must be visible in that\n * tenant. The generated surface is closed, like {@link Expense}'s.\n */\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableName: 'expense_receipts',\n api: { include: [] },\n mcp: { include: [] },\n cli: false,\n indexes: [\n {\n name: 'expense_receipts_expense_sha256_key',\n columns: ['expenseId', 'contentSha256'],\n unique: true,\n },\n {\n name: 'expense_receipts_tenant_sha256_idx',\n columns: ['tenantId', 'contentSha256'],\n },\n ],\n})\nexport class ExpenseReceipt extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n /** Owning tenant; always the expense's tenant. */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /** The expense this receipt proves. Deleting the expense removes the link. */\n @foreignKey(Expense, {\n required: true,\n requiredFor: 'identity',\n onDelete: 'CASCADE',\n })\n expenseId: string = '';\n\n /** The smrt-assets `Asset` holding the file. */\n @crossPackageRef('@happyvertical/smrt-assets:Asset', {\n required: true,\n requiredFor: 'identity',\n })\n assetId: string = '';\n\n /** Profile that uploaded the file. */\n @crossPackageRef('@happyvertical/smrt-profiles:Profile')\n uploadedByProfileId: string | null = null;\n\n /** Original filename as uploaded. */\n @field({ type: 'text' })\n filename: string = '';\n\n /** MIME type of the file. */\n @field({ type: 'text' })\n mimeType: string = '';\n\n /** Size of the file in bytes. */\n @field({ type: 'integer' })\n byteCount: number = 0;\n\n /** Lowercase hex SHA-256 of the file's bytes. */\n @field({ type: 'text', required: true, requiredFor: 'identity' })\n contentSha256: string = '';\n\n constructor(options: ExpenseReceiptOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.expenseId !== undefined) this.expenseId = options.expenseId;\n if (options.assetId !== undefined) this.assetId = options.assetId;\n if (options.uploadedByProfileId !== undefined)\n this.uploadedByProfileId = options.uploadedByProfileId;\n if (options.filename !== undefined) this.filename = options.filename;\n if (options.mimeType !== undefined) this.mimeType = options.mimeType;\n if (options.byteCount !== undefined) this.byteCount = options.byteCount;\n if (options.contentSha256 !== undefined)\n this.contentSha256 = options.contentSha256;\n }\n\n /**\n * Validate the link, refuse a second copy of the same file on the same\n * expense, then persist. Never touches the expense.\n *\n * @throws {DuplicateReceiptError} when the expense already has this file.\n * @throws {ExpenseError} `EXPENSE_RECEIPT_INVALID` for a bad hash, a\n * missing or foreign-tenant expense or asset, or a change to an\n * immutable column.\n */\n override async save(options?: SmrtSaveOptions): Promise<this> {\n return this.withTransaction(() => this.saveValidated(options));\n }\n\n private async saveValidated(options?: SmrtSaveOptions): Promise<this> {\n const label = this.id || '<new>';\n this.tenantId = normalizeTenantId(this.tenantId);\n this.contentSha256 = normalizeSha256(\n 'ExpenseReceipt',\n label,\n this.contentSha256,\n );\n assertMinorUnits(\n 'ExpenseReceipt',\n label,\n 'byteCount',\n this.byteCount,\n 'EXPENSE_RECEIPT_INVALID',\n );\n if (!this.expenseId || !this.assetId) {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n `ExpenseReceipt ${label}: expenseId and assetId are required.`,\n );\n }\n\n await this.assertUnallocatedSource();\n const persisted = this.id\n ? (((await this.db.get(this.tableName, { id: this.id })) as\n | Record<string, unknown>\n | undefined\n | null) ?? null)\n : null;\n // The checks below are against `persisted`; pin the write to that row.\n const inserting = await pinNaturalKey('ExpenseReceipt', this, persisted);\n if (persisted) {\n const self = this as unknown as Record<string, unknown>;\n for (const [fieldName, column] of IMMUTABLE) {\n // The tenant is compared as it will be written: an empty tenantId\n // saved inside a tenant context is filled in by the interceptor.\n const value =\n fieldName === 'tenantId'\n ? effectiveTenant(this.tenantId)\n : self[fieldName];\n if (String(persisted[column] ?? '') !== String(value ?? '')) {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n `ExpenseReceipt ${this.id}: ${fieldName} cannot change; attach ` +\n 'a new receipt instead.',\n );\n }\n }\n } else {\n await this.assertLinkTargets(label);\n await this.assertNotDuplicate();\n }\n\n try {\n return await super.save(options);\n } catch (error) {\n if (inserting && isUniqueViolationError(error)) {\n throw await this.classifyInsertConflict(error);\n }\n throw error;\n }\n }\n\n /**\n * A refused INSERT is either the same file racing onto the same expense,\n * or a natural-key collision with another receipt.\n *\n * Classified from the error first, by the violated key's name or columns\n * (no other unique key on this table uses `expense_id` or\n * `content_sha256`). That matters inside a caller's transaction,\n * which the violation has already aborted on PostgreSQL, so nothing could\n * be re-read there. Only an adapter that reports neither falls back to a\n * re-read; if that re-read fails too, the original error is kept rather\n * than guessed at.\n */\n /** Allocation review freezes the original receipt graph as provenance. */\n private async assertUnallocatedSource(): Promise<void> {\n const { ExpenseCollection } = await import(\n '../collections/ExpenseCollection.js'\n );\n const source = await (await ExpenseCollection.create({ db: this.db })).get(\n { id: this.expenseId },\n { cache: false },\n );\n if (source) {\n if (isPostgresDatabase(this.db))\n await this.db.query(\n `SELECT id FROM expenses WHERE id = ? AND tenant_id IS NOT DISTINCT FROM ? FOR UPDATE`,\n source.id,\n source.tenantId,\n );\n await source.loadFromId();\n const historicalAllocation =\n !source.activeAllocationRevisionId &&\n (await this.db.tableExists('expense_allocation_revisions'))\n ? await this.db.get('expense_allocation_revisions', {\n source_expense_id: source.id,\n tenant_id: source.tenantId,\n })\n : null;\n if (source.activeAllocationRevisionId || historicalAllocation)\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n 'Allocated expense receipt evidence is immutable.',\n );\n }\n }\n\n /** Preserve reviewed allocation provenance through model and junction deletion. */\n override async delete(\n options: { expectedUpdatedAt?: Date | string } = {},\n ): Promise<void> {\n return this.withTransaction(async () => {\n const persisted = this.id\n ? await this.db.get(this.tableName, { id: this.id })\n : null;\n if (persisted) {\n const originalId = this.expenseId;\n this.expenseId = String(persisted.expense_id);\n try {\n await this.assertUnallocatedSource();\n } finally {\n this.expenseId = originalId;\n }\n }\n await super.delete(options);\n });\n }\n\n private async classifyInsertConflict(error: unknown): Promise<unknown> {\n const info = classifyDatabaseError(error);\n const columns = violatedColumns(error);\n if (\n info.constraint === RECEIPT_FILE_KEY ||\n info.driverMessages.some((text) => text.includes(RECEIPT_FILE_KEY)) ||\n columns.some((column) => RECEIPT_FILE_COLUMNS.has(column))\n ) {\n return new DuplicateReceiptError(this.expenseId, this.contentSha256, {\n cause: error,\n });\n }\n if (info.constraint || columns.length > 0) {\n // Another named key: the natural key or the primary key.\n return identityConflict('ExpenseReceipt', this, error);\n }\n try {\n await this.assertNotDuplicate();\n } catch (duplicate) {\n if (duplicate instanceof DuplicateReceiptError) {\n return new DuplicateReceiptError(this.expenseId, this.contentSha256, {\n cause: error,\n });\n }\n return error;\n }\n return identityConflict('ExpenseReceipt', this, error);\n }\n\n private async assertLinkTargets(label: string): Promise<void> {\n const { ExpenseCollection } = await import(\n '../collections/ExpenseCollection.js'\n );\n const expenses = await ExpenseCollection.create({ db: this.db });\n const expense = await expenses.get({ id: this.expenseId });\n if (!expense) {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n `ExpenseReceipt ${label}: expense ${this.expenseId} was not found.`,\n );\n }\n if (this.tenantId === null || this.tenantId === undefined) {\n this.tenantId = expense.tenantId ?? null;\n }\n if ((this.tenantId ?? null) !== (expense.tenantId ?? null)) {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n `ExpenseReceipt ${label}: a receipt belongs to its expense's tenant.`,\n );\n }\n\n const assets = await AssetCollection.create({ db: this.db });\n const asset = await assets.get({ id: this.assetId });\n const assetTenant = asset?.tenantId ?? null;\n if (!asset || (assetTenant !== null && assetTenant !== this.tenantId)) {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n `ExpenseReceipt ${label}: asset ${this.assetId} was not found in ` +\n \"the expense's tenant.\",\n );\n }\n if (!this.filename) this.filename = asset.name ?? '';\n if (!this.mimeType) this.mimeType = asset.mimeType ?? '';\n }\n\n private async assertNotDuplicate(): Promise<void> {\n const { ExpenseReceiptCollection } = await import(\n '../collections/ExpenseReceiptCollection.js'\n );\n const receipts = await ExpenseReceiptCollection.create({ db: this.db });\n const existing = await receipts.list({\n where: {\n expenseId: this.expenseId,\n contentSha256: this.contentSha256,\n },\n limit: 1,\n });\n if (existing.length > 0) {\n throw new DuplicateReceiptError(this.expenseId, this.contentSha256);\n }\n }\n}\n","/**\n * ExpenseReceiptCollection — attach receipts and find files shared between\n * expenses.\n *\n * @packageDocumentation\n */\n\nimport {\n type JunctionAttachOptions,\n SmrtJunction,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { ExpenseReceipt } from '../models/ExpenseReceipt.js';\nimport {\n type AttachReceiptInput,\n type DuplicateReceiptGroup,\n ExpenseError,\n type FindDuplicateReceiptsOptions,\n} from '../types.js';\n\nconst DEFAULT_DUPLICATE_LIMIT = 100;\nconst MAX_DUPLICATE_LIMIT = 1000;\n\n/**\n * Junction collection over `expense_receipts` (left: expense, right: asset).\n * Reads go through the normal tenant interceptors.\n *\n * Writes: {@link attachReceipt} adds a receipt; the inherited `detach()`\n * removes one (an explicit act; the asset itself is kept). The inherited\n * `attach()` and `setLinks()` are refused because they cannot carry the\n * content hash and `setLinks()` deletes before it writes.\n *\n * Collection classes are registered too, so this one carries its own closed\n * surface; without it every public method here would become an MCP tool.\n */\n@smrt({ api: { include: [] }, mcp: { include: [] }, cli: false })\nexport class ExpenseReceiptCollection extends SmrtJunction<ExpenseReceipt> { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n static readonly _itemClass = ExpenseReceipt;\n protected leftField = 'expenseId';\n protected rightField = 'assetId';\n protected override sortField: string | null = 'createdAt';\n protected override positionField: string | null = null;\n\n /**\n * Attach a receipt file to an expense.\n *\n * Does not change the expense in any way — in particular not its review\n * state.\n *\n * @throws {DuplicateReceiptError} when this expense already carries a file\n * with the same SHA-256.\n */\n async attachReceipt(input: AttachReceiptInput): Promise<ExpenseReceipt> {\n const receipt = await this.create({\n expenseId: input.expenseId,\n assetId: input.assetId,\n contentSha256: input.contentSha256,\n uploadedByProfileId: input.uploadedByProfileId ?? null,\n filename: input.filename ?? '',\n mimeType: input.mimeType ?? '',\n byteCount: input.byteCount ?? 0,\n });\n await receipt.save();\n return receipt;\n }\n\n /**\n * Refused: a receipt is evidence and needs its content hash, which a\n * generic junction attach does not carry. Use {@link attachReceipt}.\n *\n * @throws {ExpenseError} `EXPENSE_RECEIPT_INVALID`, always.\n */\n override async attach(\n _expenseId: string,\n _assetId: string,\n _opts: JunctionAttachOptions = {},\n ): Promise<ExpenseReceipt> {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n 'ExpenseReceiptCollection.attach() is not supported: use ' +\n 'attachReceipt(), which records and checks the file hash.',\n );\n }\n\n /**\n * Refused before anything is deleted. The inherited replace-all deletes\n * every receipt of the expense and re-attaches without hashes, which would\n * lose the evidence. Attach with {@link attachReceipt}; remove a link with\n * `detach()`.\n *\n * @throws {ExpenseError} `EXPENSE_RECEIPT_INVALID`, always.\n */\n override async setLinks(\n _expenseId: string,\n _assetIds: string[],\n _opts: JunctionAttachOptions = {},\n ): Promise<void> {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n 'ExpenseReceiptCollection.setLinks() is not supported: it would delete ' +\n 'receipt evidence. Use attachReceipt() to add and detach() to remove.',\n );\n }\n\n /** Receipts of one expense, oldest first. */\n async receiptsFor(expenseId: string): Promise<ExpenseReceipt[]> {\n return this.byLeft(expenseId);\n }\n\n /**\n * Files (by SHA-256) attached to more than one expense, for a person to\n * review. Nothing is changed or rejected: the same receipt on two expenses\n * may be a split cost or a double claim, and only a reviewer can tell.\n *\n * With `expenseId`, reports only files that expense shares with others;\n * without it, scans the visible tenant (largest groups first).\n */\n async findDuplicateReceipts(\n options: FindDuplicateReceiptsOptions = {},\n ): Promise<DuplicateReceiptGroup[]> {\n const limit = Math.min(\n Math.max(Math.trunc(options.limit ?? DEFAULT_DUPLICATE_LIMIT), 1),\n MAX_DUPLICATE_LIMIT,\n );\n\n let hashes: string[];\n if (options.expenseId) {\n const own = await this.byLeft(options.expenseId);\n hashes = [...new Set(own.map((receipt) => receipt.contentSha256))];\n } else {\n const [facet] = await this.facets({\n fields: [{ field: 'contentSha256', limit: MAX_DUPLICATE_LIMIT }],\n });\n // One row per (expense, hash) is enforced, so count > 1 means the\n // hash sits on more than one expense.\n // Already only shared hashes (largest groups first), so limiting the\n // hashes here limits the groups.\n hashes = (facet?.values ?? [])\n .filter((value) => value.count > 1)\n .map((value) => String(value.value))\n .slice(0, limit);\n }\n // The expense's own hashes include its unique receipts, so the limit is\n // applied to the groups below, after unshared hashes are dropped.\n if (hashes.length === 0) return [];\n\n const rows = await this.list({\n where: { contentSha256: hashes },\n orderBy: ['content_sha256 ASC', 'created_at ASC'],\n });\n const byHash = new Map<string, ExpenseReceipt[]>();\n for (const receipt of rows) {\n const group = byHash.get(receipt.contentSha256) ?? [];\n group.push(receipt);\n byHash.set(receipt.contentSha256, group);\n }\n\n const groups: DuplicateReceiptGroup[] = [];\n for (const [contentSha256, receipts] of byHash) {\n const expenseIds = [\n ...new Set(receipts.map((receipt) => receipt.expenseId)),\n ].sort();\n if (expenseIds.length < 2) continue;\n groups.push({ contentSha256, expenseIds, receipts });\n }\n groups.sort(\n (a, b) =>\n b.expenseIds.length - a.expenseIds.length ||\n a.contentSha256.localeCompare(b.contentSha256),\n );\n return groups.slice(0, limit);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAM,mBAAmB;AAGzB,IAAM,uCAAuB,IAAI,IAAI,CAAC,cAAc,gBAAgB,CAAC;AAQrE,SAAS,gBAAgB,OAA0B;CACjD,MAAM,UAAW,OACb;CAGJ,QADE,OAAO,SAAS,cAAc,WAAW,QAAQ,YAAY,GAAA,CAE5D,MAAM,GAAG,CAAA,CACT,KAAK,WAAW,OAAO,KAAK,CAAC,CAAA,CAC7B,OAAO,OAAO;AACnB;AAQA,IAAM,YAAY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Q,eAAe,KAAK;EACzC;EAEA,MAAM,SAAkC,CAAC;EACzC,KAAA,MAAW,CAAC,eAAe,aAAa,QAAQ;GAC9C,MAAM,aAAa,CACjB,GAAG,IAAI,IAAI,SAAS,KAAK,YAAY,QAAQ,SAAS,CAAC,CACzD,CAAA,CAAE,KAAK;GACP,IAAI,WAAW,SAAS,GAAG;GAC3B,OAAO,KAAK;IAAE;IAAe;IAAY;GAAS,CAAC;EACrD;EACA,OAAO,MACJ,GAAG,MACF,EAAE,WAAW,SAAS,EAAE,WAAW,UACnC,EAAE,cAAc,cAAc,EAAE,aAAa,CACjD;EACA,OAAO,OAAO,MAAM,GAAG,KAAK;CAC9B;AACF;AAxI6E,cAAhE,0BAAuE,mBAAkB,8BAAA;AACpG,cADW,0BACK,cAAa,cAAA;AADlB,2BAAN,gBAAA,CADN,KAAK;CAAE,KAAK,EAAE,SAAS,CAAC,EAAE;CAAG,KAAK,EAAE,SAAS,CAAC,EAAE;CAAG,KAAK;AAAM,CAAC,CAAA,GACnD,wBAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ExpenseReceiptCollection } from "./ExpenseReceiptCollection-
|
|
1
|
+
import { t as ExpenseReceiptCollection } from "./ExpenseReceiptCollection-B-ESJn1g.js";
|
|
2
2
|
import { i as withActionPrincipal, n as authorizeExpenseAction, r as principalHolds, t as ExpenseActionError } from "./principal-_1CdcvvW.js";
|
|
3
3
|
import { ExpenseError } from "../types.js";
|
|
4
4
|
//#region src/actions/expense-actions.ts
|
|
@@ -134,4 +134,4 @@ async function markExpenseReimbursedAction(expenses, input) {
|
|
|
134
134
|
//#endregion
|
|
135
135
|
export { attachExpenseReceiptAction, markExpenseReimbursedAction, recordExpenseAction, reviewExpenseAction };
|
|
136
136
|
|
|
137
|
-
//# sourceMappingURL=expense-actions-
|
|
137
|
+
//# sourceMappingURL=expense-actions-C_Y7CrnB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expense-actions-B6A8fu37.js","names":[],"sources":["../../src/actions/expense-actions.ts"],"sourcesContent":["/**\n * Service-backed write actions for `Expense` and `ExpenseReceipt` (#4001).\n *\n * The generated CRUD surface stays closed: these are the only generated\n * writes, and each delegates to the existing domain flow — `Expense.save()`\n * with its review lock and refund/commitment/vendor guards, the method-only\n * `review()` / `reject()` / `markReimbursed()`, and\n * `ExpenseReceiptCollection.attachReceipt()` with its hash deduplication.\n * The thin `ExpenseCollection` methods call in here.\n */\nimport type { SmrtClassOptions } from '@happyvertical/smrt-core';\nimport type { ExpenseCollection } from '../collections/ExpenseCollection.js';\nimport { ExpenseReceiptCollection } from '../collections/ExpenseReceiptCollection.js';\nimport type { Expense } from '../models/Expense.js';\nimport type { ExpenseReceipt } from '../models/ExpenseReceipt.js';\nimport {\n ExpenseError,\n type ExpenseErrorCode,\n type ExpenseFinancialBreakdown,\n type ExpensePayer,\n} from '../types.js';\nimport {\n authorizeExpenseAction,\n ExpenseActionError,\n type ExpenseActionPrincipal,\n principalHolds,\n withActionPrincipal,\n} from './principal.js';\n\n/** Body of the `record` action. Tenant and recorder come from the session. */\nexport interface RecordExpenseActionInput {\n costObjectType?: string;\n costObjectId?: string;\n category?: string;\n description?: string;\n /** Integer minor units of `currency`. */\n amount: number;\n currency: string;\n /** `YYYY-MM-DD`. */\n incurredOn: string;\n paidBy?: ExpensePayer;\n /** Defaults to the signed-in person when `paidBy` is `person`. */\n paidByProfileId?: string | null;\n paidByName?: string | null;\n vendorId?: string | null;\n commitmentId?: string | null;\n commitmentLineId?: string | null;\n refundOfId?: string | null;\n reimbursable?: boolean;\n financialBreakdown?: ExpenseFinancialBreakdown | null;\n}\n\n/** Body of the `attachReceipt` action. */\nexport interface AttachExpenseReceiptActionInput {\n expenseId: string;\n assetId: string;\n contentSha256: string;\n filename?: string;\n mimeType?: string;\n byteCount?: number;\n}\n\n/** Body of the `recordReview` action. */\nexport interface ReviewExpenseActionInput {\n expenseId: string;\n /** `approve` accepts the cost; `reject` refuses it and needs a `reason`. */\n decision: 'approve' | 'reject';\n note?: string;\n reason?: string;\n}\n\n/** Body of the `recordReimbursement` action. */\nexport interface MarkExpenseReimbursedActionInput {\n expenseId: string;\n /** Optional expected full remaining reimbursement in minor units. */\n amount?: number;\n /** Payroll line, payables reference, or transfer id of the payback. */\n reference?: string;\n}\n\n/** `record` fields copied onto the new expense; everything else is ignored. */\nconst RECORD_FIELDS = [\n 'costObjectType',\n 'costObjectId',\n 'category',\n 'description',\n 'amount',\n 'currency',\n 'incurredOn',\n 'paidByName',\n 'vendorId',\n 'commitmentId',\n 'commitmentLineId',\n 'refundOfId',\n 'reimbursable',\n] as const;\n\nconst CONFLICT_CODES = new Set<ExpenseErrorCode>([\n 'EXPENSE_REVIEW_TRANSITION',\n 'EXPENSE_REVIEW_FIELDS_LOCKED',\n 'EXPENSE_IDENTITY_CONFLICT',\n 'EXPENSE_RECEIPT_DUPLICATE',\n]);\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n 'The action body must be a JSON object.',\n );\n }\n return value as Record<string, unknown>;\n}\n\nfunction optionalString(\n body: Record<string, unknown>,\n key: string,\n): string | undefined {\n const value = body[key];\n if (value === undefined || value === null) return undefined;\n if (typeof value !== 'string') {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n `${key} must be a string.`,\n );\n }\n return value;\n}\n\nfunction requiredString(body: Record<string, unknown>, key: string): string {\n const value = optionalString(body, key)?.trim();\n if (!value) {\n throw new ExpenseActionError(400, 'invalid_request', `${key} is required.`);\n }\n return value;\n}\n\n/** Domain refusals become 4xx with their stable code; others pass through. */\nasync function domainCall<T>(fn: () => Promise<T>): Promise<T> {\n try {\n return await fn();\n } catch (error) {\n if (error instanceof ExpenseError) {\n throw new ExpenseActionError(\n CONFLICT_CODES.has(error.code) ? 409 : 400,\n error.code,\n error.message,\n );\n }\n throw error;\n }\n}\n\nfunction itemClass(expenses: ExpenseCollection) {\n return (expenses.constructor as unknown as { _itemClass: unknown })\n ._itemClass as typeof Expense;\n}\n\nfunction options(expenses: ExpenseCollection): SmrtClassOptions {\n return expenses.options;\n}\n\nasync function loadExpense(\n expenses: ExpenseCollection,\n principal: ExpenseActionPrincipal,\n body: Record<string, unknown>,\n): Promise<Expense> {\n const expenseId = requiredString(body, 'expenseId');\n const expense = await expenses.get({ id: expenseId });\n // Optional tenancy also admits global (NULL-tenant) rows in a tenant\n // context; a write must land on the principal's own tenant only.\n if (!expense || (expense.tenantId ?? null) !== principal.tenantId) {\n throw new ExpenseActionError(\n 404,\n 'not_found',\n `Expense ${expenseId} was not found.`,\n );\n }\n return expense;\n}\n\n/**\n * `record`: a new `unreviewed` expense, recorded by the signed-in person in\n * their tenant. Review, reimbursement and duplicate fields are never taken\n * from the body. Paying on someone else's behalf needs `expenses.recordReview`.\n */\nexport async function recordExpenseAction(\n expenses: ExpenseCollection,\n input: unknown,\n): Promise<Expense> {\n const body = asRecord(input);\n const principal = await authorizeExpenseAction(\n itemClass(expenses),\n 'record',\n options(expenses),\n { allowSuperAdminBypass: true },\n );\n const paidBy = (optionalString(body, 'paidBy') ?? 'company') as ExpensePayer;\n let paidByProfileId: string | null = null;\n if (paidBy === 'person') {\n paidByProfileId =\n optionalString(body, 'paidByProfileId')?.trim() || principal.profileId;\n if (\n paidByProfileId !== principal.profileId &&\n !(await principalHolds(\n itemClass(expenses),\n 'recordReview',\n options(expenses),\n ))\n ) {\n throw new ExpenseActionError(\n 403,\n 'permission_denied',\n \"Recording another person's expense needs the recordReview permission.\",\n );\n }\n }\n const fields: Record<string, unknown> = {};\n for (const key of RECORD_FIELDS) {\n if (body[key] !== undefined) fields[key] = body[key];\n }\n const breakdown = body.financialBreakdown;\n if (\n breakdown !== undefined &&\n breakdown !== null &&\n (typeof breakdown !== 'object' || Array.isArray(breakdown))\n ) {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n 'financialBreakdown must be an object or null.',\n );\n }\n return withActionPrincipal(principal, () =>\n // One create: `collection.create()` saves, and `Expense.save()` validates\n // the facts (`validateShape()` parses them) before its first INSERT, so an\n // invalid breakdown never leaves a half-recorded row behind.\n domainCall(() =>\n expenses.create({\n ...fields,\n ...(breakdown !== undefined\n ? {\n financialBreakdown:\n breakdown === null ? null : JSON.stringify(breakdown),\n }\n : {}),\n tenantId: principal.tenantId,\n paidBy,\n paidByProfileId,\n recordedByProfileId: principal.profileId,\n recordedAt: null,\n }),\n ),\n );\n}\n\n/**\n * `attachReceipt`: link a stored asset to an expense as its receipt through\n * `ExpenseReceiptCollection.attachReceipt()`. The uploader is the signed-in\n * person, who must have recorded or paid the expense unless they hold\n * `expenses.recordReview`.\n */\nexport async function attachExpenseReceiptAction(\n expenses: ExpenseCollection,\n input: unknown,\n): Promise<ExpenseReceipt> {\n const body = asRecord(input);\n const principal = await authorizeExpenseAction(\n itemClass(expenses),\n 'attachReceipt',\n options(expenses),\n { allowSuperAdminBypass: true },\n );\n return withActionPrincipal(principal, async () => {\n const expense = await loadExpense(expenses, principal, body);\n if (\n expense.recordedByProfileId !== principal.profileId &&\n expense.paidByProfileId !== principal.profileId &&\n !(await principalHolds(\n itemClass(expenses),\n 'recordReview',\n options(expenses),\n ))\n ) {\n throw new ExpenseActionError(\n 403,\n 'permission_denied',\n \"Attaching a receipt to another person's expense needs the recordReview permission.\",\n );\n }\n const byteCount = body.byteCount;\n if (byteCount !== undefined && typeof byteCount !== 'number') {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n 'byteCount must be a number.',\n );\n }\n const receipts = await ExpenseReceiptCollection.create(options(expenses));\n return domainCall(() =>\n receipts.attachReceipt({\n expenseId: expense.id as string,\n assetId: requiredString(body, 'assetId'),\n contentSha256: requiredString(body, 'contentSha256'),\n uploadedByProfileId: principal.profileId,\n ...(optionalString(body, 'filename') !== undefined\n ? { filename: optionalString(body, 'filename') }\n : {}),\n ...(optionalString(body, 'mimeType') !== undefined\n ? { mimeType: optionalString(body, 'mimeType') }\n : {}),\n ...(byteCount !== undefined ? { byteCount: byteCount as number } : {}),\n }),\n );\n });\n}\n\n/**\n * `recordReview`: accept (`Expense.review()`) or refuse with a reason\n * (`Expense.reject()`), attributed to the signed-in reviewer. Money: needs an\n * explicit `expenses.recordReview` grant, super-admin bypass does not apply.\n * Named apart from `Expense.review()` so allowlisting the collection action\n * never opens the instance method, which takes the reviewer from its input.\n */\nexport async function reviewExpenseAction(\n expenses: ExpenseCollection,\n input: unknown,\n): Promise<Expense> {\n const body = asRecord(input);\n const principal = await authorizeExpenseAction(\n itemClass(expenses),\n 'recordReview',\n options(expenses),\n { allowSuperAdminBypass: false },\n );\n const decision = optionalString(body, 'decision');\n if (decision !== 'approve' && decision !== 'reject') {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n \"decision must be 'approve' or 'reject'.\",\n );\n }\n return withActionPrincipal(principal, async () => {\n const expense = await loadExpense(expenses, principal, body);\n return domainCall(() =>\n decision === 'approve'\n ? expense.review({\n reviewerProfileId: principal.profileId,\n note: optionalString(body, 'note') ?? '',\n })\n : expense.reject({\n reviewerProfileId: principal.profileId,\n reason: optionalString(body, 'reason') ?? '',\n }),\n );\n });\n}\n\n/**\n * `recordReimbursement`: record that the person who paid has been paid back\n * (`Expense.markReimbursed()`); never changes the review state. Money: needs\n * an explicit `expenses.recordReimbursement` grant.\n */\nexport async function markExpenseReimbursedAction(\n expenses: ExpenseCollection,\n input: unknown,\n): Promise<Expense> {\n const body = asRecord(input);\n const principal = await authorizeExpenseAction(\n itemClass(expenses),\n 'recordReimbursement',\n options(expenses),\n { allowSuperAdminBypass: false },\n );\n return withActionPrincipal(principal, async () => {\n const expense = await loadExpense(expenses, principal, body);\n const reference = optionalString(body, 'reference');\n const amount = body.amount;\n if (\n amount !== undefined &&\n (typeof amount !== 'number' ||\n !Number.isSafeInteger(amount) ||\n amount <= 0)\n ) {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n 'amount must be a positive safe integer.',\n );\n }\n return domainCall(() =>\n expense.markReimbursed({\n ...(reference !== undefined ? { reference } : {}),\n ...(amount !== undefined ? { amount: amount as number } : {}),\n }),\n );\n });\n}\n"],"mappings":";;;;AAiFA,IAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,iCAAiB,IAAI,IAAsB;CAC/C;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,SAAS,OAAyC;CACzD,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAC5D,MAAM,IAAI,mBACR,KACA,mBACA,wCACF;CAEF,OAAO;AACT;AAEA,SAAS,eACP,MACA,KACoB;CACpB,MAAM,QAAQ,KAAK;CACnB,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO,KAAA;CAClD,IAAI,OAAO,UAAU,UACnB,MAAM,IAAI,mBACR,KACA,mBACA,GAAG,IAAG,mBACR;CAEF,OAAO;AACT;AAEA,SAAS,eAAe,MAA+B,KAAqB;CAC1E,MAAM,QAAQ,eAAe,MAAM,GAAG,CAAA,EAAG,KAAK;CAC9C,IAAI,CAAC,OACH,MAAM,IAAI,mBAAmB,KAAK,mBAAmB,GAAG,IAAG,cAAe;CAE5E,OAAO;AACT;AAGA,eAAe,WAAc,IAAkC;CAC7D,IAAI;EACF,OAAO,MAAM,GAAG;CAClB,SAAS,OAAO;EACd,IAAI,iBAAiB,cACnB,MAAM,IAAI,mBACR,eAAe,IAAI,MAAM,IAAI,IAAI,MAAM,KACvC,MAAM,MACN,MAAM,OACR;EAEF,MAAM;CACR;AACF;AAEA,SAAS,UAAU,UAA6B;CAC9C,OAAQ,SAAS,YACd;AACL;AAEA,SAAS,QAAQ,UAA+C;CAC9D,OAAO,SAAS;AAClB;AAEA,eAAe,YACb,UACA,WACA,MACkB;CAClB,MAAM,YAAY,eAAe,MAAM,WAAW;CAClD,MAAM,UAAU,MAAM,SAAS,IAAI,EAAE,I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GACb,mBAAmB,UAAU;GAC7B,MAAM,eAAe,MAAM,MAAM,KAAK;EACxC,CAAC,IACD,QAAQ,OAAO;GACb,mBAAmB,UAAU;GAC7B,QAAQ,eAAe,MAAM,QAAQ,KAAK;EAC5C,CAAC,CACP;CACF,CAAC;AACH;AAOA,eAAsB,4BACpB,UACA,OACkB;CAClB,MAAM,OAAO,SAAS,KAAK;CAC3B,MAAM,YAAY,MAAM,uBACtB,UAAU,QAAQ,GAClB,uBACA,QAAQ,QAAQ,GAChB,EAAE,uBAAuB,MAAM,CACjC;CACA,OAAO,oBAAoB,WAAW,YAAY;EAChD,MAAM,UAAU,MAAM,YAAY,UAAU,WAAW,IAAI;EAC3D,MAAM,YAAY,eAAe,MAAM,WAAW;EAClD,MAAM,SAAS,KAAK;EACpB,IACE,WAAW,KAAA,MACV,OAAO,WAAW,YACjB,CAAC,OAAO,cAAc,MAAM,KAC5B,UAAU,IAEZ,MAAM,IAAI,mBACR,KACA,mBACA,yCACF;EAEF,OAAO,iBACL,QAAQ,eAAe;GACrB,GAAI,cAAc,KAAA,IAAY,EAAE,UAAU,IAAI,CAAC;GAC/C,GAAI,WAAW,KAAA,IAAY,EAAE,OAAyB,IAAI,CAAC;EAC7D,CAAC,CACH;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"expense-actions-C_Y7CrnB.js","names":[],"sources":["../../src/actions/expense-actions.ts"],"sourcesContent":["/**\n * Service-backed write actions for `Expense` and `ExpenseReceipt` (#4001).\n *\n * The generated CRUD surface stays closed: these are the only generated\n * writes, and each delegates to the existing domain flow — `Expense.save()`\n * with its review lock and refund/commitment/vendor guards, the method-only\n * `review()` / `reject()` / `markReimbursed()`, and\n * `ExpenseReceiptCollection.attachReceipt()` with its hash deduplication.\n * The thin `ExpenseCollection` methods call in here.\n */\nimport type { SmrtClassOptions } from '@happyvertical/smrt-core';\nimport type { ExpenseCollection } from '../collections/ExpenseCollection.js';\nimport { ExpenseReceiptCollection } from '../collections/ExpenseReceiptCollection.js';\nimport type { Expense } from '../models/Expense.js';\nimport type { ExpenseReceipt } from '../models/ExpenseReceipt.js';\nimport {\n ExpenseError,\n type ExpenseErrorCode,\n type ExpenseFinancialBreakdown,\n type ExpensePayer,\n} from '../types.js';\nimport {\n authorizeExpenseAction,\n ExpenseActionError,\n type ExpenseActionPrincipal,\n principalHolds,\n withActionPrincipal,\n} from './principal.js';\n\n/** Body of the `record` action. Tenant and recorder come from the session. */\nexport interface RecordExpenseActionInput {\n costObjectType?: string;\n costObjectId?: string;\n category?: string;\n description?: string;\n /** Integer minor units of `currency`. */\n amount: number;\n currency: string;\n /** `YYYY-MM-DD`. */\n incurredOn: string;\n paidBy?: ExpensePayer;\n /** Defaults to the signed-in person when `paidBy` is `person`. */\n paidByProfileId?: string | null;\n paidByName?: string | null;\n vendorId?: string | null;\n commitmentId?: string | null;\n commitmentLineId?: string | null;\n refundOfId?: string | null;\n reimbursable?: boolean;\n financialBreakdown?: ExpenseFinancialBreakdown | null;\n}\n\n/** Body of the `attachReceipt` action. */\nexport interface AttachExpenseReceiptActionInput {\n expenseId: string;\n assetId: string;\n contentSha256: string;\n filename?: string;\n mimeType?: string;\n byteCount?: number;\n}\n\n/** Body of the `recordReview` action. */\nexport interface ReviewExpenseActionInput {\n expenseId: string;\n /** `approve` accepts the cost; `reject` refuses it and needs a `reason`. */\n decision: 'approve' | 'reject';\n note?: string;\n reason?: string;\n}\n\n/** Body of the `recordReimbursement` action. */\nexport interface MarkExpenseReimbursedActionInput {\n expenseId: string;\n /** Optional expected full remaining reimbursement in minor units. */\n amount?: number;\n /** Payroll line, payables reference, or transfer id of the payback. */\n reference?: string;\n}\n\n/** `record` fields copied onto the new expense; everything else is ignored. */\nconst RECORD_FIELDS = [\n 'costObjectType',\n 'costObjectId',\n 'category',\n 'description',\n 'amount',\n 'currency',\n 'incurredOn',\n 'paidByName',\n 'vendorId',\n 'commitmentId',\n 'commitmentLineId',\n 'refundOfId',\n 'reimbursable',\n] as const;\n\nconst CONFLICT_CODES = new Set<ExpenseErrorCode>([\n 'EXPENSE_REVIEW_TRANSITION',\n 'EXPENSE_REVIEW_FIELDS_LOCKED',\n 'EXPENSE_IDENTITY_CONFLICT',\n 'EXPENSE_RECEIPT_DUPLICATE',\n]);\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n 'The action body must be a JSON object.',\n );\n }\n return value as Record<string, unknown>;\n}\n\nfunction optionalString(\n body: Record<string, unknown>,\n key: string,\n): string | undefined {\n const value = body[key];\n if (value === undefined || value === null) return undefined;\n if (typeof value !== 'string') {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n `${key} must be a string.`,\n );\n }\n return value;\n}\n\nfunction requiredString(body: Record<string, unknown>, key: string): string {\n const value = optionalString(body, key)?.trim();\n if (!value) {\n throw new ExpenseActionError(400, 'invalid_request', `${key} is required.`);\n }\n return value;\n}\n\n/** Domain refusals become 4xx with their stable code; others pass through. */\nasync function domainCall<T>(fn: () => Promise<T>): Promise<T> {\n try {\n return await fn();\n } catch (error) {\n if (error instanceof ExpenseError) {\n throw new ExpenseActionError(\n CONFLICT_CODES.has(error.code) ? 409 : 400,\n error.code,\n error.message,\n );\n }\n throw error;\n }\n}\n\nfunction itemClass(expenses: ExpenseCollection) {\n return (expenses.constructor as unknown as { _itemClass: unknown })\n ._itemClass as typeof Expense;\n}\n\nfunction options(expenses: ExpenseCollection): SmrtClassOptions {\n return expenses.options;\n}\n\nasync function loadExpense(\n expenses: ExpenseCollection,\n principal: ExpenseActionPrincipal,\n body: Record<string, unknown>,\n): Promise<Expense> {\n const expenseId = requiredString(body, 'expenseId');\n const expense = await expenses.get({ id: expenseId });\n // Optional tenancy also admits global (NULL-tenant) rows in a tenant\n // context; a write must land on the principal's own tenant only.\n if (!expense || (expense.tenantId ?? null) !== principal.tenantId) {\n throw new ExpenseActionError(\n 404,\n 'not_found',\n `Expense ${expenseId} was not found.`,\n );\n }\n return expense;\n}\n\n/**\n * `record`: a new `unreviewed` expense, recorded by the signed-in person in\n * their tenant. Review, reimbursement and duplicate fields are never taken\n * from the body. Paying on someone else's behalf needs `expenses.recordReview`.\n */\nexport async function recordExpenseAction(\n expenses: ExpenseCollection,\n input: unknown,\n): Promise<Expense> {\n const body = asRecord(input);\n const principal = await authorizeExpenseAction(\n itemClass(expenses),\n 'record',\n options(expenses),\n { allowSuperAdminBypass: true },\n );\n const paidBy = (optionalString(body, 'paidBy') ?? 'company') as ExpensePayer;\n let paidByProfileId: string | null = null;\n if (paidBy === 'person') {\n paidByProfileId =\n optionalString(body, 'paidByProfileId')?.trim() || principal.profileId;\n if (\n paidByProfileId !== principal.profileId &&\n !(await principalHolds(\n itemClass(expenses),\n 'recordReview',\n options(expenses),\n ))\n ) {\n throw new ExpenseActionError(\n 403,\n 'permission_denied',\n \"Recording another person's expense needs the recordReview permission.\",\n );\n }\n }\n const fields: Record<string, unknown> = {};\n for (const key of RECORD_FIELDS) {\n if (body[key] !== undefined) fields[key] = body[key];\n }\n const breakdown = body.financialBreakdown;\n if (\n breakdown !== undefined &&\n breakdown !== null &&\n (typeof breakdown !== 'object' || Array.isArray(breakdown))\n ) {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n 'financialBreakdown must be an object or null.',\n );\n }\n return withActionPrincipal(principal, () =>\n // One create: `collection.create()` saves, and `Expense.save()` validates\n // the facts (`validateShape()` parses them) before its first INSERT, so an\n // invalid breakdown never leaves a half-recorded row behind.\n domainCall(() =>\n expenses.create({\n ...fields,\n ...(breakdown !== undefined\n ? {\n financialBreakdown:\n breakdown === null ? null : JSON.stringify(breakdown),\n }\n : {}),\n tenantId: principal.tenantId,\n paidBy,\n paidByProfileId,\n recordedByProfileId: principal.profileId,\n recordedAt: null,\n }),\n ),\n );\n}\n\n/**\n * `attachReceipt`: link a stored asset to an expense as its receipt through\n * `ExpenseReceiptCollection.attachReceipt()`. The uploader is the signed-in\n * person, who must have recorded or paid the expense unless they hold\n * `expenses.recordReview`.\n */\nexport async function attachExpenseReceiptAction(\n expenses: ExpenseCollection,\n input: unknown,\n): Promise<ExpenseReceipt> {\n const body = asRecord(input);\n const principal = await authorizeExpenseAction(\n itemClass(expenses),\n 'attachReceipt',\n options(expenses),\n { allowSuperAdminBypass: true },\n );\n return withActionPrincipal(principal, async () => {\n const expense = await loadExpense(expenses, principal, body);\n if (\n expense.recordedByProfileId !== principal.profileId &&\n expense.paidByProfileId !== principal.profileId &&\n !(await principalHolds(\n itemClass(expenses),\n 'recordReview',\n options(expenses),\n ))\n ) {\n throw new ExpenseActionError(\n 403,\n 'permission_denied',\n \"Attaching a receipt to another person's expense needs the recordReview permission.\",\n );\n }\n const byteCount = body.byteCount;\n if (byteCount !== undefined && typeof byteCount !== 'number') {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n 'byteCount must be a number.',\n );\n }\n const receipts = await ExpenseReceiptCollection.create(options(expenses));\n return domainCall(() =>\n receipts.attachReceipt({\n expenseId: expense.id as string,\n assetId: requiredString(body, 'assetId'),\n contentSha256: requiredString(body, 'contentSha256'),\n uploadedByProfileId: principal.profileId,\n ...(optionalString(body, 'filename') !== undefined\n ? { filename: optionalString(body, 'filename') }\n : {}),\n ...(optionalString(body, 'mimeType') !== undefined\n ? { mimeType: optionalString(body, 'mimeType') }\n : {}),\n ...(byteCount !== undefined ? { byteCount: byteCount as number } : {}),\n }),\n );\n });\n}\n\n/**\n * `recordReview`: accept (`Expense.review()`) or refuse with a reason\n * (`Expense.reject()`), attributed to the signed-in reviewer. Money: needs an\n * explicit `expenses.recordReview` grant, super-admin bypass does not apply.\n * Named apart from `Expense.review()` so allowlisting the collection action\n * never opens the instance method, which takes the reviewer from its input.\n */\nexport async function reviewExpenseAction(\n expenses: ExpenseCollection,\n input: unknown,\n): Promise<Expense> {\n const body = asRecord(input);\n const principal = await authorizeExpenseAction(\n itemClass(expenses),\n 'recordReview',\n options(expenses),\n { allowSuperAdminBypass: false },\n );\n const decision = optionalString(body, 'decision');\n if (decision !== 'approve' && decision !== 'reject') {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n \"decision must be 'approve' or 'reject'.\",\n );\n }\n return withActionPrincipal(principal, async () => {\n const expense = await loadExpense(expenses, principal, body);\n return domainCall(() =>\n decision === 'approve'\n ? expense.review({\n reviewerProfileId: principal.profileId,\n note: optionalString(body, 'note') ?? '',\n })\n : expense.reject({\n reviewerProfileId: principal.profileId,\n reason: optionalString(body, 'reason') ?? '',\n }),\n );\n });\n}\n\n/**\n * `recordReimbursement`: record that the person who paid has been paid back\n * (`Expense.markReimbursed()`); never changes the review state. Money: needs\n * an explicit `expenses.recordReimbursement` grant.\n */\nexport async function markExpenseReimbursedAction(\n expenses: ExpenseCollection,\n input: unknown,\n): Promise<Expense> {\n const body = asRecord(input);\n const principal = await authorizeExpenseAction(\n itemClass(expenses),\n 'recordReimbursement',\n options(expenses),\n { allowSuperAdminBypass: false },\n );\n return withActionPrincipal(principal, async () => {\n const expense = await loadExpense(expenses, principal, body);\n const reference = optionalString(body, 'reference');\n const amount = body.amount;\n if (\n amount !== undefined &&\n (typeof amount !== 'number' ||\n !Number.isSafeInteger(amount) ||\n amount <= 0)\n ) {\n throw new ExpenseActionError(\n 400,\n 'invalid_request',\n 'amount must be a positive safe integer.',\n );\n }\n return domainCall(() =>\n expense.markReimbursed({\n ...(reference !== undefined ? { reference } : {}),\n ...(amount !== undefined ? { amount: amount as number } : {}),\n }),\n );\n });\n}\n"],"mappings":";;;;AAiFA,IAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,iCAAiB,IAAI,IAAsB;CAC/C;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,SAAS,OAAyC;CACzD,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAC5D,MAAM,IAAI,mBACR,KACA,mBACA,wCACF;CAEF,O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