@things-factory/biz-base 10.1.316 → 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.
- package/dist-client/entity360/counterparty-360.d.ts +23 -0
- package/dist-client/entity360/counterparty-360.js +33 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +1 -0
- package/dist-server/service/counterparty/counterparty-bank-account-mutation.js +6 -2
- package/dist-server/service/counterparty/counterparty-bank-account-query.js +8 -2
- package/dist-server/service/counterparty/counterparty-query.js +5 -0
- package/dist-server/service/counterparty/counterparty-scope.d.ts +12 -0
- package/dist-server/service/counterparty/counterparty-scope.js +20 -0
- package/package.json +5 -5
- package/translations/en.json +2 -1
- package/translations/es.json +2 -1
- package/translations/ja.json +2 -1
- package/translations/ko.json +2 -1
- package/translations/ms.json +2 -1
- package/translations/zh.json +2 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Entity360KindDeclaration, type Entity360Subject } from '@operato/layout';
|
|
2
|
+
/**
|
|
3
|
+
* **The counterparty 360 kind - declared once, here** (ADR-0067, ADR-0211).
|
|
4
|
+
*
|
|
5
|
+
* A counterparty is biz-base's row, shared by every product: the office reads it as a customer or a supplier, the yard
|
|
6
|
+
* as a carrier. The kind - its name, the typename that opens it, its heading - belongs to the module that owns the row,
|
|
7
|
+
* so each product only hangs its own sections on it (`registerEntity360Section('counterparty', …)`). Before this, the
|
|
8
|
+
* office declared the kind itself and a second product would have had to declare it again; the registry refuses a kind
|
|
9
|
+
* named twice, so two products in one app would have fought over it.
|
|
10
|
+
*
|
|
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`).
|
|
16
|
+
*
|
|
17
|
+
* A product may pass what is its own to decide - `assistantSubject` (whether its AI dock follows the open 360) and a
|
|
18
|
+
* `title` / `context` of its own. The kind name and the typename are not the product's to change.
|
|
19
|
+
*/
|
|
20
|
+
export declare const COUNTERPARTY_360_KIND = "counterparty";
|
|
21
|
+
export type Counterparty360Options = Partial<Pick<Entity360KindDeclaration, 'title' | 'context' | 'assistantSubject'>>;
|
|
22
|
+
export declare const counterpartyTitle: ({ value }: Pick<Entity360Subject, "value">) => string;
|
|
23
|
+
export declare function registerCounterparty360(options?: Counterparty360Options): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { i18next } from '@operato/i18n';
|
|
2
|
+
import { registerEntity360Kind } from '@operato/layout';
|
|
3
|
+
/**
|
|
4
|
+
* **The counterparty 360 kind - declared once, here** (ADR-0067, ADR-0211).
|
|
5
|
+
*
|
|
6
|
+
* A counterparty is biz-base's row, shared by every product: the office reads it as a customer or a supplier, the yard
|
|
7
|
+
* as a carrier. The kind - its name, the typename that opens it, its heading - belongs to the module that owns the row,
|
|
8
|
+
* so each product only hangs its own sections on it (`registerEntity360Section('counterparty', …)`). Before this, the
|
|
9
|
+
* office declared the kind itself and a second product would have had to declare it again; the registry refuses a kind
|
|
10
|
+
* named twice, so two products in one app would have fought over it.
|
|
11
|
+
*
|
|
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`).
|
|
17
|
+
*
|
|
18
|
+
* A product may pass what is its own to decide - `assistantSubject` (whether its AI dock follows the open 360) and a
|
|
19
|
+
* `title` / `context` of its own. The kind name and the typename are not the product's to change.
|
|
20
|
+
*/
|
|
21
|
+
export const COUNTERPARTY_360_KIND = 'counterparty';
|
|
22
|
+
export const counterpartyTitle = ({ value }) => value?.name || '';
|
|
23
|
+
export function registerCounterparty360(options = {}) {
|
|
24
|
+
registerEntity360Kind({
|
|
25
|
+
kind: COUNTERPARTY_360_KIND,
|
|
26
|
+
typenames: ['Counterparty'],
|
|
27
|
+
id: value => value?.partyIdentifier || value?.id,
|
|
28
|
+
title: counterpartyTitle,
|
|
29
|
+
context: () => i18next.t('text.entity360-counterparty'),
|
|
30
|
+
...options
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=counterparty-360.js.map
|
package/dist-client/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { CounterpartySelect } from './counterparty-select.js';
|
|
2
2
|
export { CounterpartyRegisterForm } from './counterparty-register-form.js';
|
|
3
3
|
export { COUNTERPARTY_PROVISIONAL_PRIVILEGE, COUNTERPARTY_REGISTER_PRIVILEGE, counterpartyCreatable, counterpartyRegistrationMode, mayRegisterCounterparty, registerCounterparty, type CounterpartyPick } from './counterparty-register.js';
|
|
4
|
+
export { COUNTERPARTY_360_KIND, counterpartyTitle, registerCounterparty360, type Counterparty360Options } from './entity360/counterparty-360.js';
|
package/dist-client/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { CounterpartySelect } from './counterparty-select.js';
|
|
2
2
|
export { CounterpartyRegisterForm } from './counterparty-register-form.js';
|
|
3
3
|
export { COUNTERPARTY_PROVISIONAL_PRIVILEGE, COUNTERPARTY_REGISTER_PRIVILEGE, counterpartyCreatable, counterpartyRegistrationMode, mayRegisterCounterparty, registerCounterparty } from './counterparty-register.js';
|
|
4
|
+
export { COUNTERPARTY_360_KIND, counterpartyTitle, registerCounterparty360 } from './entity360/counterparty-360.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
20
|
-
|
|
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
|
}
|
|
@@ -15,6 +15,11 @@ const counterparty_choice_1 = require("./counterparty-choice");
|
|
|
15
15
|
let CounterpartyQuery = class CounterpartyQuery {
|
|
16
16
|
async counterparty(id, context) {
|
|
17
17
|
const repository = (0, shell_1.getRepository)(counterparty_1.Counterparty);
|
|
18
|
+
/* an address names it by its party identifier (an older one by its row id) - counterpartyRowIdOf */
|
|
19
|
+
const rowId = await (0, counterparty_scope_1.counterpartyRowIdOf)(repository.manager, context.state.domain, id);
|
|
20
|
+
if (!rowId)
|
|
21
|
+
return null;
|
|
22
|
+
id = rowId;
|
|
18
23
|
const scope = await (0, counterparty_scope_1.counterpartyScopeOf)(repository.manager, context.state.domain);
|
|
19
24
|
const found = await repository.findOne({ where: { domain: { id: (0, typeorm_1.In)([scope.domainId, scope.ownerId]) }, id } });
|
|
20
25
|
return found && (0, counterparty_scope_1.isReadableBy)(found, scope) ? found : null;
|
|
@@ -45,3 +45,15 @@ export declare function isReadableBy(row: Pick<Counterparty, 'kind'> & {
|
|
|
45
45
|
* twice names nothing the second time. Returns how many it named.
|
|
46
46
|
*/
|
|
47
47
|
export declare function issueMissingPartyIdentifiers(tx: EntityManager): Promise<number>;
|
|
48
|
+
/**
|
|
49
|
+
* **The counterparty an address names** - by its party identifier, the name it is given outside the database (a 360's address, a
|
|
50
|
+
* link from another screen or product), or by the row id an older address carried; within the counterparties this domain reads.
|
|
51
|
+
* Answers the row id - what a door reads its rows by inside the database - or undefined when no such counterparty is readable here.
|
|
52
|
+
*
|
|
53
|
+
* Addresses carry the party identifier, never the row id (2026-11-28, the user). An address saved before then still opens: a key
|
|
54
|
+
* that is a row id is read as one. A key in neither form is never compared with the row id column (Postgres refuses a text there).
|
|
55
|
+
*/
|
|
56
|
+
export declare function counterpartyRowIdOf(tx: EntityManager, domain: {
|
|
57
|
+
id: string;
|
|
58
|
+
parentId?: string | null;
|
|
59
|
+
}, key: string | null | undefined): Promise<string | undefined>;
|
|
@@ -7,6 +7,7 @@ exports.issuePartyIdentifier = issuePartyIdentifier;
|
|
|
7
7
|
exports.readableBy = readableBy;
|
|
8
8
|
exports.isReadableBy = isReadableBy;
|
|
9
9
|
exports.issueMissingPartyIdentifiers = issueMissingPartyIdentifiers;
|
|
10
|
+
exports.counterpartyRowIdOf = counterpartyRowIdOf;
|
|
10
11
|
const typeorm_1 = require("typeorm");
|
|
11
12
|
const ops_contract_1 = require("@operato/ops-contract");
|
|
12
13
|
const shell_1 = require("@things-factory/shell");
|
|
@@ -115,4 +116,23 @@ async function issueMissingPartyIdentifiers(tx) {
|
|
|
115
116
|
}
|
|
116
117
|
return unnamed.length;
|
|
117
118
|
}
|
|
119
|
+
const ROW_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
120
|
+
/**
|
|
121
|
+
* **The counterparty an address names** - by its party identifier, the name it is given outside the database (a 360's address, a
|
|
122
|
+
* link from another screen or product), or by the row id an older address carried; within the counterparties this domain reads.
|
|
123
|
+
* Answers the row id - what a door reads its rows by inside the database - or undefined when no such counterparty is readable here.
|
|
124
|
+
*
|
|
125
|
+
* Addresses carry the party identifier, never the row id (2026-11-28, the user). An address saved before then still opens: a key
|
|
126
|
+
* that is a row id is read as one. A key in neither form is never compared with the row id column (Postgres refuses a text there).
|
|
127
|
+
*/
|
|
128
|
+
async function counterpartyRowIdOf(tx, domain, key) {
|
|
129
|
+
const said = key?.trim();
|
|
130
|
+
if (!said)
|
|
131
|
+
return undefined;
|
|
132
|
+
const scope = await counterpartyScopeOf(tx, domain);
|
|
133
|
+
const within = { domain: { id: (0, typeorm_1.In)([scope.domainId, scope.ownerId]) } };
|
|
134
|
+
const where = [{ ...within, partyIdentifier: said }, ...(ROW_ID.test(said) ? [{ ...within, id: said }] : [])];
|
|
135
|
+
const found = await tx.getRepository(counterparty_1.Counterparty).findOne({ where: where });
|
|
136
|
+
return found && isReadableBy(found, scope) ? found.id : undefined;
|
|
137
|
+
}
|
|
118
138
|
//# sourceMappingURL=counterparty-scope.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/biz-base",
|
|
3
|
-
"version": "10.1.
|
|
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.
|
|
69
|
-
"@things-factory/auth-base": "^10.1.
|
|
70
|
-
"@things-factory/fact-change": "^10.1.
|
|
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": "
|
|
72
|
+
"gitHead": "3985f246f6496318e88facbe4321deb3c0bf1b72"
|
|
73
73
|
}
|
package/translations/en.json
CHANGED
|
@@ -83,5 +83,6 @@
|
|
|
83
83
|
"task.biz-base.counterparty-registering.name": "Registering counterparties where met",
|
|
84
84
|
"task.biz-base.counterparty-registering.description": "Registers a counterparty first met at a gate, a dock or a sale, provisionally. Does not confirm or merge, and does not read what is kept about counterparties.",
|
|
85
85
|
"text.counterparty-register-provisional-guide": "Registers a counterparty met here, provisionally. It can be used at once; whoever keeps the counterparties confirms it. If its business number is one already registered, that counterparty is taken.",
|
|
86
|
-
"text.counterparty-provisional": "provisional"
|
|
86
|
+
"text.counterparty-provisional": "provisional",
|
|
87
|
+
"text.entity360-counterparty": "counterparty"
|
|
87
88
|
}
|
package/translations/es.json
CHANGED
|
@@ -83,5 +83,6 @@
|
|
|
83
83
|
"task.biz-base.counterparty-registering.name": "Registrar contrapartes en el lugar",
|
|
84
84
|
"task.biz-base.counterparty-registering.description": "Registra de forma provisional una contraparte encontrada por primera vez en una puerta, un muelle o una venta. No confirma ni fusiona, ni lee los datos de las contrapartes.",
|
|
85
85
|
"text.counterparty-register-provisional-guide": "Registra de forma provisional una contraparte encontrada aquí. Se puede usar de inmediato; quien gestiona las contrapartes la confirma. Si su número fiscal ya está registrado, se toma esa contraparte.",
|
|
86
|
-
"text.counterparty-provisional": "provisional"
|
|
86
|
+
"text.counterparty-provisional": "provisional",
|
|
87
|
+
"text.entity360-counterparty": "contraparte"
|
|
87
88
|
}
|
package/translations/ja.json
CHANGED
|
@@ -83,5 +83,6 @@
|
|
|
83
83
|
"task.biz-base.counterparty-registering.name": "取引先の現場登録",
|
|
84
84
|
"task.biz-base.counterparty-registering.description": "ゲート・ドック・営業の現場で初めて会った取引先を仮登録します。確定・統合や取引先情報の閲覧はしません。",
|
|
85
85
|
"text.counterparty-register-provisional-guide": "ここで会った取引先を仮登録します。すぐに使え、取引先を管理する側が確認して確定します。事業者番号が登録済みの取引先と同じなら、その取引先を選びます。",
|
|
86
|
-
"text.counterparty-provisional": "仮"
|
|
86
|
+
"text.counterparty-provisional": "仮",
|
|
87
|
+
"text.entity360-counterparty": "取引先"
|
|
87
88
|
}
|
package/translations/ko.json
CHANGED
|
@@ -83,5 +83,6 @@
|
|
|
83
83
|
"task.biz-base.counterparty-registering.name": "거래처 현장 등록",
|
|
84
84
|
"task.biz-base.counterparty-registering.description": "게이트 · 도크 · 영업 현장에서 처음 만난 거래처를 임시로 등록합니다. 확정 · 합치기와 거래처 정보 읽기는 하지 않습니다.",
|
|
85
85
|
"text.counterparty-register-provisional-guide": "처음 만난 거래처를 임시로 등록합니다. 바로 쓸 수 있고, 거래처를 관리하는 쪽이 확인한 뒤 확정합니다. 사업자번호가 이미 등록된 거래처와 같으면 그 거래처를 고릅니다.",
|
|
86
|
-
"text.counterparty-provisional": "임시"
|
|
86
|
+
"text.counterparty-provisional": "임시",
|
|
87
|
+
"text.entity360-counterparty": "거래처"
|
|
87
88
|
}
|
package/translations/ms.json
CHANGED
|
@@ -83,5 +83,6 @@
|
|
|
83
83
|
"task.biz-base.counterparty-registering.name": "Mendaftar rakan niaga di tempat",
|
|
84
84
|
"task.biz-base.counterparty-registering.description": "Mendaftar secara sementara rakan niaga yang pertama kali ditemui di pintu masuk, dok atau jualan. Tidak mengesahkan atau menggabungkan, dan tidak membaca maklumat rakan niaga.",
|
|
85
85
|
"text.counterparty-register-provisional-guide": "Mendaftar secara sementara rakan niaga yang ditemui di sini. Ia boleh digunakan serta-merta; pengurus rakan niaga akan mengesahkannya. Jika nombor perniagaannya sudah didaftarkan, rakan niaga itu dipilih.",
|
|
86
|
-
"text.counterparty-provisional": "sementara"
|
|
86
|
+
"text.counterparty-provisional": "sementara",
|
|
87
|
+
"text.entity360-counterparty": "rakan niaga"
|
|
87
88
|
}
|
package/translations/zh.json
CHANGED
|
@@ -83,5 +83,6 @@
|
|
|
83
83
|
"task.biz-base.counterparty-registering.name": "现场登记往来单位",
|
|
84
84
|
"task.biz-base.counterparty-registering.description": "在闸口、码头或销售现场临时登记初次遇到的往来单位。不进行确认、合并,也不读取往来单位的详细信息。",
|
|
85
85
|
"text.counterparty-register-provisional-guide": "临时登记在此遇到的往来单位。可立即使用,由管理往来单位的一方确认。若营业执照号与已登记单位相同,则选用该单位。",
|
|
86
|
-
"text.counterparty-provisional": "临时"
|
|
86
|
+
"text.counterparty-provisional": "临时",
|
|
87
|
+
"text.entity360-counterparty": "往来单位"
|
|
87
88
|
}
|