@hed-hog/finance 0.0.240 → 0.0.245

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.
@@ -188,11 +188,11 @@ LANGUAGE plpgsql
188
188
  AS $$
189
189
  DECLARE
190
190
  v_title_id BIGINT;
191
- v_current_status financial_title_status;
191
+ v_current_status financial_title_status_enum;
192
192
  v_total_installments INTEGER;
193
193
  v_open_installments INTEGER;
194
194
  v_settled_installments INTEGER;
195
- v_next_status financial_title_status;
195
+ v_next_status financial_title_status_enum;
196
196
  BEGIN
197
197
  v_title_id := COALESCE(NEW.title_id, OLD.title_id);
198
198
 
@@ -0,0 +1,70 @@
1
+ -- Adiciona tipos aceitos de arquivo na setting_list para o slug storage-accept-mimetype.
2
+ -- Idempotente: não duplica valores já existentes.
3
+
4
+ WITH target AS (
5
+ SELECT id
6
+ FROM setting
7
+ WHERE slug = 'storage-accept-mimetype'
8
+ FOR UPDATE
9
+ ),
10
+ extra(mime, ord) AS (
11
+ VALUES
12
+ ('text/csv', 1),
13
+ ('application/vnd.ms-excel', 2),
14
+ ('text/plain', 3),
15
+ ('application/ofx', 4),
16
+ ('application/x-ofx', 5),
17
+ ('application/octet-stream', 6)
18
+ ),
19
+ existing AS (
20
+ SELECT sl.setting_id, sl.value
21
+ FROM setting_list sl
22
+ JOIN target t ON t.id = sl.setting_id
23
+ ),
24
+ missing AS (
25
+ SELECT
26
+ t.id AS setting_id,
27
+ e.mime,
28
+ e.ord
29
+ FROM target t
30
+ CROSS JOIN extra e
31
+ LEFT JOIN existing ex
32
+ ON ex.setting_id = t.id
33
+ AND ex.value = e.mime
34
+ WHERE ex.value IS NULL
35
+ ),
36
+ base_order AS (
37
+ SELECT
38
+ t.id AS setting_id,
39
+ COALESCE(MAX(sl."order"), 0) AS max_order
40
+ FROM target t
41
+ LEFT JOIN setting_list sl ON sl.setting_id = t.id
42
+ GROUP BY t.id
43
+ ),
44
+ ordered_missing AS (
45
+ SELECT
46
+ m.setting_id,
47
+ m.mime,
48
+ b.max_order + ROW_NUMBER() OVER (PARTITION BY m.setting_id ORDER BY m.ord) AS next_order
49
+ FROM missing m
50
+ JOIN base_order b ON b.setting_id = m.setting_id
51
+ )
52
+ INSERT INTO setting_list (setting_id, "order", value, created_at, updated_at)
53
+ SELECT
54
+ setting_id,
55
+ next_order,
56
+ mime,
57
+ NOW(),
58
+ NOW()
59
+ FROM ordered_missing;
60
+
61
+ -- Verificação
62
+ SELECT
63
+ s.id,
64
+ s.slug,
65
+ sl."order",
66
+ sl.value
67
+ FROM setting s
68
+ JOIN setting_list sl ON sl.setting_id = s.id
69
+ WHERE s.slug = 'storage-accept-mimetype'
70
+ ORDER BY sl."order";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hed-hog/finance",
3
- "version": "0.0.240",
3
+ "version": "0.0.245",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -9,9 +9,9 @@
9
9
  "@nestjs/core": "^11",
10
10
  "@nestjs/jwt": "^11",
11
11
  "@nestjs/mapped-types": "*",
12
- "@hed-hog/tag": "0.0.240",
13
12
  "@hed-hog/api-pagination": "0.0.5",
14
13
  "@hed-hog/api-prisma": "0.0.4",
14
+ "@hed-hog/tag": "0.0.240",
15
15
  "@hed-hog/api-locale": "0.0.11",
16
16
  "@hed-hog/api": "0.0.3",
17
17
  "@hed-hog/contact": "0.0.240",
@@ -1,2 +0,0 @@
1
- -- Conteúdo consolidado em constraints.sql.
2
- -- Este arquivo é mantido apenas por compatibilidade histórica de nomenclatura.