@things-factory/biz-base 10.1.183 → 10.1.188

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.
@@ -4,6 +4,7 @@ import { Counterparty } from './counterparty';
4
4
  import { CounterpartyBankAccount } from './counterparty-bank-account';
5
5
  export declare class CounterpartyBankAccountQuery {
6
6
  counterpartyBankAccounts(counterpartyId: string, context: ResolverContext): Promise<CounterpartyBankAccount[]>;
7
+ accountTail(account: CounterpartyBankAccount): string | undefined;
7
8
  counterparty(account: CounterpartyBankAccount): Promise<Counterparty | null>;
8
9
  passbookCopy(account: CounterpartyBankAccount): Promise<Attachment | null>;
9
10
  creator(account: CounterpartyBankAccount): Promise<User | null>;
@@ -9,6 +9,7 @@ const shell_1 = require("@things-factory/shell");
9
9
  const counterparty_1 = require("./counterparty");
10
10
  const counterparty_bank_account_1 = require("./counterparty-bank-account");
11
11
  const counterparty_bank_account_service_1 = require("./counterparty-bank-account-service");
12
+ const counterparty_choice_1 = require("./counterparty-choice");
12
13
  /** The one file a record keeps under a refType, or null. */
13
14
  async function documentOf(domainId, refType, refBy) {
14
15
  return await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({ where: { domain: { id: domainId }, refType, refBy }, order: { createdAt: 'DESC' } });
@@ -20,6 +21,9 @@ let CounterpartyBankAccountQuery = class CounterpartyBankAccountQuery {
20
21
  order: { createdAt: 'ASC' }
21
22
  });
22
23
  }
24
+ accountTail(account) {
25
+ return (0, counterparty_choice_1.accountTailOf)(account.accountNumber);
26
+ }
23
27
  async counterparty(account) {
24
28
  return account.counterparty ?? (account.counterpartyId ? await (0, shell_1.getRepository)(counterparty_1.Counterparty).findOneBy({ id: account.counterpartyId }) : null);
25
29
  }
@@ -43,6 +47,13 @@ tslib_1.__decorate([
43
47
  tslib_1.__metadata("design:paramtypes", [String, Object]),
44
48
  tslib_1.__metadata("design:returntype", Promise)
45
49
  ], CounterpartyBankAccountQuery.prototype, "counterpartyBankAccounts", null);
50
+ tslib_1.__decorate([
51
+ (0, type_graphql_1.FieldResolver)(type => String, { nullable: true, description: "The account number's last four digits - what one sees without the keeper's privilege" }),
52
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
53
+ tslib_1.__metadata("design:type", Function),
54
+ tslib_1.__metadata("design:paramtypes", [counterparty_bank_account_1.CounterpartyBankAccount]),
55
+ tslib_1.__metadata("design:returntype", String)
56
+ ], CounterpartyBankAccountQuery.prototype, "accountTail", null);
46
57
  tslib_1.__decorate([
47
58
  (0, type_graphql_1.FieldResolver)(type => counterparty_1.Counterparty, { nullable: true }),
48
59
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
@@ -51,6 +62,7 @@ tslib_1.__decorate([
51
62
  tslib_1.__metadata("design:returntype", Promise)
52
63
  ], CounterpartyBankAccountQuery.prototype, "counterparty", null);
53
64
  tslib_1.__decorate([
65
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
54
66
  (0, type_graphql_1.FieldResolver)(type => attachment_base_1.Attachment, { nullable: true, description: 'The passbook copy (통장사본) - it shows the account number' }),
55
67
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
56
68
  tslib_1.__metadata("design:type", Function),
@@ -85,6 +97,7 @@ let CounterpartyFilesQuery = class CounterpartyFilesQuery {
85
97
  };
86
98
  exports.CounterpartyFilesQuery = CounterpartyFilesQuery;
87
99
  tslib_1.__decorate([
100
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
88
101
  (0, type_graphql_1.FieldResolver)(type => attachment_base_1.Attachment, { nullable: true, description: 'Its business registration certificate (사업자등록증)' }),
89
102
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
90
103
  tslib_1.__metadata("design:type", Function),
@@ -92,7 +105,8 @@ tslib_1.__decorate([
92
105
  tslib_1.__metadata("design:returntype", Promise)
93
106
  ], CounterpartyFilesQuery.prototype, "businessRegistration", null);
94
107
  tslib_1.__decorate([
95
- (0, type_graphql_1.FieldResolver)(type => type_graphql_1.Int, { description: 'How many accounts it is paid into are registered' }),
108
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
109
+ (0, type_graphql_1.FieldResolver)(type => type_graphql_1.Int, { nullable: true, description: 'How many accounts it is paid into are registered' }),
96
110
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
97
111
  tslib_1.__metadata("design:type", Function),
98
112
  tslib_1.__metadata("design:paramtypes", [counterparty_1.Counterparty]),
@@ -1 +1 @@
1
- {"version":3,"file":"counterparty-bank-account-query.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty-bank-account-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA6F;AAE7F,qEAA4D;AAC5D,yDAAgD;AAChD,iDAAqD;AAErD,iDAA6C;AAC7C,2EAAqE;AACrE,2FAAuG;AAEvG,4DAA4D;AAC5D,KAAK,UAAU,UAAU,CAAC,QAA4B,EAAE,OAAe,EAAE,KAAa;IACpF,OAAO,MAAM,IAAA,qBAAa,EAAC,4BAAU,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAS,EAAE,CAAC,CAAA;AAC9I,CAAC;AAGM,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAGjC,AAAN,KAAK,CAAC,wBAAwB,CAAwB,cAAsB,EAAS,OAAwB;QAC3G,OAAO,MAAM,IAAA,qBAAa,EAAC,mDAAuB,CAAC,CAAC,IAAI,CAAC;YACvD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE;YACxF,KAAK,EAAE,EAAE,SA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E,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACjH,CAAC;CACF,CAAA;AAVY,wDAAsB;AAE3B;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;IACzF,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAe,2BAAY;;kEAE5D;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;IACxE,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAe,2BAAY;;8DAExD;iCATU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,2BAAY,CAAC;GACV,sBAAsB,CAUlC","sourcesContent":["import { Arg, Ctx, Directive, FieldResolver, Int, Query, Resolver, Root } from 'type-graphql'\n\nimport { Attachment } from '@things-factory/attachment-base'\nimport { User } from '@things-factory/auth-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { Counterparty } from './counterparty'\nimport { CounterpartyBankAccount } from './counterparty-bank-account'\nimport { BUSINESS_REGISTRATION_REF_TYPE, PASSBOOK_REF_TYPE } from './counterparty-bank-account-service'\n\n/** The one file a record keeps under a refType, or null. */\nasync function documentOf(domainId: string | undefined, refType: string, refBy: string): Promise<Attachment | null> {\n return await getRepository(Attachment).findOne({ where: { domain: { id: domainId }, refType, refBy }, order: { createdAt: 'DESC' } as any })\n}\n\n@Resolver(CounterpartyBankAccount)\nexport class CounterpartyBankAccountQuery {\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [CounterpartyBankAccount], { description: 'The accounts a counterparty of the domain is paid into' })\n async counterpartyBankAccounts(@Arg('counterpartyId') counterpartyId: string, @Ctx() context: ResolverContext): Promise<CounterpartyBankAccount[]> {\n return await getRepository(CounterpartyBankAccount).find({\n where: { domain: { id: context.state.domain.id }, counterparty: { id: counterpartyId } },\n order: { createdAt: 'ASC' }\n })\n }\n\n @FieldResolver(type => Counterparty, { nullable: true })\n async counterparty(@Root() account: CounterpartyBankAccount): Promise<Counterparty | null> {\n return account.counterparty ?? (account.counterpartyId ? await getRepository(Counterparty).findOneBy({ id: account.counterpartyId }) : null)\n }\n\n @FieldResolver(type => Attachment, { nullable: true, description: 'The passbook copy (통장사본) - it shows the account number' })\n async passbookCopy(@Root() account: CounterpartyBankAccount): Promise<Attachment | null> {\n return await documentOf(account.domainId, PASSBOOK_REF_TYPE, account.id)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() account: CounterpartyBankAccount): Promise<User | null> {\n return account.creator ?? (account.creatorId ? await getRepository(User).findOneBy({ id: account.creatorId }) : null)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() account: CounterpartyBankAccount): Promise<User | null> {\n return account.updater ?? (account.updaterId ? await getRepository(User).findOneBy({ id: account.updaterId }) : null)\n }\n}\n\n/** What a counterparty has on file: its business registration and the accounts it is paid into. */\n@Resolver(Counterparty)\nexport class CounterpartyFilesQuery {\n @FieldResolver(type => Attachment, { nullable: true, description: 'Its business registration certificate (사업자등록증)' })\n async businessRegistration(@Root() counterparty: Counterparty): Promise<Attachment | null> {\n return await documentOf(counterparty.domainId, BUSINESS_REGISTRATION_REF_TYPE, counterparty.id)\n }\n\n @FieldResolver(type => Int, { description: 'How many accounts it is paid into are registered' })\n async bankAccountCount(@Root() counterparty: Counterparty): Promise<number> {\n return await getRepository(CounterpartyBankAccount).count({ where: { counterparty: { id: counterparty.id } } })\n }\n}\n"]}
1
+ {"version":3,"file":"counterparty-bank-account-query.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty-bank-account-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA6F;AAE7F,qEAA4D;AAC5D,yDAAgD;AAChD,iDAAqD;AAErD,iDAA6C;AAC7C,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,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;IACzF,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAe,2BAAY;;kEAE5D;AAIK;IAFL,IAAA,wBAAS,EAAC,oFAAoF,CAAC;IAC/F,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;IACxF,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAe,2BAAY;;8DAExD;iCAXU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,2BAAY,CAAC;GACV,sBAAsB,CAYlC","sourcesContent":["import { Arg, Ctx, Directive, FieldResolver, Int, Query, Resolver, Root } from 'type-graphql'\n\nimport { Attachment } from '@things-factory/attachment-base'\nimport { User } from '@things-factory/auth-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { Counterparty } from './counterparty'\nimport { CounterpartyBankAccount } from './counterparty-bank-account'\nimport { BUSINESS_REGISTRATION_REF_TYPE, PASSBOOK_REF_TYPE } from './counterparty-bank-account-service'\nimport { accountTailOf } from './counterparty-choice'\n\n/** The one file a record keeps under a refType, or null. */\nasync function documentOf(domainId: string | undefined, refType: string, refBy: string): Promise<Attachment | null> {\n return await getRepository(Attachment).findOne({ where: { domain: { id: domainId }, refType, refBy }, order: { createdAt: 'DESC' } as any })\n}\n\n@Resolver(CounterpartyBankAccount)\nexport class CounterpartyBankAccountQuery {\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [CounterpartyBankAccount], { description: 'The accounts a counterparty of the domain is paid into' })\n async counterpartyBankAccounts(@Arg('counterpartyId') counterpartyId: string, @Ctx() context: ResolverContext): Promise<CounterpartyBankAccount[]> {\n return await getRepository(CounterpartyBankAccount).find({\n where: { domain: { id: context.state.domain.id }, counterparty: { id: counterpartyId } },\n order: { createdAt: 'ASC' }\n })\n }\n\n @FieldResolver(type => String, { nullable: true, description: \"The account number's last four digits - what one sees without the keeper's privilege\" })\n accountTail(@Root() account: CounterpartyBankAccount): string | undefined {\n return accountTailOf(account.accountNumber)\n }\n\n @FieldResolver(type => Counterparty, { nullable: true })\n async counterparty(@Root() account: CounterpartyBankAccount): Promise<Counterparty | null> {\n return account.counterparty ?? (account.counterpartyId ? await getRepository(Counterparty).findOneBy({ id: account.counterpartyId }) : null)\n }\n\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @FieldResolver(type => Attachment, { nullable: true, description: 'The passbook copy (통장사본) - it shows the account number' })\n async passbookCopy(@Root() account: CounterpartyBankAccount): Promise<Attachment | null> {\n return await documentOf(account.domainId, PASSBOOK_REF_TYPE, account.id)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() account: CounterpartyBankAccount): Promise<User | null> {\n return account.creator ?? (account.creatorId ? await getRepository(User).findOneBy({ id: account.creatorId }) : null)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() account: CounterpartyBankAccount): Promise<User | null> {\n return account.updater ?? (account.updaterId ? await getRepository(User).findOneBy({ id: account.updaterId }) : null)\n }\n}\n\n/** What a counterparty has on file: its business registration and the accounts it is paid into. */\n@Resolver(Counterparty)\nexport class CounterpartyFilesQuery {\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @FieldResolver(type => Attachment, { nullable: true, description: 'Its business registration certificate (사업자등록증)' })\n async businessRegistration(@Root() counterparty: Counterparty): Promise<Attachment | null> {\n return await documentOf(counterparty.domainId, BUSINESS_REGISTRATION_REF_TYPE, counterparty.id)\n }\n\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @FieldResolver(type => Int, { nullable: true, description: 'How many accounts it is paid into are registered' })\n async bankAccountCount(@Root() counterparty: Counterparty): Promise<number> {\n return await getRepository(CounterpartyBankAccount).count({ where: { counterparty: { id: counterparty.id } } })\n }\n}\n"]}
@@ -48,16 +48,19 @@ tslib_1.__decorate([
48
48
  ], CounterpartyBankAccount.prototype, "bankName", void 0);
49
49
  tslib_1.__decorate([
50
50
  (0, typeorm_1.Column)(),
51
- (0, type_graphql_1.Field)({ description: 'The account number, its digits - one counterparty\'s in the domain' }),
51
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
52
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The account number, its digits - one counterparty\'s in the domain' }),
52
53
  tslib_1.__metadata("design:type", String)
53
54
  ], CounterpartyBankAccount.prototype, "accountNumber", void 0);
54
55
  tslib_1.__decorate([
55
56
  (0, typeorm_1.Column)({ nullable: true }),
57
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
56
58
  (0, type_graphql_1.Field)({ nullable: true, description: 'The account holder (예금주) as the bank has it' }),
57
59
  tslib_1.__metadata("design:type", String)
58
60
  ], CounterpartyBankAccount.prototype, "holderName", void 0);
59
61
  tslib_1.__decorate([
60
62
  (0, typeorm_1.Column)({ type: 'text', nullable: true }),
63
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
61
64
  (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
62
65
  tslib_1.__metadata("design:type", String)
63
66
  ], CounterpartyBankAccount.prototype, "notes", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"counterparty-bank-account.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty-bank-account.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAAoJ;AAEpJ,yDAAgD;AAChD,iDAA8C;AAE9C,iDAA6C;AAE7C;;;;;;;GAOG;AAKI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;CA4DnC,CAAA;AA5DY,0DAAuB;AAGzB;IAFR,IAAA,g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AAA,oBAAU,EAAC,CAAC,OAAgC,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0DAChD;kCA3DP,uBAAuB;IAJnC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,gCAAgC,EAAE,CAAC,OAAgC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACvK,IAAA,eAAK,EAAC,gCAAgC,EAAE,CAAC,OAAgC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACxJ,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;GACzD,uBAAuB,CA4DnC","sourcesContent":["import { Field, ID, ObjectType } 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\nimport { Counterparty } from './counterparty'\n\n/**\n * An account a counterparty is paid into — where money to it goes, and how a bank line paying it is told apart (ADR-0134).\n *\n * Not the business's own account (accounting `BankAccount`, a book of its money): this one has no balance and no lines.\n * Only an account a person confirmed is kept; what the bank lines suggest is read from them, never stored.\n *\n * The number is kept as its digits (`accountKey`) and is one counterparty's in the domain — an account has one holder.\n */\n@Entity()\n@Index('ix_counterparty_bank_account_0', (account: CounterpartyBankAccount) => [account.domain, account.accountNumber], { unique: true, where: '\"deleted_at\" IS NULL' })\n@Index('ix_counterparty_bank_account_1', (account: CounterpartyBankAccount) => [account.domain, account.counterparty], { where: '\"deleted_at\" IS NULL' })\n@ObjectType({ description: 'An account a counterparty is paid into' })\nexport class CounterpartyBankAccount {\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 record this is' })\n domain?: Domain\n\n @RelationId((account: CounterpartyBankAccount) => account.domain)\n domainId?: string\n\n @ManyToOne(type => Counterparty, { nullable: false })\n @Field(type => Counterparty, { nullable: true, description: 'The counterparty the account is of' })\n counterparty?: Counterparty\n\n @RelationId((account: CounterpartyBankAccount) => account.counterparty)\n counterpartyId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The bank' })\n bankName?: string\n\n @Column()\n @Field({ description: 'The account number, its digits - one counterparty\\'s in the domain' })\n accountNumber: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The account holder (예금주) as the bank has it' })\n holderName?: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\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' })\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((account: CounterpartyBankAccount) => account.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((account: CounterpartyBankAccount) => account.updater)\n updaterId?: string\n}\n"]}
1
+ {"version":3,"file":"counterparty-bank-account.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty-bank-account.ts"],"names":[],"mappings":";;;;AAAA,+CAA+D;AAC/D,qCAAoJ;AAEpJ,yDAAgD;AAChD,iDAA8C;AAE9C,iDAA6C;AAE7C;;;;;;;GAOG;AAKI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;CAgEnC,CAA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,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;sCAClE,gBAAI;wDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgC,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0DAChD;kCA/DP,uBAAuB;IAJnC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,gCAAgC,EAAE,CAAC,OAAgC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACvK,IAAA,eAAK,EAAC,gCAAgC,EAAE,CAAC,OAAgC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACxJ,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;GACzD,uBAAuB,CAgEnC","sourcesContent":["import { Directive, Field, ID, ObjectType } 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\nimport { Counterparty } from './counterparty'\n\n/**\n * An account a counterparty is paid into — where money to it goes, and how a bank line paying it is told apart (ADR-0134).\n *\n * Not the business's own account (accounting `BankAccount`, a book of its money): this one has no balance and no lines.\n * Only an account a person confirmed is kept; what the bank lines suggest is read from them, never stored.\n *\n * The number is kept as its digits (`accountKey`) and is one counterparty's in the domain — an account has one holder.\n */\n@Entity()\n@Index('ix_counterparty_bank_account_0', (account: CounterpartyBankAccount) => [account.domain, account.accountNumber], { unique: true, where: '\"deleted_at\" IS NULL' })\n@Index('ix_counterparty_bank_account_1', (account: CounterpartyBankAccount) => [account.domain, account.counterparty], { where: '\"deleted_at\" IS NULL' })\n@ObjectType({ description: 'An account a counterparty is paid into' })\nexport class CounterpartyBankAccount {\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 record this is' })\n domain?: Domain\n\n @RelationId((account: CounterpartyBankAccount) => account.domain)\n domainId?: string\n\n @ManyToOne(type => Counterparty, { nullable: false })\n @Field(type => Counterparty, { nullable: true, description: 'The counterparty the account is of' })\n counterparty?: Counterparty\n\n @RelationId((account: CounterpartyBankAccount) => account.counterparty)\n counterpartyId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The bank' })\n bankName?: string\n\n /* The number, the holder and the notes are the keeper's (ADR-0139); a chooser sees the bank and `accountTail`. */\n @Column()\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'The account number, its digits - one counterparty\\'s in the domain' })\n accountNumber: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true, description: 'The account holder (예금주) as the bank has it' })\n holderName?: string\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 @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' })\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((account: CounterpartyBankAccount) => account.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((account: CounterpartyBankAccount) => account.updater)\n updaterId?: string\n}\n"]}
@@ -0,0 +1,66 @@
1
+ import { Repository } from 'typeorm';
2
+ import { ListParam } from '@things-factory/shell';
3
+ import { Counterparty, CounterpartyKind } from './counterparty';
4
+ import { CounterpartyBankAccount } from './counterparty-bank-account';
5
+ /** What the list door searches - the counterparty keeper's door. */
6
+ export declare const COUNTERPARTY_SEARCHABLES: string[];
7
+ /** What a choice is searched, filtered and sorted by - the fields it shows, so a search tells nothing about a closed field. */
8
+ export declare const CHOICE_SEARCHABLES: string[];
9
+ export declare const CHOICE_FILTERABLES: string[];
10
+ /** A choice door is no way to read the whole list at once. */
11
+ export declare const CHOICE_LIMIT = 50;
12
+ export declare class CounterpartyChoice {
13
+ id: string;
14
+ name: string;
15
+ kind: CounterpartyKind;
16
+ businessNumber?: string;
17
+ }
18
+ export declare class CounterpartyChoiceList {
19
+ items: CounterpartyChoice[];
20
+ total: number;
21
+ }
22
+ export declare class CounterpartyAccountChoice {
23
+ id: string;
24
+ bankName?: string;
25
+ accountTail?: string;
26
+ }
27
+ /** An account number's last four digits - what a chooser and a summary show of it. */
28
+ export declare function accountTailOf(number: string | null | undefined): string | undefined;
29
+ /** What a door lets a list be read by. */
30
+ export interface ListRules {
31
+ searchables: string[];
32
+ filterables?: string[];
33
+ sortables?: string[];
34
+ defaultLimit?: number;
35
+ maxLimit?: number;
36
+ }
37
+ /** One page of a domain's counterparties - the list door and the choice door read through this one function. */
38
+ export declare function counterpartyPage(repository: Repository<Counterparty>, domain: {
39
+ id: string;
40
+ }, params: ListParam, rules: ListRules): Promise<{
41
+ items: Counterparty[];
42
+ total: number;
43
+ }>;
44
+ /**
45
+ * Counterparties to pick from - asked as any list is (a picker sends filters, a page and sortings), answered only by
46
+ * what a choice shows: active ones, searched, filtered and sorted by the shown fields, a capped page at a time.
47
+ */
48
+ export declare function counterpartyChoicesOf(repository: Repository<Counterparty>, domain: {
49
+ id: string;
50
+ }, params: ListParam | undefined): Promise<{
51
+ items: {
52
+ id: string;
53
+ name: string;
54
+ kind: CounterpartyKind;
55
+ businessNumber: string;
56
+ }[];
57
+ total: number;
58
+ }>;
59
+ /** The accounts one counterparty is paid into, as one picks them. */
60
+ export declare function counterpartyAccountChoicesOf(repository: Repository<CounterpartyBankAccount>, domain: {
61
+ id: string;
62
+ }, counterpartyId: string): Promise<{
63
+ id: string;
64
+ bankName: string;
65
+ accountTail: string;
66
+ }[]>;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CounterpartyAccountChoice = exports.CounterpartyChoiceList = exports.CounterpartyChoice = exports.CHOICE_LIMIT = exports.CHOICE_FILTERABLES = exports.CHOICE_SEARCHABLES = exports.COUNTERPARTY_SEARCHABLES = void 0;
4
+ exports.accountTailOf = accountTailOf;
5
+ exports.counterpartyPage = counterpartyPage;
6
+ exports.counterpartyChoicesOf = counterpartyChoicesOf;
7
+ exports.counterpartyAccountChoicesOf = counterpartyAccountChoicesOf;
8
+ const tslib_1 = require("tslib");
9
+ const type_graphql_1 = require("type-graphql");
10
+ const shell_1 = require("@things-factory/shell");
11
+ const counterparty_1 = require("./counterparty");
12
+ /*
13
+ * Choosing a counterparty without reading it (ADR-0139, design/published-read-privilege): `counterparty-published`
14
+ * opens what points at a counterparty and nothing else. Its types are its own - no relation to follow - so the closed
15
+ * fields of Counterparty cannot be reached from a choice.
16
+ */
17
+ /** What the list door searches - the counterparty keeper's door. */
18
+ exports.COUNTERPARTY_SEARCHABLES = ['name', 'aliases', 'businessNumber', 'representative', 'notes'];
19
+ /** What a choice is searched, filtered and sorted by - the fields it shows, so a search tells nothing about a closed field. */
20
+ exports.CHOICE_SEARCHABLES = ['name', 'businessNumber'];
21
+ /* `active` is the door's own filter: an inactive counterparty is not offered. */
22
+ exports.CHOICE_FILTERABLES = [...exports.CHOICE_SEARCHABLES, 'active'];
23
+ /** A choice door is no way to read the whole list at once. */
24
+ exports.CHOICE_LIMIT = 50;
25
+ let CounterpartyChoice = class CounterpartyChoice {
26
+ };
27
+ exports.CounterpartyChoice = CounterpartyChoice;
28
+ tslib_1.__decorate([
29
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
30
+ tslib_1.__metadata("design:type", String)
31
+ ], CounterpartyChoice.prototype, "id", void 0);
32
+ tslib_1.__decorate([
33
+ (0, type_graphql_1.Field)({ description: 'The name the business knows it by' }),
34
+ tslib_1.__metadata("design:type", String)
35
+ ], CounterpartyChoice.prototype, "name", void 0);
36
+ tslib_1.__decorate([
37
+ (0, type_graphql_1.Field)(type => counterparty_1.CounterpartyKind, { description: 'A company or a person' }),
38
+ tslib_1.__metadata("design:type", String)
39
+ ], CounterpartyChoice.prototype, "kind", void 0);
40
+ tslib_1.__decorate([
41
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Business registration number - tells apart two counterparties of one name (ADR-0132)' }),
42
+ tslib_1.__metadata("design:type", String)
43
+ ], CounterpartyChoice.prototype, "businessNumber", void 0);
44
+ exports.CounterpartyChoice = CounterpartyChoice = tslib_1.__decorate([
45
+ (0, type_graphql_1.ObjectType)({ description: 'A counterparty as one picks it: which one, and nothing about it' })
46
+ ], CounterpartyChoice);
47
+ let CounterpartyChoiceList = class CounterpartyChoiceList {
48
+ };
49
+ exports.CounterpartyChoiceList = CounterpartyChoiceList;
50
+ tslib_1.__decorate([
51
+ (0, type_graphql_1.Field)(type => [CounterpartyChoice]),
52
+ tslib_1.__metadata("design:type", Array)
53
+ ], CounterpartyChoiceList.prototype, "items", void 0);
54
+ tslib_1.__decorate([
55
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
56
+ tslib_1.__metadata("design:type", Number)
57
+ ], CounterpartyChoiceList.prototype, "total", void 0);
58
+ exports.CounterpartyChoiceList = CounterpartyChoiceList = tslib_1.__decorate([
59
+ (0, type_graphql_1.ObjectType)({ description: 'A page of counterparties to pick from' })
60
+ ], CounterpartyChoiceList);
61
+ let CounterpartyAccountChoice = class CounterpartyAccountChoice {
62
+ };
63
+ exports.CounterpartyAccountChoice = CounterpartyAccountChoice;
64
+ tslib_1.__decorate([
65
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
66
+ tslib_1.__metadata("design:type", String)
67
+ ], CounterpartyAccountChoice.prototype, "id", void 0);
68
+ tslib_1.__decorate([
69
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The bank' }),
70
+ tslib_1.__metadata("design:type", String)
71
+ ], CounterpartyAccountChoice.prototype, "bankName", void 0);
72
+ tslib_1.__decorate([
73
+ (0, type_graphql_1.Field)({ nullable: true, description: "The account number's last four digits" }),
74
+ tslib_1.__metadata("design:type", String)
75
+ ], CounterpartyAccountChoice.prototype, "accountTail", void 0);
76
+ exports.CounterpartyAccountChoice = CounterpartyAccountChoice = tslib_1.__decorate([
77
+ (0, type_graphql_1.ObjectType)({ description: "An account a counterparty is paid into, as one picks it: the bank and the number's last four digits" })
78
+ ], CounterpartyAccountChoice);
79
+ /** An account number's last four digits - what a chooser and a summary show of it. */
80
+ function accountTailOf(number) {
81
+ const digits = String(number ?? '').replace(/\D/g, '');
82
+ return digits ? digits.slice(-4) : undefined;
83
+ }
84
+ /** One page of a domain's counterparties - the list door and the choice door read through this one function. */
85
+ async function counterpartyPage(repository, domain, params, rules) {
86
+ const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({ domain: domain, params, repository, ...rules, alias: 'counterparty' });
87
+ queryBuilder.addOrderBy('counterparty.name', 'ASC');
88
+ const [items, total] = await queryBuilder.getManyAndCount();
89
+ return { items, total };
90
+ }
91
+ /**
92
+ * Counterparties to pick from - asked as any list is (a picker sends filters, a page and sortings), answered only by
93
+ * what a choice shows: active ones, searched, filtered and sorted by the shown fields, a capped page at a time.
94
+ */
95
+ async function counterpartyChoicesOf(repository, domain, params) {
96
+ const asked = (params ?? {});
97
+ const filters = [...(asked.filters ?? []), { name: 'active', operator: 'eq', value: true }];
98
+ const { items, total } = await counterpartyPage(repository, domain, { ...asked, filters }, {
99
+ searchables: exports.CHOICE_SEARCHABLES,
100
+ filterables: exports.CHOICE_FILTERABLES,
101
+ sortables: exports.CHOICE_SEARCHABLES,
102
+ defaultLimit: exports.CHOICE_LIMIT,
103
+ maxLimit: exports.CHOICE_LIMIT
104
+ });
105
+ return { items: items.map(one => ({ id: one.id, name: one.name, kind: one.kind, businessNumber: one.businessNumber })), total };
106
+ }
107
+ /** The accounts one counterparty is paid into, as one picks them. */
108
+ async function counterpartyAccountChoicesOf(repository, domain, counterpartyId) {
109
+ const accounts = await repository.find({ where: { domain: { id: domain.id }, counterparty: { id: counterpartyId } }, order: { createdAt: 'ASC' }, take: exports.CHOICE_LIMIT });
110
+ return accounts.map(one => ({ id: one.id, bankName: one.bankName, accountTail: accountTailOf(one.accountNumber) }));
111
+ }
112
+ //# sourceMappingURL=counterparty-choice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"counterparty-choice.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty-choice.ts"],"names":[],"mappings":";;;AA6CA,sCAGC;AAYD,4CAKC;AAMD,sDAWC;AAGD,oEAGC;;AAxFD,+CAAyD;AAGzD,iDAAgF;AAEhF,iDAA+D;AAG/D;;;;GAIG;AAEH,oEAAoE;AACvD,QAAA,wBAAwB,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAA;AACxG,+HAA+H;AAClH,QAAA,kBAAkB,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAC5D,iFAAiF;AACpE,QAAA,kBAAkB,GAAG,CAAC,GAAG,0BAAkB,EAAE,QAAQ,CAAC,CAAA;AACnE,8DAA8D;AACjD,QAAA,YAAY,GAAG,EAAE,CAAA;AAGvB,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;C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KAAK,EAAE,OAAO,EAAe,EAAE;QACtG,WAAW,EAAE,0BAAkB;QAC/B,WAAW,EAAE,0BAAkB;QAC/B,SAAS,EAAE,0BAAkB;QAC7B,YAAY,EAAE,oBAAY;QAC1B,QAAQ,EAAE,oBAAY;KACvB,CAAC,CAAA;IACF,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAA;AACjI,CAAC;AAED,qEAAqE;AAC9D,KAAK,UAAU,4BAA4B,CAAC,UAA+C,EAAE,MAAsB,EAAE,cAAsB;IAChJ,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,EAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAS,EAAE,IAAI,EAAE,oBAAY,EAAE,CAAC,CAAA;IACrL,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAA;AACrH,CAAC","sourcesContent":["import { Field, ID, Int, ObjectType } from 'type-graphql'\nimport { Repository } from 'typeorm'\n\nimport { getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'\n\nimport { Counterparty, CounterpartyKind } from './counterparty'\nimport { CounterpartyBankAccount } from './counterparty-bank-account'\n\n/*\n * Choosing a counterparty without reading it (ADR-0139, design/published-read-privilege): `counterparty-published`\n * opens what points at a counterparty and nothing else. Its types are its own - no relation to follow - so the closed\n * fields of Counterparty cannot be reached from a choice.\n */\n\n/** What the list door searches - the counterparty keeper's door. */\nexport const COUNTERPARTY_SEARCHABLES = ['name', 'aliases', 'businessNumber', 'representative', 'notes']\n/** What a choice is searched, filtered and sorted by - the fields it shows, so a search tells nothing about a closed field. */\nexport const CHOICE_SEARCHABLES = ['name', 'businessNumber']\n/* `active` is the door's own filter: an inactive counterparty is not offered. */\nexport const CHOICE_FILTERABLES = [...CHOICE_SEARCHABLES, 'active']\n/** A choice door is no way to read the whole list at once. */\nexport const CHOICE_LIMIT = 50\n\n@ObjectType({ description: 'A counterparty as one picks it: which one, and nothing about it' })\nexport class CounterpartyChoice {\n @Field(type => ID) id: string\n @Field({ description: 'The name the business knows it by' }) name: string\n @Field(type => CounterpartyKind, { description: 'A company or a person' }) kind: CounterpartyKind\n @Field({ nullable: true, description: 'Business registration number - tells apart two counterparties of one name (ADR-0132)' }) businessNumber?: string\n}\n\n@ObjectType({ description: 'A page of counterparties to pick from' })\nexport class CounterpartyChoiceList {\n @Field(type => [CounterpartyChoice]) items: CounterpartyChoice[]\n @Field(type => Int) total: number\n}\n\n@ObjectType({ description: \"An account a counterparty is paid into, as one picks it: the bank and the number's last four digits\" })\nexport class CounterpartyAccountChoice {\n @Field(type => ID) id: string\n @Field({ nullable: true, description: 'The bank' }) bankName?: string\n @Field({ nullable: true, description: \"The account number's last four digits\" }) accountTail?: string\n}\n\n/** An account number's last four digits - what a chooser and a summary show of it. */\nexport function accountTailOf(number: string | null | undefined): string | undefined {\n const digits = String(number ?? '').replace(/\\D/g, '')\n return digits ? digits.slice(-4) : undefined\n}\n\n/** What a door lets a list be read by. */\nexport interface ListRules {\n searchables: string[]\n filterables?: string[]\n sortables?: string[]\n defaultLimit?: number\n maxLimit?: number\n}\n\n/** One page of a domain's counterparties - the list door and the choice door read through this one function. */\nexport async function counterpartyPage(repository: Repository<Counterparty>, domain: { id: string }, params: ListParam, rules: ListRules) {\n const queryBuilder = getQueryBuilderFromListParams({ domain: domain as any, params, repository, ...rules, alias: 'counterparty' })\n queryBuilder.addOrderBy('counterparty.name', 'ASC')\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n}\n\n/**\n * Counterparties to pick from - asked as any list is (a picker sends filters, a page and sortings), answered only by\n * what a choice shows: active ones, searched, filtered and sorted by the shown fields, a capped page at a time.\n */\nexport async function counterpartyChoicesOf(repository: Repository<Counterparty>, domain: { id: string }, params: ListParam | undefined) {\n const asked = (params ?? {}) as ListParam\n const filters = [...(asked.filters ?? []), { name: 'active', operator: 'eq', value: true }]\n const { items, total } = await counterpartyPage(repository, domain, { ...asked, filters } as ListParam, {\n searchables: CHOICE_SEARCHABLES,\n filterables: CHOICE_FILTERABLES,\n sortables: CHOICE_SEARCHABLES,\n defaultLimit: CHOICE_LIMIT,\n maxLimit: CHOICE_LIMIT\n })\n return { items: items.map(one => ({ id: one.id, name: one.name, kind: one.kind, businessNumber: one.businessNumber })), total }\n}\n\n/** The accounts one counterparty is paid into, as one picks them. */\nexport async function counterpartyAccountChoicesOf(repository: Repository<CounterpartyBankAccount>, domain: { id: string }, counterpartyId: string) {\n const accounts = await repository.find({ where: { domain: { id: domain.id }, counterparty: { id: counterpartyId } } as any, order: { createdAt: 'ASC' } as any, take: CHOICE_LIMIT })\n return accounts.map(one => ({ id: one.id, bankName: one.bankName, accountTail: accountTailOf(one.accountNumber) }))\n}\n"]}
@@ -2,9 +2,12 @@ import { User } from '@things-factory/auth-base';
2
2
  import { Domain, ListParam } from '@things-factory/shell';
3
3
  import { Counterparty } from './counterparty';
4
4
  import { CounterpartyList } from './counterparty-type';
5
+ import { CounterpartyAccountChoice, CounterpartyChoiceList } from './counterparty-choice';
5
6
  export declare class CounterpartyQuery {
6
7
  counterparty(id: string, context: ResolverContext): Promise<Counterparty | null>;
7
8
  counterparties(params: ListParam, context: ResolverContext): Promise<CounterpartyList>;
9
+ counterpartyChoices(params: ListParam, context: ResolverContext): Promise<CounterpartyChoiceList>;
10
+ counterpartyAccountChoices(counterpartyId: string, context: ResolverContext): Promise<CounterpartyAccountChoice[]>;
8
11
  domain(counterparty: Counterparty): Promise<Domain | null>;
9
12
  creator(counterparty: Counterparty): Promise<User | null>;
10
13
  updater(counterparty: Counterparty): Promise<User | null>;
@@ -6,22 +6,22 @@ const type_graphql_1 = require("type-graphql");
6
6
  const auth_base_1 = require("@things-factory/auth-base");
7
7
  const shell_1 = require("@things-factory/shell");
8
8
  const counterparty_1 = require("./counterparty");
9
+ const counterparty_bank_account_1 = require("./counterparty-bank-account");
9
10
  const counterparty_type_1 = require("./counterparty-type");
11
+ const counterparty_choice_1 = require("./counterparty-choice");
10
12
  let CounterpartyQuery = class CounterpartyQuery {
11
13
  async counterparty(id, context) {
12
14
  return await (0, shell_1.getRepository)(counterparty_1.Counterparty).findOne({ where: { domain: { id: context.state.domain.id }, id } });
13
15
  }
14
16
  async counterparties(params, context) {
15
- const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
16
- domain: context.state.domain,
17
- params,
18
- repository: (0, shell_1.getRepository)(counterparty_1.Counterparty),
19
- searchables: ['name', 'aliases', 'businessNumber', 'representative', 'notes'],
20
- alias: 'counterparty'
21
- });
22
- queryBuilder.addOrderBy('counterparty.name', 'ASC');
23
- const [items, total] = await queryBuilder.getManyAndCount();
24
- return { items, total };
17
+ return await (0, counterparty_choice_1.counterpartyPage)((0, shell_1.getRepository)(counterparty_1.Counterparty), context.state.domain, params, { searchables: counterparty_choice_1.COUNTERPARTY_SEARCHABLES });
18
+ }
19
+ /* Picking a counterparty without reading it - every seat may (ADR-0139). */
20
+ async counterpartyChoices(params, context) {
21
+ return (await (0, counterparty_choice_1.counterpartyChoicesOf)((0, shell_1.getRepository)(counterparty_1.Counterparty), context.state.domain, params));
22
+ }
23
+ async counterpartyAccountChoices(counterpartyId, context) {
24
+ return await (0, counterparty_choice_1.counterpartyAccountChoicesOf)((0, shell_1.getRepository)(counterparty_bank_account_1.CounterpartyBankAccount), context.state.domain, counterpartyId);
25
25
  }
26
26
  async domain(counterparty) {
27
27
  return counterparty.domain ?? (counterparty.domainId ? await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: counterparty.domainId }) : null);
@@ -52,6 +52,24 @@ tslib_1.__decorate([
52
52
  tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
53
53
  tslib_1.__metadata("design:returntype", Promise)
54
54
  ], CounterpartyQuery.prototype, "counterparties", null);
55
+ tslib_1.__decorate([
56
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty-published", privilege: "query", domainOwnerGranted: true)'),
57
+ (0, type_graphql_1.Query)(returns => counterparty_choice_1.CounterpartyChoiceList, { description: 'Counterparties to pick from - which one, nothing about it; a capped page at a time' }),
58
+ tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
59
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
60
+ tslib_1.__metadata("design:type", Function),
61
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
62
+ tslib_1.__metadata("design:returntype", Promise)
63
+ ], CounterpartyQuery.prototype, "counterpartyChoices", null);
64
+ tslib_1.__decorate([
65
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty-published", privilege: "query", domainOwnerGranted: true)'),
66
+ (0, type_graphql_1.Query)(returns => [counterparty_choice_1.CounterpartyAccountChoice], { description: "The accounts a counterparty is paid into, to pick one - the bank and the number's last four digits" }),
67
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('counterpartyId')),
68
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
69
+ tslib_1.__metadata("design:type", Function),
70
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
71
+ tslib_1.__metadata("design:returntype", Promise)
72
+ ], CounterpartyQuery.prototype, "counterpartyAccountChoices", null);
55
73
  tslib_1.__decorate([
56
74
  (0, type_graphql_1.FieldResolver)(type => shell_1.Domain, { nullable: true }),
57
75
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
@@ -1 +1 @@
1
- {"version":3,"file":"counterparty-query.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,yDAAgD;AAChD,iDAAuG;AAEvG,iDAA6C;AAC7C,2DAAsD;AAG/C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAGtB,AAAN,KAAK,CAAC,YAAY,CAAY,EAAU,EAAS,OAAwB;QACvE,OAAO,MAAM,IAAA,qBAAa,EAAC,2BAAY,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IAC9G,CAAC;IAIK,AAAN,KAAK,CAAC,cAAc,CAA0B,MAAiB,EAAS,OAAwB;QAC9F,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM;YAC5B,MAAM;YACN,UAAU,EAAE,IAAA,qBAAa,EAAC,2BAAY,CAAC;YACvC,WAAW,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,CAAC;YAC7E,KAAK,EAAE,cAAc;SACtB,CAAC,CAAA;QACF,YAAY,CAAC,UAAU,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAA;QACnD,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAA;QAC3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CAAS,YAA0B;QAC7C,OAAO,YAAY,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC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AAC,iBAAS,CAAC,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;uDAW9D;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACpC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAe,2BAAY;;+CAE9C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAe,2BAAY;;gDAE/C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAe,2BAAY;;gDAE/C;4BAnCU,iBAAiB;IAD7B,IAAA,uBAAQ,EAAC,2BAAY,CAAC;GACV,iBAAiB,CAoC7B","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Counterparty } from './counterparty'\nimport { CounterpartyList } from './counterparty-type'\n\n@Resolver(Counterparty)\nexport class CounterpartyQuery {\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Counterparty, { nullable: true, description: 'To fetch a counterparty of the domain' })\n async counterparty(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Counterparty | null> {\n return await getRepository(Counterparty).findOne({ where: { domain: { id: context.state.domain.id }, id } })\n }\n\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => CounterpartyList, { description: \"To fetch a page of the domain's counterparties\" })\n async counterparties(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<CounterpartyList> {\n const queryBuilder = getQueryBuilderFromListParams({\n domain: context.state.domain,\n params,\n repository: getRepository(Counterparty),\n searchables: ['name', 'aliases', 'businessNumber', 'representative', 'notes'],\n alias: 'counterparty'\n })\n queryBuilder.addOrderBy('counterparty.name', 'ASC')\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n }\n\n @FieldResolver(type => Domain, { nullable: true })\n async domain(@Root() counterparty: Counterparty): Promise<Domain | null> {\n return counterparty.domain ?? (counterparty.domainId ? await getRepository(Domain).findOneBy({ id: counterparty.domainId }) : null)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() counterparty: Counterparty): Promise<User | null> {\n return counterparty.creator ?? (counterparty.creatorId ? await getRepository(User).findOneBy({ id: counterparty.creatorId }) : null)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() counterparty: Counterparty): Promise<User | null> {\n return counterparty.updater ?? (counterparty.updaterId ? await getRepository(User).findOneBy({ id: counterparty.updaterId }) : null)\n }\n}\n"]}
1
+ {"version":3,"file":"counterparty-query.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,yDAAgD;AAChD,iDAAwE;AAExE,iDAA6C;AAC7C,2EAAqE;AACrE,2DAAsD;AACtD,+DAO8B;AAGvB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAGtB,AAAN,KAAK,CAAC,YAAY,CAAY,EAAU,EAAS,OAAwB;QACvE,OAAO,MAAM,IAAA,qBAAa,EAAC,2BAAY,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IAC9G,CAAC;IAIK,AAAN,KAAK,CAAC,cAAc,CAA0B,MAA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AAE,EAAE,WAAW,EAAE,oGAAoG,EAAE,CAAC;IACnI,mBAAA,IAAA,kBAAG,EAAC,gBAAgB,CAAC,CAAA;IAA0B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;mEAErF;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACpC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAe,2BAAY;;+CAE9C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAe,2BAAY;;gDAE/C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAe,2BAAY;;gDAE/C;4BAvCU,iBAAiB;IAD7B,IAAA,uBAAQ,EAAC,2BAAY,CAAC;GACV,iBAAiB,CAwC7B","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Counterparty } from './counterparty'\nimport { CounterpartyBankAccount } from './counterparty-bank-account'\nimport { CounterpartyList } from './counterparty-type'\nimport {\n CounterpartyAccountChoice,\n counterpartyAccountChoicesOf,\n CounterpartyChoiceList,\n counterpartyChoicesOf,\n counterpartyPage,\n COUNTERPARTY_SEARCHABLES\n} from './counterparty-choice'\n\n@Resolver(Counterparty)\nexport class CounterpartyQuery {\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Counterparty, { nullable: true, description: 'To fetch a counterparty of the domain' })\n async counterparty(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Counterparty | null> {\n return await getRepository(Counterparty).findOne({ where: { domain: { id: context.state.domain.id }, id } })\n }\n\n @Directive('@privilege(category: \"counterparty\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => CounterpartyList, { description: \"To fetch a page of the domain's counterparties\" })\n async counterparties(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<CounterpartyList> {\n return await counterpartyPage(getRepository(Counterparty), context.state.domain, params, { searchables: COUNTERPARTY_SEARCHABLES })\n }\n\n /* Picking a counterparty without reading it - every seat may (ADR-0139). */\n @Directive('@privilege(category: \"counterparty-published\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => CounterpartyChoiceList, { description: 'Counterparties to pick from - which one, nothing about it; a capped page at a time' })\n async counterpartyChoices(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<CounterpartyChoiceList> {\n return (await counterpartyChoicesOf(getRepository(Counterparty), context.state.domain, params)) as any\n }\n\n @Directive('@privilege(category: \"counterparty-published\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [CounterpartyAccountChoice], { description: \"The accounts a counterparty is paid into, to pick one - the bank and the number's last four digits\" })\n async counterpartyAccountChoices(@Arg('counterpartyId') counterpartyId: string, @Ctx() context: ResolverContext): Promise<CounterpartyAccountChoice[]> {\n return await counterpartyAccountChoicesOf(getRepository(CounterpartyBankAccount), context.state.domain, counterpartyId)\n }\n\n @FieldResolver(type => Domain, { nullable: true })\n async domain(@Root() counterparty: Counterparty): Promise<Domain | null> {\n return counterparty.domain ?? (counterparty.domainId ? await getRepository(Domain).findOneBy({ id: counterparty.domainId }) : null)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() counterparty: Counterparty): Promise<User | null> {\n return counterparty.creator ?? (counterparty.creatorId ? await getRepository(User).findOneBy({ id: counterparty.creatorId }) : null)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() counterparty: Counterparty): Promise<User | null> {\n return counterparty.updater ?? (counterparty.updaterId ? await getRepository(User).findOneBy({ id: counterparty.updaterId }) : null)\n }\n}\n"]}
@@ -27,6 +27,8 @@ var CounterpartyKind;
27
27
  * A business registration number is one counterparty's in the domain; a name is not — two businesses may trade under
28
28
  * one name, told apart by their numbers.
29
29
  */
30
+ /* The fields past what points at a counterparty are its keeper's: `counterparty:query`, on the declaration, nullable -
31
+ whatever row they are reached from (ADR-0139). */
30
32
  let Counterparty = class Counterparty {
31
33
  };
32
34
  exports.Counterparty = Counterparty;
@@ -51,6 +53,7 @@ tslib_1.__decorate([
51
53
  ], Counterparty.prototype, "name", void 0);
52
54
  tslib_1.__decorate([
53
55
  (0, typeorm_1.Column)({ type: 'text', nullable: true }),
56
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
54
57
  (0, type_graphql_1.Field)({ nullable: true, description: 'Other names it appears under — in bank lines, old ledgers — one per line or comma' }),
55
58
  tslib_1.__metadata("design:type", String)
56
59
  ], Counterparty.prototype, "aliases", void 0);
@@ -66,41 +69,49 @@ tslib_1.__decorate([
66
69
  ], Counterparty.prototype, "businessNumber", void 0);
67
70
  tslib_1.__decorate([
68
71
  (0, typeorm_1.Column)({ nullable: true }),
72
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
69
73
  (0, type_graphql_1.Field)({ nullable: true, description: 'Sub-business place number, when tax invoices go to a branch' }),
70
74
  tslib_1.__metadata("design:type", String)
71
75
  ], Counterparty.prototype, "branchNumber", void 0);
72
76
  tslib_1.__decorate([
73
77
  (0, typeorm_1.Column)({ nullable: true }),
78
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
74
79
  (0, type_graphql_1.Field)({ nullable: true, description: 'Representative' }),
75
80
  tslib_1.__metadata("design:type", String)
76
81
  ], Counterparty.prototype, "representative", void 0);
77
82
  tslib_1.__decorate([
78
83
  (0, typeorm_1.Column)({ type: 'text', nullable: true }),
84
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
79
85
  (0, type_graphql_1.Field)({ nullable: true, description: 'Address' }),
80
86
  tslib_1.__metadata("design:type", String)
81
87
  ], Counterparty.prototype, "address", void 0);
82
88
  tslib_1.__decorate([
83
89
  (0, typeorm_1.Column)({ type: 'text', nullable: true }),
90
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
84
91
  (0, type_graphql_1.Field)({ nullable: true, description: 'Address bills are sent to, when not the address' }),
85
92
  tslib_1.__metadata("design:type", String)
86
93
  ], Counterparty.prototype, "billingAddress", void 0);
87
94
  tslib_1.__decorate([
88
95
  (0, typeorm_1.Column)({ nullable: true }),
96
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
89
97
  (0, type_graphql_1.Field)({ nullable: true, description: 'Business type (업태)' }),
90
98
  tslib_1.__metadata("design:type", String)
91
99
  ], Counterparty.prototype, "businessType", void 0);
92
100
  tslib_1.__decorate([
93
101
  (0, typeorm_1.Column)({ nullable: true }),
102
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
94
103
  (0, type_graphql_1.Field)({ nullable: true, description: 'Business item (종목)' }),
95
104
  tslib_1.__metadata("design:type", String)
96
105
  ], Counterparty.prototype, "businessItem", void 0);
97
106
  tslib_1.__decorate([
98
107
  (0, typeorm_1.Column)({ default: false }),
99
- (0, type_graphql_1.Field)({ description: 'Whether its sales to it are zero-rated for VAT' }),
108
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
109
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Whether its sales to it are zero-rated for VAT' }),
100
110
  tslib_1.__metadata("design:type", Boolean)
101
111
  ], Counterparty.prototype, "zeroRated", void 0);
102
112
  tslib_1.__decorate([
103
113
  (0, typeorm_1.Column)({ type: 'text', nullable: true }),
114
+ (0, type_graphql_1.Directive)('@privilege(category: "counterparty", privilege: "query", domainOwnerGranted: true)'),
104
115
  (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
105
116
  tslib_1.__metadata("design:type", String)
106
117
  ], Counterparty.prototype, "notes", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"counterparty.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,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;AAKI,IAAM,YAAY,GAAlB,MAAM,YAAY;CAyFxB,CAAA;AAzFY,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,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,EAAE,CAAC;GACpF,YAAY,CAyFxB","sourcesContent":["import { 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@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 @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 @Field({ nullable: true, description: 'Sub-business place number, when tax invoices go to a branch' })\n branchNumber?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Representative' })\n representative?: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Address' })\n address?: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Address bills are sent to, when not the address' })\n billingAddress?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Business type (업태)' })\n businessType?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Business item (종목)' })\n businessItem?: string\n\n @Column({ default: false })\n @Field({ description: 'Whether its sales to it are zero-rated for VAT' })\n zeroRated: boolean\n\n @Column({ type: 'text', nullable: 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;AAC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E,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"]}
@@ -7,6 +7,7 @@ export * from './counterparty/counterparty-names';
7
7
  export * from './counterparty/counterparty-service';
8
8
  export * from './counterparty/counterparty-bank-account';
9
9
  export * from './counterparty/counterparty-bank-account-service';
10
+ export * from './counterparty/counterparty-choice';
10
11
  export * from './worker/worker';
11
12
  export * from './company/company-types';
12
13
  export * from './bizplace/bizplace-types';
@@ -19,6 +19,7 @@ tslib_1.__exportStar(require("./counterparty/counterparty-names"), exports);
19
19
  tslib_1.__exportStar(require("./counterparty/counterparty-service"), exports);
20
20
  tslib_1.__exportStar(require("./counterparty/counterparty-bank-account"), exports);
21
21
  tslib_1.__exportStar(require("./counterparty/counterparty-bank-account-service"), exports);
22
+ tslib_1.__exportStar(require("./counterparty/counterparty-choice"), exports);
22
23
  tslib_1.__exportStar(require("./worker/worker"), exports);
23
24
  /* EXPORT TYPES */
24
25
  tslib_1.__exportStar(require("./company/company-types"), exports);