@things-factory/sales 10.1.278 → 10.1.279

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 (62) hide show
  1. package/package.json +23 -7
  2. package/CHANGELOG.md +0 -8
  3. package/dist-client/bootstrap.js.map +0 -1
  4. package/dist-client/close-months.js.map +0 -1
  5. package/dist-client/entity360/opportunity-360.js.map +0 -1
  6. package/dist-client/entity360/quotation-360.js.map +0 -1
  7. package/dist-client/index.js.map +0 -1
  8. package/dist-client/list-filters.js.map +0 -1
  9. package/dist-client/opportunity-attach.js.map +0 -1
  10. package/dist-client/opportunity-words.js.map +0 -1
  11. package/dist-client/pages/opportunity-editor.js.map +0 -1
  12. package/dist-client/pages/opportunity-list.js.map +0 -1
  13. package/dist-client/pages/quotation-editor.js.map +0 -1
  14. package/dist-client/pages/quotation-list.js.map +0 -1
  15. package/dist-client/pages/sales-product-list.js.map +0 -1
  16. package/dist-client/quotation-attach.js.map +0 -1
  17. package/dist-client/quotation-preview.js.map +0 -1
  18. package/dist-client/quotation-words.js.map +0 -1
  19. package/dist-client/route.js.map +0 -1
  20. package/dist-client/sales-product-pick.js.map +0 -1
  21. package/dist-client/sales-product-words.js.map +0 -1
  22. package/dist-client/tsconfig.tsbuildinfo +0 -1
  23. package/dist-server/controllers/index.js.map +0 -1
  24. package/dist-server/index.js.map +0 -1
  25. package/dist-server/middlewares/index.js.map +0 -1
  26. package/dist-server/migrations/index.js.map +0 -1
  27. package/dist-server/role-tasks.js.map +0 -1
  28. package/dist-server/routes.js.map +0 -1
  29. package/dist-server/service/index.js.map +0 -1
  30. package/dist-server/service/opportunity/index.js.map +0 -1
  31. package/dist-server/service/opportunity/opportunity-event-query.js.map +0 -1
  32. package/dist-server/service/opportunity/opportunity-event.js.map +0 -1
  33. package/dist-server/service/opportunity/opportunity-mutation.js.map +0 -1
  34. package/dist-server/service/opportunity/opportunity-query.js.map +0 -1
  35. package/dist-server/service/opportunity/opportunity-rules.js.map +0 -1
  36. package/dist-server/service/opportunity/opportunity-service.js.map +0 -1
  37. package/dist-server/service/opportunity/opportunity-subject.js.map +0 -1
  38. package/dist-server/service/opportunity/opportunity-type.js.map +0 -1
  39. package/dist-server/service/opportunity/opportunity.js.map +0 -1
  40. package/dist-server/service/quotation/index.js.map +0 -1
  41. package/dist-server/service/quotation/quotation-event-query.js.map +0 -1
  42. package/dist-server/service/quotation/quotation-event.js.map +0 -1
  43. package/dist-server/service/quotation/quotation-item-query.js.map +0 -1
  44. package/dist-server/service/quotation/quotation-item.js.map +0 -1
  45. package/dist-server/service/quotation/quotation-mutation.js.map +0 -1
  46. package/dist-server/service/quotation/quotation-query.js.map +0 -1
  47. package/dist-server/service/quotation/quotation-rules.js.map +0 -1
  48. package/dist-server/service/quotation/quotation-service.js.map +0 -1
  49. package/dist-server/service/quotation/quotation-status.js.map +0 -1
  50. package/dist-server/service/quotation/quotation-type.js.map +0 -1
  51. package/dist-server/service/quotation/quotation.js.map +0 -1
  52. package/dist-server/service/sales-event.js.map +0 -1
  53. package/dist-server/service/sales-product/index.js.map +0 -1
  54. package/dist-server/service/sales-product/sales-product-mutation.js.map +0 -1
  55. package/dist-server/service/sales-product/sales-product-query.js.map +0 -1
  56. package/dist-server/service/sales-product/sales-product-rules.js.map +0 -1
  57. package/dist-server/service/sales-product/sales-product-service.js.map +0 -1
  58. package/dist-server/service/sales-product/sales-product-type.js.map +0 -1
  59. package/dist-server/service/sales-product/sales-product.js.map +0 -1
  60. package/dist-server/service/sales-read.js.map +0 -1
  61. package/dist-server/tsconfig.tsbuildinfo +0 -1
  62. package/dist-server/work-doors.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,wDAA6B;AAC7B,oDAAyB;AAEzB,oBAAiB;AAEjB,yDAA4D;AAC5D,6CAAyC;AACzC,qDAAyD;AACzD,mFAAsF;AAEtF,KAAK,MAAM,IAAI,IAAI,uBAAU;IAAE,IAAA,4BAAgB,EAAC,IAAI,CAAC,CAAA;AACrD,IAAA,+BAAkB,GAAE,CAAA;AACpB,IAAA,gDAA0B,GAAE,CAAA;AAC5B,wBAAqB","sourcesContent":["export * from './migrations'\nexport * from './middlewares'\nexport * from './service'\n\nimport './routes'\n\nimport { registerRoleTask } from '@things-factory/auth-base'\nimport { ROLE_TASKS } from './role-tasks'\nimport { registerSalesReads } from './service/sales-read'\nimport { registerOpportunitySubject } from './service/opportunity/opportunity-subject'\n\nfor (const task of ROLE_TASKS) registerRoleTask(task)\nregisterSalesReads()\nregisterOpportunitySubject()\nimport './work-doors'\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/middlewares/index.ts"],"names":[],"mappings":";;AAEA,0CAEC;AAFD,SAAgB,eAAe,CAAC,IAAS;IACvC,kCAAkC;AACpC,CAAC","sourcesContent":["import Koa from 'koa'\n\nexport function initMiddlewares(_app: Koa) {\n /* can add middlewares into app */\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA","sourcesContent":["const glob = require('glob')\nconst path = require('path')\n\nexport var migrations = []\n\nglob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {\n if (file.indexOf('index.js') !== -1) return\n migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])\n})\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"role-tasks.js","sourceRoot":"","sources":["../server/role-tasks.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAIU,QAAA,UAAU,GAAe;IACpC,EAAE,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;IACzE,EAAE,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE;CACtF,CAAA","sourcesContent":["/*\n * The work this module names, for the seats applications build (ADR-0139 decision 11).\n *\n * A task holds whole privileges: each opens everything its doors open, and the words under `task.<id>` in this\n * module's translations say what that is. Seats are put together by applications (`RoleTemplate.tasks`).\n *\n * Data only - `server/index.ts` registers it - so an application's tests read it without starting the framework.\n */\n\nimport type { RoleTask } from '@things-factory/auth-base'\n\nexport const ROLE_TASKS: RoleTask[] = [\n { id: 'sales.reading', grants: [{ category: 'sales', axes: ['query'] }] },\n { id: 'sales.keeping', grants: [{ category: 'sales', axes: ['query', 'mutation'] }] }\n]\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;;;;OAKG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF;;OAEG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;OAEG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF;;OAEG;AACL,CAAC,CAAC,CAAA","sourcesContent":["process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {\n /*\n * can add global public routes to application (auth not required, tenancy not required)\n *\n * ex) routes.get('/path', async(context, next) => {})\n * ex) routes.post('/path', async(context, next) => {})\n */\n})\n\nprocess.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {\n /*\n * can add global private routes to application (auth required, tenancy not required)\n */\n})\n\nprocess.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {\n /*\n * can add domain public routes to application (auth not required, tenancy required)\n */\n})\n\nprocess.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {\n /*\n * can add domain private routes to application (auth required, tenancy required)\n */\n})\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,gEAAqC;AACrC,qEAA0C;AAC1C,sEAA2C;AAC3C,sEAA2C;AAC3C,wEAA6C;AAC7C,qEAA0C;AAC1C,oEAAyC;AACzC,0EAA+C;AAC/C,0EAA+C;AAC/C,4EAAiD;AACjD,yEAA8C;AAC9C,wEAA6C;AAC7C,8EAAmD;AACnD,gFAAqD;AACrD,6EAAkD;AAClD,uDAA4B;AAE5B,mEAA4C;AAC5C,+DAAwC;AACxC,sEAA+C;AAElC,QAAA,QAAQ,GAAG,CAAC,GAAG,SAAS,CAAC,QAAQ,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;AACrF,QAAA,WAAW,GAAG,CAAC,GAAG,SAAS,CAAC,WAAW,EAAE,GAAG,WAAW,CAAC,WAAW,EAAE,GAAG,YAAY,CAAC,WAAW,CAAC,CAAA;AACjG,QAAA,MAAM,GAAG,EAAE,eAAe,EAAE,CAAC,GAAG,SAAS,CAAC,SAAS,EAAE,GAAG,WAAW,CAAC,SAAS,EAAE,GAAG,YAAY,CAAC,SAAS,CAAC,EAAE,CAAA","sourcesContent":["export * from './quotation/quotation'\nexport * from './quotation/quotation-item'\nexport * from './quotation/quotation-event'\nexport * from './quotation/quotation-rules'\nexport * from './quotation/quotation-service'\nexport * from './quotation/quotation-type'\nexport * from './opportunity/opportunity'\nexport * from './opportunity/opportunity-event'\nexport * from './opportunity/opportunity-rules'\nexport * from './opportunity/opportunity-service'\nexport * from './opportunity/opportunity-type'\nexport * from './sales-product/sales-product'\nexport * from './sales-product/sales-product-rules'\nexport * from './sales-product/sales-product-service'\nexport * from './sales-product/sales-product-type'\nexport * from './sales-read'\n\nimport * as opportunity from './opportunity'\nimport * as quotation from './quotation'\nimport * as salesProduct from './sales-product'\n\nexport const entities = [...quotation.entities, ...opportunity.entities, ...salesProduct.entities]\nexport const subscribers = [...quotation.subscribers, ...opportunity.subscribers, ...salesProduct.subscribers]\nexport const schema = { resolverClasses: [...quotation.resolvers, ...opportunity.resolvers, ...salesProduct.resolvers] }\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/opportunity/index.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAC3C,2DAAsD;AACtD,uEAAiE;AACjE,iEAA4D;AAC5D,2DAAsD;AAEzC,QAAA,QAAQ,GAAG,CAAC,yBAAW,EAAE,oCAAgB,CAAC,CAAA;AAC1C,QAAA,SAAS,GAAG,CAAC,oCAAgB,EAAE,0CAAmB,EAAE,+CAAqB,CAAC,CAAA;AAC1E,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { Opportunity } from './opportunity'\nimport { OpportunityEvent } from './opportunity-event'\nimport { OpportunityEventQuery } from './opportunity-event-query'\nimport { OpportunityMutation } from './opportunity-mutation'\nimport { OpportunityQuery } from './opportunity-query'\n\nexport const entities = [Opportunity, OpportunityEvent]\nexport const resolvers = [OpportunityQuery, OpportunityMutation, OpportunityEventQuery]\nexport const subscribers = []\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"opportunity-event-query.js","sourceRoot":"","sources":["../../../server/service/opportunity/opportunity-event-query.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,iDAA6D;AAC7D,+CAA4D;AAE5D,2DAAsD;AAG/C,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEhC,KAAK,CAAS,GAAqB;QACjC,OAAO,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACpG,CAAC;IAGD,MAAM,CAAS,GAAqB;QAClC,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,qBAAa,EAAC,cAAM,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACzG,CAAC;IAGD,OAAO,CAAS,GAAqB;QACnC,OAAO,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAC1G,CAAC;IAGD,OAAO,CAAS,GAAqB;QACnC,OAAO,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAC1G,CAAC;CACF,CAAA;AApBY,sDAAqB;AAEhC;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,oCAAgB;;kDAElC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1C,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,oCAAgB;;mDAEnC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,oCAAgB;;oDAEpC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,oCAAgB;;oDAEpC;gCAnBU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,oCAAgB,CAAC;GACd,qBAAqB,CAoBjC","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { FieldResolver, Resolver, Root } from 'type-graphql'\n\nimport { OpportunityEvent } from './opportunity-event'\n\n@Resolver(OpportunityEvent)\nexport class OpportunityEventQuery {\n @FieldResolver(type => User, { nullable: true })\n actor(@Root() row: OpportunityEvent) {\n return row.actor ?? (row.actorId ? getRepository(User).findOneBy({ id: row.actorId }) : undefined)\n }\n\n @FieldResolver(type => Domain, { nullable: true })\n domain(@Root() row: OpportunityEvent) {\n return row.domain ?? (row.domainId ? getRepository(Domain).findOneBy({ id: row.domainId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n creator(@Root() row: OpportunityEvent) {\n return row.creator ?? (row.creatorId ? getRepository(User).findOneBy({ id: row.creatorId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n updater(@Root() row: OpportunityEvent) {\n return row.updater ?? (row.updaterId ? getRepository(User).findOneBy({ id: row.updaterId }) : undefined)\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"opportunity-event.js","sourceRoot":"","sources":["../../../server/service/opportunity/opportunity-event.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,iDAA4D;AAC5D,+CAAyD;AACzD,qCAAoJ;AAEpJ,+CAA2C;AAC3C,2DAAsD;AAEtD,4HAA4H;AAIrH,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CA2E5B,CAAA;AA3EY,4CAAgB;AAGlB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;4CACC;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,CAAC;sCACjC,cAAM;gDAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;;kDACrC;AAGjB;IADC,IAAA,mBAAS,EAA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AE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;iDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;;mDACrC;2BA1EP,gBAAgB;IAH5B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,wBAAwB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAClG,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oGAAoG,EAAE,CAAC;GACrH,gBAAgB,CA2E5B","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Domain, ScalarObject } from '@things-factory/shell'\nimport { Field, ID, Int, ObjectType } from 'type-graphql'\nimport { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\n\nimport { Opportunity } from './opportunity'\nimport { OpportunityStage } from './opportunity-rules'\n\n/** The same shape as QuotationEvent, with the stage it left and the stage and probability it took (ADR-0138 decision 6). */\n@Entity()\n@Index('ix_opportunity_event_0', (event: OpportunityEvent) => [event.opportunity, event.createdAt])\n@ObjectType({ description: 'Entity for OpportunityEvent — what happened to an opportunity, with the stage it moved from and to' })\nexport class OpportunityEvent {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true })\n domain?: Domain\n\n @RelationId((event: OpportunityEvent) => event.domain)\n domainId?: string\n\n @ManyToOne(type => Opportunity, { nullable: false })\n opportunity: Opportunity\n\n @RelationId((event: OpportunityEvent) => event.opportunity)\n @Field({ description: 'The opportunity the event happened to' })\n opportunityId: string\n\n @Column()\n @Field({ description: 'What happened: CREATED, UPDATED, STAGED, WON, LOST, or REOPENED when the record a win became was undone' })\n action: string\n\n @Column({ nullable: true })\n @Field(type => OpportunityStage, { nullable: true, description: 'The stage it moved from; empty when it was created' })\n fromStage?: OpportunityStage\n\n @Column()\n @Field(type => OpportunityStage, { description: 'The stage it stood at after the event' })\n stage: OpportunityStage\n\n @Column({ type: 'int' })\n @Field(type => Int, { description: 'The probability it had after the event, in percent' })\n probability: number\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Why, when it was lost' })\n reason?: string\n\n @Column({ type: 'simple-json' })\n @Field(type => ScalarObject, { description: 'The opportunity as it stood after the event' })\n snapshot: any\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n actor?: User\n\n @RelationId((event: OpportunityEvent) => event.actor)\n actorId?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When it happened' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When the row last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When the row was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((event: OpportunityEvent) => event.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((event: OpportunityEvent) => event.updater)\n updaterId?: string\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"opportunity-mutation.js","sourceRoot":"","sources":["../../../server/service/opportunity/opportunity-mutation.ts"],"names":[],"mappings":";;;;AAAA,iDAAqD;AACrD,+CAAqF;AAErF,+CAA2C;AAC3C,2DAAsD;AACtD,+DAAyE;AACzE,yDAAmD;AAEnD,iIAAiI;AAG1H,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAI9B,iBAAiB,CAAqB,WAA2B,EAAS,OAAwB;QAChG,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,OAAO,IAAA,qC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AAG,EAAC,aAAa,CAAC,CAAA;IAA+B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;qDAAtB,iCAAc;;4DAGvF;AAKD;IAHC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,gFAAgF,CAAC;IAC3F,IAAA,uBAAQ,EAAC,IAAI,CAAC,EAAE,CAAC,yBAAW,EAAE,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;IACvF,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,EAAC,QAAQ,CAAC,CAAA;IAAkB,mBAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAAoB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;0DAGlI;8BAvBU,mBAAmB;IAF/B,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,EAAC,yBAAW,CAAC;GACT,mBAAmB,CAwB/B","sourcesContent":["import { SpeakRefusals } from '@things-factory/shell'\nimport { Arg, Ctx, Directive, Mutation, Resolver, UseMiddleware } from 'type-graphql'\n\nimport { Opportunity } from './opportunity'\nimport { OpportunityStage } from './opportunity-rules'\nimport { closeOpportunity, saveOpportunity } from './opportunity-service'\nimport { NewOpportunity } from './opportunity-type'\n\n/* Winning has no door here: the application that turns a won opportunity into its own record closes it (ADR-0138 decision 8). */\n@UseMiddleware(SpeakRefusals)\n@Resolver(Opportunity)\nexport class OpportunityMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Opportunity, { description: 'To create an opportunity' })\n createOpportunity(@Arg('opportunity') opportunity: NewOpportunity, @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return saveOpportunity(tx, domain, user, opportunity)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Opportunity, { description: 'To change an open opportunity, move it to another open stage, or open a lost one again' })\n updateOpportunity(@Arg('id') id: string, @Arg('opportunity') opportunity: NewOpportunity, @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return saveOpportunity(tx, domain, user, opportunity, id)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Opportunity, { description: 'To close an open opportunity as lost, with the reason' })\n loseOpportunity(@Arg('id') id: string, @Arg('reason') reason: string, @Arg('closedOn', { nullable: true }) closedOn: string, @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return closeOpportunity(tx, domain, user, id, OpportunityStage.LOST, { reason, closedOn })\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"opportunity-query.js","sourceRoot":"","sources":["../../../server/service/opportunity/opportunity-query.ts"],"names":[],"mappings":";;;;AAAA,yDAAoE;AACpE,uDAAuD;AACvD,iDAAsH;AACtH,+CAA6G;AAE7G,sDAAkD;AAClD,sEAAwE;AACxE,+CAA2C;AAC3C,2DAAsD;AACtD,2DAAiF;AACjF,+DAAuF;AACvF,yDAAoG;AAI7F,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAG3B,WAAW,CAAY,EAAU,EAAS,OAAwB;QAChE,OAAO,IAAA,qBAAa,EAAC,yBAAW,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACvG,CAAC;IAIK,AAAN,KAAK,CAAC,aAAa,CAA0B,MAAiB,EAAS,OAAwB;QAC7F,MAAM,KAAK,GAAG,IAAA,qCAA6B,EAAC;YAC1C,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM;YAC5B,MAAM;YACN,UAAU,EAAE,IAA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,IAAI,EAAE,CAAC;IACzC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,yBAAW;;6CAE7B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1C,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,yBAAW;;8CAE9B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,yBAAW;;+CAE/B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,yBAAW;;+CAE/B;2BA7EU,gBAAgB;IAF5B,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,EAAC,yBAAW,CAAC;GACT,gBAAgB,CA8E5B","sourcesContent":["import { getDomainAssignees, User } from '@things-factory/auth-base'\nimport { Counterparty } from '@things-factory/biz-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam, SpeakRefusals } from '@things-factory/shell'\nimport { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root, UseMiddleware } from 'type-graphql'\n\nimport { Quotation } from '../quotation/quotation'\nimport { quotationsOfOpportunity } from '../quotation/quotation-service'\nimport { Opportunity } from './opportunity'\nimport { OpportunityEvent } from './opportunity-event'\nimport { isOpen, OpportunityStage, STAGE_PROBABILITY } from './opportunity-rules'\nimport { OPPORTUNITY_SEARCHABLES, opportunityStageCounts } from './opportunity-service'\nimport { OpportunityList, OpportunityStageCount, OpportunityStageDefault } from './opportunity-type'\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(Opportunity)\nexport class OpportunityQuery {\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => Opportunity, { nullable: true, description: 'To fetch an opportunity' })\n opportunity(@Arg('id') id: string, @Ctx() context: ResolverContext) {\n return getRepository(Opportunity).findOne({ where: { id, domain: { id: context.state.domain.id } } })\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => OpportunityList, { description: 'To fetch a page of opportunities' })\n async opportunities(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<OpportunityList> {\n const query = getQueryBuilderFromListParams({\n domain: context.state.domain,\n params,\n repository: getRepository(Opportunity),\n searchables: OPPORTUNITY_SEARCHABLES\n })\n const [items, total] = await query.getManyAndCount()\n return { items, total }\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [OpportunityStageCount], { description: 'To count the opportunities in each stage, under the list conditions other than the stage, every stage in order' })\n opportunityStageCounts(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext) {\n return opportunityStageCounts(getRepository(Opportunity).manager, context.state.domain, params)\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [OpportunityEvent], { description: 'To fetch what happened to an opportunity, oldest first' })\n opportunityEvents(@Arg('opportunityId') opportunityId: string, @Ctx() context: ResolverContext) {\n return getRepository(OpportunityEvent).find({ where: { domain: { id: context.state.domain.id }, opportunity: { id: opportunityId } }, order: { createdAt: 'ASC' } })\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [OpportunityStageDefault], { description: 'To fetch the stages in order, with the probability each gives' })\n opportunityStages(): OpportunityStageDefault[] {\n return Object.values(OpportunityStage).map(stage => ({ stage, probability: STAGE_PROBABILITY[stage], open: isOpen(stage) }))\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [User], { description: 'To fetch the people an opportunity may be put in the charge of' })\n opportunityOwners(@Ctx() context: ResolverContext) {\n return getDomainAssignees(context.state.domain)\n }\n\n @FieldResolver(type => [Quotation], { description: 'The quotations that answer the opportunity, every version' })\n quotations(@Root() row: Opportunity) {\n return quotationsOfOpportunity(undefined, { id: row.domainId } as Domain, row.id)\n }\n\n @FieldResolver(type => Counterparty, { nullable: true })\n counterparty(@Root() row: Opportunity) {\n return row.counterparty ?? (row.counterpartyId ? getRepository(Counterparty).findOneBy({ id: row.counterpartyId }) : undefined)\n }\n\n @FieldResolver(type => Counterparty, { nullable: true })\n endCustomer(@Root() row: Opportunity) {\n return row.endCustomer ?? (row.endCustomerId ? getRepository(Counterparty).findOneBy({ id: row.endCustomerId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n owner(@Root() row: Opportunity) {\n return row.owner ?? (row.ownerId ? getRepository(User).findOneBy({ id: row.ownerId }) : undefined)\n }\n\n @FieldResolver(type => Domain, { nullable: true })\n domain(@Root() row: Opportunity) {\n return row.domain ?? (row.domainId ? getRepository(Domain).findOneBy({ id: row.domainId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n creator(@Root() row: Opportunity) {\n return row.creator ?? (row.creatorId ? getRepository(User).findOneBy({ id: row.creatorId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n updater(@Root() row: Opportunity) {\n return row.updater ?? (row.updaterId ? getRepository(User).findOneBy({ id: row.updaterId }) : undefined)\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"opportunity-rules.js","sourceRoot":"","sources":["../../../server/service/opportunity/opportunity-rules.ts"],"names":[],"mappings":";;;AAuCA,8BAIC;AAGD,4CAGC;AAjDD,+CAA+C;AAE/C,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IAC1B,iCAAa,CAAA;IACb,yCAAqB,CAAA;IACrB,qCAAiB,CAAA;IACjB,+CAA2B,CAAA;IAC3B,+BAAW,CAAA;IACX,iCAAa,CAAA;AACf,CAA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IAC7E,IAAI,KAAK,KAAK,gBAAgB,CAAC,GAAG,IAAI,KAAK,KAAK,gBAAgB,CAAC,IAAI;QAAE,OAAO,yBAAiB,CAAC,KAAK,CAAC,CAAA;IACtG,OAAO,KAAK,IAAI,yBAAiB,CAAC,KAAK,CAAC,CAAA;AAC1C,CAAC;AAEM,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAK,KAAgB,IAAI,CAAC,IAAK,KAAgB,IAAI,GAAG,CAAA;AAApH,QAAA,gBAAgB,oBAAoG;AAE1H,MAAM,UAAU,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAAnG,QAAA,UAAU,cAAyF","sourcesContent":["import { registerEnumType } from 'type-graphql'\n\nexport enum OpportunityStage {\n LEAD = 'LEAD',\n PROPOSAL = 'PROPOSAL',\n QUOTED = 'QUOTED',\n NEGOTIATION = 'NEGOTIATION',\n WON = 'WON',\n LOST = 'LOST'\n}\nregisterEnumType(OpportunityStage, {\n name: 'OpportunityStage',\n description: 'where a sales opportunity stands — lead, proposal, quoted, negotiation, then won or lost'\n})\n\n/** The stages a person moves an opportunity through, in order; the two after them close it. */\nexport const OPEN_STAGES = [OpportunityStage.LEAD, OpportunityStage.PROPOSAL, OpportunityStage.QUOTED, OpportunityStage.NEGOTIATION]\n\n/*\n * The probability a stage starts an opportunity at, in percent. These are judgements, not measurements: nobody has\n * counted how often a proposal of ours is won. A person changes the probability of one opportunity whenever they know\n * better, and the history (OpportunityEvent) will one day show each stage's real rate beside these (ADR-0138 decision 5).\n */\nexport const STAGE_PROBABILITY: Record<OpportunityStage, number> = {\n [OpportunityStage.LEAD]: 10,\n [OpportunityStage.PROPOSAL]: 30,\n [OpportunityStage.QUOTED]: 50,\n [OpportunityStage.NEGOTIATION]: 70,\n [OpportunityStage.WON]: 100,\n [OpportunityStage.LOST]: 0\n}\n\nexport const isOpen = (stage: string) => OPEN_STAGES.includes(stage as OpportunityStage)\n\n/**\n * Whether an opportunity may go from one stage to another. A person moves an open one to any open stage, or closes it\n * as lost; a lost one may be opened again. Winning closes it for good — an application turns the win into its own\n * record (a contract) and only it closes an opportunity as won.\n */\nexport function stageMove(from: string, to: string): boolean {\n if (from === to || from === OpportunityStage.WON) return false\n if (isOpen(to)) return true\n return isOpen(from) && (to === OpportunityStage.WON || to === OpportunityStage.LOST)\n}\n\n/** The probability an opportunity keeps after a stage change: the one a person gave, or the stage's own. */\nexport function probabilityAfter(stage: OpportunityStage, given?: number | null): number {\n if (stage === OpportunityStage.WON || stage === OpportunityStage.LOST) return STAGE_PROBABILITY[stage]\n return given ?? STAGE_PROBABILITY[stage]\n}\n\nexport const validProbability = (value: unknown) => Number.isInteger(value) && (value as number) >= 0 && (value as number) <= 100\n\nexport const validMonth = (value: unknown) => typeof value === 'string' && /^\\d{4}-(0[1-9]|1[0-2])$/.test(value)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"opportunity-service.js","sourceRoot":"","sources":["../../../server/service/opportunity/opportunity-service.ts"],"names":[],"mappings":";;;AAoBA,wDAGC;AAED,kDAIC;AAMD,0CAuDC;AAMD,4CAsBC;AAOD,oDAUC;AAvID,yDAA8D;AAC9D,uDAAuD;AACvD,qDAAkE;AAClE,iDAAiG;AAGjG,gDAAiD;AACjD,+CAA2C;AAC3C,2DAAsD;AACtD,2DAAyH;AAGzH,oHAAoH;AACvG,QAAA,uBAAuB,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;AAE9D;;;;GAIG;AACI,KAAK,UAAU,sBAAsB,CAAC,EAAiB,EAAE,MAAc,EAAE,MAAiB;IAC/F,MAAM,OAAO,GAAG,MAAM,IAAA,wBAAgB,EAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,aAAa,CAAC,yBAAW,CAAC,EAAE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E,oBAAoB,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,CAAC,CAAA;IACtL,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAA;AAC7E,CAAC","sourcesContent":["import { getDomainAssignees } from '@things-factory/auth-base'\nimport { Counterparty } from '@things-factory/biz-base'\nimport { currencyDigits, validDay } from '@things-factory/invoice'\nimport { calendarDay, countListByField, Domain, ListParam, Refusal } from '@things-factory/shell'\nimport { EntityManager } from 'typeorm'\n\nimport { recordSalesEvent } from '../sales-event'\nimport { Opportunity } from './opportunity'\nimport { OpportunityEvent } from './opportunity-event'\nimport { isOpen, OpportunityStage, probabilityAfter, stageMove, validMonth, validProbability } from './opportunity-rules'\nimport { NewOpportunity } from './opportunity-type'\n\n/** What the list finds the opportunities by — a term matched in these, as the list and its stage counts both do. */\nexport const OPPORTUNITY_SEARCHABLES = ['name', 'description']\n\n/**\n * How many opportunities each stage holds, under the list's other conditions — its search and any filter but the\n * stage, so the counts beside the stage chips agree with one another whichever stages are chosen. Counted by the\n * database, grouped by stage; a stage holding none is given as 0, in stage order, each saying whether it is open.\n */\nexport async function opportunityStageCounts(tx: EntityManager, domain: Domain, params: ListParam) {\n const counted = await countListByField({ domain, params, repository: tx.getRepository(Opportunity), searchables: OPPORTUNITY_SEARCHABLES, field: 'stage' })\n return Object.values(OpportunityStage).map(stage => ({ stage, count: counted.get(stage) ?? 0, open: isOpen(stage) }))\n}\n\nexport async function opportunityInDomain(tx: EntityManager, domain: Domain, id: string) {\n const opportunity = await tx.getRepository(Opportunity).findOne({ where: { id, domain: { id: domain.id } } })\n if (!opportunity) throw new Refusal('opportunity-not-found', {}, 'Opportunity not found')\n return opportunity\n}\n\n/**\n * Create an opportunity, or change one a person may still change. An open one takes any open stage; a lost one is\n * opened again by giving it an open stage. Closing is `closeOpportunity`'s.\n */\nexport async function saveOpportunity(tx: EntityManager, domain: Domain, user: any, input: NewOpportunity, id?: string) {\n const old = id ? await opportunityInDomain(tx, domain, id) : undefined\n const stage = input.stage ?? old?.stage ?? OpportunityStage.LEAD\n /* A closed one changes only by being opened again, and only a lost one may be. */\n if (old && !isOpen(old.stage) && !(isOpen(stage) && stageMove(old.stage, stage))) throw new Refusal('opportunity-closed', {}, 'A closed opportunity is not changed')\n if (!isOpen(stage)) throw new Refusal('opportunity-stage-open-required', {}, 'Give an open stage; won and lost are closings')\n\n const name = input.name?.trim()\n if (!name) throw new Refusal('opportunity-name-required', {}, 'Name the opportunity')\n if (!Number.isFinite(input.amount) || input.amount < 0) throw new Refusal('opportunity-amount-invalid', {}, 'The expected amount is zero or more')\n const currency = (input.currency?.trim() || 'KRW').toUpperCase()\n currencyDigits(currency)\n if (!validMonth(input.expectedCloseMonth)) throw new Refusal('opportunity-close-month-invalid', {}, 'Give the expected month as YYYY-MM')\n if (input.probability !== undefined && input.probability !== null && !validProbability(input.probability))\n throw new Refusal('opportunity-probability-invalid', { value: String(input.probability), min: 0, max: 100 }, 'The probability is a whole number from 0 to 100')\n\n const counterparties = tx.getRepository(Counterparty)\n const counterparty = input.counterpartyId ? await counterparties.findOne({ where: { id: input.counterpartyId, domain: { id: domain.id } } }) : null\n if (!counterparty) throw new Refusal('opportunity-counterparty-required', {}, 'Choose the counterparty of this domain')\n const endCustomer = input.endCustomerId ? await counterparties.findOne({ where: { id: input.endCustomerId, domain: { id: domain.id } } }) : null\n if (input.endCustomerId && !endCustomer) throw new Refusal('opportunity-end-customer-invalid', {}, 'Choose the end customer among the counterparties of this domain')\n\n const ownerId = input.ownerId || old?.ownerId || user.id\n /* The people work here may be given to — auth-base's one answer, the same a license's recipient gets. */\n if (ownerId !== user.id && ownerId !== old?.ownerId && !(await getDomainAssignees(domain, tx)).some(one => one.id === ownerId))\n throw new Refusal('opportunity-owner-invalid', {}, 'Put it in the charge of a member of this domain')\n\n const staged = !!old && old.stage !== stage\n /* The probability follows the stage unless the person gave one; with the stage unchanged it stays as it was. */\n const probability = !old || staged ? probabilityAfter(stage, input.probability) : input.probability ?? old.probability\n\n const repository = tx.getRepository(Opportunity)\n const row = await repository.save(\n repository.create({\n ...(old ? { id: old.id, creator: old.creatorId ? ({ id: old.creatorId } as any) : undefined } : { creator: user }),\n domain,\n name,\n counterparty,\n endCustomer: endCustomer ?? null,\n amount: input.amount,\n currency,\n expectedCloseMonth: input.expectedCloseMonth,\n stage,\n probability,\n owner: { id: ownerId } as any,\n /* A lost opportunity opened again is no longer closed. */\n closedOn: null,\n lostReason: null,\n description: input.description?.trim() || null,\n updater: user\n })\n )\n const saved = await opportunityInDomain(tx, domain, row.id)\n await recordOpportunityEvent(tx, domain, user, saved, !old ? 'CREATED' : staged ? 'STAGED' : 'UPDATED', staged ? old.stage : undefined)\n return saved\n}\n\n/**\n * Close an open opportunity — lost, with the reason, by a person; won by the application that turned it into its own\n * record (Office's contract, ADR-0138 decision 8). The day is the domain's today unless one is given.\n */\nexport async function closeOpportunity(\n tx: EntityManager,\n domain: Domain,\n user: any,\n id: string,\n outcome: OpportunityStage.WON | OpportunityStage.LOST,\n { closedOn, reason }: { closedOn?: string; reason?: string } = {}\n) {\n const opportunity = await opportunityInDomain(tx, domain, id)\n if (!stageMove(opportunity.stage, outcome)) throw new Refusal('opportunity-stage-move-invalid', {}, 'The opportunity cannot move to that stage')\n if (outcome === OpportunityStage.LOST && !reason?.trim()) throw new Refusal('opportunity-reason-required', {}, 'Say why it was lost')\n const day = closedOn || calendarDay(domain.timezone)\n if (!validDay(day)) throw new Refusal('opportunity-closed-on-invalid', {}, 'Give the closing day as YYYY-MM-DD')\n\n const from = opportunity.stage\n await tx.getRepository(Opportunity).update(\n { id: opportunity.id },\n { stage: outcome, probability: probabilityAfter(outcome), closedOn: day, lostReason: outcome === OpportunityStage.LOST ? reason!.trim() : null, updater: user }\n )\n const closed = await opportunityInDomain(tx, domain, id)\n await recordOpportunityEvent(tx, domain, user, closed, outcome, from, outcome === OpportunityStage.LOST ? closed.lostReason : undefined)\n return closed\n}\n\n/**\n * A won opportunity opened again, because the record its win became was undone - an application's contract link taken\n * back (the user, 2026-10-30: 「계약 연결을 취소할 수 있어야지」). Only the application that closed it as won undoes it; a\n * person does not move a won one. It goes back to the open stage it was won from, with that stage's probability.\n */\nexport async function reopenWonOpportunity(tx: EntityManager, domain: Domain, user: any, id: string, reason: string) {\n const opportunity = await opportunityInDomain(tx, domain, id)\n if (opportunity.stage !== OpportunityStage.WON) throw new Refusal('opportunity-not-won', {}, 'Only a won opportunity is opened again this way')\n if (!reason?.trim()) throw new Refusal('opportunity-reopen-reason-required', {}, 'Say why it is opened again')\n const won = await tx.getRepository(OpportunityEvent).findOne({ where: { opportunity: { id }, action: OpportunityStage.WON } as any, order: { createdAt: 'DESC' } as any })\n const stage = won?.fromStage && isOpen(won.fromStage) ? won.fromStage : OpportunityStage.NEGOTIATION\n await tx.getRepository(Opportunity).update({ id }, { stage, probability: probabilityAfter(stage), closedOn: null, lostReason: null, updater: user } as any)\n const reopened = await opportunityInDomain(tx, domain, id)\n await recordOpportunityEvent(tx, domain, user, reopened, 'REOPENED', OpportunityStage.WON, reason.trim())\n return reopened\n}\n\nfunction recordOpportunityEvent(tx: EntityManager, domain: Domain, user: any, opportunity: Opportunity, action: string, fromStage?: OpportunityStage, reason?: string) {\n return recordSalesEvent(\n tx,\n OpportunityEvent,\n { opportunity, fromStage: fromStage ?? null, stage: opportunity.stage, probability: opportunity.probability },\n { domain, user, action, reason, snapshot: snapshotOf(opportunity) }\n )\n}\n\n/** The opportunity as it stood. */\nfunction snapshotOf(opportunity: Opportunity) {\n const keys = ['id', 'name', 'counterpartyId', 'endCustomerId', 'amount', 'currency', 'expectedCloseMonth', 'stage', 'probability', 'ownerId', 'closedOn', 'lostReason', 'description']\n return Object.fromEntries(keys.map(key => [key, opportunity[key] ?? null]))\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"opportunity-subject.js","sourceRoot":"","sources":["../../../server/service/opportunity/opportunity-subject.ts"],"names":[],"mappings":";;;AAkBA,gEAEC;AApBD;;;;;GAKG;AACH,+DAAwF;AACxF,iDAAqD;AAErD,2FAA2F;AAC9E,QAAA,mBAAmB,GAAkB;IAChD,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAA,qBAAa,EAAC,aAAa,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAS,EAAE,SAAS,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC;IACvJ,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;CAC5E,CAAA;AAED,SAAgB,0BAA0B;IACxC,IAAA,oCAAqB,EAAC,2BAAmB,CAAC,CAAA;AAC5C,CAAC","sourcesContent":["/**\n * The opportunity whose 360 is open, named for the AI each turn (operato-application design/ai/screen-pattern.md §2-1).\n *\n * The 360 kind `opportunity` anchors its conversation to `opportunity:<uuid>`; the record is named only for someone\n * the 360's own read (`Query.opportunity`) lets through.\n */\nimport { registerRecordSubject, type RecordSubject } from '@things-factory/ai-assistant'\nimport { getRepository } from '@things-factory/shell'\n\n/* By entity name - the entity's decorators stay out of what a test of this has to load. */\nexport const OPPORTUNITY_SUBJECT: RecordSubject = {\n axis: 'opportunity',\n noun: 'sales opportunity',\n door: 'Query.opportunity',\n read: (rowId, domainId) => getRepository('Opportunity').findOne({ where: { id: rowId, domain: { id: domainId } } as any, relations: ['counterparty'] }),\n nameOf: row => [row.name, row.counterparty?.name].filter(Boolean).join(' ')\n}\n\nexport function registerOpportunitySubject(): void {\n registerRecordSubject(OPPORTUNITY_SUBJECT)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"opportunity-type.js","sourceRoot":"","sources":["../../../server/service/opportunity/opportunity-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAuE;AAEvE,+CAA2C;AAC3C,2DAAsD;AAG/C,IAAM,cAAc,GAApB,MAAM,cAAc;CAW1B,CAAA;AAXY,wCAAc;AACiC;IAAzD,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;;4CAAa;AACW;IAAhF,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;;sDAAuB;AACM;IAA5G,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mEAAmE,EAAE,CAAC;;qDAAuB;AAC9D;IAApE,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAK,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;;8CAAe;AACD;IAAjF,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;;gDAAkB;AAC5B;IAAtE,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;;0DAA2B;AACiC;IAAjI,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oCAAgB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,8DAA8D,EAAE,CAAC;;6CAAyB;AACyB;IAAlL,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0HAA0H,EAAE,CAAC;;mDAAqB;AAC1G;IAA5F,IAAA,oBAAK,EAAC,EAAE,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AqB;AAC+B;IAA9D,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oCAAgB,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;;oDAAwB;AAC4B;IAAjH,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,2EAA2E,EAAE,CAAC;;oDAAc;AACN;IAAxH,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,+FAA+F,EAAE,CAAC;;mDAAc;gCAH3H,qBAAqB;IADjC,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,yDAAyD,EAAE,CAAC;GAC1E,qBAAqB,CAIjC","sourcesContent":["import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Opportunity } from './opportunity'\nimport { OpportunityStage } from './opportunity-rules'\n\n@InputType({ description: 'An opportunity to create, or what a person changes on one' })\nexport class NewOpportunity {\n @Field({ description: 'What the opportunity is called' }) name: string\n @Field({ description: 'Id of the counterparty the domain would contract with' }) counterpartyId: string\n @Field({ nullable: true, description: 'Id of the end customer, when the work comes through another party' }) endCustomerId?: string\n @Field(type => Float, { description: 'Expected amount before tax' }) amount: number\n @Field({ nullable: true, description: 'ISO 4217 currency code, KRW when empty' }) currency?: string\n @Field({ description: 'Month the domain expects to win it, YYYY-MM' }) expectedCloseMonth: string\n @Field(type => OpportunityStage, { nullable: true, description: 'An open stage; a new opportunity starts as a lead when empty' }) stage?: OpportunityStage\n @Field(type => Float, { nullable: true, description: 'Chance of winning in percent, a whole number from 0 to 100 - another is refused naming it; the stage gives it when empty' }) probability?: number\n @Field({ nullable: true, description: 'Id of the person in charge; the caller when empty' }) ownerId?: string\n @Field({ nullable: true, description: 'Notes' }) description?: string\n}\n\n@ObjectType({ description: 'A page of opportunities' })\nexport class OpportunityList {\n @Field(type => [Opportunity], { description: 'Opportunities on the page' }) items: Opportunity[]\n @Field(type => Int, { description: 'Number of opportunities matching the list parameters' }) total: number\n}\n\n@ObjectType({ description: 'A stage and the probability it starts an opportunity at' })\nexport class OpportunityStageDefault {\n @Field(type => OpportunityStage, { description: 'The stage' }) stage: OpportunityStage\n @Field(type => Int, { description: 'The probability the stage gives, in percent — a judgement, not a measurement' }) probability: number\n @Field({ description: 'Whether a person moves an opportunity through this stage; won and lost close it' }) open: boolean\n}\n\n@ObjectType({ description: 'A stage and how many opportunities the list holds in it' })\nexport class OpportunityStageCount {\n @Field(type => OpportunityStage, { description: 'The stage' }) stage: OpportunityStage\n @Field(type => Int, { description: 'Opportunities in the stage under the list conditions other than the stage' }) count: number\n @Field({ description: 'Whether the stage is open; the list starts with the open stages chosen, won and lost left out' }) open: boolean\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"opportunity.js","sourceRoot":"","sources":["../../../server/service/opportunity/opportunity.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,uDAAuD;AACvD,iDAA2D;AAC3D,+CAAgE;AAChE,qCAAoJ;AAEpJ,2DAAsD;AAEtD;;;GAGG;AAMI,IAAM,WAAW,GAAjB,MAAM,WAAW;CAiGvB,CAAA;AAjGY,kCAAW;AAGb;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;uCACC;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,CAAC;sCACjC,cAAM;2CAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;;6CAC5C;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;;yCAC7C;AAIZ;IAFC,IAAA,mBAAS,EA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IALvB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,kBAAkB,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAChI,IAAA,eAAK,EAAC,kBAAkB,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACvG,IAAA,eAAK,EAAC,kBAAkB,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IACtG,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,4DAA4D,EAAE,CAAC;GAC7E,WAAW,CAiGvB","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Counterparty } from '@things-factory/biz-base'\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 { OpportunityStage } from './opportunity-rules'\n\n/**\n * A sales opportunity — work the domain hopes to win, before there is a contract: with whom, for how much, by when,\n * and how likely. A person moves it through the stages; it closes as won or lost (ADR-0138 decision 5).\n */\n@Entity()\n@Index('ix_opportunity_0', (opportunity: Opportunity) => [opportunity.domain, opportunity.stage, opportunity.expectedCloseMonth])\n@Index('ix_opportunity_1', (opportunity: Opportunity) => [opportunity.domain, opportunity.counterparty])\n@Index('ix_opportunity_2', (opportunity: Opportunity) => [opportunity.domain, opportunity.endCustomer])\n@ObjectType({ description: 'Entity for Opportunity — work hoped for, before a contract' })\nexport class Opportunity {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true })\n domain?: Domain\n\n @RelationId((opportunity: Opportunity) => opportunity.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'What the opportunity is called' })\n name: string\n\n @ManyToOne(type => Counterparty, { nullable: false })\n @Field(type => Counterparty, { nullable: true, description: 'The party the domain would contract with' })\n counterparty: Counterparty\n\n @RelationId((opportunity: Opportunity) => opportunity.counterparty)\n @Field({ description: 'Id of the party the domain would contract with' })\n counterpartyId: string\n\n @ManyToOne(type => Counterparty, { nullable: true })\n @Field(type => Counterparty, { nullable: true, description: 'The end customer, when the work comes through another party' })\n endCustomer?: Counterparty\n\n @RelationId((opportunity: Opportunity) => opportunity.endCustomer)\n @Field({ nullable: true, description: 'Id of the end customer' })\n endCustomerId?: string\n\n @Column({ ...moneyColumn(), default: 0 })\n @Field(type => Float, { description: 'Expected amount before tax' })\n amount: number\n\n @Column({ default: 'KRW' })\n @Field({ description: 'ISO 4217 currency code of the amount' })\n currency: string\n\n @Column()\n @Field({ description: 'Month the domain expects to win it, YYYY-MM' })\n expectedCloseMonth: string\n\n @Column({ default: OpportunityStage.LEAD })\n @Field(type => OpportunityStage, { description: 'Lead, proposal, quoted, negotiation, won or lost' })\n stage: OpportunityStage\n\n @Column({ type: 'int' })\n @Field(type => Int, { description: 'Chance of winning in percent, 0 to 100 — the stage gives it, a person may change it' })\n probability: number\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n owner?: User\n\n @RelationId((opportunity: Opportunity) => opportunity.owner)\n @Field({ nullable: true, description: 'Id of the person in charge' })\n ownerId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Day it was closed as won or lost, YYYY-MM-DD' })\n closedOn?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Why it was lost' })\n lostReason?: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Notes' })\n description?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When the opportunity was created' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When the opportunity last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When the opportunity was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((opportunity: Opportunity) => opportunity.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((opportunity: Opportunity) => opportunity.updater)\n updaterId?: string\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/quotation/index.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,uDAAkD;AAClD,mEAA6D;AAC7D,qDAAgD;AAChD,iEAA2D;AAC3D,6DAAwD;AACxD,uDAAkD;AAErC,QAAA,QAAQ,GAAG,CAAC,qBAAS,EAAE,8BAAa,EAAE,gCAAc,CAAC,CAAA;AACrD,QAAA,SAAS,GAAG,CAAC,gCAAc,EAAE,sCAAiB,EAAE,yCAAkB,EAAE,2CAAmB,CAAC,CAAA;AACxF,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { Quotation } from './quotation'\nimport { QuotationEvent } from './quotation-event'\nimport { QuotationEventQuery } from './quotation-event-query'\nimport { QuotationItem } from './quotation-item'\nimport { QuotationItemQuery } from './quotation-item-query'\nimport { QuotationMutation } from './quotation-mutation'\nimport { QuotationQuery } from './quotation-query'\n\nexport const entities = [Quotation, QuotationItem, QuotationEvent]\nexport const resolvers = [QuotationQuery, QuotationMutation, QuotationItemQuery, QuotationEventQuery]\nexport const subscribers = []\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation-event-query.js","sourceRoot":"","sources":["../../../server/service/quotation/quotation-event-query.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,iDAA6D;AAC7D,+CAA4D;AAE5D,uDAAkD;AAG3C,IAAM,mBAAmB,GAAzB,MAAM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a,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1C,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,gCAAc;;iDAEjC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,gCAAc;;kDAElC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,gCAAc;;kDAElC;8BAlBU,mBAAmB;IAD/B,IAAA,uBAAQ,EAAC,gCAAc,CAAC;GACZ,mBAAmB,CAmB/B","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { FieldResolver, Resolver, Root } from 'type-graphql'\n\nimport { QuotationEvent } from './quotation-event'\n\n@Resolver(QuotationEvent)\nexport class QuotationEventQuery {\n @FieldResolver(type => User, { nullable: true })\n actor(@Root() row: QuotationEvent) {\n return row.actor ?? (row.actorId ? getRepository(User).findOneBy({ id: row.actorId }) : undefined)\n }\n @FieldResolver(type => Domain, { nullable: true })\n domain(@Root() row: QuotationEvent) {\n return row.domain ?? (row.domainId ? getRepository(Domain).findOneBy({ id: row.domainId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n creator(@Root() row: QuotationEvent) {\n return row.creator ?? (row.creatorId ? getRepository(User).findOneBy({ id: row.creatorId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n updater(@Root() row: QuotationEvent) {\n return row.updater ?? (row.updaterId ? getRepository(User).findOneBy({ id: row.updaterId }) : undefined)\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation-event.js","sourceRoot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BAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;+CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,KAAqB,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;;iDACnC;yBA9DP,cAAc;IAH1B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,sBAAsB,EAAE,CAAC,KAAqB,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC5F,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,8FAA8F,EAAE,CAAC;GAC/G,cAAc,CA+D1B","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Domain, ScalarObject } from '@things-factory/shell'\nimport { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\n\nimport { Quotation } from './quotation'\n\n@Entity()\n@Index('ix_quotation_event_0', (event: QuotationEvent) => [event.quotation, event.createdAt])\n@ObjectType({ description: 'Entity for QuotationEvent — what happened to a quotation, with the document as it then stood' })\nexport class QuotationEvent {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true })\n domain?: Domain\n\n @RelationId((event: QuotationEvent) => event.domain)\n domainId?: string\n\n @ManyToOne(type => Quotation, { nullable: false })\n quotation: Quotation\n\n @RelationId((event: QuotationEvent) => event.quotation)\n @Field({ description: 'The quotation the event happened to' })\n quotationId: string\n\n @Column()\n @Field({ description: 'What happened: CREATED, UPDATED, SENT, ACCEPTED, REJECTED, EXPIRED, REVISED or SUPERSEDED' })\n action: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Why, when the buyer declined' })\n reason?: string\n\n @Column({ type: 'simple-json' })\n @Field(type => ScalarObject, { description: 'The quotation as it stood after the action' })\n snapshot: any\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n actor?: User\n\n @RelationId((event: QuotationEvent) => event.actor)\n actorId?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When it happened' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When the row last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When the row was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((event: QuotationEvent) => event.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((event: QuotationEvent) => event.updater)\n updaterId?: string\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation-item-query.js","sourceRoot":"","sources":["../../../server/service/quotation/quotation-item-query.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,iDAA6D;AAC7D,+CAA4D;AAE5D,qDAAgD;AAGzC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAG7B,MAAM,CAAS,GAAkB;QAC/B,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,qBAAa,EAAC,cAAM,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACzG,CAAC;IAGD,OAAO,CAAS,GAAkB;QAChC,OAAO,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAC1G,CAAC;IAGD,OAAO,CAAS,GAAkB;QAChC,OAAO,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAC1G,CAAC;CACF,CAAA;AAhBY,gDAAkB;AAG7B;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1C,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,8BAAa;;gDAEhC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,8BAAa;;iDAEjC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,8BAAa;;iDAEjC;6BAfU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,kBAAkB,CAgB9B","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { FieldResolver, Resolver, Root } from 'type-graphql'\n\nimport { QuotationItem } from './quotation-item'\n\n@Resolver(QuotationItem)\nexport class QuotationItemQuery {\n\n @FieldResolver(type => Domain, { nullable: true })\n domain(@Root() row: QuotationItem) {\n return row.domain ?? (row.domainId ? getRepository(Domain).findOneBy({ id: row.domainId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n creator(@Root() row: QuotationItem) {\n return row.creator ?? (row.creatorId ? getRepository(User).findOneBy({ id: row.creatorId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n updater(@Root() row: QuotationItem) {\n return row.updater ?? (row.updaterId ? getRepository(User).findOneBy({ id: row.updaterId }) : undefined)\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation-item.js","sourceRoot":"","sources":["../../../server/service/quotation/quotation-item.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,qDAAwD;AACxD,iDAA8C;AAC9C,+CAAoD;AACpD,qCAA4I;AAE5I,2CAAuC;AAKhC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,wBAAc;CA4ChD,CAAA;AA5CY,sCAAa;AAGf;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;yCACC;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,CAAC;sCACjC,cAAM;6CAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,IAAmB,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;;+CAChC;AAGjB;IADC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,qBAAS,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;sCAC1F,qBAAS;gDAAA;AAIpB;IAFC,IAAA,oBAAU,EAAC,CAAC,IAAmB,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;IACnD,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,mCAAmC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,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtF,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oDAAoD,EAAE,CAAC;GACrE,aAAa,CA4CzB","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { CommercialLine } from '@things-factory/invoice'\nimport { Domain } from '@things-factory/shell'\nimport { Field, ID, ObjectType } from 'type-graphql'\nimport { CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\n\nimport { Quotation } from './quotation'\n\n@Entity()\n@Index('ix_quotation_item_0', (item: QuotationItem) => [item.quotation, item.position])\n@ObjectType({ description: 'Entity for QuotationItem — one line of a quotation' })\nexport class QuotationItem extends CommercialLine {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true })\n domain?: Domain\n\n @RelationId((item: QuotationItem) => item.domain)\n domainId?: string\n\n @ManyToOne(type => Quotation, quotation => quotation.items, { nullable: false, onDelete: 'CASCADE' })\n quotation: Quotation\n\n @RelationId((item: QuotationItem) => item.quotation)\n @Field({ description: 'The quotation the line belongs to' })\n quotationId: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When the line was written' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When the line last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When the line was removed' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((item: QuotationItem) => item.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((item: QuotationItem) => item.updater)\n updaterId?: string\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation-mutation.js","sourceRoot":"","sources":["../../../server/service/quotation/quotation-mutation.ts"],"names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S,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,gFAAgF,CAAC;IAC3F,IAAA,uBAAQ,EAAC,IAAI,CAAC,EAAE,CAAC,qBAAS,EAAE,EAAE,WAAW,EAAE,mEAAmE,EAAE,CAAC;IACjG,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wDAG5C;4BAvDU,iBAAiB;IAF7B,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,iBAAiB,CAwD7B","sourcesContent":["import { SpeakRefusals } from '@things-factory/shell'\nimport { Arg, Ctx, Directive, Mutation, Resolver, UseMiddleware } from 'type-graphql'\n\nimport { Quotation } from './quotation'\nimport { reviseQuotation, saveQuotation, transitionQuotation } from './quotation-service'\nimport { NewQuotation } from './quotation-type'\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(Quotation)\nexport class QuotationMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Quotation, { description: 'To create a quotation draft' })\n createQuotation(@Arg('quotation') quotation: NewQuotation, @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return saveQuotation(tx, domain, user, quotation)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Quotation, { description: 'To replace the head and lines of a quotation draft' })\n updateQuotation(@Arg('id') id: string, @Arg('quotation') quotation: NewQuotation, @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return saveQuotation(tx, domain, user, quotation, id)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Quotation, { description: 'To send a quotation draft; its amounts are fixed from then on' })\n sendQuotation(@Arg('id') id: string, @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return transitionQuotation(tx, domain, user, id, 'SENT')\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Quotation, { description: 'To record that the buyer accepted a sent quotation' })\n acceptQuotation(@Arg('id') id: string, @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return transitionQuotation(tx, domain, user, id, 'ACCEPTED')\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Quotation, { description: 'To record that the buyer declined a sent quotation, with the reason' })\n rejectQuotation(@Arg('id') id: string, @Arg('reason') reason: string, @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return transitionQuotation(tx, domain, user, id, 'REJECTED', reason)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Quotation, { description: 'To close a sent quotation whose last day has passed' })\n expireQuotation(@Arg('id') id: string, @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return transitionQuotation(tx, domain, user, id, 'EXPIRED')\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Quotation, { description: 'To start the next version of a sent quotation, keeping its number' })\n reviseQuotation(@Arg('id') id: string, @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return reviseQuotation(tx, domain, user, id)\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation-query.js","sourceRoot":"","sources":["../../../server/service/quotation/quotation-query.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,qDAAwJ;AACxJ,iDAAsI;AACtI,+CAAoH;AAEpH,4DAAwD;AACxD,2CAAuC;AACvC,uDAAkD;AAClD,qDAAgD;AAChD,2DAAqG;AACrG,qDAAgD;AAIzC,IAAM,cAAc,GAApB,MAAM,cAAc;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,IAAI,CAAC,EAAE,CAAC,oBAAK,EAAE,EAAE,WAAW,EAAE,6DAA6D,EAAE,CAAC;IACrF,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;sDAElD;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,yBAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1C,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,qBAAS;;iDAEjC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1C,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,qBAAS;;4CAE5B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,qBAAS;;6CAE7B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,qBAAS;;6CAE7B;yBA7FU,cAAc;IAF1B,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,cAAc,CA8F1B","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { DocumentFile, DocumentFileFormat, documentFileOf, DocumentTaxGroup, lineSupplyOf, printTranslator, taxGroupsOf } from '@things-factory/invoice'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam, ListValueCount, SpeakRefusals } from '@things-factory/shell'\nimport { Arg, Args, Ctx, Directive, FieldResolver, Float, Query, Resolver, Root, UseMiddleware } from 'type-graphql'\n\nimport { Opportunity } from '../opportunity/opportunity'\nimport { Quotation } from './quotation'\nimport { QuotationEvent } from './quotation-event'\nimport { QuotationItem } from './quotation-item'\nimport { QUOTATION_SEARCHABLES, quotationInDomain, quotationStatusCounts } from './quotation-service'\nimport { QuotationList } from './quotation-type'\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(Quotation)\nexport class QuotationQuery {\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => Quotation, { nullable: true, description: 'To fetch a quotation' })\n quotation(@Arg('id') id: string, @Ctx() context: ResolverContext) {\n return getRepository(Quotation).findOne({ where: { id, domain: { id: context.state.domain.id } } })\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => QuotationList, { description: 'To fetch a page of quotations' })\n async quotations(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<QuotationList> {\n const query = getQueryBuilderFromListParams({\n domain: context.state.domain,\n params,\n repository: getRepository(Quotation),\n searchables: QUOTATION_SEARCHABLES\n })\n const [items, total] = await query.getManyAndCount()\n return { items, total }\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [ListValueCount], { description: 'To count the quotations in each status, under the list conditions other than the status, every status in order' })\n quotationStatusCounts(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext) {\n return quotationStatusCounts(getRepository(Quotation).manager, context.state.domain, params)\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [Quotation], { description: 'To fetch every version of a quotation number, oldest first' })\n quotationVersions(@Arg('number') number: string, @Ctx() context: ResolverContext) {\n return getRepository(Quotation).find({ where: { domain: { id: context.state.domain.id }, number }, order: { version: 'ASC' } })\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [QuotationEvent], { description: 'To fetch what happened to a quotation, oldest first' })\n quotationEvents(@Arg('quotationId') quotationId: string, @Ctx() context: ResolverContext) {\n return getRepository(QuotationEvent).find({ where: { domain: { id: context.state.domain.id }, quotation: { id: quotationId } }, order: { createdAt: 'ASC' } })\n }\n\n /* The quotation as its buyer reads it (ADR-0170 decision 10) - the page to preview and print, or the PDF to download. */\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => DocumentFile, { description: 'Prints a quotation as an HTML page or a PDF, in Korean or English - its own language when none is named' })\n async quotationDocumentFile(\n @Arg('id') id: string,\n @Arg('format', type => DocumentFileFormat, { description: 'An HTML page or a PDF' }) format: DocumentFileFormat,\n @Arg('language', { nullable: true, description: 'The language of the print, ko or en - the quotation\\'s own when empty' }) language: string,\n @Ctx() context: ResolverContext\n ): Promise<DocumentFile> {\n const quotation = await quotationInDomain(getRepository(Quotation).manager, context.state.domain, id)\n const print = printTranslator(context, language || quotation.language)\n return documentFileOf(quotation, format, {\n ...print,\n title: print.t('title.quotation-print'),\n numberLabel: 'field.quotation-number',\n terms: [\n { label: print.t('field.quotation-version'), value: `v${quotation.version}` },\n { label: print.t('field.quotation-valid-until'), value: quotation.validUntil }\n ]\n })\n }\n\n @FieldResolver(type => [QuotationItem])\n async items(@Root() quotation: Quotation) {\n return quotation.items ?? getRepository(QuotationItem).find({ where: { quotation: { id: quotation.id } }, order: { position: 'ASC' } })\n }\n\n @FieldResolver(type => [DocumentTaxGroup])\n async taxGroups(@Root() quotation: Quotation) {\n return taxGroupsOf({ ...quotation, items: await this.items(quotation) })\n }\n\n @FieldResolver(type => Float, { description: \"The lines' supply before the discount of the whole document\" })\n async lineSupplyAmount(@Root() quotation: Quotation) {\n return lineSupplyOf({ ...quotation, items: await this.items(quotation) })\n }\n\n @FieldResolver(type => Opportunity, { nullable: true })\n opportunity(@Root() row: Quotation) {\n return row.opportunity ?? (row.opportunityId ? getRepository(Opportunity).findOneBy({ id: row.opportunityId }) : undefined)\n }\n\n @FieldResolver(type => Domain, { nullable: true })\n domain(@Root() row: Quotation) {\n return row.domain ?? (row.domainId ? getRepository(Domain).findOneBy({ id: row.domainId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n creator(@Root() row: Quotation) {\n return row.creator ?? (row.creatorId ? getRepository(User).findOneBy({ id: row.creatorId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n updater(@Root() row: Quotation) {\n return row.updater ?? (row.updaterId ? getRepository(User).findOneBy({ id: row.updaterId }) : undefined)\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation-rules.js","sourceRoot":"","sources":["../../../server/service/quotation/quotation-rules.ts"],"names":[],"mappings":";;AAKA,kDAMC;AAGD,8BAEC;AAhBD,2CAA6C;AAI7C,8GAA8G;AAC9G,SAAgB,mBAAmB,CAAC,MAAc,EAAE,MAAuB,EAAE,UAAkB,EAAE,KAAa;IAC5G,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,2BAAe,CAAC,KAAK,IAAI,UAAU,IAAI,KAAK;QAAE,OAAO,2BAAe,CAAC,IAAI,CAAA;IAC7G,IAAI,MAAM,KAAK,UAAU,IAAI,MAAM,KAAK,2BAAe,CAAC,IAAI,IAAI,UAAU,IAAI,KAAK;QAAE,OAAO,2BAAe,CAAC,QAAQ,CAAA;IACpH,IAAI,MAAM,KAAK,UAAU,IAAI,MAAM,KAAK,2BAAe,CAAC,IAAI;QAAE,OAAO,2BAAe,CAAC,QAAQ,CAAA;IAC7F,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,2BAAe,CAAC,IAAI,IAAI,UAAU,GAAG,KAAK;QAAE,OAAO,2BAAe,CAAC,OAAO,CAAA;IACjH,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,wEAAwE;AACxE,SAAgB,SAAS,CAAC,MAAc;IACtC,OAAO,CAAC,2BAAe,CAAC,IAAI,EAAE,2BAAe,CAAC,QAAQ,EAAE,2BAAe,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAyB,CAAC,CAAA;AACtH,CAAC","sourcesContent":["import { QuotationStatus } from './quotation'\n\nexport type QuotationAction = 'SENT' | 'ACCEPTED' | 'REJECTED' | 'EXPIRED'\n\n/** The status an action leads to from where the quotation stands on `today`, or undefined when it may not. */\nexport function quotationTransition(status: string, action: QuotationAction, validUntil: string, today: string): QuotationStatus | undefined {\n if (action === 'SENT' && status === QuotationStatus.DRAFT && validUntil >= today) return QuotationStatus.SENT\n if (action === 'ACCEPTED' && status === QuotationStatus.SENT && validUntil >= today) return QuotationStatus.ACCEPTED\n if (action === 'REJECTED' && status === QuotationStatus.SENT) return QuotationStatus.REJECTED\n if (action === 'EXPIRED' && status === QuotationStatus.SENT && validUntil < today) return QuotationStatus.EXPIRED\n return undefined\n}\n\n/** Only the latest sent version that nobody accepted may be revised. */\nexport function revisable(status: string): boolean {\n return [QuotationStatus.SENT, QuotationStatus.REJECTED, QuotationStatus.EXPIRED].includes(status as QuotationStatus)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation-service.js","sourceRoot":"","sources":["../../../server/service/quotation/quotation-service.ts"],"names":[],"mappings":";;;AAYA,8CAKC;AAED,sCA6BC;AAED,kDAmBC;AAGD,0CA2BC;AAOD,gCAgBC;AAGD,0DAGC;AAMD,sDAGC;AAzID,qDAAsJ;AACtJ,iDAAgH;AAGhH,4DAAwD;AACxD,gDAAiD;AACjD,2CAAwD;AACxD,uDAAkD;AAClD,qDAAgD;AAChD,uDAAmF;AAG5E,KAAK,UAAU,iBAAiB,CAAC,EAAiB,EAAE,MAAc,EAAE,EAAU;IACnF,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,qBAAS,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC,CAAA;IAC1I,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,e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E,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;AAChJ,CAAC;AAED,gFAAgF;AACnE,QAAA,qBAAqB,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AAErF,uHAAuH;AAChH,KAAK,UAAU,qBAAqB,CAAC,EAAiB,EAAE,MAAc,EAAE,MAAiB;IAC9F,MAAM,OAAO,GAAG,MAAM,IAAA,wBAAgB,EAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,aAAa,CAAC,qBAAS,CAAC,EAAE,WAAW,EAAE,6BAAqB,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;IACxJ,OAAO,MAAM,CAAC,MAAM,CAAC,2BAAe,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;AACjG,CAAC","sourcesContent":["import { calculateDocument, currencyDigits, HEADER_KEYS, lockDocumentDomain, normalizedHeader, TAX_ROUNDING, validDay } from '@things-factory/invoice'\nimport { calendarDay, countListByField, Domain, getRepository, ListParam, Refusal } from '@things-factory/shell'\nimport { EntityManager } from 'typeorm'\n\nimport { Opportunity } from '../opportunity/opportunity'\nimport { recordSalesEvent } from '../sales-event'\nimport { Quotation, QuotationStatus } from './quotation'\nimport { QuotationEvent } from './quotation-event'\nimport { QuotationItem } from './quotation-item'\nimport { QuotationAction, quotationTransition, revisable } from './quotation-rules'\nimport { NewQuotation } from './quotation-type'\n\nexport async function quotationInDomain(tx: EntityManager, domain: Domain, id: string) {\n const quotation = await tx.getRepository(Quotation).findOne({ where: { id, domain: { id: domain.id } }, relations: ['items', 'creator'] })\n if (!quotation) throw new Refusal('quotation-not-found', {}, 'Quotation not found')\n quotation.items.sort((a, b) => a.position - b.position)\n return quotation\n}\n\nexport async function saveQuotation(tx: EntityManager, domain: Domain, user: any, input: NewQuotation, id?: string) {\n await lockDocumentDomain(tx, domain)\n const old = id ? await quotationInDomain(tx, domain, id) : undefined\n if (old && old.status !== QuotationStatus.DRAFT) throw new Refusal('quotation-draft-required', {}, 'Revise a sent quotation to change it')\n\n const header = normalizedHeader(input)\n if (!validDay(input.validUntil)) throw new Refusal('quotation-valid-until', {}, 'A valid last day is required')\n /* A revision answers the quotation it revises: it keeps the number. */\n if (old && old.version > 1 && header.number !== old.number) throw new Refusal('quotation-revision-number', {}, 'A revision keeps its quotation number')\n\n const repository = tx.getRepository(Quotation)\n const version = old?.version ?? 1\n const duplicate = await repository.findOne({ where: { domain: { id: domain.id }, number: header.number, version } })\n if (duplicate && duplicate.id !== id) throw new Refusal('quotation-number-duplicate', {}, 'Quotation number already exists')\n\n const opportunity = input.opportunityId ? await tx.getRepository(Opportunity).findOne({ where: { id: input.opportunityId, domain: { id: domain.id } } }) : null\n if (input.opportunityId && !opportunity) throw new Refusal('quotation-opportunity-invalid', {}, 'Choose an opportunity of this domain')\n\n const { items, discountAmount, supplyAmount, taxAmount, totalAmount } = calculateDocument(input.items, header.currency, false, input.discountAmount)\n const quotation = await repository.save(\n repository.create({ ...old, ...header, version, validUntil: input.validUntil, opportunity, discountAmount, supplyAmount, taxAmount, totalAmount, domain, creator: old?.creator ?? user, updater: user, items: undefined })\n )\n const lines = tx.getRepository(QuotationItem)\n if (old) await lines.softDelete({ quotation: { id: quotation.id } })\n await lines.save(items.map(({ receivedTaxAmount, ...item }) => lines.create({ ...item, quotation, domain, creator: user, updater: user })))\n\n const saved = await quotationInDomain(tx, domain, quotation.id)\n await recordQuotationEvent(tx, domain, user, saved, old ? 'UPDATED' : 'CREATED')\n return saved\n}\n\nexport async function transitionQuotation(tx: EntityManager, domain: Domain, user: any, id: string, action: QuotationAction, reason?: string) {\n await lockDocumentDomain(tx, domain)\n const quotation = await quotationInDomain(tx, domain, id)\n const next = quotationTransition(quotation.status, action, quotation.validUntil, calendarDay(domain.timezone))\n if (!next) throw new Refusal('quotation-transition-invalid', {}, 'The quotation status or validity does not allow this')\n if (next === QuotationStatus.REJECTED && !reason?.trim()) throw new Refusal('quotation-reason-required', {}, 'Say why the buyer declined')\n if (next === QuotationStatus.SENT) {\n if (!quotation.issueDate) throw new Refusal('quotation-issue-date-required', {}, 'A quotation is sent with its issue date')\n /* What the amounts were reckoned with stays on the quotation; a later rule never recomputes them. */\n quotation.taxRounding = TAX_ROUNDING\n quotation.currencyDigits = currencyDigits(quotation.currency)\n }\n quotation.status = next\n if (next === QuotationStatus.REJECTED) quotation.outcomeReason = reason!.trim()\n quotation.updater = user\n const { items, ...head } = quotation\n await tx.getRepository(Quotation).save(head)\n await recordQuotationEvent(tx, domain, user, quotation, action, reason)\n return quotationInDomain(tx, domain, id)\n}\n\n/** A new draft version of a sent quotation, with the same number; the version it replaces is superseded. */\nexport async function reviseQuotation(tx: EntityManager, domain: Domain, user: any, id: string) {\n await lockDocumentDomain(tx, domain)\n const old = await quotationInDomain(tx, domain, id)\n if (!revisable(old.status)) throw new Refusal('quotation-revision-invalid', {}, 'Only a sent quotation nobody accepted can be revised')\n const versions = await tx.getRepository(Quotation).find({ where: { domain: { id: domain.id }, number: old.number } })\n if (old.version !== Math.max(...versions.map(one => one.version))) throw new Refusal('quotation-latest-required', {}, 'Revise the latest version')\n\n const repository = tx.getRepository(Quotation)\n const { id: _id, items, createdAt, updatedAt, creator, updater, status, taxRounding, currencyDigits: digits, outcomeReason, opportunityId, ...document } = old\n /* A revision answers the same opportunity as the version it replaces. */\n const opportunity = opportunityId ? ({ id: opportunityId } as Opportunity) : null\n const revision = await repository.save(repository.create({ ...document, opportunity, version: old.version + 1, status: QuotationStatus.DRAFT, domain, creator: user, updater: user }))\n const lines = tx.getRepository(QuotationItem)\n await lines.save(\n items.map(({ id: _line, quotation: _parent, quotationId, createdAt, updatedAt, deletedAt, creator, updater, ...line }) =>\n lines.create({ ...line, quotation: revision, domain, creator: user, updater: user })\n )\n )\n\n old.status = QuotationStatus.SUPERSEDED\n old.updater = user\n const { items: _items, ...head } = old\n await repository.save(head)\n await recordQuotationEvent(tx, domain, user, old, 'SUPERSEDED')\n const saved = await quotationInDomain(tx, domain, revision.id)\n await recordQuotationEvent(tx, domain, user, saved, 'REVISED')\n return saved\n}\n\nfunction recordQuotationEvent(tx: EntityManager, domain: Domain, user: any, quotation: Quotation, action: string, reason?: string) {\n return recordSalesEvent(tx, QuotationEvent, { quotation }, { domain, user, action, reason, snapshot: snapshotOf(quotation) })\n}\n\n/** The quotation as printed. */\nexport function snapshotOf(quotation: Quotation) {\n const keys = ['id', ...HEADER_KEYS, 'version', 'status', 'validUntil', 'opportunityId', 'discountAmount', 'supplyAmount', 'taxAmount', 'totalAmount', 'taxRounding', 'currencyDigits', 'outcomeReason']\n return {\n ...Object.fromEntries(keys.map(key => [key, quotation[key] ?? null])),\n items: quotation.items.map(({ position, description, quantity, unit, unitPrice, discount, taxKind, taxRate, supplyAmount }) => ({\n position,\n description,\n quantity,\n unit: unit ?? null,\n unitPrice,\n discount,\n taxKind,\n taxRate,\n supplyAmount\n }))\n }\n}\n\n/** The quotations that answer an opportunity, every version, by number then version. */\nexport function quotationsOfOpportunity(tx: EntityManager | undefined, domain: Domain, opportunityId: string) {\n const repository = tx ? tx.getRepository(Quotation) : getRepository(Quotation)\n return repository.find({ where: { domain: { id: domain.id }, opportunity: { id: opportunityId } }, order: { number: 'ASC', version: 'ASC' } })\n}\n\n/** What the quotation list finds quotations by, and its status counts alike. */\nexport const QUOTATION_SEARCHABLES = ['number', 'supplierName', 'buyerName', 'notes']\n\n/** How many quotations each status chip of the list would show, under the list's other conditions, in status order. */\nexport async function quotationStatusCounts(tx: EntityManager, domain: Domain, params: ListParam) {\n const counted = await countListByField({ domain, params, repository: tx.getRepository(Quotation), searchables: QUOTATION_SEARCHABLES, field: 'status' })\n return Object.values(QuotationStatus).map(value => ({ value, count: counted.get(value) ?? 0 }))\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation-status.js","sourceRoot":"","sources":["../../../server/service/quotation/quotation-status.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAE/C,0HAA0H;AAC1H,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,gCAAa,CAAA;IACb,wCAAqB,CAAA;IACrB,wCAAqB,CAAA;IACrB,sCAAmB,CAAA;IACnB,4CAAyB,CAAA;AAC3B,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AACD,IAAA,+BAAgB,EAAC,eAAe,EAAE;IAChC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,4FAA4F;CAC1G,CAAC,CAAA","sourcesContent":["import { registerEnumType } from 'type-graphql'\n\n/* Apart from the entity, so what reads the statuses (the assistant's list read, its test) needs no type-graphql class. */\nexport enum QuotationStatus {\n DRAFT = 'DRAFT',\n SENT = 'SENT',\n ACCEPTED = 'ACCEPTED',\n REJECTED = 'REJECTED',\n EXPIRED = 'EXPIRED',\n SUPERSEDED = 'SUPERSEDED'\n}\nregisterEnumType(QuotationStatus, {\n name: 'QuotationStatus',\n description: 'state of a quotation — draft, sent, accepted, rejected, expired, or replaced by a revision'\n})\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation-type.js","sourceRoot":"","sources":["../../../server/service/quotation/quotation-type.ts"],"names":[],"mappings":";;;;AAAA,qDAAuD;AACvD,+CAAgE;AAEhE,2CAAuC;AAGhC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,uBAAa;CAG9C,CAAA;AAHY,oCAAY;AACyC;IAA/D,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;;gDAAmB;AAC4B;IAA7G,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oEAAoE,EAAE,CAAC;;mDAAuB;uBAFzH,YAAY;IADxB,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;GACxD,YAAY,CAGxB;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAa;CAGzB,CAAA;AAHY,sCAAa;AAC+C;IAAtE,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,qBAAS,CAAC,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;;4CAAmB;AACC;IAAzF,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC;;4CAAc;wBAF5F,aAAa;IADzB,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;GACvC,aAAa,CAGzB","sourcesContent":["import { DocumentInput } from '@things-factory/invoice'\nimport { Field, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Quotation } from './quotation'\n\n@InputType({ description: 'A quotation draft to create or replace' })\nexport class NewQuotation extends DocumentInput {\n @Field({ description: 'Last day the offer holds, YYYY-MM-DD' }) validUntil: string\n @Field({ nullable: true, description: 'Id of the sales opportunity the quotation answers; none when empty' }) opportunityId?: string\n}\n\n@ObjectType({ description: 'A page of quotations' })\nexport class QuotationList {\n @Field(type => [Quotation], { description: 'Quotations on the page' }) items: Quotation[]\n @Field(type => Int, { description: 'Number of quotations matching the list parameters' }) total: number\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotation.js","sourceRoot":"","sources":["../../../server/service/quotation/quotation.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,qDAA4D;AAC5D,iDAA8C;AAC9C,+CAAyD;AACzD,qCAA+J;AAE/J,4DAAwD;AACxD,qDAAgD;AAChD,yDAAoD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EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;0CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,SAAoB,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;;4CACtC;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;0CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,SAAoB,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;;4CACtC;oBAjEP,SAAS;IALrB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,SAAoB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAC3J,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,SAAoB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7G,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,SAAoB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAC5F,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,iEAAiE,EAAE,CAAC;GAClF,SAAS,CAkErB","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { CommercialDocument } from '@things-factory/invoice'\nimport { Domain } from '@things-factory/shell'\nimport { Field, ID, Int, ObjectType } from 'type-graphql'\nimport { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, OneToMany, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\n\nimport { Opportunity } from '../opportunity/opportunity'\nimport { QuotationItem } from './quotation-item'\nimport { QuotationStatus } from './quotation-status'\n\nexport { QuotationStatus }\n\n/**\n * A quotation — the same printed head and lines as an invoice, valid until a day. A sent quotation is changed by\n * revising it: the revision keeps the number and takes the next version, and the one before is superseded.\n */\n@Entity()\n@Index('ix_quotation_0', (quotation: Quotation) => [quotation.domain, quotation.number, quotation.version], { unique: true, where: '\"deleted_at\" IS NULL' })\n@Index('ix_quotation_1', (quotation: Quotation) => [quotation.domain, quotation.status, quotation.validUntil])\n@Index('ix_quotation_2', (quotation: Quotation) => [quotation.domain, quotation.opportunity])\n@ObjectType({ description: 'Entity for Quotation — a priced offer, kept with every revision' })\nexport class Quotation extends CommercialDocument {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true })\n domain?: Domain\n\n @RelationId((quotation: Quotation) => quotation.domain)\n domainId?: string\n\n @Column({ type: 'int', default: 1 })\n @Field(type => Int, { description: 'Revision of the quotation number, from 1' })\n version: number\n\n @Column({ default: QuotationStatus.DRAFT })\n @Field(type => QuotationStatus, { description: 'Draft, sent, accepted, rejected, expired or superseded' })\n status: QuotationStatus\n\n @Column()\n @Field({ description: 'Last day the offer holds, YYYY-MM-DD' })\n validUntil: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Why the buyer declined, when rejected' })\n outcomeReason?: string\n\n /* An opportunity may have several quotations; a quotation answers at most one (ADR-0138 decision 7). */\n @ManyToOne(type => Opportunity, { nullable: true })\n @Field(type => Opportunity, { nullable: true, description: 'The sales opportunity the quotation answers, when there is one' })\n opportunity?: Opportunity\n\n @RelationId((quotation: Quotation) => quotation.opportunity)\n @Field({ nullable: true, description: 'Id of the sales opportunity the quotation answers' })\n opportunityId?: string\n\n @OneToMany(type => QuotationItem, item => item.quotation)\n @Field(type => [QuotationItem], { description: 'Lines in printed order' })\n items: QuotationItem[]\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When the quotation was created' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When the quotation last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When the quotation was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((quotation: Quotation) => quotation.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((quotation: Quotation) => quotation.updater)\n updaterId?: string\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sales-event.js","sourceRoot":"","sources":["../../server/service/sales-event.ts"],"names":[],"mappings":";;AAUA,4CAGC;AAPD;;;GAGG;AACH,SAAgB,gBAAgB,CAA0B,EAAiB,EAAE,MAAuB,EAAE,OAAuB,EAAE,KAAsB;IACnJ,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IACxD,OAAO,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAoB,CAAC,CAAA;AACrJ,CAAC","sourcesContent":["import { Domain } from '@things-factory/shell'\nimport { DeepPartial, EntityManager, EntityTarget, ObjectLiteral } from 'typeorm'\n\n/** What every history row of this module carries — who, what happened, why, and the record as it then stood. */\nexport type SalesEventFacts = { domain: Domain; user: any; action: string; reason?: string; snapshot: any }\n\n/**\n * The one writer of this module's histories (ADR-0138 decision 6). A quotation's and an opportunity's events are\n * written the same way; `subject` names the record the event happened to and any fact only its history keeps.\n */\nexport function recordSalesEvent<E extends ObjectLiteral>(tx: EntityManager, target: EntityTarget<E>, subject: DeepPartial<E>, facts: SalesEventFacts) {\n const { domain, user, action, reason, snapshot } = facts\n return tx.getRepository(target).save({ ...subject, domain, actor: user, action, reason, snapshot, creator: user, updater: user } as DeepPartial<E>)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/sales-product/index.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAC9C,qEAA+D;AAC/D,+DAAyD;AAE5C,QAAA,QAAQ,GAAG,CAAC,4BAAY,CAAC,CAAA;AACzB,QAAA,SAAS,GAAG,CAAC,uCAAiB,EAAE,6CAAoB,CAAC,CAAA;AACrD,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { SalesProduct } from './sales-product'\nimport { SalesProductMutation } from './sales-product-mutation'\nimport { SalesProductQuery } from './sales-product-query'\n\nexport const entities = [SalesProduct]\nexport const resolvers = [SalesProductQuery, SalesProductMutation]\nexport const subscribers = []\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sales-product-mutation.js","sourceRoot":"","sources":["../../../server/service/sales-product/sales-product-mutation.ts"],"names":[],"mappings":";;;;AAAA,iDAAqD;AACrD,+CAAqF;AAErF,mDAA8C;AAC9C,mEAA2D;AAC3D,6DAAwD;AAIjD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAI/B,0BAA0B,CAA8C,OAA4B,EAAS,OAAwB;QACnI,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,OAAO,IAAA,yCAAiB,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;IAKK,AAAN,KAAK,CAAC,mBAAmB,CAA+B,GAAa,EAAS,OAAwB;QACpG,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,IAAA,yCAAiB,EACrB,EAAE,EACF,MAAM,EACN,IAAI,EACJ,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CACrC,CAAA;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAtBY,oDAAoB;AAI/B;IAHC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,gFAAgF,CAAC;IAC3F,IAAA,uBAAQ,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,4BAAY,CAAC,EAAE,EAAE,WAAW,EAAE,mEAAmE,EAAE,CAAC;IAC3F,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,sCAAiB,CAAC,CAAC,CAAA;IAAgC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;sEAG3G;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,gFAAgF,CAAC;IAC3F,IAAA,uBAAQ,EAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,mFAAmF,EAAE,CAAC;IACrG,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAiB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+DAS5E;+BArBU,oBAAoB;IAFhC,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,EAAC,4BAAY,CAAC;GACV,oBAAoB,CAsBhC","sourcesContent":["import { SpeakRefusals } from '@things-factory/shell'\nimport { Arg, Ctx, Directive, Mutation, Resolver, UseMiddleware } from 'type-graphql'\n\nimport { SalesProduct } from './sales-product'\nimport { saveSalesProducts } from './sales-product-service'\nimport { SalesProductPatch } from './sales-product-type'\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(SalesProduct)\nexport class SalesProductMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => [SalesProduct], { description: 'To save the product grid - new, changed and deleted rows together' })\n updateMultipleSalesProduct(@Arg('patches', type => [SalesProductPatch]) patches: SalesProductPatch[], @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n return saveSalesProducts(tx, domain, user, patches)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"sales\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(type => Boolean, { description: 'To delete sales products; quotation lines written from them keep what they copied' })\n async deleteSalesProducts(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext) {\n const { tx, domain, user } = context.state\n await saveSalesProducts(\n tx,\n domain,\n user,\n ids.map(id => ({ id, cuFlag: '-' }))\n )\n return true\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sales-product-query.js","sourceRoot":"","sources":["../../../server/service/sales-product/sales-product-query.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,iDAAsI;AACtI,+CAA6G;AAE7G,mDAA8C;AAC9C,mEAAuF;AACvF,6DAAuD;AAIhD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAG5B,YAAY,CAAY,EAAU,EAAS,OAAwB;QACjE,OAAO,IAAA,qBAAa,EAAC,4BAAY,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACxG,CAAC;IAIK,AAAN,KAAK,CAAC,aAAa,CAA0B,MAAiB,EAAS,OAAwB;QAC7F,MAAM,KAAK,GAAG,IA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AA;;6CAAM,4BAAY;;gDAEhC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,4BAAY;;gDAEhC;4BAvCU,iBAAiB;IAF7B,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,EAAC,4BAAY,CAAC;GACV,iBAAiB,CAwC7B","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam, ListValueCount, SpeakRefusals } from '@things-factory/shell'\nimport { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root, UseMiddleware } from 'type-graphql'\n\nimport { SalesProduct } from './sales-product'\nimport { PRODUCT_SEARCHABLES, salesProductActiveCounts } from './sales-product-service'\nimport { SalesProductList } from './sales-product-type'\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(SalesProduct)\nexport class SalesProductQuery {\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => SalesProduct, { nullable: true, description: 'To fetch a sales product' })\n salesProduct(@Arg('id') id: string, @Ctx() context: ResolverContext) {\n return getRepository(SalesProduct).findOne({ where: { id, domain: { id: context.state.domain.id } } })\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => SalesProductList, { description: 'To fetch a page of sales products' })\n async salesProducts(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<SalesProductList> {\n const query = getQueryBuilderFromListParams({\n domain: context.state.domain,\n params,\n repository: getRepository(SalesProduct),\n searchables: PRODUCT_SEARCHABLES\n })\n const [items, total] = await query.getManyAndCount()\n return { items, total }\n }\n\n @Directive('@privilege(category: \"sales\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [ListValueCount], { description: 'To count the products in use (active) and out of use (inactive), under the list conditions other than active' })\n salesProductActiveCounts(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext) {\n return salesProductActiveCounts(getRepository(SalesProduct).manager, context.state.domain, params)\n }\n\n @FieldResolver(type => Domain, { nullable: true })\n domain(@Root() row: SalesProduct) {\n return row.domain ?? (row.domainId ? getRepository(Domain).findOneBy({ id: row.domainId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n creator(@Root() row: SalesProduct) {\n return row.creator ?? (row.creatorId ? getRepository(User).findOneBy({ id: row.creatorId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n updater(@Root() row: SalesProduct) {\n return row.updater ?? (row.updaterId ? getRepository(User).findOneBy({ id: row.updaterId }) : undefined)\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sales-product-rules.js","sourceRoot":"","sources":["../../../server/service/sales-product/sales-product-rules.ts"],"names":[],"mappings":";;;AAoBA,wBAEC;AAtBD,+CAA+C;AAE/C,iHAAiH;AACjH,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,uCAAmB,CAAA;IACnB,mCAAe,CAAA;AACjB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B;AACD,IAAA,+BAAgB,EAAC,gBAAgB,EAAE;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,oGAAoG;CAClH,CAAC,CAAA;AAEF,yHAAyH;AAC5G,QAAA,YAAY,GAAqC;IAC5D,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,GAAG;IAC7B,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,GAAG;IAC/B,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,KAAK;CAChC,CAAA;AAED,SAAgB,MAAM,CAAC,IAA+B,EAAE,IAAoB;IAC1E,OAAO,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,oBAAY,CAAC,IAAwB,CAAC,IAAI,oBAAY,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;AACpH,CAAC","sourcesContent":["import { registerEnumType } from 'type-graphql'\n\n/* Apart from the entity, so what reads the kinds (the screens' words, the tests) needs no type-graphql class. */\nexport enum SalesProductKind {\n GOODS = 'GOODS',\n SERVICE = 'SERVICE',\n LABOR = 'LABOR'\n}\nregisterEnumType(SalesProductKind, {\n name: 'SalesProductKind',\n description: 'what a sales product is — goods, a service sold as a lot, or labor sold by the grade of the people'\n})\n\n/** The unit a product is sold in when none is written: goods by the piece, a service as one lot, labor by man-months. */\nexport const DEFAULT_UNIT: Record<SalesProductKind, string> = {\n [SalesProductKind.GOODS]: '개',\n [SalesProductKind.SERVICE]: '식',\n [SalesProductKind.LABOR]: 'M/M'\n}\n\nexport function unitOf(kind: SalesProductKind | string, unit?: string | null): string {\n return String(unit ?? '').trim() || DEFAULT_UNIT[kind as SalesProductKind] || DEFAULT_UNIT[SalesProductKind.GOODS]\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sales-product-service.js","sourceRoot":"","sources":["../../../server/service/sales-product/sales-product-service.ts"],"names":[],"mappings":";;;AAmDA,8CA6BC;AASD,4DAOC;AAhGD,qDAAwD;AACxD,iDAAoF;AACpF,qCAA2C;AAE3C,mDAA8C;AAC9C,+DAAgE;AAGhE,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAU,CAAA;AAEtD,mHAAmH;AACnH,SAAS,KAAK,CAAC,KAAwB,EAAE,GAAkB;IACzD,MAAM,GAAG,GAAwB,EAAE,CAAA;IACnC,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,GAAG,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;QAC5C,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,eAAO,CAAC,6BAA6B,EAAE,EAAE,EAAE,yBAA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,OAAO;QACL,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE;QACpC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE;KACxC,CAAA;AACH,CAAC","sourcesContent":["import { currencyDigits } from '@things-factory/invoice'\nimport { countListByField, Domain, ListParam, Refusal } from '@things-factory/shell'\nimport { EntityManager, In } from 'typeorm'\n\nimport { SalesProduct } from './sales-product'\nimport { SalesProductKind, unitOf } from './sales-product-rules'\nimport { SalesProductPatch } from './sales-product-type'\n\nconst TEXT = ['grade', 'spec', 'description'] as const\n\n/** A patch as the row it writes: words trimmed, the unit the kind's when blank, the price and currency checked. */\nfunction rowOf(patch: SalesProductPatch, old?: SalesProduct): Partial<SalesProduct> {\n const row: Record<string, any> = {}\n if (patch.code !== undefined || !old) {\n const code = String(patch.code ?? '').trim()\n if (!code) throw new Refusal('sales-product-code-required', {}, 'Give the product a code')\n row.code = code\n }\n if (patch.name !== undefined || !old) {\n const name = String(patch.name ?? '').trim()\n if (!name) throw new Refusal('sales-product-name-required', {}, 'Name the product')\n row.name = name\n }\n const kind = patch.kind ?? old?.kind ?? SalesProductKind.GOODS\n row.kind = kind\n for (const field of TEXT) if (patch[field] !== undefined) row[field] = String(patch[field] ?? '').trim() || null\n /* A blank unit is the kind's - also when the kind changes and the unit was the old kind's own. */\n if (patch.unit !== undefined || !old) row.unit = unitOf(kind, patch.unit)\n else if (patch.kind !== undefined) row.unit = old.unit === unitOf(old.kind) ? unitOf(kind) : old.unit\n if (patch.currency !== undefined || !old) {\n row.currency = (String(patch.currency ?? '').trim() || 'KRW').toUpperCase()\n currencyDigits(row.currency)\n }\n if (patch.unitPrice !== undefined || !old) {\n const price = patch.unitPrice ?? 0\n if (!Number.isFinite(price) || price < 0) throw new Refusal('sales-product-price-invalid', {}, 'The price is zero or more')\n /* A quotation line takes a price to four decimals (invoice's document-amounts) - a finer one would be refused there. */\n if (Math.abs(price * 10_000 - Math.round(price * 10_000)) > 1e-6)\n throw new Refusal('sales-product-price-decimals', { value: String(price), max: 4 }, 'unitPrice: at most four decimals')\n row.unitPrice = price\n }\n if (patch.taxKind !== undefined || !old) row.taxKind = patch.taxKind ?? 'TAXABLE'\n if (patch.active !== undefined || !old) row.active = patch.active !== false\n return row\n}\n\n/**\n * Apply grid rows to a domain's products: `+` (or no id) registers, `M` changes, `-` deletes (softly). A code is the\n * domain's once among the products not deleted. Nothing names a product - a quotation line copies what it says - so a\n * product is deleted freely.\n */\nexport async function saveSalesProducts(tx: EntityManager, domain: Domain, user: any, patches: SalesProductPatch[]) {\n const repository = tx.getRepository(SalesProduct)\n const deletes = patches.filter(one => one.cuFlag === '-' && one.id).map(one => one.id!)\n const changes = patches.filter(one => one.cuFlag !== '-')\n\n if (deletes.length) {\n const owned = await repository.find({ where: { domain: { id: domain.id }, id: In(deletes) }, select: ['id'] })\n if (owned.length !== deletes.length) throw new Refusal('sales-product-not-found', {}, 'A product was not found - reload and try again')\n await repository.softDelete({ id: In(deletes) })\n }\n\n const rows: Partial<SalesProduct>[] = []\n for (const patch of changes) {\n const old = patch.id && patch.cuFlag !== '+' ? await repository.findOne({ where: { domain: { id: domain.id }, id: patch.id } }) : undefined\n if (patch.id && patch.cuFlag !== '+' && !old) throw new Refusal('sales-product-not-found', {}, 'A product was not found - reload and try again')\n rows.push({ ...(old ?? {}), ...rowOf(patch, old ?? undefined) })\n }\n\n /* One code, one product: against the rows kept and against one another in the batch. */\n const codes = rows.map(row => row.code!)\n const taken = codes.length ? await repository.find({ where: { domain: { id: domain.id }, code: In(codes) }, select: ['id', 'code'] }) : []\n for (const [index, row] of rows.entries()) {\n const clash = taken.find(one => one.code === row.code && one.id !== row.id) || rows.find((other, at) => at < index && other.code === row.code)\n if (clash) throw new Refusal('sales-product-code-duplicate', { code: row.code }, `Product code ${row.code} is already in use`)\n }\n\n const saved: SalesProduct[] = []\n for (const row of rows) saved.push(await repository.save({ ...row, domain, ...(row.id ? {} : { creator: user }), updater: user } as SalesProduct))\n return saved\n}\n\n/** What the product list finds products by, and its in-use counts alike. */\nexport const PRODUCT_SEARCHABLES = ['code', 'name', 'grade', 'spec', 'description']\n\n/**\n * How many products are in use and out of use, under the list's other conditions - the numbers beside the list's\n * `active` and `inactive` chips. The database gives a boolean as it keeps it (true or 1), read here as one.\n */\nexport async function salesProductActiveCounts(tx: EntityManager, domain: Domain, params: ListParam) {\n const counted = await countListByField({ domain, params, repository: tx.getRepository(SalesProduct), searchables: PRODUCT_SEARCHABLES, field: 'active' })\n const of = (on: boolean) => [...counted].filter(([value]) => (value === 'true' || value === '1') === on).reduce((sum, [, count]) => sum + count, 0)\n return [\n { value: 'active', count: of(true) },\n { value: 'inactive', count: of(false) }\n ]\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sales-product-type.js","sourceRoot":"","sources":["../../../server/service/sales-product/sales-product-type.ts"],"names":[],"mappings":";;;;AAAA,qDAAiD;AACjD,+CAA2E;AAE3E,mDAA8C;AAC9C,+DAAwD;AAGjD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAc7B,CAAA;AAdY,8CAAiB;AAC4D;IAAvF,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;;6CAAY;AACjB;IAAjF,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;;iDAAgB;AACZ;IAApF,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;;+CAAc;AAC5B;IAArE,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;;+CAAc;AAC8B;IAAhH,IAAA,oBAAK,EAAC,IAAI,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AI,CAAC,EAAE,CAAC,CAAC,4BAAY,CAAC,EAAE,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;;+CAAsB;AACL;IAAvF,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;;+CAAc;2BAF1F,gBAAgB;IAD5B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;GAC3C,gBAAgB,CAG5B","sourcesContent":["import { TaxKind } from '@things-factory/invoice'\nimport { Field, Float, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { SalesProduct } from './sales-product'\nimport { SalesProductKind } from './sales-product-rules'\n\n@InputType({ description: 'A row of the product grid (cuFlag + for new, M for changed, - for deleted)' })\nexport class SalesProductPatch {\n @Field(type => ID, { nullable: true, description: 'The product; empty for a new one' }) id?: string\n @Field({ nullable: true, description: 'Grid flag: + new, M changed, - deleted' }) cuFlag?: string\n @Field({ nullable: true, description: 'Code of the product, unique in the domain' }) code?: string\n @Field({ nullable: true, description: 'What the product is called' }) name?: string\n @Field(type => SalesProductKind, { nullable: true, description: 'Goods, a service or labor; goods when empty' }) kind?: SalesProductKind\n @Field({ nullable: true, description: 'Grade of the people, for labor' }) grade?: string\n @Field({ nullable: true, description: 'Specification' }) spec?: string\n @Field({ nullable: true, description: 'Unit it is sold in; the kind gives it when empty' }) unit?: string\n @Field(type => Float, { nullable: true, description: 'Price of one unit, before tax' }) unitPrice?: number\n @Field({ nullable: true, description: 'ISO 4217 currency code, KRW when empty' }) currency?: string\n @Field(type => TaxKind, { nullable: true, description: 'Taxable, zero-rated or exempt; taxable when empty' }) taxKind?: TaxKind\n @Field({ nullable: true, description: 'Whether it is still offered for new quotation lines' }) active?: boolean\n @Field({ nullable: true, description: 'Notes' }) description?: string\n}\n\n@ObjectType({ description: 'A page of sales products' })\nexport class SalesProductList {\n @Field(type => [SalesProduct], { description: 'Products on the page' }) items: SalesProduct[]\n @Field(type => Int, { description: 'Number of products matching the list parameters' }) total: number\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sales-product.js","sourceRoot":"","sources":["../../../server/service/sales-product/sales-product.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,qDAAiD;AACjD,iDAA2D;AAC3D,+CAA2D;AAC3D,qCAAoJ;AAEpJ,+DAAwD;AAExD;;;;GAIG;AAII,IAAM,YAAY,GAAlB,MAAM,YAAY;CAiFxB,CAAA;AAjFY,oCAAY;AAGd;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;wCACC;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,CAAC;sCACjC,cAAM;4CAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,OAAqB,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;;8CACrC;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;;0CACxD;AAIZ;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,2DAA2D,EAAE,CAAC;;0CACxE;AAIZ;IAFC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,sCAAgB,CAAC,KAAK,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,sCAAgB,EAAE,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;;0CACxD;AAItB;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,oBAAK,EAAC,EAAE,QAAQ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,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACvI,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,qEAAqE,EAAE,CAAC;GACtF,YAAY,CAiFxB","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { TaxKind } from '@things-factory/invoice'\nimport { Domain, moneyColumn } from '@things-factory/shell'\nimport { Field, Float, ID, ObjectType } from 'type-graphql'\nimport { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\n\nimport { SalesProductKind } from './sales-product-rules'\n\n/**\n * A product the domain sells - goods, a service, or the labor of people of a grade - with the price it is offered at\n * (ADR-0171). A quotation line chosen from it copies its name, unit, price and taxation at that moment; the line is the\n * quotation's from then on, and a later price here never changes a written quotation.\n */\n@Entity()\n@Index('ix_sales_product_0', (product: SalesProduct) => [product.domain, product.code], { unique: true, where: '\"deleted_at\" IS NULL' })\n@ObjectType({ description: 'Entity for SalesProduct — a product the domain sells, and its price' })\nexport class SalesProduct {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true })\n domain?: Domain\n\n @RelationId((product: SalesProduct) => product.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'Code of the product, unique in the domain' })\n code: string\n\n @Column()\n @Field({ description: 'What the product is called, as a quotation line prints it' })\n name: string\n\n @Column({ default: SalesProductKind.GOODS })\n @Field(type => SalesProductKind, { description: 'Goods, a service or labor' })\n kind: SalesProductKind\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Grade of the people, for labor - a senior or a junior engineer' })\n grade?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Specification, printed after the name' })\n spec?: string\n\n @Column()\n @Field({ description: 'Unit it is sold in - pieces for goods, a lot for a service, man-months for labor unless written' })\n unit: string\n\n @Column({ ...moneyColumn({ scale: 4 }), default: 0 })\n @Field(type => Float, { description: 'Price of one unit, before tax' })\n unitPrice: number\n\n @Column({ default: 'KRW' })\n @Field({ description: 'ISO 4217 currency code of the price' })\n currency: string\n\n @Column({ default: TaxKind.TAXABLE })\n @Field(type => TaxKind, { description: 'Taxable, zero-rated or exempt' })\n taxKind: TaxKind\n\n @Column({ default: true })\n @Field({ description: 'Whether it is still offered for new quotation lines' })\n active: boolean\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Notes' })\n description?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When the product was registered' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When the product last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When the product was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((product: SalesProduct) => product.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((product: SalesProduct) => product.updater)\n updaterId?: string\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sales-read.js","sourceRoot":"","sources":["../../server/service/sales-read.ts"],"names":[],"mappings":";;;AA0EA,gDAEC;AA5ED,+DAAgG;AAEhG,uEAAkE;AAClE,mEAA8D;AAE9D;;;;;GAKG;AACU,QAAA,qBAAqB,GAAa;IAC7C,GAAG,EAAE,mBAAmB;IACxB,KAAK,EAAE,wBAAwB;IAC/B,IAAI,EAAE,6BAA6B;IACnC,SAAS,EAAE,eAAe;IAC1B,SAAS,EACP,iKAAiK;IACnK,OAAO,EAAE;QACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,wBAAwB,EAAE;QACpE,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,EAAE,IA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E,IAAI,EAAE,QAAQ,EAAE;QACzC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE;KAClC;IACD,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,kCAAe,CAAC,EAAE;IACnE,MAAM,EAAE,+CAA+C;IACvD,KAAK,EAAE,gBAAgB;CACxB,CAAA;AAED,gHAAgH;AACnG,QAAA,kBAAkB,GAAG,CAAC,6BAAqB,CAAC,GAAG,EAAE,2BAAmB,CAAC,GAAG,CAAC,CAAA;AAEtF,sGAAsG;AACtG,SAAgB,kBAAkB;IAChC,KAAK,MAAM,IAAI,IAAI,CAAC,6BAAqB,EAAE,2BAAmB,CAAC;QAAE,IAAA,iCAAkB,EAAC,IAAA,6BAAc,EAAC,IAAI,CAAC,CAAC,CAAA;AAC3G,CAAC","sourcesContent":["import { listReadTarget, registerReadTarget, type ListRead } from '@things-factory/ai-assistant'\n\nimport { OpportunityStage } from './opportunity/opportunity-rules'\nimport { QuotationStatus } from './quotation/quotation-status'\n\n/*\n * 영업 기회 and 견적 as the assistant reads them (design/ai/read-targets.md §3) - each list screen's own query, as the\n * person: what the sales door lets them see, they read with the assistant. The rows a person picks on a list\n * (「AI와 작업」) go as `opportunity:<uuid>` and `quotation:<uuid>` - each key's last part - and are read here by their\n * ids. The search words are the resolvers' searchables, field for field; a test holds them equal.\n */\nexport const OPPORTUNITY_LIST_READ: ListRead = {\n key: 'sales.opportunity',\n title: 'title.opportunity-list',\n name: 'Sales opportunities (영업 기회)',\n listQuery: 'opportunities',\n selection:\n 'id name stage probability amount currency expectedCloseMonth closedOn lostReason description counterparty { id name } endCustomer { id name } owner { id name }',\n columns: [\n { name: 'name', type: 'string', labelKey: 'field.opportunity-name' },\n { name: 'counterparty', path: 'counterparty.name', type: 'string', labelKey: 'field.opportunity-counterparty' },\n { name: 'endCustomer', path: 'endCustomer.name', type: 'string', labelKey: 'field.opportunity-end-customer' },\n { name: 'stage', type: 'string', labelKey: 'field.opportunity-stage' },\n { name: 'probability', type: 'number', labelKey: 'field.opportunity-probability' },\n { name: 'currency', type: 'string' },\n { name: 'amount', type: 'number', total: true, currency: 'currency', labelKey: 'field.opportunity-amount' },\n { name: 'expectedCloseMonth', type: 'string', labelKey: 'field.opportunity-expected-close-month' },\n { name: 'closedOn', type: 'date' },\n { name: 'lostReason', type: 'string' },\n { name: 'owner', path: 'owner.name', type: 'string', labelKey: 'field.opportunity-owner' },\n { name: 'description', type: 'string' }\n ],\n monthField: 'expectedCloseMonth',\n status: { field: 'stage', values: Object.values(OpportunityStage) },\n search: 'fields name, description',\n route: 'opportunity-list'\n}\n\nexport const QUOTATION_LIST_READ: ListRead = {\n key: 'sales.quotation',\n title: 'title.quotation-list',\n name: 'Quotations (견적) - every version of every number',\n listQuery: 'quotations',\n selection:\n 'id number version status direction currency supplierName buyerName issueDate validUntil purchaseOrder paymentTerms notes outcomeReason opportunityId supplyAmount taxAmount totalAmount',\n columns: [\n { name: 'number', type: 'string', labelKey: 'field.quotation-number' },\n { name: 'version', type: 'number', labelKey: 'field.quotation-version' },\n { name: 'status', type: 'string', labelKey: 'field.quotation-status' },\n { name: 'direction', type: 'string' },\n { name: 'supplierName', type: 'string' },\n { name: 'buyerName', type: 'string' },\n { name: 'issueDate', type: 'date', labelKey: 'field.quotation-issue-date' },\n { name: 'validUntil', type: 'date', labelKey: 'field.quotation-valid-until' },\n { name: 'opportunityId', type: 'string' },\n { name: 'currency', type: 'string' },\n { name: 'supplyAmount', type: 'number', total: true, currency: 'currency' },\n { name: 'taxAmount', type: 'number', total: true, currency: 'currency' },\n { name: 'totalAmount', type: 'number', total: true, currency: 'currency', labelKey: 'field.quotation-total-amount' },\n { name: 'purchaseOrder', type: 'string' },\n { name: 'paymentTerms', type: 'string' },\n { name: 'outcomeReason', type: 'string' },\n { name: 'notes', type: 'string' }\n ],\n dateField: 'issueDate',\n status: { field: 'status', values: Object.values(QuotationStatus) },\n search: 'fields number, supplierName, buyerName, notes',\n route: 'quotation-list'\n}\n\n/** The keys an application's assistant mode names in its `readTargets` to read opportunities and quotations. */\nexport const SALES_READ_TARGETS = [OPPORTUNITY_LIST_READ.key, QUOTATION_LIST_READ.key]\n\n/** At boot: the assistant may read the opportunity and quotation lists, in a mode that names them. */\nexport function registerSalesReads(): void {\n for (const list of [OPPORTUNITY_LIST_READ, QUOTATION_LIST_READ]) registerReadTarget(listReadTarget(list))\n}\n"]}