@kohost/api-client 7.13.0 → 7.14.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/dist/.tsbuildinfo +1 -0
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +4 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/money.d.ts +21 -0
- package/dist/lib/money.js +29 -1
- package/dist/lib/money.js.map +1 -1
- package/dist/models/cost.d.ts +17 -0
- package/dist/models/cost.js +38 -0
- package/dist/models/cost.js.map +1 -0
- package/dist/models/emailMessage.js +2 -0
- package/dist/models/emailMessage.js.map +1 -1
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.js +3 -1
- package/dist/models/index.js.map +1 -1
- package/dist/schemas/bill.d.ts +14 -6
- package/dist/schemas/bill.js +14 -11
- package/dist/schemas/bill.js.map +1 -1
- package/dist/schemas/cost.d.ts +227 -0
- package/dist/schemas/cost.js +45 -0
- package/dist/schemas/cost.js.map +1 -0
- package/dist/schemas/costEntry.d.ts +222 -0
- package/dist/schemas/costEntry.js +162 -0
- package/dist/schemas/costEntry.js.map +1 -0
- package/dist/schemas/emailMessage.d.ts +12 -0
- package/dist/schemas/emailMessage.js +8 -0
- package/dist/schemas/emailMessage.js.map +1 -1
- package/dist/schemas/index.d.ts +7 -6
- package/dist/schemas/index.js +2 -1
- package/dist/schemas/ticket.d.ts +25 -26
- package/dist/schemas/ticket.js +60 -245
- package/dist/schemas/ticket.js.map +1 -1
- package/dist/useCases/createCost.d.ts +27 -0
- package/dist/useCases/createCost.js +47 -0
- package/dist/useCases/createCost.js.map +1 -0
- package/dist/useCases/editCost.d.ts +36 -0
- package/dist/useCases/editCost.js +47 -0
- package/dist/useCases/editCost.js.map +1 -0
- package/dist/useCases/index.d.ts +5 -0
- package/dist/useCases/index.js +11 -1
- package/dist/useCases/index.js.map +1 -1
- package/dist/useCases/reinstateCost.d.ts +36 -0
- package/dist/useCases/reinstateCost.js +47 -0
- package/dist/useCases/reinstateCost.js.map +1 -0
- package/dist/useCases/setCostInvoice.d.ts +36 -0
- package/dist/useCases/setCostInvoice.js +47 -0
- package/dist/useCases/setCostInvoice.js.map +1 -0
- package/dist/useCases/writeOffCost.d.ts +36 -0
- package/dist/useCases/writeOffCost.js +47 -0
- package/dist/useCases/writeOffCost.js.map +1 -0
- package/dist/validate.d.ts +23 -0
- package/dist/validate.js +4 -1
- package/dist/validate.js.map +1 -1
- package/package.json +1 -1
package/dist/models/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { Bill } from "./bill.js";
|
|
|
7
7
|
import { BillingCategory } from "./billingCategory.js";
|
|
8
8
|
import { Camera } from "./camera.js";
|
|
9
9
|
import { Category } from "./category.js";
|
|
10
|
+
import { Cost } from "./cost.js";
|
|
10
11
|
import { Courtesy } from "./courtesy.js";
|
|
11
12
|
import { Credential } from "./credential.js";
|
|
12
13
|
import { Department } from "./department.js";
|
|
@@ -58,6 +59,7 @@ var models_exports = /* @__PURE__ */ __exportAll({
|
|
|
58
59
|
BillingCategory: () => BillingCategory,
|
|
59
60
|
Camera: () => Camera,
|
|
60
61
|
Category: () => Category,
|
|
62
|
+
Cost: () => Cost,
|
|
61
63
|
Courtesy: () => Courtesy,
|
|
62
64
|
Credential: () => Credential,
|
|
63
65
|
Department: () => Department,
|
|
@@ -103,6 +105,6 @@ var models_exports = /* @__PURE__ */ __exportAll({
|
|
|
103
105
|
WindowCovering: () => WindowCovering
|
|
104
106
|
});
|
|
105
107
|
//#endregion
|
|
106
|
-
export { Alarm, Announcement, Automation, Bill, BillingCategory, Camera, Category, Courtesy, Credential, Department, Dimmer, DiscoveredDevice, EmailMessage, EnergyReport, EnergyReportShard, Entity, Gateway, Group, Identification, Integration, Issue, Lock, Log, MediaFile, MediaSource, MotionSensor, Notification, Organization, Payment, Policy, Product, Property, Reservation, Resource, SOSEvent, SOSType, Server, Session, ShortLink, SmsMessage, Space, Switch, System, SystemUser, Thermostat, Ticket, TimeSheet, User, Vendor, WindowCovering, models_exports };
|
|
108
|
+
export { Alarm, Announcement, Automation, Bill, BillingCategory, Camera, Category, Cost, Courtesy, Credential, Department, Dimmer, DiscoveredDevice, EmailMessage, EnergyReport, EnergyReportShard, Entity, Gateway, Group, Identification, Integration, Issue, Lock, Log, MediaFile, MediaSource, MotionSensor, Notification, Organization, Payment, Policy, Product, Property, Reservation, Resource, SOSEvent, SOSType, Server, Session, ShortLink, SmsMessage, Space, Switch, System, SystemUser, Thermostat, Ticket, TimeSheet, User, Vendor, WindowCovering, models_exports };
|
|
107
109
|
|
|
108
110
|
//# sourceMappingURL=index.js.map
|
package/dist/models/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../.generated/models/index.ts"],"sourcesContent":["/* This file is automatically generated. Do not modify it manually. */\n\nexport { Entity } from \"./entity.js\";\n\nexport { Alarm, type AlarmData } from \"./alarm.js\";\nexport { Announcement, type AnnouncementData } from \"./announcement.js\";\nexport { Automation, type AutomationData } from \"./automation.js\";\nexport { Bill, type BillData } from \"./bill.js\";\nexport { BillingCategory, type BillingCategoryData } from \"./billingCategory.js\";\nexport { Camera, type CameraData } from \"./camera.js\";\nexport { Category, type CategoryData } from \"./category.js\";\nexport { Courtesy, type CourtesyData } from \"./courtesy.js\";\nexport { Credential, type CredentialData } from \"./credential.js\";\nexport { Department, type DepartmentData } from \"./department.js\";\nexport { Dimmer, type DimmerData } from \"./dimmer.js\";\nexport { DiscoveredDevice, type DiscoveredDeviceData } from \"./discoveredDevice.js\";\nexport { EmailMessage, type EmailMessageData } from \"./emailMessage.js\";\nexport { EnergyReport, type EnergyReportData } from \"./energyReport.js\";\nexport { EnergyReportShard, type EnergyReportShardData } from \"./energyReportShard.js\";\nexport { Gateway, type GatewayData } from \"./gateway.js\";\nexport { Group, type GroupData } from \"./group.js\";\nexport { Identification, type IdentificationData } from \"./identification.js\";\nexport { Integration, type IntegrationData } from \"./integration.js\";\nexport { Issue, type IssueData } from \"./issue.js\";\nexport { Lock, type LockData } from \"./lock.js\";\nexport { Log, type LogData } from \"./log.js\";\nexport { MediaFile, type MediaFileData } from \"./mediaFile.js\";\nexport { MediaSource, type MediaSourceData } from \"./mediaSource.js\";\nexport { MotionSensor, type MotionSensorData } from \"./motionSensor.js\";\nexport { Notification, type NotificationData } from \"./notification.js\";\nexport { Organization, type OrganizationData } from \"./organization.js\";\nexport { Payment, type PaymentData } from \"./payment.js\";\nexport { Policy, type PolicyData } from \"./policy.js\";\nexport { Product, type ProductData } from \"./product.js\";\nexport { Property, type PropertyData } from \"./property.js\";\nexport { Reservation, type ReservationData } from \"./reservation.js\";\nexport { Resource, type ResourceData } from \"./resource.js\";\nexport { Server, type ServerData } from \"./server.js\";\nexport { Session, type SessionData } from \"./session.js\";\nexport { ShortLink, type ShortLinkData } from \"./shortLink.js\";\nexport { SmsMessage, type SmsMessageData } from \"./smsMessage.js\";\nexport { SOSEvent, type SOSEventData } from \"./sosEvent.js\";\nexport { SOSType, type SOSTypeData } from \"./sosType.js\";\nexport { Space, type SpaceData } from \"./space.js\";\nexport { Switch, type SwitchData } from \"./switch.js\";\nexport { System, type SystemData } from \"./system.js\";\nexport { SystemUser, type SystemUserData } from \"./systemUser.js\";\nexport { Thermostat, type ThermostatData } from \"./thermostat.js\";\nexport { Ticket, type TicketData } from \"./ticket.js\";\nexport { TimeSheet, type TimeSheetData } from \"./timeSheet.js\";\nexport { User, type UserData } from \"./user.js\";\nexport { Vendor, type VendorData } from \"./vendor.js\";\nexport { WindowCovering, type WindowCoveringData } from \"./windowCovering.js\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../.generated/models/index.ts"],"sourcesContent":["/* This file is automatically generated. Do not modify it manually. */\n\nexport { Entity } from \"./entity.js\";\n\nexport { Alarm, type AlarmData } from \"./alarm.js\";\nexport { Announcement, type AnnouncementData } from \"./announcement.js\";\nexport { Automation, type AutomationData } from \"./automation.js\";\nexport { Bill, type BillData } from \"./bill.js\";\nexport { BillingCategory, type BillingCategoryData } from \"./billingCategory.js\";\nexport { Camera, type CameraData } from \"./camera.js\";\nexport { Category, type CategoryData } from \"./category.js\";\nexport { Cost, type CostData } from \"./cost.js\";\nexport { Courtesy, type CourtesyData } from \"./courtesy.js\";\nexport { Credential, type CredentialData } from \"./credential.js\";\nexport { Department, type DepartmentData } from \"./department.js\";\nexport { Dimmer, type DimmerData } from \"./dimmer.js\";\nexport { DiscoveredDevice, type DiscoveredDeviceData } from \"./discoveredDevice.js\";\nexport { EmailMessage, type EmailMessageData } from \"./emailMessage.js\";\nexport { EnergyReport, type EnergyReportData } from \"./energyReport.js\";\nexport { EnergyReportShard, type EnergyReportShardData } from \"./energyReportShard.js\";\nexport { Gateway, type GatewayData } from \"./gateway.js\";\nexport { Group, type GroupData } from \"./group.js\";\nexport { Identification, type IdentificationData } from \"./identification.js\";\nexport { Integration, type IntegrationData } from \"./integration.js\";\nexport { Issue, type IssueData } from \"./issue.js\";\nexport { Lock, type LockData } from \"./lock.js\";\nexport { Log, type LogData } from \"./log.js\";\nexport { MediaFile, type MediaFileData } from \"./mediaFile.js\";\nexport { MediaSource, type MediaSourceData } from \"./mediaSource.js\";\nexport { MotionSensor, type MotionSensorData } from \"./motionSensor.js\";\nexport { Notification, type NotificationData } from \"./notification.js\";\nexport { Organization, type OrganizationData } from \"./organization.js\";\nexport { Payment, type PaymentData } from \"./payment.js\";\nexport { Policy, type PolicyData } from \"./policy.js\";\nexport { Product, type ProductData } from \"./product.js\";\nexport { Property, type PropertyData } from \"./property.js\";\nexport { Reservation, type ReservationData } from \"./reservation.js\";\nexport { Resource, type ResourceData } from \"./resource.js\";\nexport { Server, type ServerData } from \"./server.js\";\nexport { Session, type SessionData } from \"./session.js\";\nexport { ShortLink, type ShortLinkData } from \"./shortLink.js\";\nexport { SmsMessage, type SmsMessageData } from \"./smsMessage.js\";\nexport { SOSEvent, type SOSEventData } from \"./sosEvent.js\";\nexport { SOSType, type SOSTypeData } from \"./sosType.js\";\nexport { Space, type SpaceData } from \"./space.js\";\nexport { Switch, type SwitchData } from \"./switch.js\";\nexport { System, type SystemData } from \"./system.js\";\nexport { SystemUser, type SystemUserData } from \"./systemUser.js\";\nexport { Thermostat, type ThermostatData } from \"./thermostat.js\";\nexport { Ticket, type TicketData } from \"./ticket.js\";\nexport { TimeSheet, type TimeSheetData } from \"./timeSheet.js\";\nexport { User, type UserData } from \"./user.js\";\nexport { Vendor, type VendorData } from \"./vendor.js\";\nexport { WindowCovering, type WindowCoveringData } from \"./windowCovering.js\";\n"],"mappings":""}
|
package/dist/schemas/bill.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ export declare const billSchema: {
|
|
|
93
93
|
readonly oneOf: readonly [{
|
|
94
94
|
readonly type: "object";
|
|
95
95
|
readonly additionalProperties: false;
|
|
96
|
-
readonly required: readonly ["id", "type"
|
|
96
|
+
readonly required: readonly ["id", "type"];
|
|
97
97
|
readonly properties: {
|
|
98
98
|
readonly id: {
|
|
99
99
|
readonly type: "string";
|
|
@@ -102,15 +102,23 @@ export declare const billSchema: {
|
|
|
102
102
|
readonly type: {
|
|
103
103
|
readonly type: "string";
|
|
104
104
|
readonly enum: readonly ["cost"];
|
|
105
|
-
readonly description: "Discriminator: a line drawn from a
|
|
105
|
+
readonly description: "Discriminator: a line drawn from a recorded cost entry.";
|
|
106
106
|
};
|
|
107
|
-
readonly
|
|
107
|
+
readonly source: {
|
|
108
108
|
readonly type: "string";
|
|
109
|
-
readonly
|
|
109
|
+
readonly enum: readonly ["ticket", "adhoc"];
|
|
110
|
+
readonly default: "ticket";
|
|
111
|
+
readonly description: string;
|
|
112
|
+
};
|
|
113
|
+
readonly ticketId: {
|
|
114
|
+
readonly type: readonly ["string", "null"];
|
|
115
|
+
readonly default: null;
|
|
116
|
+
readonly description: string;
|
|
110
117
|
};
|
|
111
118
|
readonly costId: {
|
|
112
|
-
readonly type: "string";
|
|
113
|
-
readonly
|
|
119
|
+
readonly type: readonly ["string", "null"];
|
|
120
|
+
readonly default: null;
|
|
121
|
+
readonly description: string;
|
|
114
122
|
};
|
|
115
123
|
readonly categoryId: {
|
|
116
124
|
readonly type: readonly ["string", "null"];
|
package/dist/schemas/bill.js
CHANGED
|
@@ -94,12 +94,7 @@ const billSchema = {
|
|
|
94
94
|
items: { oneOf: [{
|
|
95
95
|
type: "object",
|
|
96
96
|
additionalProperties: false,
|
|
97
|
-
required: [
|
|
98
|
-
"id",
|
|
99
|
-
"type",
|
|
100
|
-
"ticketId",
|
|
101
|
-
"costId"
|
|
102
|
-
],
|
|
97
|
+
required: ["id", "type"],
|
|
103
98
|
properties: {
|
|
104
99
|
id: {
|
|
105
100
|
type: "string",
|
|
@@ -108,15 +103,23 @@ const billSchema = {
|
|
|
108
103
|
type: {
|
|
109
104
|
type: "string",
|
|
110
105
|
enum: ["cost"],
|
|
111
|
-
description: "Discriminator: a line drawn from a
|
|
106
|
+
description: "Discriminator: a line drawn from a recorded cost entry."
|
|
112
107
|
},
|
|
113
|
-
|
|
108
|
+
source: {
|
|
114
109
|
type: "string",
|
|
115
|
-
|
|
110
|
+
enum: ["ticket", "adhoc"],
|
|
111
|
+
default: "ticket",
|
|
112
|
+
description: "Where the claimed cost entry lives, and therefore how `costId` resolves: on a ticket, or in the costs collection."
|
|
113
|
+
},
|
|
114
|
+
ticketId: {
|
|
115
|
+
type: ["string", "null"],
|
|
116
|
+
default: null,
|
|
117
|
+
description: "The ID of the ticket the claimed cost entry lives on. Null on an `adhoc` line, which no ticket carries."
|
|
116
118
|
},
|
|
117
119
|
costId: {
|
|
118
|
-
type: "string",
|
|
119
|
-
|
|
120
|
+
type: ["string", "null"],
|
|
121
|
+
default: null,
|
|
122
|
+
description: "The ID of the claimed cost entry: an entry within the ticket on a `ticket` line, a costs-collection document on an `adhoc` one."
|
|
120
123
|
},
|
|
121
124
|
categoryId: {
|
|
122
125
|
type: ["string", "null"],
|
package/dist/schemas/bill.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bill.js","names":[],"sources":["../../.generated/schemas/bill.ts"],"sourcesContent":["import defs, { ISODateString } from \"./definitions\";\nimport type { FromSchema } from \"json-schema-to-ts\";\nimport { mediaFileSchema } from \"./mediaFile\";\n\n// One bill line is a discriminated union on `type`, so `lines.items` is their\n// `oneOf`. The two branches are disjoint via the `type` const plus\n// `additionalProperties: false`, so a line validates against exactly one.\n//\n// A cost line references a ticket cost entry by `(ticketId, costId)`. While the\n// bill is a draft it carries only the reference, the picked `categoryId`, and\n// any draft-time adjustment; the customer-facing `amount`, `description`, and\n// `categoryName` are live-read from the cost entry and snapshotted onto the\n// line at mark-sent. The billed amount is the marked-up actual (or the\n// `adjustedAmount` override, floored at zero) — vendor truth on the cost entry\n// is never touched.\nconst costLineSchema = {\n type: \"object\",\n additionalProperties: false,\n required: [\"id\", \"type\", \"ticketId\", \"costId\"],\n properties: {\n id: {\n type: \"string\",\n description: \"Server-minted ID of the bill line.\",\n },\n type: {\n type: \"string\",\n enum: [\"cost\"],\n description: \"Discriminator: a line drawn from a ticket cost entry.\",\n },\n ticketId: {\n type: \"string\",\n description: \"The ID of the ticket the claimed cost entry lives on.\",\n },\n costId: {\n type: \"string\",\n description: \"The ID of the claimed cost entry within the ticket.\",\n },\n categoryId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The picked billing category, inherited from the claimed cost entry \" +\n \"when the claim does not name one. Optional while drafting, required \" +\n \"at mark-sent. Manual pick — never derived from the ticket's issue.\",\n },\n categoryName: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The category name snapshotted at mark-sent. Null while drafting, \" +\n \"when it live-reads from the category library.\",\n },\n adjustedAmount: {\n type: [\"integer\", \"null\"],\n minimum: 0,\n default: null,\n description:\n \"Optional draft-time override of the billed amount in integer cents, \" +\n \"floored at zero, replacing the marked-up actual at display and \" +\n \"snapshot. Requires `adjustmentReason`. A credit (below zero) is a \" +\n \"manual line instead.\",\n },\n adjustmentReason: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"Short required reason accompanying `adjustedAmount`, kept for the \" +\n \"internal record.\",\n },\n amount: {\n type: [\"integer\", \"null\"],\n default: null,\n description:\n \"The billed amount in integer cents, snapshotted at mark-sent. Null \" +\n \"while drafting, when it live-reads (marked-up actual or the \" +\n \"adjustment) from the cost entry.\",\n },\n description: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The line description, snapshotted at mark-sent. Null while drafting, \" +\n \"when it live-reads from the cost entry.\",\n },\n taxable: {\n type: \"boolean\",\n default: false,\n description:\n \"Whether the line's amount joins the bill's taxable subtotal. \" +\n \"Customer-facing: locks at mark-sent.\",\n },\n },\n} as const;\n\n// A manual line is a literal customer-facing row with no markup math: a\n// `description` and `amount` (which may be negative, serving as a credit) and\n// an optional `propertyId`. The independent internal fields — informational\n// `cost` (never derives the amount), `vendorId`, the vendor-invoice file, and\n// `vendorInvoiceNumber` — are redacted org-side via `canSeeCostSplit` and stay\n// editable in any bill state.\nconst manualLineSchema = {\n type: \"object\",\n additionalProperties: false,\n required: [\"id\", \"type\", \"description\", \"amount\"],\n properties: {\n id: {\n type: \"string\",\n description: \"Server-minted ID of the bill line.\",\n },\n type: {\n type: \"string\",\n enum: [\"manual\"],\n description: \"Discriminator: a literal, non-ticket line.\",\n },\n description: {\n type: \"string\",\n minLength: 1,\n description: \"The literal customer-facing description.\",\n },\n amount: {\n type: \"integer\",\n description:\n \"The billed amount in integer cents. May be negative, serving as a \" +\n \"credit (reference the reason in the description).\",\n },\n propertyId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The property the manual line is attributed to, when it concerns one.\",\n },\n categoryId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The picked billing category. Optional while drafting, required at \" +\n \"mark-sent.\",\n },\n categoryName: {\n type: [\"string\", \"null\"],\n default: null,\n description: \"The category name snapshotted at mark-sent.\",\n },\n cost: {\n type: [\"integer\", \"null\"],\n default: null,\n description:\n \"Informational internal vendor cost in integer cents. Never derives \" +\n \"the amount. Redacted org-side.\",\n },\n vendorId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"Optional reference to the org-scoped Vendor. Internal, redacted \" +\n \"org-side.\",\n },\n vendorInvoice: {\n anyOf: [{ $ref: \"mediaFile.json\" }, { type: \"null\" }],\n default: null,\n description:\n \"The vendor's invoice file backing the line, mirroring the cost-entry \" +\n \"field. Internal, redacted org-side.\",\n },\n vendorInvoiceNumber: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The vendor's own invoice number. Internal, redacted org-side.\",\n },\n taxable: {\n type: \"boolean\",\n default: false,\n description:\n \"Whether the line's amount joins the bill's taxable subtotal. \" +\n \"Customer-facing: locks at mark-sent.\",\n },\n },\n} as const;\n\nexport const billSchema = {\n $schema: \"http://json-schema.org/draft-07/schema\",\n $id: \"bill.json\",\n title: \"Bill\",\n description:\n \"A OneBill bill, stored platform-wide and stamped with its organization: \" +\n \"KFC staff assemble billed lines from the \" +\n \"uninvoiced cost pool (plus manual lines) into a draft, then mark it sent \" +\n \"to freeze and reveal it to the customer. Lifecycle draft → sent → paid, \" +\n \"plus void. Customers see a bill in-app only once sent.\",\n type: \"object\",\n required: [\"id\", \"organizationId\", \"status\", \"currency\", \"lines\"],\n additionalProperties: false,\n properties: {\n id: {\n $ref: \"definitions.json#/definitions/id\",\n },\n type: {\n type: \"string\",\n enum: [\"bill\"],\n default: \"bill\",\n },\n organizationId: {\n type: \"string\",\n description:\n \"The organization the bill invoices. Bills live in one admin-database \" +\n \"collection across every organization, so each carries its owner \" +\n \"explicitly — stamped from the request context at creation, never \" +\n \"client-supplied.\",\n },\n status: {\n type: \"string\",\n enum: [\"draft\", \"sent\", \"paid\", \"void\"],\n default: \"draft\",\n description:\n \"Lifecycle state. `sent` freezes customer-facing fields and reveals \" +\n \"the bill to the org; `paid` records manual payment; `void` releases \" +\n \"cost-entry claims and hides the bill from the org view. Drafts \" +\n \"hard-delete rather than voiding.\",\n },\n invoiceNumber: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"Kohost's own invoice number, `KB-<n>` from a single global sequence. \" +\n \"System-assigned at mark-sent and never entered by hand: null while \" +\n \"the bill is a draft, immutable once set. A wrong bill is corrected \" +\n \"by void-and-reissue, so numbers gap and are never reused.\",\n },\n period: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n 'Display-only month label (e.g. \"July 2026\"). A UI hint; the bill\\'s ' +\n \"membership is defined by its lines, not a calendar bucket.\",\n },\n currency: {\n type: \"string\",\n enum: [\"USD\"],\n default: \"USD\",\n description: \"ISO 4217 currency code. USD only in v1.\",\n },\n fileId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The generated bill PDF's media-file ID, minted atomically at \" +\n \"mark-sent.\",\n },\n fileUrl: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The generated bill PDF's file-store URL, snapshotted at mark-sent \" +\n \"alongside fileId. Held so the sent-bill surface and the sent \" +\n \"notification email can mint a signed, unauthenticated download link \" +\n \"without a file lookup. Unsigned on its own (a bare link 401s).\",\n },\n memo: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"Internal KFC-only note. Never customer-facing; editable in any state.\",\n },\n billingAddress: {\n anyOf: [\n { $ref: \"definitions.json#/definitions/address\" },\n { type: \"null\" },\n ],\n default: null,\n description:\n \"The org billing address snapshotted at mark-sent. Null while \" +\n \"drafting, when it live-reads from the Organization. Mark-sent \" +\n \"requires a complete address (line1, city, state, postalCode).\",\n },\n taxRate: {\n type: [\"number\", \"null\"],\n default: null,\n minimum: 0,\n description:\n \"Tax rate as a plain float percent applied to the taxable line \" +\n \"subtotal. While drafting, null means the platform default rate; the \" +\n \"effective rate is snapshotted at mark-sent.\",\n },\n taxExempt: {\n type: \"boolean\",\n default: false,\n description:\n \"The organization's tax exemption snapshotted at mark-sent. While \" +\n \"drafting it live-reads from the Organization.\",\n },\n shippingAmount: {\n type: [\"integer\", \"null\"],\n default: null,\n minimum: 0,\n description:\n \"Shipping & handling in integer cents, added to the grand total on \" +\n \"top of the line subtotal and tax. Null means none.\",\n },\n lines: {\n type: \"array\",\n default: [],\n description:\n \"The bill's lines: cost lines claimed from the uninvoiced pool and \" +\n \"literal manual lines.\",\n items: {\n oneOf: [costLineSchema, manualLineSchema],\n },\n },\n sentAt: {\n $ref: \"definitions.json#/definitions/date\",\n description: \"When the bill was marked sent. Absent until sent.\",\n },\n paidAt: {\n $ref: \"definitions.json#/definitions/date\",\n description: \"When the bill was marked paid. Absent until paid.\",\n },\n voidedAt: {\n $ref: \"definitions.json#/definitions/date\",\n description: \"When the bill was voided. Absent unless voided.\",\n },\n createdAt: {\n $ref: \"definitions.json#/definitions/date\",\n },\n updatedAt: {\n $ref: \"definitions.json#/definitions/date\",\n },\n },\n} as const;\n\nexport type BillSchema = FromSchema<\n typeof billSchema,\n {\n references: [typeof defs, typeof mediaFileSchema];\n deserialize: [\n {\n pattern: {\n format: \"date-time\";\n };\n output: Date | ISODateString;\n },\n ];\n }\n>;\n\n/** One line on a bill: a cost line or a manual line. */\nexport type BillLine = NonNullable<BillSchema[\"lines\"]>[number];\n"],"mappings":"AAoLA,MAAa,aAAa;CACxB,SAAS;CACT,KAAK;CACL,OAAO;CACP,aACE;CAKF,MAAM;CACN,UAAU;EAAC;EAAM;EAAkB;EAAU;EAAY;CAAO;CAChE,sBAAsB;CACtB,YAAY;EACV,IAAI,EACF,MAAM,mCACR;EACA,MAAM;GACJ,MAAM;GACN,MAAM,CAAC,MAAM;GACb,SAAS;EACX;EACA,gBAAgB;GACd,MAAM;GACN,aACE;EAIJ;EACA,QAAQ;GACN,MAAM;GACN,MAAM;IAAC;IAAS;IAAQ;IAAQ;GAAM;GACtC,SAAS;GACT,aACE;EAIJ;EACA,eAAe;GACb,MAAM,CAAC,UAAU,MAAM;GACvB,SAAS;GACT,aACE;EAIJ;EACA,QAAQ;GACN,MAAM,CAAC,UAAU,MAAM;GACvB,SAAS;GACT,aACE;EAEJ;EACA,UAAU;GACR,MAAM;GACN,MAAM,CAA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{"version":3,"file":"bill.js","names":[],"sources":["../../.generated/schemas/bill.ts"],"sourcesContent":["import defs, { ISODateString } from \"./definitions\";\nimport type { FromSchema } from \"json-schema-to-ts\";\nimport { mediaFileSchema } from \"./mediaFile\";\n\n// One bill line is a discriminated union on `type`, so `lines.items` is their\n// `oneOf`. The two branches are disjoint via the `type` const plus\n// `additionalProperties: false`, so a line validates against exactly one.\n//\n// A cost line always names its entry by `costId`; `source` says which\n// collection to look it up in. A `ticket` line resolves through\n// `(ticketId, costId)`, an `adhoc` line reads `costId` straight off the costs\n// collection with `ticketId` null. The claim path is what pairs the two, since\n// JSON Schema cannot state the pairing without splitting the branch and\n// breaking the `type` discriminator every reader keys off.\n//\n// While the bill is a draft the line carries only the reference, the picked\n// `categoryId`, and any draft-time adjustment; the customer-facing `amount`,\n// `description`, and `categoryName` are live-read from the claimed entry and\n// snapshotted onto the line at mark-sent. The billed amount is the marked-up\n// actual (or the `adjustedAmount` override, floored at zero) — vendor truth on\n// the entry is never touched.\nconst costLineSchema = {\n type: \"object\",\n additionalProperties: false,\n required: [\"id\", \"type\"],\n properties: {\n id: {\n type: \"string\",\n description: \"Server-minted ID of the bill line.\",\n },\n type: {\n type: \"string\",\n enum: [\"cost\"],\n description: \"Discriminator: a line drawn from a recorded cost entry.\",\n },\n source: {\n type: \"string\",\n enum: [\"ticket\", \"adhoc\"],\n default: \"ticket\",\n description:\n \"Where the claimed cost entry lives, and therefore how `costId` \" +\n \"resolves: on a ticket, or in the costs collection.\",\n },\n ticketId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The ID of the ticket the claimed cost entry lives on. Null on an \" +\n \"`adhoc` line, which no ticket carries.\",\n },\n costId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The ID of the claimed cost entry: an entry within the ticket on a \" +\n \"`ticket` line, a costs-collection document on an `adhoc` one.\",\n },\n categoryId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The picked billing category, inherited from the claimed cost entry \" +\n \"when the claim does not name one. Optional while drafting, required \" +\n \"at mark-sent. Manual pick — never derived from the ticket's issue.\",\n },\n categoryName: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The category name snapshotted at mark-sent. Null while drafting, \" +\n \"when it live-reads from the category library.\",\n },\n adjustedAmount: {\n type: [\"integer\", \"null\"],\n minimum: 0,\n default: null,\n description:\n \"Optional draft-time override of the billed amount in integer cents, \" +\n \"floored at zero, replacing the marked-up actual at display and \" +\n \"snapshot. Requires `adjustmentReason`. A credit (below zero) is a \" +\n \"manual line instead.\",\n },\n adjustmentReason: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"Short required reason accompanying `adjustedAmount`, kept for the \" +\n \"internal record.\",\n },\n amount: {\n type: [\"integer\", \"null\"],\n default: null,\n description:\n \"The billed amount in integer cents, snapshotted at mark-sent. Null \" +\n \"while drafting, when it live-reads (marked-up actual or the \" +\n \"adjustment) from the cost entry.\",\n },\n description: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The line description, snapshotted at mark-sent. Null while drafting, \" +\n \"when it live-reads from the cost entry.\",\n },\n taxable: {\n type: \"boolean\",\n default: false,\n description:\n \"Whether the line's amount joins the bill's taxable subtotal. \" +\n \"Customer-facing: locks at mark-sent.\",\n },\n },\n} as const;\n\n// A manual line is a literal customer-facing row with no markup math: a\n// `description` and `amount` (which may be negative, serving as a credit) and\n// an optional `propertyId`. The independent internal fields — informational\n// `cost` (never derives the amount), `vendorId`, the vendor-invoice file, and\n// `vendorInvoiceNumber` — are redacted org-side via `canSeeCostSplit` and stay\n// editable in any bill state.\nconst manualLineSchema = {\n type: \"object\",\n additionalProperties: false,\n required: [\"id\", \"type\", \"description\", \"amount\"],\n properties: {\n id: {\n type: \"string\",\n description: \"Server-minted ID of the bill line.\",\n },\n type: {\n type: \"string\",\n enum: [\"manual\"],\n description: \"Discriminator: a literal, non-ticket line.\",\n },\n description: {\n type: \"string\",\n minLength: 1,\n description: \"The literal customer-facing description.\",\n },\n amount: {\n type: \"integer\",\n description:\n \"The billed amount in integer cents. May be negative, serving as a \" +\n \"credit (reference the reason in the description).\",\n },\n propertyId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The property the manual line is attributed to, when it concerns one.\",\n },\n categoryId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The picked billing category. Optional while drafting, required at \" +\n \"mark-sent.\",\n },\n categoryName: {\n type: [\"string\", \"null\"],\n default: null,\n description: \"The category name snapshotted at mark-sent.\",\n },\n cost: {\n type: [\"integer\", \"null\"],\n default: null,\n description:\n \"Informational internal vendor cost in integer cents. Never derives \" +\n \"the amount. Redacted org-side.\",\n },\n vendorId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"Optional reference to the org-scoped Vendor. Internal, redacted \" +\n \"org-side.\",\n },\n vendorInvoice: {\n anyOf: [{ $ref: \"mediaFile.json\" }, { type: \"null\" }],\n default: null,\n description:\n \"The vendor's invoice file backing the line, mirroring the cost-entry \" +\n \"field. Internal, redacted org-side.\",\n },\n vendorInvoiceNumber: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The vendor's own invoice number. Internal, redacted org-side.\",\n },\n taxable: {\n type: \"boolean\",\n default: false,\n description:\n \"Whether the line's amount joins the bill's taxable subtotal. \" +\n \"Customer-facing: locks at mark-sent.\",\n },\n },\n} as const;\n\nexport const billSchema = {\n $schema: \"http://json-schema.org/draft-07/schema\",\n $id: \"bill.json\",\n title: \"Bill\",\n description:\n \"A OneBill bill, stored platform-wide and stamped with its organization: \" +\n \"KFC staff assemble billed lines from the \" +\n \"uninvoiced cost pool (plus manual lines) into a draft, then mark it sent \" +\n \"to freeze and reveal it to the customer. Lifecycle draft → sent → paid, \" +\n \"plus void. Customers see a bill in-app only once sent.\",\n type: \"object\",\n required: [\"id\", \"organizationId\", \"status\", \"currency\", \"lines\"],\n additionalProperties: false,\n properties: {\n id: {\n $ref: \"definitions.json#/definitions/id\",\n },\n type: {\n type: \"string\",\n enum: [\"bill\"],\n default: \"bill\",\n },\n organizationId: {\n type: \"string\",\n description:\n \"The organization the bill invoices. Bills live in one admin-database \" +\n \"collection across every organization, so each carries its owner \" +\n \"explicitly — stamped from the request context at creation, never \" +\n \"client-supplied.\",\n },\n status: {\n type: \"string\",\n enum: [\"draft\", \"sent\", \"paid\", \"void\"],\n default: \"draft\",\n description:\n \"Lifecycle state. `sent` freezes customer-facing fields and reveals \" +\n \"the bill to the org; `paid` records manual payment; `void` releases \" +\n \"cost-entry claims and hides the bill from the org view. Drafts \" +\n \"hard-delete rather than voiding.\",\n },\n invoiceNumber: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"Kohost's own invoice number, `KB-<n>` from a single global sequence. \" +\n \"System-assigned at mark-sent and never entered by hand: null while \" +\n \"the bill is a draft, immutable once set. A wrong bill is corrected \" +\n \"by void-and-reissue, so numbers gap and are never reused.\",\n },\n period: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n 'Display-only month label (e.g. \"July 2026\"). A UI hint; the bill\\'s ' +\n \"membership is defined by its lines, not a calendar bucket.\",\n },\n currency: {\n type: \"string\",\n enum: [\"USD\"],\n default: \"USD\",\n description: \"ISO 4217 currency code. USD only in v1.\",\n },\n fileId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The generated bill PDF's media-file ID, minted atomically at \" +\n \"mark-sent.\",\n },\n fileUrl: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The generated bill PDF's file-store URL, snapshotted at mark-sent \" +\n \"alongside fileId. Held so the sent-bill surface and the sent \" +\n \"notification email can mint a signed, unauthenticated download link \" +\n \"without a file lookup. Unsigned on its own (a bare link 401s).\",\n },\n memo: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"Internal KFC-only note. Never customer-facing; editable in any state.\",\n },\n billingAddress: {\n anyOf: [\n { $ref: \"definitions.json#/definitions/address\" },\n { type: \"null\" },\n ],\n default: null,\n description:\n \"The org billing address snapshotted at mark-sent. Null while \" +\n \"drafting, when it live-reads from the Organization. Mark-sent \" +\n \"requires a complete address (line1, city, state, postalCode).\",\n },\n taxRate: {\n type: [\"number\", \"null\"],\n default: null,\n minimum: 0,\n description:\n \"Tax rate as a plain float percent applied to the taxable line \" +\n \"subtotal. While drafting, null means the platform default rate; the \" +\n \"effective rate is snapshotted at mark-sent.\",\n },\n taxExempt: {\n type: \"boolean\",\n default: false,\n description:\n \"The organization's tax exemption snapshotted at mark-sent. While \" +\n \"drafting it live-reads from the Organization.\",\n },\n shippingAmount: {\n type: [\"integer\", \"null\"],\n default: null,\n minimum: 0,\n description:\n \"Shipping & handling in integer cents, added to the grand total on \" +\n \"top of the line subtotal and tax. Null means none.\",\n },\n lines: {\n type: \"array\",\n default: [],\n description:\n \"The bill's lines: cost lines claimed from the uninvoiced pool and \" +\n \"literal manual lines.\",\n items: {\n oneOf: [costLineSchema, manualLineSchema],\n },\n },\n sentAt: {\n $ref: \"definitions.json#/definitions/date\",\n description: \"When the bill was marked sent. Absent until sent.\",\n },\n paidAt: {\n $ref: \"definitions.json#/definitions/date\",\n description: \"When the bill was marked paid. Absent until paid.\",\n },\n voidedAt: {\n $ref: \"definitions.json#/definitions/date\",\n description: \"When the bill was voided. Absent unless voided.\",\n },\n createdAt: {\n $ref: \"definitions.json#/definitions/date\",\n },\n updatedAt: {\n $ref: \"definitions.json#/definitions/date\",\n },\n },\n} as const;\n\nexport type BillSchema = FromSchema<\n typeof billSchema,\n {\n references: [typeof defs, typeof mediaFileSchema];\n deserialize: [\n {\n pattern: {\n format: \"date-time\";\n };\n output: Date | ISODateString;\n },\n ];\n }\n>;\n\n/** One line on a bill: a cost line or a manual line. */\nexport type BillLine = NonNullable<BillSchema[\"lines\"]>[number];\n"],"mappings":"AAwMA,MAAa,aAAa;CACxB,SAAS;CACT,KAAK;CACL,OAAO;CACP,aACE;CAKF,MAAM;CACN,UAAU;EAAC;EAAM;EAAkB;EAAU;EAAY;CAAO;CAChE,sBAAsB;CACtB,YAAY;EACV,IAAI,EACF,MAAM,mCACR;EACA,M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AAU,MAAM;MACvB,SAAS;MACT,aACE;KAEJ;KACA,eAAe;MACb,OAAO,CAAC,EAAE,MAAM,iBAAiB,GAAG,EAAE,MAAM,OAAO,CAAC;MACpD,SAAS;MACT,aACE;KAEJ;KACA,qBAAqB;MACnB,MAAM,CAAC,UAAU,MAAM;MACvB,SAAS;MACT,aACE;KACJ;KACA,SAAS;MACP,MAAM;MACN,SAAS;MACT,aACE;KAEJ;IACF;GAiI8B,CAAgB,EAC1C;EACF;EACA,QAAQ;GACN,MAAM;GACN,aAAa;EACf;EACA,QAAQ;GACN,MAAM;GACN,aAAa;EACf;EACA,UAAU;GACR,MAAM;GACN,aAAa;EACf;EACA,WAAW,EACT,MAAM,qCACR;EACA,WAAW,EACT,MAAM,qCACR;CACF;AACF"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import defs, { ISODateString } from "./definitions.js";
|
|
2
|
+
import type { FromSchema } from "json-schema-to-ts";
|
|
3
|
+
import { mediaFileSchema } from "./mediaFile.js";
|
|
4
|
+
export declare const costSchema: {
|
|
5
|
+
readonly $schema: "http://json-schema.org/draft-07/schema";
|
|
6
|
+
readonly $id: "cost.json";
|
|
7
|
+
readonly title: "Cost";
|
|
8
|
+
readonly description: string;
|
|
9
|
+
readonly type: "object";
|
|
10
|
+
readonly required: readonly ["id", "description", "currency", "price", "estimate", "markup", "organizationId"];
|
|
11
|
+
readonly additionalProperties: false;
|
|
12
|
+
readonly properties: {
|
|
13
|
+
readonly id: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly description: "The ID of the cost entry.";
|
|
16
|
+
};
|
|
17
|
+
readonly description: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly description: "What the cost covers.";
|
|
20
|
+
};
|
|
21
|
+
readonly currency: {
|
|
22
|
+
readonly type: "string";
|
|
23
|
+
readonly default: "USD";
|
|
24
|
+
readonly description: "ISO 4217 currency code of the entry's amounts.";
|
|
25
|
+
};
|
|
26
|
+
readonly price: {
|
|
27
|
+
readonly type: "object";
|
|
28
|
+
readonly additionalProperties: false;
|
|
29
|
+
readonly required: readonly ["amount", "recordedBy", "recordedAt"];
|
|
30
|
+
readonly description: string;
|
|
31
|
+
readonly properties: {
|
|
32
|
+
readonly amount: {
|
|
33
|
+
readonly type: "integer";
|
|
34
|
+
readonly minimum: 0;
|
|
35
|
+
readonly description: "The amount in integer cents.";
|
|
36
|
+
};
|
|
37
|
+
readonly recordedBy: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
readonly description: "The ID of the user who recorded the amount.";
|
|
40
|
+
};
|
|
41
|
+
readonly recordedAt: {
|
|
42
|
+
readonly $ref: "definitions.json#/definitions/date";
|
|
43
|
+
readonly description: "When the amount was recorded.";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
readonly estimate: {
|
|
48
|
+
readonly type: "object";
|
|
49
|
+
readonly additionalProperties: false;
|
|
50
|
+
readonly required: readonly ["amount", "recordedBy", "recordedAt"];
|
|
51
|
+
readonly description: string;
|
|
52
|
+
readonly properties: {
|
|
53
|
+
readonly amount: {
|
|
54
|
+
readonly type: "integer";
|
|
55
|
+
readonly minimum: 0;
|
|
56
|
+
readonly description: "The amount in integer cents.";
|
|
57
|
+
};
|
|
58
|
+
readonly recordedBy: {
|
|
59
|
+
readonly type: "string";
|
|
60
|
+
readonly description: "The ID of the user who recorded the amount.";
|
|
61
|
+
};
|
|
62
|
+
readonly recordedAt: {
|
|
63
|
+
readonly $ref: "definitions.json#/definitions/date";
|
|
64
|
+
readonly description: "When the amount was recorded.";
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
readonly actual: {
|
|
69
|
+
readonly type: "object";
|
|
70
|
+
readonly additionalProperties: false;
|
|
71
|
+
readonly required: readonly ["amount", "recordedBy", "recordedAt"];
|
|
72
|
+
readonly description: string;
|
|
73
|
+
readonly properties: {
|
|
74
|
+
readonly amount: {
|
|
75
|
+
readonly type: "integer";
|
|
76
|
+
readonly minimum: 0;
|
|
77
|
+
readonly description: "The amount in integer cents.";
|
|
78
|
+
};
|
|
79
|
+
readonly recordedBy: {
|
|
80
|
+
readonly type: "string";
|
|
81
|
+
readonly description: "The ID of the user who recorded the amount.";
|
|
82
|
+
};
|
|
83
|
+
readonly recordedAt: {
|
|
84
|
+
readonly $ref: "definitions.json#/definitions/date";
|
|
85
|
+
readonly description: "When the amount was recorded.";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
readonly markup: {
|
|
90
|
+
readonly type: "object";
|
|
91
|
+
readonly additionalProperties: false;
|
|
92
|
+
readonly required: readonly ["percent"];
|
|
93
|
+
readonly properties: {
|
|
94
|
+
readonly percent: {
|
|
95
|
+
readonly type: "number";
|
|
96
|
+
readonly description: string;
|
|
97
|
+
};
|
|
98
|
+
readonly custom: {
|
|
99
|
+
readonly type: "boolean";
|
|
100
|
+
readonly default: false;
|
|
101
|
+
readonly description: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
readonly vendorId: {
|
|
106
|
+
readonly type: readonly ["string", "null"];
|
|
107
|
+
readonly default: null;
|
|
108
|
+
readonly description: string;
|
|
109
|
+
};
|
|
110
|
+
readonly categoryId: {
|
|
111
|
+
readonly type: readonly ["string", "null"];
|
|
112
|
+
readonly default: null;
|
|
113
|
+
readonly description: string;
|
|
114
|
+
};
|
|
115
|
+
readonly vendorInvoices: {
|
|
116
|
+
readonly type: "array";
|
|
117
|
+
readonly items: {
|
|
118
|
+
readonly $ref: "mediaFile.json";
|
|
119
|
+
};
|
|
120
|
+
readonly default: readonly [];
|
|
121
|
+
readonly description: string;
|
|
122
|
+
};
|
|
123
|
+
readonly vendorInvoiceNumber: {
|
|
124
|
+
readonly type: readonly ["string", "null"];
|
|
125
|
+
readonly default: null;
|
|
126
|
+
readonly description: string;
|
|
127
|
+
};
|
|
128
|
+
readonly billId: {
|
|
129
|
+
readonly type: readonly ["string", "null"];
|
|
130
|
+
readonly default: null;
|
|
131
|
+
readonly description: string;
|
|
132
|
+
};
|
|
133
|
+
readonly writtenOff: {
|
|
134
|
+
readonly type: "boolean";
|
|
135
|
+
readonly default: false;
|
|
136
|
+
readonly description: string;
|
|
137
|
+
};
|
|
138
|
+
readonly billingReview: {
|
|
139
|
+
readonly type: "array";
|
|
140
|
+
readonly default: readonly [];
|
|
141
|
+
readonly description: string;
|
|
142
|
+
readonly items: {
|
|
143
|
+
readonly type: "object";
|
|
144
|
+
readonly additionalProperties: false;
|
|
145
|
+
readonly required: readonly ["id", "action", "performedAt"];
|
|
146
|
+
readonly properties: {
|
|
147
|
+
readonly id: {
|
|
148
|
+
readonly type: "string";
|
|
149
|
+
readonly description: "The ID of the billing review entry.";
|
|
150
|
+
};
|
|
151
|
+
readonly action: {
|
|
152
|
+
readonly type: "string";
|
|
153
|
+
readonly enum: readonly ["writtenOff", "reinstated", "divergenceAcknowledged"];
|
|
154
|
+
};
|
|
155
|
+
readonly performedBy: {
|
|
156
|
+
readonly type: readonly ["string", "null"];
|
|
157
|
+
readonly default: null;
|
|
158
|
+
readonly description: string;
|
|
159
|
+
};
|
|
160
|
+
readonly performedAt: {
|
|
161
|
+
readonly $ref: "definitions.json#/definitions/date";
|
|
162
|
+
readonly description: "When the entry was appended.";
|
|
163
|
+
};
|
|
164
|
+
readonly note: {
|
|
165
|
+
readonly type: readonly ["string", "null"];
|
|
166
|
+
readonly default: null;
|
|
167
|
+
readonly description: "Free-text rationale for the action.";
|
|
168
|
+
};
|
|
169
|
+
readonly billedAmount: {
|
|
170
|
+
readonly type: "integer";
|
|
171
|
+
readonly minimum: 0;
|
|
172
|
+
readonly description: string;
|
|
173
|
+
};
|
|
174
|
+
readonly priceAmount: {
|
|
175
|
+
readonly type: "integer";
|
|
176
|
+
readonly minimum: 0;
|
|
177
|
+
readonly description: string;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
readonly type: {
|
|
183
|
+
readonly type: "string";
|
|
184
|
+
readonly enum: readonly ["cost"];
|
|
185
|
+
readonly default: "cost";
|
|
186
|
+
};
|
|
187
|
+
readonly source: {
|
|
188
|
+
readonly type: "string";
|
|
189
|
+
readonly enum: readonly ["adhoc"];
|
|
190
|
+
readonly default: "adhoc";
|
|
191
|
+
readonly description: string;
|
|
192
|
+
};
|
|
193
|
+
readonly organizationId: {
|
|
194
|
+
readonly type: "string";
|
|
195
|
+
readonly description: string;
|
|
196
|
+
};
|
|
197
|
+
readonly propertyId: {
|
|
198
|
+
readonly type: readonly ["string", "null"];
|
|
199
|
+
readonly default: null;
|
|
200
|
+
readonly description: "The property the cost is attributed to, when it concerns one.";
|
|
201
|
+
};
|
|
202
|
+
readonly createdBy: {
|
|
203
|
+
readonly type: readonly ["string", "null"];
|
|
204
|
+
readonly default: null;
|
|
205
|
+
readonly description: string;
|
|
206
|
+
};
|
|
207
|
+
readonly createdAt: {
|
|
208
|
+
readonly $ref: "definitions.json#/definitions/date";
|
|
209
|
+
};
|
|
210
|
+
readonly updatedAt: {
|
|
211
|
+
readonly $ref: "definitions.json#/definitions/date";
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
export type CostSchema = FromSchema<typeof costSchema, {
|
|
216
|
+
references: [typeof defs, typeof mediaFileSchema];
|
|
217
|
+
deserialize: [
|
|
218
|
+
{
|
|
219
|
+
pattern: {
|
|
220
|
+
format: "date-time";
|
|
221
|
+
};
|
|
222
|
+
output: Date | ISODateString;
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
}>;
|
|
226
|
+
/** One entry of a cost's append-only billing review history. */
|
|
227
|
+
export type CostBillingReviewEntry = NonNullable<CostSchema["billingReview"]>[number];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { costEntryProperties, costEntryRequired } from "./costEntry.js";
|
|
2
|
+
//#region .generated/schemas/cost.ts
|
|
3
|
+
const costSchema = {
|
|
4
|
+
$schema: "http://json-schema.org/draft-07/schema",
|
|
5
|
+
$id: "cost.json",
|
|
6
|
+
title: "Cost",
|
|
7
|
+
description: "A OneBill cost entry that no ticket carries: a recurring vendor charge, an expense found while reconciling an invoice, a pass-through cost. It shares the money shape and reconciliation lifecycle of a ticket cost entry and moves through the uninvoiced pool the same way, but because no ticket carries it the DNE approval gate never applies. Stored platform-wide beside bills and stamped with its organization.",
|
|
8
|
+
type: "object",
|
|
9
|
+
required: [...costEntryRequired, "organizationId"],
|
|
10
|
+
additionalProperties: false,
|
|
11
|
+
properties: {
|
|
12
|
+
...costEntryProperties,
|
|
13
|
+
type: {
|
|
14
|
+
type: "string",
|
|
15
|
+
enum: ["cost"],
|
|
16
|
+
default: "cost"
|
|
17
|
+
},
|
|
18
|
+
source: {
|
|
19
|
+
type: "string",
|
|
20
|
+
enum: ["adhoc"],
|
|
21
|
+
default: "adhoc",
|
|
22
|
+
description: "How the entry came to be recorded. Only `adhoc` today, a biller typing in a charge; the enum is what lets a later importer or integration land in the same collection without a second one. A ticket cost entry carries no source: living on the ticket is what says where it came from."
|
|
23
|
+
},
|
|
24
|
+
organizationId: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "The organization the cost is billed to. These entries live in one admin-database collection across every organization, so each carries its owner explicitly — stamped from the request context at creation, never client-supplied."
|
|
27
|
+
},
|
|
28
|
+
propertyId: {
|
|
29
|
+
type: ["string", "null"],
|
|
30
|
+
default: null,
|
|
31
|
+
description: "The property the cost is attributed to, when it concerns one."
|
|
32
|
+
},
|
|
33
|
+
createdBy: {
|
|
34
|
+
type: ["string", "null"],
|
|
35
|
+
default: null,
|
|
36
|
+
description: "The ID of the billing staff member who recorded the entry. Null when the write was not user-attributable."
|
|
37
|
+
},
|
|
38
|
+
createdAt: { $ref: "definitions.json#/definitions/date" },
|
|
39
|
+
updatedAt: { $ref: "definitions.json#/definitions/date" }
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { costSchema };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=cost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.js","names":[],"sources":["../../.generated/schemas/cost.ts"],"sourcesContent":["import defs, { ISODateString } from \"./definitions\";\nimport type { FromSchema } from \"json-schema-to-ts\";\nimport { costEntryProperties, costEntryRequired } from \"./costEntry\";\nimport { mediaFileSchema } from \"./mediaFile\";\n\nexport const costSchema = {\n $schema: \"http://json-schema.org/draft-07/schema\",\n $id: \"cost.json\",\n title: \"Cost\",\n description:\n \"A OneBill cost entry that no ticket carries: a recurring vendor charge, \" +\n \"an expense found while reconciling an invoice, a pass-through cost. It \" +\n \"shares the money shape and reconciliation lifecycle of a ticket cost \" +\n \"entry and moves through the uninvoiced pool the same way, but because no \" +\n \"ticket carries it the DNE approval gate never applies. Stored \" +\n \"platform-wide beside bills and stamped with its organization.\",\n type: \"object\",\n required: [...costEntryRequired, \"organizationId\"],\n additionalProperties: false,\n properties: {\n ...costEntryProperties,\n type: {\n type: \"string\",\n enum: [\"cost\"],\n default: \"cost\",\n },\n source: {\n type: \"string\",\n enum: [\"adhoc\"],\n default: \"adhoc\",\n description:\n \"How the entry came to be recorded. Only `adhoc` today, a biller \" +\n \"typing in a charge; the enum is what lets a later importer or \" +\n \"integration land in the same collection without a second one. A \" +\n \"ticket cost entry carries no source: living on the ticket is what \" +\n \"says where it came from.\",\n },\n organizationId: {\n type: \"string\",\n description:\n \"The organization the cost is billed to. These entries live in one \" +\n \"admin-database collection across every organization, so each \" +\n \"carries its owner explicitly — stamped from the request context at \" +\n \"creation, never client-supplied.\",\n },\n propertyId: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The property the cost is attributed to, when it concerns one.\",\n },\n createdBy: {\n type: [\"string\", \"null\"],\n default: null,\n description:\n \"The ID of the billing staff member who recorded the entry. Null \" +\n \"when the write was not user-attributable.\",\n },\n createdAt: {\n $ref: \"definitions.json#/definitions/date\",\n },\n updatedAt: {\n $ref: \"definitions.json#/definitions/date\",\n },\n },\n} as const;\n\nexport type CostSchema = FromSchema<\n typeof costSchema,\n {\n references: [typeof defs, typeof mediaFileSchema];\n deserialize: [\n {\n pattern: {\n format: \"date-time\";\n };\n output: Date | ISODateString;\n },\n ];\n }\n>;\n\n/** One entry of a cost's append-only billing review history. */\nexport type CostBillingReviewEntry = NonNullable<\n CostSchema[\"billingReview\"]\n>[number];\n"],"mappings":";;AAKA,MAAa,aAAa;CACxB,SAAS;CACT,KAAK;CACL,OAAO;CACP,aACE;CAMF,MAAM;CACN,UAAU,CAAC,GAAG,mBAAmB,gBAAgB;CACjD,sBAAsB;CACtB,YAAY;EACV,GAAG;EACH,MAAM;GACJ,MAAM;GACN,MAAM,CAAC,MAAM;GACb,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,MAAM,CAAC,OAAO;GACd,SAAS;GACT,aACE;EAKJ;EACA,gBAAgB;GACd,MAAM;GACN,aACE;EAIJ;EACA,YAAY;GACV,MAAM,CAAC,UAAU,MAAM;GACvB,SAAS;GACT,aACE;EACJ;EACA,WAAW;GACT,MAAM,CAAC,UAAU,MAAM;GACvB,SAAS;GACT,aACE;EAEJ;EACA,WAAW,EACT,MAAM,qCACR;EACA,WAAW,EACT,MAAM,qCACR;CACF;AACF"}
|