Skip to content

Commit 4f50c96

Browse files
committed
MODFQMMGR-746 Switch to mod-settings for tenant addresses
1 parent aef945e commit 4f50c96

8 files changed

Lines changed: 141 additions & 35 deletions

File tree

src/main/resources/db/source-views/bundled/configuration/mod-configuration/src_configuration_config_data.json5

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
name: 'src_configuration_tenant_addresses',
3+
dependsOn: [['${tenant_id}_mod_settings', 'tenant_addresses']],
4+
sql: 'SELECT * FROM ${tenant_id}_mod_settings.tenant_addresses',
5+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
id: '3fe1b126-52d1-4b72-a346-9a73721c6931',
3+
name: 'simple_tenant_addresses',
4+
private: true,
5+
sources: [
6+
{
7+
type: 'db',
8+
alias: 'addr',
9+
target: 'src_configuration_tenant_addresses',
10+
},
11+
],
12+
requiredPermissions: [
13+
'tenant-addresses.collection.get'
14+
],
15+
columns: [
16+
{
17+
name: 'id',
18+
dataType: {
19+
dataType: 'rangedUUIDType',
20+
},
21+
isIdColumn: true,
22+
queryable: true,
23+
visibleByDefault: false,
24+
hidden: true,
25+
essential: true,
26+
valueGetter: ':addr.id',
27+
},
28+
{
29+
name: 'name',
30+
dataType: {
31+
dataType: 'stringType',
32+
},
33+
isIdColumn: false,
34+
queryable: true,
35+
visibleByDefault: false,
36+
essential: true,
37+
valueGetter: ":addr.name",
38+
source: {
39+
entityTypeId: '3fe1b126-52d1-4b72-a346-9a73721c6931',
40+
columnName: 'name',
41+
},
42+
valueSourceApi: {
43+
path: 'tenant-addresses',
44+
valueJsonPath: '$.addresses.*.name',
45+
labelJsonPath: '$.addresses.*.name',
46+
},
47+
},
48+
{
49+
name: 'address',
50+
sourceAlias: 'addr',
51+
dataType: {
52+
dataType: 'stringType',
53+
},
54+
isIdColumn: false,
55+
queryable: true,
56+
visibleByDefault: true,
57+
essential: true,
58+
valueGetter: ":sourceAlias.address",
59+
idColumnName: 'id',
60+
source: {
61+
entityTypeId: '3fe1b126-52d1-4b72-a346-9a73721c6931',
62+
columnName: 'address',
63+
},
64+
valueSourceApi: {
65+
path: 'tenant-addresses',
66+
valueJsonPath: '$.addresses.*.id',
67+
labelJsonPath: '$.addresses.*.address',
68+
}
69+
},
70+
],
71+
defaultSort: [
72+
{
73+
columnName: 'id',
74+
direction: 'ASC',
75+
},
76+
],
77+
}

src/main/resources/entity-types/finance/simple_exchange_rate.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
],
2323
requiredPermissions: [
2424
"finance.exchange-rate.item.get",
25-
"configuration.entries.collection.get", // Not directly used here, but this is required to populate currency_exchange_rates; users without this permission can't access the configured system currency, so we shouldn't expose it here
25+
"locale.item.get", // Not directly used here, but this is required to populate currency_exchange_rates; users without this permission can't access the configured system currency, so we shouldn't expose it here
2626
],
2727
columns: [
2828
{
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
id: '5c4cb0c9-c8bf-4fe5-b844-4de90ca445dc',
3+
name: 'composite_invoice',
4+
private: false,
5+
sources: [
6+
{
7+
alias: 'invoice',
8+
type: 'entity-type',
9+
targetId: '4d626ce1-1880-48d2-9d4c-81667fdc5dbb', // simple_invoice
10+
targetField: 'id',
11+
sourceField: 'invoice_line.invoice_id',
12+
useIdColumns: true,
13+
essentialOnly: false,
14+
order: 10,
15+
},
16+
{
17+
alias: 'bill_to',
18+
type: 'entity-type',
19+
targetId: '3fe1b126-52d1-4b72-a346-9a73721c6931', // simple_tenant_addresses
20+
targetField: 'id',
21+
sourceField: 'invoice.bill_to_id',
22+
essentialOnly: true,
23+
order: 20,
24+
},
25+
],
26+
defaultSort: [
27+
{
28+
columnName: '"invoice.invoice".id',
29+
direction: 'ASC',
30+
},
31+
],
32+
}

src/main/resources/entity-types/invoice/simple_invoice.json5

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
id: '4d626ce1-1880-48d2-9d4c-81667fdc5dbb',
33
name: 'simple_invoice',
4-
private: false,
4+
private: true,
55
requiredPermissions: [
66
'invoice.invoices.collection.get',
77
'acquisitions-units.units.collection.get',
88
'finance.fiscal-years.collection.get',
99
'batch-groups.collection.get',
1010
'users.collection.get',
11-
'configuration.entries.collection.get',
1211
'invoice.invoice-lines.collection.get',
1312
'organizations.organizations.collection.get'
1413
],
@@ -149,32 +148,14 @@
149148
essential: true,
150149
hidden: true,
151150
valueGetter: ":invoice.jsonb->>'billTo'",
152-
},
153-
{
154-
name: 'bill_to',
155-
dataType: {
156-
dataType: 'stringType',
157-
},
158-
queryable: false,
159-
visibleByDefault: false,
160-
essential: true,
161-
valueGetter: "( \
162-
SELECT \
163-
(config_data.jsonb ->> 'value')::jsonb ->> 'address' \
164-
FROM \
165-
${tenant_id}_mod_fqm_manager.src_configuration_config_data config_data \
166-
WHERE \
167-
config_data.id = (:invoice.jsonb ->> 'billTo')::uuid \
168-
)",
169-
filterValueGetter: "( \
170-
SELECT \
171-
lower((config_data.jsonb ->> 'value')::jsonb ->> 'address') \
172-
FROM \
173-
${tenant_id}_mod_fqm_manager.src_configuration_config_data config_data \
174-
WHERE \
175-
config_data.id = (:invoice.jsonb ->> 'billTo')::uuid \
176-
)",
177-
valueFunction: 'lower(:value)',
151+
joinsTo: [
152+
{
153+
targetId: '3fe1b126-52d1-4b72-a346-9a73721c6931', // simple_tenant_addresses
154+
targetField: 'id',
155+
type: 'equality-cast-uuid',
156+
direction: 'left',
157+
},
158+
]
178159
},
179160
{
180161
name: 'chk_subscription_overlap',

src/main/resources/entity-types/orders/purchase_order_lines.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
// Technically, these 2 permissions get inherited from the exchange rate source, but since the table is used directly here, too, the permissions are included here
8888
// If we can remove the explicit reference to the currency_exchange_rates table, then we can remove these from this entity type and just inherit them
8989
'finance.exchange-rate.item.get',
90-
'configuration.entries.collection.get', // This isn't directly used here, but this is required to populate currency_exchange_rates; users without this permission can't access the configured system currency, so we shouldn't expose it here
90+
'locale.item.get', // This isn't directly used here, but this is required to populate currency_exchange_rates; users without this permission can't access the configured system currency, so we shouldn't expose it here
9191
],
9292
columns: [
9393
{

src/main/resources/entity-types/orders/simple_purchase_order.json5

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@
112112
queryable: true,
113113
visibleByDefault: false,
114114
valueGetter: ":sourceAlias.jsonb->>'billTo'",
115+
joinsTo: [
116+
{
117+
targetId: '3fe1b126-52d1-4b72-a346-9a73721c6931', // simple_tenant_addresses
118+
targetField: 'id',
119+
type: 'equality-cast-uuid',
120+
direction: 'left',
121+
},
122+
],
115123
},
116124
{
117125
name: 'close_reason',
@@ -290,6 +298,14 @@
290298
queryable: true,
291299
visibleByDefault: false,
292300
valueGetter: ":sourceAlias.jsonb->>'shipTo'",
301+
joinsTo: [
302+
{
303+
targetId: '3fe1b126-52d1-4b72-a346-9a73721c6931', // simple_tenant_addresses
304+
targetField: 'id',
305+
type: 'equality-cast-uuid',
306+
direction: 'left',
307+
},
308+
]
293309
},
294310
{
295311
name: 'template',

0 commit comments

Comments
 (0)