@things-factory/biz-base 10.1.241 → 10.1.244

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.
@@ -1 +1 @@
1
- {"version":3,"file":"counterparty.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty.ts"],"names":[],"mappings":";;;;AAAA,+CAAiF;AACjF,qCAAoJ;AAEpJ,yDAAgD;AAChD,iDAA8C;AAE9C,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,qCAAiB,CAAA;AACnB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAA,+BAAgB,EAAC,gBAAgB,EAAE;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,iDAAiD;CAC/D,CAAC,CAAA;AAEF;;;;;;;;;;;GAWG;AACH;oDACoD;AAK7C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAkGxB,CAAA;AAlGY,oCAAY;AAGd;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;;wCACrC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;sCACvF,cAAM;4CAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,YAA0B,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;;8CAC/C;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,oEAAoE,EAAE,CAAC;;0CACjF;AAKZ;IAHC,IAAA,gBAAM,EAAC,EAAE,IAAI,E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YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACvI,IAAA,eAAK,EAAC,mBAAmB,EAAE,CAAC,YAA0B,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAC/J,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,mEAAmE,EAAE,CAAC;GACpF,YAAY,CAkGxB","sourcesContent":["import { Directive, Field, ID, ObjectType, registerEnumType } from 'type-graphql'\nimport { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\n\nexport enum CounterpartyKind {\n COMPANY = 'COMPANY',\n PERSON = 'PERSON'\n}\n\nregisterEnumType(CounterpartyKind, {\n name: 'CounterpartyKind',\n description: 'Whether a counterparty is a company or a person'\n})\n\n/**\n * A company or person a domain signs with, bills, is billed by, or pays — its own list of them.\n *\n * Each domain keeps its counterparties itself: who they are to this business, the names it calls them by, whether\n * it still deals with them. Another domain's list is not shared or seen. The people to talk to there are contacts\n * (`@things-factory/contact`), which point at the counterparty.\n *\n * For a person nothing beyond what identifies them to the business is kept — no resident registration number.\n *\n * A business registration number is one counterparty's in the domain; a name is not — two businesses may trade under\n * one name, told apart by their numbers.\n */\n/* The fields past what points at a counterparty are its keeper's: `counterparty:query`, on the declaration, nullable -\n whatever row they are reached from (ADR-0139). */\n@Entity()\n@Index('ix_counterparty_0', (counterparty: Counterparty) => [counterparty.domain, counterparty.name], { where: '\"deleted_at\" IS NULL' })\n@Index('ix_counterparty_1', (counterparty: Counterparty) => [counterparty.domain, counterparty.businessNumber], { unique: true, where: '\"deleted_at\" IS NULL' })\n@ObjectType({ description: 'Entity for Counterparty — a company or person a domain deals with' })\nexport class Counterparty {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain whose counterparty this is' })\n domain?: Domain\n\n @RelationId((counterparty: Counterparty) => counterparty.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'The name the business knows it by; two counterparties may share it' })\n name: string\n\n @Column({ type: 'text', nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Other names it appears under — in bank lines, old ledgers — one per line or comma' })\n aliases?: string\n\n @Column({ default: CounterpartyKind.COMPANY })\n @Field(type => CounterpartyKind, { description: 'A company or a person' })\n kind: CounterpartyKind\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Business registration number, 123-45-67890 - one counterparty\\'s in the domain' })\n businessNumber?: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Sub-business place number, when tax invoices go to a branch' })\n branchNumber?: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Representative' })\n representative?: string\n\n @Column({ type: 'text', nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Address' })\n address?: string\n\n @Column({ type: 'text', nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Address bills are sent to, when not the address' })\n billingAddress?: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Business type (업태)' })\n businessType?: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Business item (종목)' })\n businessItem?: string\n\n @Column({ default: false })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Whether its sales to it are zero-rated for VAT' })\n zeroRated: boolean\n\n @Column({ type: 'text', nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n\n @Column({ default: true })\n @Field({ description: 'An inactive counterparty stays on old rows but is not offered for new ones' })\n active: boolean\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When it was registered' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When it last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When it was deleted — the rows that name it are kept' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who registered it' })\n creator?: User\n\n @RelationId((counterparty: Counterparty) => counterparty.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed it' })\n updater?: User\n\n @RelationId((counterparty: Counterparty) => counterparty.updater)\n updaterId?: string\n}\n"]}
1
+ {"version":3,"file":"counterparty.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty.ts"],"names":[],"mappings":";;;;AAAA,+CAAiF;AACjF,qCAAoJ;AAEpJ,yDAAgD;AAChD,iDAA8C;AAE9C;;;;;GAKG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,+CAA2B,CAAA;IAC3B,qCAAiB,CAAA;IACjB,iCAAa,CAAA;AACf,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B;AAED,IAAA,+BAAgB,EAAC,gBAAgB,EAAE;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,mFAAmF;CACjG,CAAC,CAAA;AAEF;;;;;;;;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Field, ID, ObjectType, registerEnumType } from 'type-graphql'\nimport { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\n\n/**\n * Who a counterparty is (ADR-0132 §0-2). `COMPANY` is any business with a registration number - a corporation, a\n * sole proprietor, an association; `INSTITUTION` a state body or public institution (a tax office, a public\n * corporation); `PERSON` someone who is not a business; `SELF` the domain's own company, at most one - the other side\n * of money moved between its own accounts. Where a counterparty is from is `country`, not a kind.\n */\nexport enum CounterpartyKind {\n COMPANY = 'COMPANY',\n INSTITUTION = 'INSTITUTION',\n PERSON = 'PERSON',\n SELF = 'SELF'\n}\n\nregisterEnumType(CounterpartyKind, {\n name: 'CounterpartyKind',\n description: 'A business, a state or public institution, a person, or the domain\\'s own company'\n})\n\n/**\n * A company or person a domain signs with, bills, is billed by, or pays — its own list of them.\n *\n * Each domain keeps its counterparties itself: who they are to this business, the names it calls them by, whether\n * it still deals with them. Another domain's list is not shared or seen. The people to talk to there are contacts\n * (`@things-factory/contact`), which point at the counterparty.\n *\n * For a person nothing beyond what identifies them to the business is kept — no resident registration number.\n *\n * A business registration number is one counterparty's in the domain; a name is not — two businesses may trade under\n * one name, told apart by their numbers.\n */\n/* The fields past what points at a counterparty are its keeper's: `counterparty:query`, on the declaration, nullable -\n whatever row they are reached from (ADR-0139). */\n@Entity()\n@Index('ix_counterparty_0', (counterparty: Counterparty) => [counterparty.domain, counterparty.name], { where: '\"deleted_at\" IS NULL' })\n@Index('ix_counterparty_1', (counterparty: Counterparty) => [counterparty.domain, counterparty.businessNumber], { unique: true, where: '\"deleted_at\" IS NULL' })\n@ObjectType({ description: 'Entity for Counterparty — a company or person a domain deals with' })\nexport class Counterparty {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain whose counterparty this is' })\n domain?: Domain\n\n @RelationId((counterparty: Counterparty) => counterparty.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'The name the business knows it by; two counterparties may share it' })\n name: string\n\n @Column({ type: 'text', nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Other names it appears under — in bank lines, old ledgers — one per line or comma' })\n aliases?: string\n\n @Column({ default: CounterpartyKind.COMPANY })\n @Field(type => CounterpartyKind, { description: 'A business, an institution, a person, or our own company' })\n kind: CounterpartyKind\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Country, ISO 3166-1 alpha-2 (US, JP); empty for one at home' })\n country?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Business registration number, 123-45-67890 - one counterparty\\'s in the domain' })\n businessNumber?: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Sub-business place number, when tax invoices go to a branch' })\n branchNumber?: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Representative' })\n representative?: string\n\n @Column({ type: 'text', nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Address' })\n address?: string\n\n @Column({ type: 'text', nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Address bills are sent to, when not the address' })\n billingAddress?: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Business type (업태)' })\n businessType?: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Business item (종목)' })\n businessItem?: string\n\n @Column({ default: false })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Whether its sales to it are zero-rated for VAT' })\n zeroRated: boolean\n\n @Column({ type: 'text', nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n\n @Column({ default: true })\n @Field({ description: 'An inactive counterparty stays on old rows but is not offered for new ones' })\n active: boolean\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When it was registered' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When it last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When it was deleted — the rows that name it are kept' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who registered it' })\n creator?: User\n\n @RelationId((counterparty: Counterparty) => counterparty.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed it' })\n updater?: User\n\n @RelationId((counterparty: Counterparty) => counterparty.updater)\n updaterId?: string\n}\n"]}