@things-factory/saas 0.0.0-stage → 10.1.234

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +19 -2
  2. package/dist-client/bootstrap.d.ts +1 -0
  3. package/dist-client/bootstrap.js +5 -0
  4. package/dist-client/bootstrap.js.map +1 -0
  5. package/dist-client/components/saas-bill-editor.d.ts +59 -0
  6. package/dist-client/components/saas-bill-editor.js +211 -0
  7. package/dist-client/components/saas-bill-editor.js.map +1 -0
  8. package/dist-client/entity360/saas-account-360.d.ts +12 -0
  9. package/dist-client/entity360/saas-account-360.js +231 -0
  10. package/dist-client/entity360/saas-account-360.js.map +1 -0
  11. package/dist-client/index.d.ts +3 -0
  12. package/dist-client/index.js +4 -0
  13. package/dist-client/index.js.map +1 -0
  14. package/dist-client/pages/saas-account-list.d.ts +57 -0
  15. package/dist-client/pages/saas-account-list.js +175 -0
  16. package/dist-client/pages/saas-account-list.js.map +1 -0
  17. package/dist-client/pages/saas-account-page.d.ts +54 -0
  18. package/dist-client/pages/saas-account-page.js +352 -0
  19. package/dist-client/pages/saas-account-page.js.map +1 -0
  20. package/dist-client/pages/saas-cost-trend.d.ts +23 -0
  21. package/dist-client/pages/saas-cost-trend.js +219 -0
  22. package/dist-client/pages/saas-cost-trend.js.map +1 -0
  23. package/dist-client/route.d.ts +1 -0
  24. package/dist-client/route.js +16 -0
  25. package/dist-client/route.js.map +1 -0
  26. package/dist-client/tsconfig.tsbuildinfo +1 -0
  27. package/dist-client/words.d.ts +47 -0
  28. package/dist-client/words.js +39 -0
  29. package/dist-client/words.js.map +1 -0
  30. package/dist-server/index.d.ts +1 -0
  31. package/dist-server/index.js +9 -0
  32. package/dist-server/index.js.map +1 -0
  33. package/dist-server/role-tasks.d.ts +2 -0
  34. package/dist-server/role-tasks.js +16 -0
  35. package/dist-server/role-tasks.js.map +1 -0
  36. package/dist-server/service/checks.d.ts +32 -0
  37. package/dist-server/service/checks.js +83 -0
  38. package/dist-server/service/checks.js.map +1 -0
  39. package/dist-server/service/index.d.ts +20 -0
  40. package/dist-server/service/index.js +38 -0
  41. package/dist-server/service/index.js.map +1 -0
  42. package/dist-server/service/saas-access.d.ts +20 -0
  43. package/dist-server/service/saas-access.js +36 -0
  44. package/dist-server/service/saas-access.js.map +1 -0
  45. package/dist-server/service/saas-account.d.ts +43 -0
  46. package/dist-server/service/saas-account.js +166 -0
  47. package/dist-server/service/saas-account.js.map +1 -0
  48. package/dist-server/service/saas-bill.d.ts +41 -0
  49. package/dist-server/service/saas-bill.js +160 -0
  50. package/dist-server/service/saas-bill.js.map +1 -0
  51. package/dist-server/service/saas-mutation.d.ts +12 -0
  52. package/dist-server/service/saas-mutation.js +103 -0
  53. package/dist-server/service/saas-mutation.js.map +1 -0
  54. package/dist-server/service/saas-query.d.ts +69 -0
  55. package/dist-server/service/saas-query.js +215 -0
  56. package/dist-server/service/saas-query.js.map +1 -0
  57. package/dist-server/service/saas-rules.d.ts +138 -0
  58. package/dist-server/service/saas-rules.js +217 -0
  59. package/dist-server/service/saas-rules.js.map +1 -0
  60. package/dist-server/service/saas-seat.d.ts +25 -0
  61. package/dist-server/service/saas-seat.js +105 -0
  62. package/dist-server/service/saas-seat.js.map +1 -0
  63. package/dist-server/service/saas-service.d.ts +119 -0
  64. package/dist-server/service/saas-service.js +492 -0
  65. package/dist-server/service/saas-service.js.map +1 -0
  66. package/dist-server/service/saas-subscription.d.ts +44 -0
  67. package/dist-server/service/saas-subscription.js +174 -0
  68. package/dist-server/service/saas-subscription.js.map +1 -0
  69. package/dist-server/service/saas-trend-type.d.ts +9 -0
  70. package/dist-server/service/saas-trend-type.js +37 -0
  71. package/dist-server/service/saas-trend-type.js.map +1 -0
  72. package/dist-server/service/saas-type.d.ts +113 -0
  73. package/dist-server/service/saas-type.js +430 -0
  74. package/dist-server/service/saas-type.js.map +1 -0
  75. package/dist-server/tsconfig.tsbuildinfo +1 -0
  76. package/package.json +49 -4
  77. package/things-factory.config.js +13 -0
  78. package/translations/en.json +185 -0
  79. package/translations/es.json +185 -0
  80. package/translations/ja.json +185 -0
  81. package/translations/ko.json +185 -0
  82. package/translations/ms.json +185 -0
  83. package/translations/zh.json +185 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saas-service.js","sourceRoot":"","sources":["../../server/service/saas-service.ts"],"names":[],"mappings":";;;AA0EA,4CA6CC;AAKD,sDA+CC;AAGD,kDAMC;AAWD,sCAwBC;AAED,kCAGC;AAaD,oCA8BC;AAED,wCAKC;AAGD,0BAgBC;AAED,kCAGC;AA6BD,oCAgCC;AAiBD,sCA0DC;AAUD,wCAYC;AAGD,wCAGC;AAOD,oCA4BC;AAGD,sCAQC;AAxfD,2DAAwG;AACxG,iDAA6C;AAC7C,mHAAmH;AACnH,qFAA4H;AAC5H,uDAAuD;AACvD,6DAA8F;AAC9F,+DAAmE;AACnE,iDAAuD;AACvD,qCAA2C;AAE3C,+CAAoD;AACpD,iDAA4C;AAC5C,2CAAoD;AACpD,6CAaqB;AACrB,2CAAsC;AACtC,2DAAsD;AAGtD,MAAM,UAAU,GAAG,CAAC,KAAU,EAAE,QAAuB,EAAE,EAAE;IACzD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACrD,IAAI,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAA;IAC1B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,eAAO,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,IAAI,qCAAqC,CAAC,CAAA;IACxI,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,KAAU,EAAE,IAAY,EAAE,GAAW,EAAE,GAAW,EAAiB,EAAE;IAClF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAA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AC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/H,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAC,GAAG,EAAC,EAAE,CAAC,CAAC,MAAM,IAAA,6BAAe,EAAC,EAAE,EAAE,MAAM,EAAE,8BAAsB,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;KAChL,CAAA;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;AACjF,CAAC","sourcesContent":["import { BankAccount, CashFlowType, Transaction, TransactionCategory } from '@things-factory/accounting'\nimport { Asset } from '@things-factory/asset'\n/* The register grids' save, the asset module's - this module saves its grids the same way (one implementation). */\nimport { amountOf, applyPatches, dayOf, Patch, textOf, touched } from '@things-factory/asset/dist-server/service/patches.js'\nimport { Counterparty } from '@things-factory/biz-base'\nimport { fieldChanges, readFactChanges, recordFactChanges } from '@things-factory/fact-change'\nimport { Department, Employee } from '@things-factory/organization'\nimport { Domain, Refusal } from '@things-factory/shell'\nimport { EntityManager, In } from 'typeorm'\n\nimport { accountIn, SaasScope } from './saas-access'\nimport { SaasAccount } from './saas-account'\nimport { SaasBill, SaasBillLine } from './saas-bill'\nimport {\n alertsOf,\n BillFacts,\n billTotal,\n expectedOfMonth,\n MONTH,\n monthsFrom,\n SaasAccountStatus,\n SaasBilling,\n SaasSubscriptionStatus,\n seatHeld,\n shiftMonth,\n trendOf\n} from './saas-rules'\nimport { SaasSeat } from './saas-seat'\nimport { SaasSubscription } from './saas-subscription'\nimport { SaasTrend } from './saas-trend-type'\n\nconst currencyOf = (value: any, fallback: string | null) => {\n const text = String(value ?? '').trim().toUpperCase()\n if (!text) return fallback\n if (!/^[A-Z]{3}$/.test(text)) throw new Refusal('saas-currency-invalid', { value: text }, `'${text}' is not a currency code (KRW, USD)`)\n return text\n}\n\nconst intOf = (value: any, code: string, min: number, max: number): number | null => {\n if (value === null || value === undefined || value === '') return null\n const number = Number(value)\n if (!Number.isInteger(number) || number < min || number > max) throw new Refusal(code, { min, max }, `Give a whole number from ${min} to ${max}`)\n return number\n}\n\nasync function oneOf<T>(tx: EntityManager, target: any, domain: Domain, id: string | null | undefined, code: string): Promise<T | null> {\n if (!id) return null\n const found = await tx.getRepository(target).findOne({ where: { domain: { id: domain.id }, id } as any })\n if (!found) throw new Refusal(code, {}, 'What it points at was not found')\n return found as T\n}\n\nconst field = (patch: Patch, name: string, old?: any) => (patch[name] !== undefined ? patch[name] : old?.[name])\n\n/*\n * What moved on an account or a subscription, field by field (ADR-0177 decision 11) - the fact-change module keeps it.\n * A row's relations are told by their id; a new row has no history yet.\n */\nexport const SAAS_ACCOUNT_FACT = 'saas-account'\nexport const SAAS_SUBSCRIPTION_FACT = 'saas-subscription'\nconst ACCOUNT_TRACKED = ['name', 'counterpartyId', 'identifier', 'parentId', 'paymentAccountId', 'currency', 'billingDay', 'increaseAlertRate', 'status', 'closedOn'] as const\nconst SUBSCRIPTION_TRACKED = ['name', 'billing', 'quantity', 'unitPrice', 'amount', 'budget', 'everyMonths', 'startOn', 'renewalOn', 'autoRenew', 'noticeDays', 'departmentId', 'assetId', 'status', 'endedOn'] as const\nconst idsOf = (row: Record<string, any>) =>\n Object.fromEntries(Object.entries(row).map(([key, value]) => (value && typeof value === 'object' && 'id' in value ? [`${key}Id`, value.id] : value === null && ['counterparty', 'parent', 'paymentAccount', 'department', 'asset'].includes(key) ? [`${key}Id`, null] : [key, value])))\n\nasync function recordChanges(tx: EntityManager, domain: Domain, user: any, factKind: string, old: any, row: Record<string, any>, fields: readonly string[]) {\n if (!old) return\n const after = { ...old, ...idsOf(row) }\n await recordFactChanges(tx, domain, { factKind, factName: old.id, changes: fieldChanges(old, after, fields as any) }, { user, source: 'saas' })\n}\n\n/* ----------------------------------------------------------------------------------------------------------------- */\n/* Accounts (decision 2) - kept by `saas` keepers only */\n\nexport function saveSaasAccounts(tx: EntityManager, domain: Domain, user: any, patches: Patch[]) {\n return applyPatches(\n tx,\n SaasAccount,\n domain,\n user,\n patches,\n async (patch, old) => {\n const row: Record<string, any> = {}\n const name = touched(patch, 'name', old) ? textOf(patch.name) : old!.name\n if (!name) throw new Refusal('saas-account-name-required', {}, 'Name the service')\n row.name = name\n for (const one of ['identifier', 'purpose', 'billingEmail', 'secretLocation', 'description']) if (touched(patch, one, old)) row[one] = textOf(patch[one])\n if (touched(patch, 'currency', old)) row.currency = currencyOf(patch.currency, 'KRW')\n if (touched(patch, 'billingDay', old)) row.billingDay = intOf(patch.billingDay, 'saas-billing-day-invalid', 1, 31)\n if (touched(patch, 'increaseAlertRate', old)) {\n const rate = amountOf(patch.increaseAlertRate, 'saas-alert-rate-invalid')\n if (rate !== null && rate > 10) throw new Refusal('saas-alert-rate-invalid', {}, 'Give the rate as a part - 0.2 for 20%')\n row.increaseAlertRate = rate\n }\n if (touched(patch, 'counterpartyId', old)) row.counterparty = await oneOf(tx, Counterparty, domain, patch.counterpartyId, 'saas-counterparty-not-found')\n if (touched(patch, 'paymentAccountId', old)) row.paymentAccount = await oneOf(tx, BankAccount, domain, patch.paymentAccountId, 'saas-payment-account-not-found')\n if (touched(patch, 'parentId', old)) {\n const parent = await oneOf<SaasAccount>(tx, SaasAccount, domain, patch.parentId, 'saas-parent-not-found')\n if (parent && (parent.id === old?.id || (await tx.getRepository(SaasAccount).findOne({ where: { id: parent.id }, relations: ['parent'] }))?.parent))\n throw new Refusal('saas-parent-invalid', {}, 'An account is under a top account only, and not under itself')\n if (parent && old && (await tx.getRepository(SaasSubscription).count({ where: { account: { id: old.id } } as any })))\n throw new Refusal('saas-parent-has-subscriptions', {}, 'An account with subscriptions is billed itself - it cannot go under another')\n row.parent = parent\n }\n if (touched(patch, 'adminIds', old)) {\n const ids: string[] = [...new Set<string>((patch.adminIds ?? []).filter(Boolean))]\n const admins = ids.length ? await tx.getRepository(Employee).find({ where: { id: In(ids), domain: { id: domain.id } } as any }) : []\n if (admins.length !== ids.length) throw new Refusal('saas-admin-not-found', {}, 'An admin is no employee of this domain')\n row.admins = admins\n }\n if (touched(patch, 'status', old)) row.status = patch.status ?? SaasAccountStatus.ACTIVE\n if (touched(patch, 'closedOn', old)) row.closedOn = dayOf(patch.closedOn, 'saas-day-invalid')\n if ((row.status ?? old?.status) === SaasAccountStatus.CLOSED && !(row.closedOn !== undefined ? row.closedOn : old?.closedOn))\n throw new Refusal('saas-closed-on-required', {}, 'Give the day it was closed')\n await recordChanges(tx, domain, user, SAAS_ACCOUNT_FACT, old, row, ACCOUNT_TRACKED)\n return row\n },\n 'saas-account-not-found'\n )\n}\n\n/* ----------------------------------------------------------------------------------------------------------------- */\n/* Subscriptions (decision 3) - by keepers, and by the account's admins */\n\nexport async function saveSaasSubscriptions(tx: EntityManager, domain: Domain, user: any, scope: SaasScope, accountId: string, patches: Patch[]) {\n const account = await accountIn(tx, domain, scope, accountId)\n if (account.parentId && patches.some(one => one.cuFlag !== '-'))\n throw new Refusal('saas-subscription-on-sub-account', {}, 'An account under another is billed by its parent - subscribe there')\n return applyPatches(\n tx,\n SaasSubscription,\n domain,\n user,\n patches,\n async (patch, old) => {\n const row: Record<string, any> = old ? {} : { account }\n const name = touched(patch, 'name', old) ? textOf(patch.name) : old!.name\n if (!name) throw new Refusal('saas-subscription-name-required', {}, 'Name the product or plan')\n row.name = name\n const billing = (field(patch, 'billing', old) ?? SaasBilling.FIXED) as SaasBilling\n if (!Object.values(SaasBilling).includes(billing)) throw new Refusal('saas-billing-invalid', {}, 'Say how it is paid for')\n row.billing = billing\n for (const one of ['quantity', 'unitPrice', 'amount', 'budget']) if (touched(patch, one, old)) row[one] = amountOf(patch[one], 'saas-amount-invalid')\n const value = (name: string) => (row[name] !== undefined ? row[name] : old?.[name])\n if (billing === SaasBilling.SEAT && !(Number(value('quantity')) > 0 && value('unitPrice') !== null && value('unitPrice') !== undefined))\n throw new Refusal('saas-seat-price-required', {}, 'A seat plan takes its seats and the price of one')\n if ((billing === SaasBilling.FIXED || billing === SaasBilling.COMMITMENT) && (value('amount') === null || value('amount') === undefined))\n throw new Refusal('saas-amount-required', {}, 'Give what one billing costs')\n if (touched(patch, 'everyMonths', old)) row.everyMonths = intOf(patch.everyMonths, 'saas-every-months-invalid', 1, 120) ?? 1\n row.startOn = touched(patch, 'startOn', old) ? dayOf(patch.startOn, 'saas-start-on-invalid', true) : old!.startOn\n if (touched(patch, 'renewalOn', old)) row.renewalOn = dayOf(patch.renewalOn, 'saas-day-invalid')\n if (touched(patch, 'endedOn', old)) row.endedOn = dayOf(patch.endedOn, 'saas-day-invalid')\n if (touched(patch, 'autoRenew', old)) row.autoRenew = patch.autoRenew !== false\n if (touched(patch, 'noticeDays', old)) row.noticeDays = intOf(patch.noticeDays, 'saas-notice-days-invalid', 0, 365)\n if (touched(patch, 'description', old)) row.description = textOf(patch.description)\n if (touched(patch, 'departmentId', old)) row.department = await oneOf(tx, Department, domain, patch.departmentId, 'saas-department-not-found')\n if (touched(patch, 'assetId', old)) row.asset = await oneOf(tx, Asset, domain, patch.assetId, 'saas-asset-not-found')\n if (billing === SaasBilling.OWNED && !(row.asset !== undefined ? row.asset : old?.assetId))\n throw new Refusal('saas-owned-asset-required', {}, 'A license owned points at its asset in the register - its cost is there')\n if (billing === SaasBilling.COMMITMENT && !value('renewalOn')) throw new Refusal('saas-term-end-required', {}, 'A commitment takes the day its term ends')\n if (touched(patch, 'status', old)) row.status = patch.status ?? SaasSubscriptionStatus.ACTIVE\n const status = row.status ?? old?.status ?? SaasSubscriptionStatus.ACTIVE\n if (status === SaasSubscriptionStatus.CANCELLED && !value('endedOn')) throw new Refusal('saas-ended-on-required', {}, 'Give the day it ended')\n if (status === SaasSubscriptionStatus.CANCELLING && !value('renewalOn')) throw new Refusal('saas-renewal-on-required', {}, 'Not renewing needs the day it would renew')\n if (value('endedOn') && value('endedOn') < row.startOn) throw new Refusal('saas-ended-before-start', {}, 'It ended before it started')\n await recordChanges(tx, domain, user, SAAS_SUBSCRIPTION_FACT, old, row, SUBSCRIPTION_TRACKED)\n return row\n },\n 'saas-subscription-not-found',\n { account: { id: account.id } }\n )\n}\n\n/** The subscriptions of an account, with the seats held today. */\nexport async function saasSubscriptionsOf(tx: EntityManager, domain: Domain, scope: SaasScope, accountId: string, today: string) {\n const account = await accountIn(tx, domain, scope, accountId)\n const subs = await tx.getRepository(SaasSubscription).find({ where: { domain: { id: domain.id }, account: { id: account.id } } as any, relations: ['department', 'asset'], order: { name: 'ASC' } as any })\n const seats = subs.length ? await tx.getRepository(SaasSeat).find({ where: { domain: { id: domain.id }, subscription: { id: In(subs.map(one => one.id)) } } as any }) : []\n for (const sub of subs) sub.seatsHeld = seats.filter(seat => seat.subscriptionId === sub.id && seatHeld(seat, today)).length\n return subs\n}\n\n/* ----------------------------------------------------------------------------------------------------------------- */\n/* Seats (decision 6) */\n\nasync function subscriptionIn(tx: EntityManager, domain: Domain, scope: SaasScope, subscriptionId: string) {\n const sub = subscriptionId ? await tx.getRepository(SaasSubscription).findOne({ where: { domain: { id: domain.id }, id: subscriptionId } as any }) : null\n if (!sub || (scope !== 'all' && !scope.has(sub.accountId!))) throw new Refusal('saas-subscription-not-found', {}, 'The subscription was not found - reload and try again')\n return sub\n}\n\nexport async function saveSaasSeats(tx: EntityManager, domain: Domain, user: any, scope: SaasScope, subscriptionId: string, patches: Patch[]) {\n const subscription = await subscriptionIn(tx, domain, scope, subscriptionId)\n return applyPatches(\n tx,\n SaasSeat,\n domain,\n user,\n patches,\n async (patch, old) => {\n const row: Record<string, any> = old ? {} : { subscription }\n if (touched(patch, 'employeeId', old)) row.employee = await oneOf(tx, Employee, domain, patch.employeeId, 'saas-seat-employee-not-found')\n for (const one of ['holder', 'description']) if (touched(patch, one, old)) row[one] = textOf(patch[one])\n if (!(row.employee !== undefined ? row.employee : old?.employeeId) && !(row.holder !== undefined ? row.holder : old?.holder))\n throw new Refusal('saas-seat-holder-required', {}, 'Say who holds the seat - an employee, or a name')\n if (touched(patch, 'fromOn', old)) row.fromOn = dayOf(patch.fromOn, 'saas-day-invalid')\n if (touched(patch, 'untilOn', old)) row.untilOn = dayOf(patch.untilOn, 'saas-day-invalid')\n const from = row.fromOn !== undefined ? row.fromOn : old?.fromOn\n const until = row.untilOn !== undefined ? row.untilOn : old?.untilOn\n if (from && until && until < from) throw new Refusal('saas-seat-until-before-from', {}, 'It was taken back before it was given')\n return row\n },\n 'saas-seat-not-found',\n { subscription: { id: subscription.id } }\n )\n}\n\nexport async function saasSeatsOf(tx: EntityManager, domain: Domain, scope: SaasScope, subscriptionId: string) {\n const sub = await subscriptionIn(tx, domain, scope, subscriptionId)\n return tx.getRepository(SaasSeat).find({ where: { domain: { id: domain.id }, subscription: { id: sub.id } } as any, relations: ['employee'], order: { fromOn: 'DESC' } as any })\n}\n\n/* ----------------------------------------------------------------------------------------------------------------- */\n/* Bills (decisions 5, 9) - one an account a month, its lines replaced whole */\n\nexport interface SaasBillFields {\n id?: string | null\n month: string\n billedOn?: string | null\n description?: string | null\n lines: { subscriptionId?: string | null; label?: string | null; amount: number }[]\n}\n\nexport async function saveSaasBill(tx: EntityManager, domain: Domain, user: any, scope: SaasScope, accountId: string, input: SaasBillFields) {\n const account = await accountIn(tx, domain, scope, accountId)\n if (account.parentId) throw new Refusal('saas-bill-on-sub-account', {}, 'An account under another is billed by its parent')\n const month = String(input.month ?? '').trim()\n if (!MONTH.test(month)) throw new Refusal('saas-month-invalid', { value: month }, 'Write the month as YYYY-MM')\n const bills = tx.getRepository(SaasBill)\n const old = input.id ? await bills.findOne({ where: { domain: { id: domain.id }, id: input.id, account: { id: account.id } } as any }) : null\n if (input.id && !old) throw new Refusal('saas-bill-not-found', {}, 'The bill was not found - reload and try again')\n const twin = await bills.findOne({ where: { domain: { id: domain.id }, account: { id: account.id }, month } as any })\n if (twin && twin.id !== old?.id) throw new Refusal('saas-bill-month-taken', { month }, `The account already has a bill for ${month} - change that one`)\n const lines = (input.lines ?? []).filter(line => line && (line.subscriptionId || textOf(line.label) || Number(line.amount)))\n if (!lines.length) throw new Refusal('saas-bill-lines-required', {}, 'A bill takes at least one line')\n const subIds = [...new Set(lines.map(line => line.subscriptionId).filter(Boolean))] as string[]\n if (subIds.length) {\n const found = await tx.getRepository(SaasSubscription).count({ where: { domain: { id: domain.id }, account: { id: account.id }, id: In(subIds) } as any })\n if (found !== subIds.length) throw new Refusal('saas-bill-subscription-not-found', {}, 'A line names a subscription not of this account')\n }\n for (const line of lines) if (!Number.isFinite(Number(line.amount))) throw new Refusal('saas-amount-invalid', {}, 'Give the amount as a number')\n const bill = await bills.save({\n ...(old ?? { domain, account, creator: user, currency: account.currency }),\n month,\n billedOn: dayOf(input.billedOn, 'saas-day-invalid'),\n description: textOf(input.description),\n updater: user\n } as any)\n await tx.getRepository(SaasBillLine).delete({ bill: { id: bill.id } } as any)\n await tx.getRepository(SaasBillLine).save(\n lines.map(line => ({ domain, bill: { id: bill.id }, subscription: line.subscriptionId ? { id: line.subscriptionId } : null, label: textOf(line.label), amount: Number(line.amount) })) as any\n )\n return billsOf(tx, domain, [account.id]).then(all => all.find(one => one.id === bill.id)!)\n}\n\nexport async function deleteSaasBill(tx: EntityManager, domain: Domain, scope: SaasScope, id: string): Promise<boolean> {\n const bill = await tx.getRepository(SaasBill).findOne({ where: { domain: { id: domain.id }, id } as any })\n if (!bill || (scope !== 'all' && !scope.has(bill.accountId!))) throw new Refusal('saas-bill-not-found', {}, 'The bill was not found - reload and try again')\n await tx.getRepository(SaasBill).softDelete({ id })\n return true\n}\n\n/** The bills of some accounts (all when none named) from a month on, with their lines and totals, latest first. */\nexport async function billsOf(tx: EntityManager, domain: Domain, accountIds?: string[], from?: string, to?: string): Promise<SaasBill[]> {\n const query = tx\n .getRepository(SaasBill)\n .createQueryBuilder('bill')\n .leftJoinAndSelect('bill.lines', 'line')\n .leftJoinAndSelect('line.subscription', 'subscription')\n .where('bill.domain = :domain', { domain: domain.id })\n if (accountIds) {\n if (!accountIds.length) return []\n query.andWhere('bill.account IN (:...accounts)', { accounts: accountIds })\n }\n if (from) query.andWhere('bill.month >= :from', { from })\n if (to) query.andWhere('bill.month <= :to', { to })\n const bills = await query.orderBy('bill.month', 'DESC').getMany()\n for (const bill of bills) bill.total = billTotal(bill.lines ?? [])\n return bills\n}\n\nexport async function saasBillsOf(tx: EntityManager, domain: Domain, scope: SaasScope, accountId: string) {\n const account = await accountIn(tx, domain, scope, accountId)\n return billsOf(tx, domain, [account.id])\n}\n\nconst factsOf = (bill: SaasBill): BillFacts => ({\n accountId: bill.accountId!,\n month: bill.month,\n currency: bill.currency,\n lines: (bill.lines ?? []).map(line => ({ subscriptionId: line.subscriptionId ?? null, amount: Number(line.amount) }))\n})\n\n/* ----------------------------------------------------------------------------------------------------------------- */\n/* What is still to come (decision 4) - read by an application's expected cash */\n\nexport interface SaasExpectedRow {\n accountId: string\n accountName: string\n counterpartyId?: string | null\n paymentAccountId?: string | null\n month: string\n day: string | null\n amount: number\n currency: string\n /** A bill is written for the month: the amount is the bill's, not an estimate. */\n billed: boolean\n}\n\n/**\n * What each account is expected to be billed, month by month from `from` to `to`: the bill when one is written for the\n * month, else what its subscriptions say (usage at the average of its latest bills).\n */\nexport async function saasExpected(tx: EntityManager, domain: Domain, from: string, to: string): Promise<SaasExpectedRow[]> {\n const accounts = await tx.getRepository(SaasAccount).find({ where: { domain: { id: domain.id }, status: SaasAccountStatus.ACTIVE } as any })\n const top = accounts.filter(one => !one.parentId)\n if (!top.length) return []\n const subs = await tx.getRepository(SaasSubscription).find({ where: { domain: { id: domain.id }, account: { id: In(top.map(one => one.id)) } } as any })\n const bills = await billsOf(tx, domain, top.map(one => one.id), shiftMonth(from, -12), to)\n const billed = new Map<string, { month: string; amount: number }[]>()\n for (const bill of bills)\n if (bill.month < from)\n for (const line of bill.lines ?? []) if (line.subscriptionId) billed.set(line.subscriptionId, [...(billed.get(line.subscriptionId) ?? []), { month: bill.month, amount: Number(line.amount) }])\n const rows: SaasExpectedRow[] = []\n for (const account of top) {\n const own = subs.filter(one => one.accountId === account.id)\n for (const month of monthsFrom(from, to)) {\n const [year, m] = month.split('-').map(Number)\n const bill = bills.find(one => one.accountId === account.id && one.month === month)\n const expected = expectedOfMonth(account, own, billed, year, m)\n if (!bill && !expected) continue\n rows.push({\n accountId: account.id,\n accountName: account.name,\n counterpartyId: account.counterpartyId ?? null,\n paymentAccountId: account.paymentAccountId ?? null,\n month,\n day: bill?.billedOn ?? expected?.day ?? null,\n amount: bill ? bill.total! : expected!.amount,\n currency: account.currency,\n billed: !!bill\n })\n }\n }\n return rows\n}\n\n/* ----------------------------------------------------------------------------------------------------------------- */\n/* The cost trend (decision 9) */\n\n/** Whose department each employee is in. */\nasync function departmentsOfEmployees(tx: EntityManager, domain: Domain, ids: string[]): Promise<Map<string, { id: string; name: string }>> {\n if (!ids.length) return new Map()\n const employees = await tx.getRepository(Employee).find({ where: { domain: { id: domain.id }, id: In(ids) } as any, relations: ['department'] })\n return new Map(employees.filter(one => one.department).map(one => [one.id, { id: one.department!.id, name: one.department!.name }]))\n}\n\n/**\n * The bills of the months from `from` to `to` as series - all, an account, a subscription - and a department series: a\n * line of a seat plan split by the seats held at the month's end by department, any other line its subscription's\n * department. Plus what the latest month's bills are worth telling.\n */\nexport async function saasCostTrend(tx: EntityManager, domain: Domain, from: string, to: string) {\n if (!MONTH.test(from) || !MONTH.test(to) || from > to) throw new Refusal('saas-month-invalid', {}, 'Give the months as YYYY-MM, the first before the last')\n if (monthsFrom(from, to).length > 60) throw new Refusal('saas-trend-too-long', { max: 60 }, 'Up to 60 months at once')\n const bills = await billsOf(tx, domain, undefined, shiftMonth(from, -1), to)\n const facts = bills.map(factsOf)\n const trend = trendOf(facts, from, to)\n\n const accounts = await tx.getRepository(SaasAccount).find({ where: { domain: { id: domain.id } } as any, withDeleted: true })\n const subs = await tx.getRepository(SaasSubscription).find({ where: { domain: { id: domain.id } } as any, relations: ['department'], withDeleted: true })\n const seats = subs.length ? await tx.getRepository(SaasSeat).find({ where: { domain: { id: domain.id }, subscription: { id: In(subs.map(one => one.id)) } } as any }) : []\n const departmentOf = await departmentsOfEmployees(tx, domain, [...new Set(seats.map(one => one.employeeId).filter(Boolean))] as string[])\n\n const months = trend.months\n const departments = new Map<string, { key: string; departmentId: string | null; name: string | null; currency: string; amounts: number[] }>()\n const addTo = (id: string | null, name: string | null, currency: string, at: number, amount: number) => {\n const key = `${id ?? ''}|${currency}`\n let one = departments.get(key)\n if (!one) departments.set(key, (one = { key, departmentId: id, name, currency, amounts: months.map(() => 0) }))\n one.amounts[at] += amount\n }\n for (const bill of facts) {\n const at = months.indexOf(bill.month)\n if (at < 0) continue\n const monthEnd = `${bill.month}-31`\n for (const line of bill.lines) {\n const sub = subs.find(one => one.id === line.subscriptionId)\n const held = sub?.billing === SaasBilling.SEAT ? seats.filter(seat => seat.subscriptionId === sub.id && seatHeld(seat, monthEnd) && (!seat.fromOn || seat.fromOn <= monthEnd)) : []\n if (held.length) {\n for (const seat of held) {\n const department = seat.employeeId ? departmentOf.get(seat.employeeId) : undefined\n addTo(department?.id ?? sub?.department?.id ?? null, department?.name ?? sub?.department?.name ?? null, bill.currency, at, line.amount / held.length)\n }\n } else addTo(sub?.department?.id ?? null, sub?.department?.name ?? null, bill.currency, at, line.amount)\n }\n }\n\n const latest = facts.filter(one => one.month <= to).map(one => one.month).sort().pop()\n const alerts = latest\n ? facts\n .filter(one => one.month === latest)\n .flatMap(bill => {\n const account = accounts.find(one => one.id === bill.accountId)\n if (!account) return []\n const previous = facts.find(one => one.accountId === bill.accountId && one.month === shiftMonth(bill.month, -1))\n return alertsOf(account, subs.filter(one => one.accountId === account.id), bill, previous).map(alert => ({ ...alert, accountId: account.id, month: bill.month }))\n })\n : []\n\n const name = (id?: string | null) => accounts.find(one => one.id === id)?.name ?? null\n const subName = (id?: string | null) => subs.find(one => one.id === id)?.name ?? null\n return {\n months,\n all: trend.all,\n accounts: trend.accounts.map(one => ({ ...one, name: name(one.accountId) })),\n subscriptions: trend.subscriptions.map(one => ({ ...one, name: subName(one.subscriptionId), accountName: name(one.accountId) })),\n departments: [...departments.values()].map(one => ({ ...one, total: one.amounts.reduce((sum, amount) => sum + amount, 0) })).sort((a, b) => b.total - a.total),\n alerts: alerts.map(alert => ({ ...alert, accountName: name(alert.accountId), subscriptionName: subName(alert.subscriptionId) }))\n }\n}\n\n/* ----------------------------------------------------------------------------------------------------------------- */\n/* A row's months for the list and the 360 (decision 10) and what moved on it (decision 11) */\n\n/**\n * What left the bank for an account's vendor (ADR-0177 decision 10, the user 2026-10-30: 「이테크 입금 이력이 있을텐데」)\n * - the bank lines (accounting, confirmed) of money out to the account's counterparty, newest first. Only lines in the\n * account's currency count toward its months.\n */\nexport async function bankPaymentsOf(tx: EntityManager, domain: Domain, counterpartyIds: string[], from?: string, to?: string): Promise<Transaction[]> {\n if (!counterpartyIds.length) return []\n const query = tx\n .getRepository(Transaction)\n .createQueryBuilder('line')\n .where('line.domain = :domain', { domain: domain.id })\n .andWhere('line.category = :category', { category: TransactionCategory.CONFIRMED })\n .andWhere('line.type = :type', { type: CashFlowType.EXPENSE })\n .andWhere('line.counterparty IN (:...parties)', { parties: counterpartyIds })\n if (from) query.andWhere('line.transactionDate >= :from', { from })\n if (to) query.andWhere('line.transactionDate <= :to', { to })\n return query.orderBy('line.transactionDate', 'DESC').addOrderBy('line.amount', 'DESC').getMany()\n}\n\n/** The bank lines that paid an account's vendor, every one - for its 360. */\nexport async function saasPaymentsOf(tx: EntityManager, domain: Domain, scope: SaasScope, accountId: string) {\n const account = await accountIn(tx, domain, scope, accountId)\n return account.counterpartyId ? bankPaymentsOf(tx, domain, [account.counterpartyId]) : []\n}\n\n/**\n * Each account's last twelve months before this one and the next three expected (`saasExpected`). A month is its bill\n * when one is written; else, for a reader of the bank lines (`withBank`), what left the bank for its vendor that month\n * (decision 10); else empty. One read for all the accounts of a list.\n */\nexport async function saasTrendsOf(tx: EntityManager, domain: Domain, accounts: SaasAccount[], today: string, withBank = false): Promise<Map<string, SaasTrend>> {\n const trends = new Map<string, SaasTrend>()\n if (!accounts.length) return trends\n const now = today.slice(0, 7)\n const months = monthsFrom(shiftMonth(now, -12), shiftMonth(now, -1))\n const nextMonths = monthsFrom(now, shiftMonth(now, 2))\n const bills = await billsOf(tx, domain, accounts.map(one => one.id), months[0], months[months.length - 1])\n const expected = await saasExpected(tx, domain, nextMonths[0], nextMonths[nextMonths.length - 1])\n const parties = [...new Set(accounts.map(one => one.counterpartyId).filter(Boolean))] as string[]\n const paid = withBank ? await bankPaymentsOf(tx, domain, parties, `${months[0]}-01`, `${months[months.length - 1]}-31`) : []\n for (const account of accounts) {\n const own = bills.filter(one => one.accountId === account.id)\n const lines = paid.filter(line => line.counterpartyId === account.counterpartyId && (line.currency || 'KRW') === account.currency)\n const banked = (month: string) => {\n const of = lines.filter(line => line.transactionDate?.slice(0, 7) === month)\n return of.length ? of.reduce((sum, line) => sum + Number(line.amount), 0) : null\n }\n const values = months.map(month => own.find(one => one.month === month)?.total ?? banked(month))\n trends.set(account.id, {\n months,\n values,\n sources: months.map((month, i) => (own.some(one => one.month === month) ? 'bill' : values[i] === null ? null : 'bank')),\n nextMonths,\n expected: nextMonths.map(month => expected.find(one => one.accountId === account.id && one.month === month)?.amount ?? null),\n currency: account.currency\n })\n }\n return trends\n}\n\n/** What moved on an account and on each of its subscriptions, newest first. */\nexport async function saasChangesOf(tx: EntityManager, domain: Domain, scope: SaasScope, accountId: string) {\n const account = await accountIn(tx, domain, scope, accountId)\n const subs = await tx.getRepository(SaasSubscription).find({ where: { domain: { id: domain.id }, account: { id: account.id } } as any, withDeleted: true })\n const rows = [\n ...(await readFactChanges(tx, domain, SAAS_ACCOUNT_FACT, account.id)).map(one => Object.assign(one, { subject: account.name })),\n ...(await Promise.all(subs.map(async sub => (await readFactChanges(tx, domain, SAAS_SUBSCRIPTION_FACT, sub.id)).map(one => Object.assign(one, { subject: sub.name }))))).flat()\n ]\n return rows.sort((a, b) => new Date(b.at).getTime() - new Date(a.at).getTime())\n}\n"]}
@@ -0,0 +1,44 @@
1
+ import { Asset } from '@things-factory/asset';
2
+ import { User } from '@things-factory/auth-base';
3
+ import { Department } from '@things-factory/organization';
4
+ import { Domain } from '@things-factory/shell';
5
+ import { SaasAccount } from './saas-account';
6
+ import { SaasBilling, SaasSubscriptionStatus } from './saas-rules';
7
+ /**
8
+ * One thing under an account the domain decides on and can cancel (ADR-0177 decisions 1, 3): a plan with seats, a fixed
9
+ * fee, metered usage with a monthly budget, a commitment for a term, or a license owned - which points at the asset
10
+ * register and carries no amount. It is billed in the account's currency, every so many months from the month it started.
11
+ */
12
+ export declare class SaasSubscription {
13
+ readonly id: string;
14
+ domain?: Domain;
15
+ domainId?: string;
16
+ account?: SaasAccount;
17
+ accountId?: string;
18
+ name: string;
19
+ billing: SaasBilling;
20
+ quantity?: number;
21
+ unitPrice?: number;
22
+ amount?: number;
23
+ budget?: number;
24
+ everyMonths: number;
25
+ startOn: string;
26
+ renewalOn?: string;
27
+ autoRenew: boolean;
28
+ noticeDays?: number;
29
+ department?: Department;
30
+ departmentId?: string;
31
+ asset?: Asset;
32
+ assetId?: string;
33
+ status: SaasSubscriptionStatus;
34
+ endedOn?: string;
35
+ description?: string;
36
+ seatsHeld?: number;
37
+ createdAt?: Date;
38
+ updatedAt?: Date;
39
+ deletedAt?: Date;
40
+ creator?: User;
41
+ creatorId?: string;
42
+ updater?: User;
43
+ updaterId?: string;
44
+ }
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SaasSubscription = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const asset_1 = require("@things-factory/asset");
6
+ const auth_base_1 = require("@things-factory/auth-base");
7
+ const organization_1 = require("@things-factory/organization");
8
+ const shell_1 = require("@things-factory/shell");
9
+ const type_graphql_1 = require("type-graphql");
10
+ const typeorm_1 = require("typeorm");
11
+ const saas_account_1 = require("./saas-account");
12
+ const saas_rules_1 = require("./saas-rules");
13
+ /**
14
+ * One thing under an account the domain decides on and can cancel (ADR-0177 decisions 1, 3): a plan with seats, a fixed
15
+ * fee, metered usage with a monthly budget, a commitment for a term, or a license owned - which points at the asset
16
+ * register and carries no amount. It is billed in the account's currency, every so many months from the month it started.
17
+ */
18
+ let SaasSubscription = class SaasSubscription {
19
+ };
20
+ exports.SaasSubscription = SaasSubscription;
21
+ tslib_1.__decorate([
22
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
23
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier of the subscription' }),
24
+ tslib_1.__metadata("design:type", String)
25
+ ], SaasSubscription.prototype, "id", void 0);
26
+ tslib_1.__decorate([
27
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
28
+ (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain the subscription belongs to' }),
29
+ tslib_1.__metadata("design:type", shell_1.Domain)
30
+ ], SaasSubscription.prototype, "domain", void 0);
31
+ tslib_1.__decorate([
32
+ (0, typeorm_1.RelationId)((sub) => sub.domain),
33
+ tslib_1.__metadata("design:type", String)
34
+ ], SaasSubscription.prototype, "domainId", void 0);
35
+ tslib_1.__decorate([
36
+ (0, typeorm_1.ManyToOne)(type => saas_account_1.SaasAccount, { onDelete: 'CASCADE' }),
37
+ (0, type_graphql_1.Field)(type => saas_account_1.SaasAccount, { nullable: true, description: 'The account it is under' }),
38
+ tslib_1.__metadata("design:type", saas_account_1.SaasAccount)
39
+ ], SaasSubscription.prototype, "account", void 0);
40
+ tslib_1.__decorate([
41
+ (0, typeorm_1.RelationId)((sub) => sub.account),
42
+ tslib_1.__metadata("design:type", String)
43
+ ], SaasSubscription.prototype, "accountId", void 0);
44
+ tslib_1.__decorate([
45
+ (0, typeorm_1.Column)(),
46
+ (0, type_graphql_1.Field)({ description: 'The product and plan - Microsoft 365 Business Standard, AWS usage, Savings Plan 1 year, example.com' }),
47
+ tslib_1.__metadata("design:type", String)
48
+ ], SaasSubscription.prototype, "name", void 0);
49
+ tslib_1.__decorate([
50
+ (0, typeorm_1.Column)({ default: saas_rules_1.SaasBilling.FIXED }),
51
+ (0, type_graphql_1.Field)(type => saas_rules_1.SaasBilling, { description: 'How it is paid for' }),
52
+ tslib_1.__metadata("design:type", String)
53
+ ], SaasSubscription.prototype, "billing", void 0);
54
+ tslib_1.__decorate([
55
+ (0, typeorm_1.Column)({ type: 'float', nullable: true }),
56
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Seats or units - for a seat plan' }),
57
+ tslib_1.__metadata("design:type", Number)
58
+ ], SaasSubscription.prototype, "quantity", void 0);
59
+ tslib_1.__decorate([
60
+ (0, typeorm_1.Column)({ ...(0, shell_1.moneyColumn)(), nullable: true }),
61
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'The price of one seat for one billing - for a seat plan' }),
62
+ tslib_1.__metadata("design:type", Number)
63
+ ], SaasSubscription.prototype, "unitPrice", void 0);
64
+ tslib_1.__decorate([
65
+ (0, typeorm_1.Column)({ ...(0, shell_1.moneyColumn)(), nullable: true }),
66
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'What one billing costs - for a fixed fee or a commitment' }),
67
+ tslib_1.__metadata("design:type", Number)
68
+ ], SaasSubscription.prototype, "amount", void 0);
69
+ tslib_1.__decorate([
70
+ (0, typeorm_1.Column)({ ...(0, shell_1.moneyColumn)(), nullable: true }),
71
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'What a month of metered usage may cost - told when a bill is over it' }),
72
+ tslib_1.__metadata("design:type", Number)
73
+ ], SaasSubscription.prototype, "budget", void 0);
74
+ tslib_1.__decorate([
75
+ (0, typeorm_1.Column)({ type: 'int', default: 1 }),
76
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'Billed every so many months - 1 monthly, 12 yearly' }),
77
+ tslib_1.__metadata("design:type", Number)
78
+ ], SaasSubscription.prototype, "everyMonths", void 0);
79
+ tslib_1.__decorate([
80
+ (0, typeorm_1.Column)(),
81
+ (0, type_graphql_1.Field)({ description: 'The day it started - YYYY-MM-DD; billings count from its month' }),
82
+ tslib_1.__metadata("design:type", String)
83
+ ], SaasSubscription.prototype, "startOn", void 0);
84
+ tslib_1.__decorate([
85
+ (0, typeorm_1.Column)({ nullable: true }),
86
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The day it renews or its term ends - YYYY-MM-DD; a domain’s expiry' }),
87
+ tslib_1.__metadata("design:type", String)
88
+ ], SaasSubscription.prototype, "renewalOn", void 0);
89
+ tslib_1.__decorate([
90
+ (0, typeorm_1.Column)({ default: true }),
91
+ (0, type_graphql_1.Field)({ description: 'Whether the vendor renews it unless cancelled' }),
92
+ tslib_1.__metadata("design:type", Boolean)
93
+ ], SaasSubscription.prototype, "autoRenew", void 0);
94
+ tslib_1.__decorate([
95
+ (0, typeorm_1.Column)({ type: 'int', nullable: true }),
96
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'How many days before renewal it must be cancelled - told from then' }),
97
+ tslib_1.__metadata("design:type", Number)
98
+ ], SaasSubscription.prototype, "noticeDays", void 0);
99
+ tslib_1.__decorate([
100
+ (0, typeorm_1.ManyToOne)(type => organization_1.Department, { nullable: true, onDelete: 'SET NULL' }),
101
+ (0, type_graphql_1.Field)(type => organization_1.Department, { nullable: true, description: 'The department it is for - its cost when no seat says whose' }),
102
+ tslib_1.__metadata("design:type", organization_1.Department)
103
+ ], SaasSubscription.prototype, "department", void 0);
104
+ tslib_1.__decorate([
105
+ (0, typeorm_1.RelationId)((sub) => sub.department),
106
+ tslib_1.__metadata("design:type", String)
107
+ ], SaasSubscription.prototype, "departmentId", void 0);
108
+ tslib_1.__decorate([
109
+ (0, typeorm_1.ManyToOne)(type => asset_1.Asset, { nullable: true, onDelete: 'SET NULL' }),
110
+ (0, type_graphql_1.Field)(type => asset_1.Asset, { nullable: true, description: 'For a license owned: the asset of the register that carries its cost' }),
111
+ tslib_1.__metadata("design:type", asset_1.Asset)
112
+ ], SaasSubscription.prototype, "asset", void 0);
113
+ tslib_1.__decorate([
114
+ (0, typeorm_1.RelationId)((sub) => sub.asset),
115
+ tslib_1.__metadata("design:type", String)
116
+ ], SaasSubscription.prototype, "assetId", void 0);
117
+ tslib_1.__decorate([
118
+ (0, typeorm_1.Column)({ default: saas_rules_1.SaasSubscriptionStatus.ACTIVE }),
119
+ (0, type_graphql_1.Field)(type => saas_rules_1.SaasSubscriptionStatus, { description: 'In use, not to be renewed, or ended' }),
120
+ tslib_1.__metadata("design:type", String)
121
+ ], SaasSubscription.prototype, "status", void 0);
122
+ tslib_1.__decorate([
123
+ (0, typeorm_1.Column)({ nullable: true }),
124
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The day it ended - YYYY-MM-DD' }),
125
+ tslib_1.__metadata("design:type", String)
126
+ ], SaasSubscription.prototype, "endedOn", void 0);
127
+ tslib_1.__decorate([
128
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
129
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
130
+ tslib_1.__metadata("design:type", String)
131
+ ], SaasSubscription.prototype, "description", void 0);
132
+ tslib_1.__decorate([
133
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'How many seats are held today - filled by the list query' }),
134
+ tslib_1.__metadata("design:type", Number)
135
+ ], SaasSubscription.prototype, "seatsHeld", void 0);
136
+ tslib_1.__decorate([
137
+ (0, typeorm_1.CreateDateColumn)(),
138
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When the subscription was registered' }),
139
+ tslib_1.__metadata("design:type", Date)
140
+ ], SaasSubscription.prototype, "createdAt", void 0);
141
+ tslib_1.__decorate([
142
+ (0, typeorm_1.UpdateDateColumn)(),
143
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When the subscription last changed' }),
144
+ tslib_1.__metadata("design:type", Date)
145
+ ], SaasSubscription.prototype, "updatedAt", void 0);
146
+ tslib_1.__decorate([
147
+ (0, typeorm_1.DeleteDateColumn)(),
148
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When the subscription was deleted' }),
149
+ tslib_1.__metadata("design:type", Date)
150
+ ], SaasSubscription.prototype, "deletedAt", void 0);
151
+ tslib_1.__decorate([
152
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
153
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who registered it' }),
154
+ tslib_1.__metadata("design:type", auth_base_1.User)
155
+ ], SaasSubscription.prototype, "creator", void 0);
156
+ tslib_1.__decorate([
157
+ (0, typeorm_1.RelationId)((sub) => sub.creator),
158
+ tslib_1.__metadata("design:type", String)
159
+ ], SaasSubscription.prototype, "creatorId", void 0);
160
+ tslib_1.__decorate([
161
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
162
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who last changed it' }),
163
+ tslib_1.__metadata("design:type", auth_base_1.User)
164
+ ], SaasSubscription.prototype, "updater", void 0);
165
+ tslib_1.__decorate([
166
+ (0, typeorm_1.RelationId)((sub) => sub.updater),
167
+ tslib_1.__metadata("design:type", String)
168
+ ], SaasSubscription.prototype, "updaterId", void 0);
169
+ exports.SaasSubscription = SaasSubscription = tslib_1.__decorate([
170
+ (0, typeorm_1.Entity)(),
171
+ (0, typeorm_1.Index)('ix_saas_subscription_0', (sub) => [sub.domain, sub.account]),
172
+ (0, type_graphql_1.ObjectType)({ description: 'Entity for SaasSubscription — a plan, fee, usage, commitment or owned license under an account' })
173
+ ], SaasSubscription);
174
+ //# sourceMappingURL=saas-subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saas-subscription.js","sourceRoot":"","sources":["../../server/service/saas-subscription.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAC7C,yDAAgD;AAChD,+DAAyD;AACzD,iDAA2D;AAC3D,+CAAgE;AAChE,qCAAoJ;AAEpJ,iDAA4C;AAC5C,6CAAkE;AAElE;;;;GAIG;AAII,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAqH5B,CAAA;AArHY,4CAAgB;AAGlB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;;4CACzD;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;sCACxF,cAAM;gDAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,GAAqB,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;;kDACjC;AAIjB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,0BAAW,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACvD,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,0BAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;sCAC7E,0BAAW;iDAAA;AAGrB;IADC,IAAA,oBAAU,EAAC,CAAC,GAAqB,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CAAC;GACjH,gBAAgB,CAqH5B","sourcesContent":["import { Asset } from '@things-factory/asset'\nimport { User } from '@things-factory/auth-base'\nimport { Department } from '@things-factory/organization'\nimport { Domain, moneyColumn } from '@things-factory/shell'\nimport { Field, Float, ID, Int, ObjectType } from 'type-graphql'\nimport { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\n\nimport { SaasAccount } from './saas-account'\nimport { SaasBilling, SaasSubscriptionStatus } from './saas-rules'\n\n/**\n * One thing under an account the domain decides on and can cancel (ADR-0177 decisions 1, 3): a plan with seats, a fixed\n * fee, metered usage with a monthly budget, a commitment for a term, or a license owned - which points at the asset\n * register and carries no amount. It is billed in the account's currency, every so many months from the month it started.\n */\n@Entity()\n@Index('ix_saas_subscription_0', (sub: SaasSubscription) => [sub.domain, sub.account])\n@ObjectType({ description: 'Entity for SaasSubscription — a plan, fee, usage, commitment or owned license under an account' })\nexport class SaasSubscription {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier of the subscription' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain the subscription belongs to' })\n domain?: Domain\n\n @RelationId((sub: SaasSubscription) => sub.domain)\n domainId?: string\n\n @ManyToOne(type => SaasAccount, { onDelete: 'CASCADE' })\n @Field(type => SaasAccount, { nullable: true, description: 'The account it is under' })\n account?: SaasAccount\n\n @RelationId((sub: SaasSubscription) => sub.account)\n accountId?: string\n\n @Column()\n @Field({ description: 'The product and plan - Microsoft 365 Business Standard, AWS usage, Savings Plan 1 year, example.com' })\n name: string\n\n @Column({ default: SaasBilling.FIXED })\n @Field(type => SaasBilling, { description: 'How it is paid for' })\n billing: SaasBilling\n\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'Seats or units - for a seat plan' })\n quantity?: number\n\n @Column({ ...moneyColumn(), nullable: true })\n @Field(type => Float, { nullable: true, description: 'The price of one seat for one billing - for a seat plan' })\n unitPrice?: number\n\n @Column({ ...moneyColumn(), nullable: true })\n @Field(type => Float, { nullable: true, description: 'What one billing costs - for a fixed fee or a commitment' })\n amount?: number\n\n @Column({ ...moneyColumn(), nullable: true })\n @Field(type => Float, { nullable: true, description: 'What a month of metered usage may cost - told when a bill is over it' })\n budget?: number\n\n @Column({ type: 'int', default: 1 })\n @Field(type => Int, { description: 'Billed every so many months - 1 monthly, 12 yearly' })\n everyMonths: number\n\n @Column()\n @Field({ description: 'The day it started - YYYY-MM-DD; billings count from its month' })\n startOn: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The day it renews or its term ends - YYYY-MM-DD; a domain’s expiry' })\n renewalOn?: string\n\n @Column({ default: true })\n @Field({ description: 'Whether the vendor renews it unless cancelled' })\n autoRenew: boolean\n\n @Column({ type: 'int', nullable: true })\n @Field(type => Int, { nullable: true, description: 'How many days before renewal it must be cancelled - told from then' })\n noticeDays?: number\n\n @ManyToOne(type => Department, { nullable: true, onDelete: 'SET NULL' })\n @Field(type => Department, { nullable: true, description: 'The department it is for - its cost when no seat says whose' })\n department?: Department\n\n @RelationId((sub: SaasSubscription) => sub.department)\n departmentId?: string\n\n @ManyToOne(type => Asset, { nullable: true, onDelete: 'SET NULL' })\n @Field(type => Asset, { nullable: true, description: 'For a license owned: the asset of the register that carries its cost' })\n asset?: Asset\n\n @RelationId((sub: SaasSubscription) => sub.asset)\n assetId?: string\n\n @Column({ default: SaasSubscriptionStatus.ACTIVE })\n @Field(type => SaasSubscriptionStatus, { description: 'In use, not to be renewed, or ended' })\n status: SaasSubscriptionStatus\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The day it ended - YYYY-MM-DD' })\n endedOn?: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Notes' })\n description?: string\n\n @Field(type => Int, { nullable: true, description: 'How many seats are held today - filled by the list query' })\n seatsHeld?: number\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When the subscription was registered' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When the subscription last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When the subscription was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who registered it' })\n creator?: User\n\n @RelationId((sub: SaasSubscription) => sub.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed it' })\n updater?: User\n\n @RelationId((sub: SaasSubscription) => sub.updater)\n updaterId?: string\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /** A row's last twelve months and the months to come, for a list's mini chart and a 360 (ADR-0177 decision 10). */
2
+ export declare class SaasTrend {
3
+ months: string[];
4
+ values: (number | null)[];
5
+ nextMonths: string[];
6
+ expected: (number | null)[];
7
+ sources: (string | null)[];
8
+ currency: string;
9
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SaasTrend = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ /** A row's last twelve months and the months to come, for a list's mini chart and a 360 (ADR-0177 decision 10). */
7
+ let SaasTrend = class SaasTrend {
8
+ };
9
+ exports.SaasTrend = SaasTrend;
10
+ tslib_1.__decorate([
11
+ (0, type_graphql_1.Field)(type => [String], { description: 'The last twelve months, oldest first - YYYY-MM' }),
12
+ tslib_1.__metadata("design:type", Array)
13
+ ], SaasTrend.prototype, "months", void 0);
14
+ tslib_1.__decorate([
15
+ (0, type_graphql_1.Field)(type => [type_graphql_1.Float], { nullable: 'items', description: 'What was billed each of them; empty for a month with no bill' }),
16
+ tslib_1.__metadata("design:type", Array)
17
+ ], SaasTrend.prototype, "values", void 0);
18
+ tslib_1.__decorate([
19
+ (0, type_graphql_1.Field)(type => [String], { description: 'The months to come - YYYY-MM' }),
20
+ tslib_1.__metadata("design:type", Array)
21
+ ], SaasTrend.prototype, "nextMonths", void 0);
22
+ tslib_1.__decorate([
23
+ (0, type_graphql_1.Field)(type => [type_graphql_1.Float], { nullable: 'items', description: 'What is expected each month to come; empty when nothing falls in it' }),
24
+ tslib_1.__metadata("design:type", Array)
25
+ ], SaasTrend.prototype, "expected", void 0);
26
+ tslib_1.__decorate([
27
+ (0, type_graphql_1.Field)(type => [String], { nullable: 'items', description: "Where each past month's amount came from - bill, bank, or empty" }),
28
+ tslib_1.__metadata("design:type", Array)
29
+ ], SaasTrend.prototype, "sources", void 0);
30
+ tslib_1.__decorate([
31
+ (0, type_graphql_1.Field)({ description: 'The currency of the amounts' }),
32
+ tslib_1.__metadata("design:type", String)
33
+ ], SaasTrend.prototype, "currency", void 0);
34
+ exports.SaasTrend = SaasTrend = tslib_1.__decorate([
35
+ (0, type_graphql_1.ObjectType)({ description: 'An account’s months - what was billed in the last twelve, what is expected in the next three' })
36
+ ], SaasTrend);
37
+ //# sourceMappingURL=saas-trend-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saas-trend-type.js","sourceRoot":"","sources":["../../server/service/saas-trend-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAuD;AAEvD,mHAAmH;AAE5G,IAAM,SAAS,GAAf,MAAM,SAAS;CAOrB,CAAA;AAPY,8BAAS;AACwE;IAA3F,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;;yCAAiB;AACgB;IAA3H,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,oBAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,8DAA8D,EAAE,CAAC;;yCAA0B;AAC3E;IAAzE,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;;6CAAqB;AACqC;IAAlI,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,oBAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,qEAAqE,EAAE,CAAC;;2CAA4B;AAC9B;IAA/H,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,iEAAiE,EAAE,CAAC;;0CAA2B;AACnG;IAAtD,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;;2CAAiB;oBAN5D,SAAS;IADrB,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,8FAA8F,EAAE,CAAC;GAC/G,SAAS,CAOrB","sourcesContent":["import { Field, Float, ObjectType } from 'type-graphql'\n\n/** A row's last twelve months and the months to come, for a list's mini chart and a 360 (ADR-0177 decision 10). */\n@ObjectType({ description: 'An account’s months - what was billed in the last twelve, what is expected in the next three' })\nexport class SaasTrend {\n @Field(type => [String], { description: 'The last twelve months, oldest first - YYYY-MM' }) months: string[]\n @Field(type => [Float], { nullable: 'items', description: 'What was billed each of them; empty for a month with no bill' }) values: (number | null)[]\n @Field(type => [String], { description: 'The months to come - YYYY-MM' }) nextMonths: string[]\n @Field(type => [Float], { nullable: 'items', description: 'What is expected each month to come; empty when nothing falls in it' }) expected: (number | null)[]\n @Field(type => [String], { nullable: 'items', description: \"Where each past month's amount came from - bill, bank, or empty\" }) sources: (string | null)[]\n @Field({ description: 'The currency of the amounts' }) currency: string\n}\n"]}
@@ -0,0 +1,113 @@
1
+ import { SaasAccount } from './saas-account';
2
+ import { SaasAccountStatus, SaasBilling, SaasSubscriptionStatus } from './saas-rules';
3
+ export declare class SaasAccountPatch {
4
+ id?: string;
5
+ cuFlag?: string;
6
+ name?: string;
7
+ counterpartyId?: string;
8
+ identifier?: string;
9
+ parentId?: string;
10
+ purpose?: string;
11
+ adminIds?: string[];
12
+ billingEmail?: string;
13
+ paymentAccountId?: string;
14
+ currency?: string;
15
+ billingDay?: number;
16
+ secretLocation?: string;
17
+ increaseAlertRate?: number;
18
+ status?: SaasAccountStatus;
19
+ closedOn?: string;
20
+ description?: string;
21
+ }
22
+ export declare class SaasSubscriptionPatch {
23
+ id?: string;
24
+ cuFlag?: string;
25
+ name?: string;
26
+ billing?: SaasBilling;
27
+ quantity?: number;
28
+ unitPrice?: number;
29
+ amount?: number;
30
+ budget?: number;
31
+ everyMonths?: number;
32
+ startOn?: string;
33
+ renewalOn?: string;
34
+ autoRenew?: boolean;
35
+ noticeDays?: number;
36
+ departmentId?: string;
37
+ assetId?: string;
38
+ status?: SaasSubscriptionStatus;
39
+ endedOn?: string;
40
+ description?: string;
41
+ }
42
+ export declare class SaasSeatPatch {
43
+ id?: string;
44
+ cuFlag?: string;
45
+ employeeId?: string;
46
+ holder?: string;
47
+ fromOn?: string;
48
+ untilOn?: string;
49
+ description?: string;
50
+ }
51
+ export declare class SaasBillLineInput {
52
+ subscriptionId?: string;
53
+ label?: string;
54
+ amount: number;
55
+ }
56
+ export declare class SaasBillInput {
57
+ id?: string;
58
+ month: string;
59
+ billedOn?: string;
60
+ description?: string;
61
+ lines: SaasBillLineInput[];
62
+ }
63
+ export declare class SaasAccountList {
64
+ items: SaasAccount[];
65
+ total: number;
66
+ }
67
+ export declare class SaasTrendSeries {
68
+ key: string;
69
+ accountId?: string;
70
+ accountName?: string;
71
+ subscriptionId?: string;
72
+ name?: string;
73
+ currency: string;
74
+ amounts: number[];
75
+ total: number;
76
+ monthOverMonth?: number;
77
+ yearOverYear?: number;
78
+ }
79
+ export declare class SaasDepartmentSeries {
80
+ key: string;
81
+ departmentId?: string;
82
+ name?: string;
83
+ currency: string;
84
+ amounts: number[];
85
+ total: number;
86
+ }
87
+ export declare class SaasAlert {
88
+ kind: string;
89
+ accountId: string;
90
+ accountName?: string;
91
+ subscriptionId?: string;
92
+ subscriptionName?: string;
93
+ month: string;
94
+ amount: number;
95
+ limit: number;
96
+ }
97
+ export declare class SaasCostTrend {
98
+ months: string[];
99
+ all: SaasTrendSeries[];
100
+ accounts: SaasTrendSeries[];
101
+ subscriptions: SaasTrendSeries[];
102
+ departments: SaasDepartmentSeries[];
103
+ alerts: SaasAlert[];
104
+ }
105
+ export declare class SaasChange {
106
+ subject: string;
107
+ factKind: string;
108
+ field: string;
109
+ fromValue?: string;
110
+ toValue?: string;
111
+ at: Date;
112
+ changedBy?: string;
113
+ }