@things-factory/biz-base 10.1.319 → 10.1.320

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.
@@ -8,9 +8,11 @@ import { type Entity360KindDeclaration, type Entity360Subject } from '@operato/l
8
8
  * office declared the kind itself and a second product would have had to declare it again; the registry refuses a kind
9
9
  * named twice, so two products in one app would have fought over it.
10
10
  *
11
- * Its identifier is the row id (`value.id`): a counterparty has no name a person types that is unique - two companies
12
- * may share one. The heading is the name the value carries, or the one a section read (`setEntity360Value`), never the
13
- * id (`entity360Title`).
11
+ * Its identifier is its **party identifier** (`value.partyIdentifier`, ADR-0211) - the name a counterparty is given outside the
12
+ * database, which an address is (2026-11-28, the user: an address never carries a row id). A name a person types is not unique -
13
+ * two companies may share one. A value read without it falls back to its row id, and the doors take either
14
+ * (`counterpartyRowIdOf`), so an address saved before still opens. The heading is the name the value carries, or the one a
15
+ * section read (`setEntity360Value`), never the identifier (`entity360Title`).
14
16
  *
15
17
  * A product may pass what is its own to decide - `assistantSubject` (whether its AI dock follows the open 360) and a
16
18
  * `title` / `context` of its own. The kind name and the typename are not the product's to change.
@@ -9,9 +9,11 @@ import { registerEntity360Kind } from '@operato/layout';
9
9
  * office declared the kind itself and a second product would have had to declare it again; the registry refuses a kind
10
10
  * named twice, so two products in one app would have fought over it.
11
11
  *
12
- * Its identifier is the row id (`value.id`): a counterparty has no name a person types that is unique - two companies
13
- * may share one. The heading is the name the value carries, or the one a section read (`setEntity360Value`), never the
14
- * id (`entity360Title`).
12
+ * Its identifier is its **party identifier** (`value.partyIdentifier`, ADR-0211) - the name a counterparty is given outside the
13
+ * database, which an address is (2026-11-28, the user: an address never carries a row id). A name a person types is not unique -
14
+ * two companies may share one. A value read without it falls back to its row id, and the doors take either
15
+ * (`counterpartyRowIdOf`), so an address saved before still opens. The heading is the name the value carries, or the one a
16
+ * section read (`setEntity360Value`), never the identifier (`entity360Title`).
15
17
  *
16
18
  * A product may pass what is its own to decide - `assistantSubject` (whether its AI dock follows the open 360) and a
17
19
  * `title` / `context` of its own. The kind name and the typename are not the product's to change.
@@ -22,6 +24,7 @@ export function registerCounterparty360(options = {}) {
22
24
  registerEntity360Kind({
23
25
  kind: COUNTERPARTY_360_KIND,
24
26
  typenames: ['Counterparty'],
27
+ id: value => value?.partyIdentifier || value?.id,
25
28
  title: counterpartyTitle,
26
29
  context: () => i18next.t('text.entity360-counterparty'),
27
30
  ...options
@@ -7,13 +7,16 @@ const type_graphql_1 = require("type-graphql");
7
7
  const attachment_base_1 = require("@things-factory/attachment-base");
8
8
  const shell_1 = require("@things-factory/shell");
9
9
  const counterparty_1 = require("./counterparty");
10
+ const counterparty_scope_1 = require("./counterparty-scope");
10
11
  const counterparty_bank_account_1 = require("./counterparty-bank-account");
11
12
  const counterparty_bank_account_service_1 = require("./counterparty-bank-account-service");
12
13
  const counterparty_type_1 = require("./counterparty-type");
13
14
  let CounterpartyBankAccountMutation = class CounterpartyBankAccountMutation {
14
15
  async updateMultipleCounterpartyBankAccount(patches, context) {
15
16
  const { tx, domain, user } = context.state;
16
- return await (0, counterparty_bank_account_service_1.saveCounterpartyBankAccounts)(tx, domain, user, patches);
17
+ /* a 360 names its counterparty by party identifier (an older address by row id) - the rows are kept by row id */
18
+ const keyed = await Promise.all(patches.map(async (one) => (one.counterpartyId ? { ...one, counterpartyId: (await (0, counterparty_scope_1.counterpartyRowIdOf)(tx, domain, one.counterpartyId)) ?? one.counterpartyId } : one)));
19
+ return await (0, counterparty_bank_account_service_1.saveCounterpartyBankAccounts)(tx, domain, user, keyed);
17
20
  }
18
21
  async attachCounterpartyPassbook(accountId, file, context) {
19
22
  const { tx, domain } = context.state;
@@ -24,7 +27,8 @@ let CounterpartyBankAccountMutation = class CounterpartyBankAccountMutation {
24
27
  }
25
28
  async attachCounterpartyBusinessRegistration(counterpartyId, file, context) {
26
29
  const { tx, domain } = context.state;
27
- const counterparty = await tx.getRepository(counterparty_1.Counterparty).findOne({ where: { domain: { id: domain.id }, id: counterpartyId } });
30
+ const rowId = await (0, counterparty_scope_1.counterpartyRowIdOf)(tx, domain, counterpartyId);
31
+ const counterparty = rowId ? await tx.getRepository(counterparty_1.Counterparty).findOne({ where: { domain: { id: domain.id }, id: rowId } }) : null;
28
32
  if (!counterparty)
29
33
  throw new shell_1.Refusal('counterparty-not-found', {}, 'a counterparty was not found - reload and try again');
30
34
  return await (0, attachment_base_1.replaceAttachment)({ file, refType: counterparty_bank_account_service_1.BUSINESS_REGISTRATION_REF_TYPE, refBy: counterparty.id, category: 'business-registration' }, context);
@@ -7,6 +7,7 @@ const attachment_base_1 = require("@things-factory/attachment-base");
7
7
  const auth_base_1 = require("@things-factory/auth-base");
8
8
  const shell_1 = require("@things-factory/shell");
9
9
  const counterparty_1 = require("./counterparty");
10
+ const counterparty_scope_1 = require("./counterparty-scope");
10
11
  const counterparty_bank_account_1 = require("./counterparty-bank-account");
11
12
  const counterparty_bank_account_service_1 = require("./counterparty-bank-account-service");
12
13
  const counterparty_choice_1 = require("./counterparty-choice");
@@ -16,8 +17,13 @@ async function documentOf(domainId, refType, refBy) {
16
17
  }
17
18
  let CounterpartyBankAccountQuery = class CounterpartyBankAccountQuery {
18
19
  async counterpartyBankAccounts(counterpartyId, context) {
19
- return await (0, shell_1.getRepository)(counterparty_bank_account_1.CounterpartyBankAccount).find({
20
- where: { domain: { id: context.state.domain.id }, counterparty: { id: counterpartyId } },
20
+ const repository = (0, shell_1.getRepository)(counterparty_bank_account_1.CounterpartyBankAccount);
21
+ /* a 360 names its counterparty by party identifier (an older address by row id) */
22
+ const rowId = await (0, counterparty_scope_1.counterpartyRowIdOf)(repository.manager, context.state.domain, counterpartyId);
23
+ if (!rowId)
24
+ return [];
25
+ return await repository.find({
26
+ where: { domain: { id: context.state.domain.id }, counterparty: { id: rowId } },
21
27
  order: { createdAt: 'ASC' }
22
28
  });
23
29
  }
@@ -16,7 +16,10 @@ let CounterpartyQuery = class CounterpartyQuery {
16
16
  async counterparty(id, context) {
17
17
  const repository = (0, shell_1.getRepository)(counterparty_1.Counterparty);
18
18
  /* an address names it by its party identifier (an older one by its row id) - counterpartyRowIdOf */
19
- id = (await (0, counterparty_scope_1.counterpartyRowIdOf)(repository.manager, context.state.domain, id)) ?? id;
19
+ const rowId = await (0, counterparty_scope_1.counterpartyRowIdOf)(repository.manager, context.state.domain, id);
20
+ if (!rowId)
21
+ return null;
22
+ id = rowId;
20
23
  const scope = await (0, counterparty_scope_1.counterpartyScopeOf)(repository.manager, context.state.domain);
21
24
  const found = await repository.findOne({ where: { domain: { id: (0, typeorm_1.In)([scope.domainId, scope.ownerId]) }, id } });
22
25
  return found && (0, counterparty_scope_1.isReadableBy)(found, scope) ? found : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/biz-base",
3
- "version": "10.1.319",
3
+ "version": "10.1.320",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "exports": {
@@ -65,9 +65,9 @@
65
65
  "@operato/ops-contract": "^0.9.43",
66
66
  "@operato/popup": "^10.0.0",
67
67
  "@operato/styles": "^10.29.1",
68
- "@things-factory/attachment-base": "^10.1.319",
69
- "@things-factory/auth-base": "^10.1.319",
70
- "@things-factory/fact-change": "^10.1.319"
68
+ "@things-factory/attachment-base": "^10.1.320",
69
+ "@things-factory/auth-base": "^10.1.320",
70
+ "@things-factory/fact-change": "^10.1.320"
71
71
  },
72
- "gitHead": "9740f0f13130271ec920b435b6d833afdf611267"
72
+ "gitHead": "3985f246f6496318e88facbe4321deb3c0bf1b72"
73
73
  }