@opengis/pay 1.1.11 → 1.1.13

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.
@@ -1,59 +1,59 @@
1
- create schema if not exists billing;
2
-
3
- CREATE TABLE if not exists billing.accounts();
4
-
5
- ALTER TABLE billing.accounts DROP CONSTRAINT if exists billing_account_account_id_pkey cascade;
6
- ALTER TABLE billing.accounts DROP CONSTRAINT if exists billing_account_account_edrpou_unique cascade;
7
-
8
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_id text NOT NULL DEFAULT next_id();
9
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_name text NOT NULL;
10
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_edrpou text;
11
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_email text;
12
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
13
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
14
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS uid text NOT NULL;
15
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS editor_id text;
16
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
17
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS files json;
18
-
19
- COMMENT ON TABLE billing.accounts IS 'Акаунти';
20
- COMMENT ON COLUMN billing.accounts.account_id IS 'ID';
21
- COMMENT ON COLUMN billing.accounts.account_name IS 'Назва';
22
- COMMENT ON COLUMN billing.accounts.account_edrpou IS 'Код ЄДРПОУ';
23
- COMMENT ON COLUMN billing.accounts.enabled IS 'On / Off';
24
-
25
- CREATE TABLE IF NOT EXISTS billing.account_user();
26
-
27
- ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_au_id_pkey cascade;
28
- ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_account_id_fkey cascade;
29
- ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_user_id_fkey;
30
- ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_account_id_user_id_unique;
31
-
32
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS au_id text NOT NULL DEFAULT next_id();
33
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS account_id text NOT NULL;
34
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS user_id text NOT NULL;
35
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
36
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS uid text NOT NULL;
37
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS editor_id text;
38
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
39
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS files json;
40
-
41
- COMMENT ON TABLE billing.account_user IS 'Відношення акаунтів та користувачів';
42
- COMMENT ON COLUMN billing.account_user.au_id IS 'ID';
43
- COMMENT ON COLUMN billing.account_user.account_id IS 'Акаунт організації';
44
- COMMENT ON COLUMN billing.account_user.user_id IS 'Акаунт користувача';
45
-
46
- CREATE INDEX if not exists billing_account_user_account_id_btree_idx ON billing.account_user USING btree (account_id COLLATE pg_catalog."default");
47
- CREATE INDEX if not exists billing_account_user_account_id_trgm_idx ON billing.account_user USING gin (account_id COLLATE pg_catalog."default" gin_trgm_ops);
48
- CREATE INDEX if not exists billing_account_user_user_id_btree_idx ON billing.account_user USING btree (user_id COLLATE pg_catalog."default");
49
- CREATE INDEX if not exists billing_account_user_user_id_trgm_idx ON billing.account_user USING gin (user_id COLLATE pg_catalog."default" gin_trgm_ops);
50
-
51
- ALTER TABLE billing.accounts ADD CONSTRAINT billing_account_account_id_pkey PRIMARY KEY (account_id);
52
- ALTER TABLE billing.accounts ADD CONSTRAINT billing_account_account_edrpou_unique UNIQUE (account_edrpou);
53
-
54
- ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_au_id_pkey PRIMARY KEY (au_id);
55
- ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_account_id_fkey FOREIGN KEY (account_id)
56
- REFERENCES billing.accounts (account_id);
57
- ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_user_id_fkey FOREIGN KEY (user_id)
58
- REFERENCES billing.users (user_id);
59
- ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_account_id_user_id_unique UNIQUE (account_id,user_id);
1
+ create schema if not exists billing;
2
+
3
+ CREATE TABLE if not exists billing.accounts();
4
+
5
+ ALTER TABLE billing.accounts DROP CONSTRAINT if exists billing_account_account_id_pkey cascade;
6
+ ALTER TABLE billing.accounts DROP CONSTRAINT if exists billing_account_account_edrpou_unique cascade;
7
+
8
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_id text NOT NULL DEFAULT next_id();
9
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_name text NOT NULL;
10
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_edrpou text;
11
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_email text;
12
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
13
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
14
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS uid text NOT NULL;
15
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS editor_id text;
16
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
17
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS files json;
18
+
19
+ COMMENT ON TABLE billing.accounts IS 'Акаунти';
20
+ COMMENT ON COLUMN billing.accounts.account_id IS 'ID';
21
+ COMMENT ON COLUMN billing.accounts.account_name IS 'Назва';
22
+ COMMENT ON COLUMN billing.accounts.account_edrpou IS 'Код ЄДРПОУ';
23
+ COMMENT ON COLUMN billing.accounts.enabled IS 'On / Off';
24
+
25
+ CREATE TABLE IF NOT EXISTS billing.account_user();
26
+
27
+ ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_au_id_pkey cascade;
28
+ ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_account_id_fkey cascade;
29
+ ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_user_id_fkey;
30
+ ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_account_id_user_id_unique;
31
+
32
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS au_id text NOT NULL DEFAULT next_id();
33
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS account_id text NOT NULL;
34
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS user_id text NOT NULL;
35
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
36
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS uid text NOT NULL;
37
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS editor_id text;
38
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
39
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS files json;
40
+
41
+ COMMENT ON TABLE billing.account_user IS 'Відношення акаунтів та користувачів';
42
+ COMMENT ON COLUMN billing.account_user.au_id IS 'ID';
43
+ COMMENT ON COLUMN billing.account_user.account_id IS 'Акаунт організації';
44
+ COMMENT ON COLUMN billing.account_user.user_id IS 'Акаунт користувача';
45
+
46
+ CREATE INDEX if not exists billing_account_user_account_id_btree_idx ON billing.account_user USING btree (account_id COLLATE pg_catalog."default");
47
+ CREATE INDEX if not exists billing_account_user_account_id_trgm_idx ON billing.account_user USING gin (account_id COLLATE pg_catalog."default" gin_trgm_ops);
48
+ CREATE INDEX if not exists billing_account_user_user_id_btree_idx ON billing.account_user USING btree (user_id COLLATE pg_catalog."default");
49
+ CREATE INDEX if not exists billing_account_user_user_id_trgm_idx ON billing.account_user USING gin (user_id COLLATE pg_catalog."default" gin_trgm_ops);
50
+
51
+ ALTER TABLE billing.accounts ADD CONSTRAINT billing_account_account_id_pkey PRIMARY KEY (account_id);
52
+ ALTER TABLE billing.accounts ADD CONSTRAINT billing_account_account_edrpou_unique UNIQUE (account_edrpou);
53
+
54
+ ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_au_id_pkey PRIMARY KEY (au_id);
55
+ ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_account_id_fkey FOREIGN KEY (account_id)
56
+ REFERENCES billing.accounts (account_id);
57
+ ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_user_id_fkey FOREIGN KEY (user_id)
58
+ REFERENCES billing.users (user_id);
59
+ ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_account_id_user_id_unique UNIQUE (account_id,user_id);
@@ -1,74 +1,74 @@
1
- create schema if not exists billing;
2
-
3
- CREATE TABLE IF NOT EXISTS billing.products();
4
- ALTER TABLE billing.products DROP CONSTRAINT IF EXISTS billing_product_id_pkey CASCADE;
5
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS product_id text not null default next_id();
6
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS name text not null;
7
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS description text;
8
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS price_type text;
9
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS image text;
10
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
11
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
12
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS uid text NOT NULL;
13
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS editor_id text;
14
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
15
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS files json;
16
-
17
- CREATE TABLE IF NOT EXISTS billing.plans();
18
- ALTER TABLE billing.plans DROP CONSTRAINT IF EXISTS billing_plan_id_pkey CASCADE;
19
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS plan_id text not null default next_id();
20
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS name text not null;
21
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
22
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS multiplier numeric not null default 0;
23
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
24
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS uid text NOT NULL;
25
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS editor_id text;
26
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
27
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS files json;
28
-
29
- CREATE TABLE IF NOT EXISTS billing.product_plans();
30
- ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_plan_id_pkey CASCADE;
31
- ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_product_id_fkey CASCADE;
32
- ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_plan_id_fkey CASCADE;
33
-
34
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS product_plan_id text not null default next_id();
35
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS product_id text not null;
36
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS plan_id text not null;
37
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS price numeric not null default 0;
38
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS max_unit numeric not null default 1;
39
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS enabled boolean default true;
40
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
41
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS uid text NOT NULL;
42
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS editor_id text;
43
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
44
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS files json;
45
-
46
- ALTER TABLE billing.products ADD CONSTRAINT billing_product_id_pkey PRIMARY KEY (product_id);
47
- ALTER TABLE billing.plans ADD CONSTRAINT billing_plan_id_pkey PRIMARY KEY (plan_id);
48
-
49
- ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_plan_id_pkey PRIMARY KEY (product_plan_id);
50
- ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_product_id_fkey FOREIGN KEY (product_id)
51
- REFERENCES billing.products (product_id);
52
- ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_plan_id_fkey FOREIGN KEY (plan_id)
53
- REFERENCES billing.plans (plan_id);
54
-
55
- COMMENT ON TABLE billing.products IS 'Товари (послуги)';
56
- COMMENT ON COLUMN billing.products.product_id IS 'ID';
57
- COMMENT ON COLUMN billing.products.name IS 'Назва';
58
- COMMENT ON COLUMN billing.products.description IS 'Опис';
59
- COMMENT ON COLUMN billing.products.price_type IS 'Тип плати (account/unit)';
60
- COMMENT ON COLUMN billing.products.image is 'Зображення';
61
- COMMENT ON COLUMN billing.products.enabled is 'On / Off';
62
-
63
- COMMENT ON TABLE billing.plans IS 'Перелік тарифних планів';
64
- COMMENT ON COLUMN billing.plans.plan_id IS 'ID';
65
- COMMENT ON COLUMN billing.plans.name IS 'Назва';
66
- COMMENT ON COLUMN billing.plans.enabled is 'On / Off';
67
-
68
- COMMENT ON TABLE billing.product_plans IS 'Відношення планів та товарів (послуг)';
69
- COMMENT ON COLUMN billing.product_plans.product_plan_id is 'ID';
70
- COMMENT ON COLUMN billing.product_plans.product_id is 'ID товару (послуги)';
71
- COMMENT ON COLUMN billing.product_plans.plan_id is 'ID тарифного плану';
72
- COMMENT ON COLUMN billing.product_plans.price is 'Вартість';
73
- COMMENT ON COLUMN billing.product_plans.max_unit is 'Максимальна кількість користувачів в межах тарифу';
1
+ create schema if not exists billing;
2
+
3
+ CREATE TABLE IF NOT EXISTS billing.products();
4
+ ALTER TABLE billing.products DROP CONSTRAINT IF EXISTS billing_product_id_pkey CASCADE;
5
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS product_id text not null default next_id();
6
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS name text not null;
7
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS description text;
8
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS price_type text;
9
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS image text;
10
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
11
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
12
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS uid text NOT NULL;
13
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS editor_id text;
14
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
15
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS files json;
16
+
17
+ CREATE TABLE IF NOT EXISTS billing.plans();
18
+ ALTER TABLE billing.plans DROP CONSTRAINT IF EXISTS billing_plan_id_pkey CASCADE;
19
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS plan_id text not null default next_id();
20
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS name text not null;
21
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
22
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS multiplier numeric not null default 0;
23
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
24
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS uid text NOT NULL;
25
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS editor_id text;
26
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
27
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS files json;
28
+
29
+ CREATE TABLE IF NOT EXISTS billing.product_plans();
30
+ ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_plan_id_pkey CASCADE;
31
+ ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_product_id_fkey CASCADE;
32
+ ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_plan_id_fkey CASCADE;
33
+
34
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS product_plan_id text not null default next_id();
35
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS product_id text not null;
36
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS plan_id text not null;
37
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS price numeric not null default 0;
38
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS max_unit numeric not null default 1;
39
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS enabled boolean default true;
40
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
41
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS uid text NOT NULL;
42
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS editor_id text;
43
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
44
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS files json;
45
+
46
+ ALTER TABLE billing.products ADD CONSTRAINT billing_product_id_pkey PRIMARY KEY (product_id);
47
+ ALTER TABLE billing.plans ADD CONSTRAINT billing_plan_id_pkey PRIMARY KEY (plan_id);
48
+
49
+ ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_plan_id_pkey PRIMARY KEY (product_plan_id);
50
+ ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_product_id_fkey FOREIGN KEY (product_id)
51
+ REFERENCES billing.products (product_id);
52
+ ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_plan_id_fkey FOREIGN KEY (plan_id)
53
+ REFERENCES billing.plans (plan_id);
54
+
55
+ COMMENT ON TABLE billing.products IS 'Товари (послуги)';
56
+ COMMENT ON COLUMN billing.products.product_id IS 'ID';
57
+ COMMENT ON COLUMN billing.products.name IS 'Назва';
58
+ COMMENT ON COLUMN billing.products.description IS 'Опис';
59
+ COMMENT ON COLUMN billing.products.price_type IS 'Тип плати (account/unit)';
60
+ COMMENT ON COLUMN billing.products.image is 'Зображення';
61
+ COMMENT ON COLUMN billing.products.enabled is 'On / Off';
62
+
63
+ COMMENT ON TABLE billing.plans IS 'Перелік тарифних планів';
64
+ COMMENT ON COLUMN billing.plans.plan_id IS 'ID';
65
+ COMMENT ON COLUMN billing.plans.name IS 'Назва';
66
+ COMMENT ON COLUMN billing.plans.enabled is 'On / Off';
67
+
68
+ COMMENT ON TABLE billing.product_plans IS 'Відношення планів та товарів (послуг)';
69
+ COMMENT ON COLUMN billing.product_plans.product_plan_id is 'ID';
70
+ COMMENT ON COLUMN billing.product_plans.product_id is 'ID товару (послуги)';
71
+ COMMENT ON COLUMN billing.product_plans.plan_id is 'ID тарифного плану';
72
+ COMMENT ON COLUMN billing.product_plans.price is 'Вартість';
73
+ COMMENT ON COLUMN billing.product_plans.max_unit is 'Максимальна кількість користувачів в межах тарифу';
74
74
  COMMENT ON COLUMN billing.product_plans.enabled is 'On / Off';
@@ -1,36 +1,36 @@
1
- create schema if not exists billing;
2
-
3
- CREATE TABLE if not exists billing.subscriptions();
4
- alter table billing.subscriptions drop constraint if exists billing_subscriptions_subscription_id_pkey cascade;
5
- alter table billing.subscriptions drop constraint if exists billing_subscriptions_account_id_fkey cascade;
6
- alter table billing.subscriptions drop constraint if exists billing_subscriptions_product_id_fkey cascade;
7
- alter table billing.subscriptions drop constraint if exists billing_subscriptions_plan_id_fkey cascade;
8
-
9
- alter table billing.subscriptions add column if not exists subscription_id text not null default next_id();
10
- alter table billing.subscriptions add column if not exists account_id text not null;
11
- alter table billing.subscriptions add column if not exists product_id text not null;
12
- alter table billing.subscriptions add column if not exists product_plan_id text not null;
13
- alter table billing.subscriptions add column if not exists is_trial boolean not null default false;
14
- alter table billing.subscriptions add column if not exists start_date date not null default CURRENT_DATE;
15
- alter table billing.subscriptions add column if not exists cdate timestamp without time zone default date_trunc('seconds'::text, now());
16
- alter table billing.subscriptions add column if not exists uid text not null;
17
- alter table billing.subscriptions add column if not exists editor_id text;
18
- alter table billing.subscriptions add column if not exists editor_date timestamp without time zone;
19
- alter table billing.subscriptions add column if not exists files json;
20
-
21
- ALTER TABLE billing.subscriptions add constraint billing_subscriptions_subscription_id_pkey PRIMARY KEY(subscription_id);
22
- ALTER TABLE billing.subscriptions add constraint billing_subscriptions_account_id_fkey FOREIGN KEY(account_id)
23
- REFERENCES billing.accounts (account_id);
24
- ALTER TABLE billing.subscriptions add constraint billing_subscriptions_product_id_fkey FOREIGN KEY(product_id)
25
- REFERENCES billing.products (product_id);
26
- ALTER TABLE billing.subscriptions add constraint billing_subscriptions_plan_id_fkey FOREIGN KEY(product_plan_id)
27
- REFERENCES billing.product_plans (product_plan_id);
28
-
29
- COMMENT ON TABLE billing.subscriptions IS 'Підписки';
30
- COMMENT ON COLUMN billing.subscriptions.subscription_id IS 'ID';
31
-
32
- COMMENT ON COLUMN billing.subscriptions.account_id IS 'ID акаунту';
33
- COMMENT ON COLUMN billing.subscriptions.product_id IS 'ID товару';
34
- COMMENT ON COLUMN billing.subscriptions.product_plan_id IS 'ID тарифного плану';
35
- COMMENT ON COLUMN billing.subscriptions.is_trial IS 'Випробувальний строк';
1
+ create schema if not exists billing;
2
+
3
+ CREATE TABLE if not exists billing.subscriptions();
4
+ alter table billing.subscriptions drop constraint if exists billing_subscriptions_subscription_id_pkey cascade;
5
+ alter table billing.subscriptions drop constraint if exists billing_subscriptions_account_id_fkey cascade;
6
+ alter table billing.subscriptions drop constraint if exists billing_subscriptions_product_id_fkey cascade;
7
+ alter table billing.subscriptions drop constraint if exists billing_subscriptions_plan_id_fkey cascade;
8
+
9
+ alter table billing.subscriptions add column if not exists subscription_id text not null default next_id();
10
+ alter table billing.subscriptions add column if not exists account_id text not null;
11
+ alter table billing.subscriptions add column if not exists product_id text not null;
12
+ alter table billing.subscriptions add column if not exists product_plan_id text not null;
13
+ alter table billing.subscriptions add column if not exists is_trial boolean not null default false;
14
+ alter table billing.subscriptions add column if not exists start_date date not null default CURRENT_DATE;
15
+ alter table billing.subscriptions add column if not exists cdate timestamp without time zone default date_trunc('seconds'::text, now());
16
+ alter table billing.subscriptions add column if not exists uid text not null;
17
+ alter table billing.subscriptions add column if not exists editor_id text;
18
+ alter table billing.subscriptions add column if not exists editor_date timestamp without time zone;
19
+ alter table billing.subscriptions add column if not exists files json;
20
+
21
+ ALTER TABLE billing.subscriptions add constraint billing_subscriptions_subscription_id_pkey PRIMARY KEY(subscription_id);
22
+ ALTER TABLE billing.subscriptions add constraint billing_subscriptions_account_id_fkey FOREIGN KEY(account_id)
23
+ REFERENCES billing.accounts (account_id);
24
+ ALTER TABLE billing.subscriptions add constraint billing_subscriptions_product_id_fkey FOREIGN KEY(product_id)
25
+ REFERENCES billing.products (product_id);
26
+ ALTER TABLE billing.subscriptions add constraint billing_subscriptions_plan_id_fkey FOREIGN KEY(product_plan_id)
27
+ REFERENCES billing.product_plans (product_plan_id);
28
+
29
+ COMMENT ON TABLE billing.subscriptions IS 'Підписки';
30
+ COMMENT ON COLUMN billing.subscriptions.subscription_id IS 'ID';
31
+
32
+ COMMENT ON COLUMN billing.subscriptions.account_id IS 'ID акаунту';
33
+ COMMENT ON COLUMN billing.subscriptions.product_id IS 'ID товару';
34
+ COMMENT ON COLUMN billing.subscriptions.product_plan_id IS 'ID тарифного плану';
35
+ COMMENT ON COLUMN billing.subscriptions.is_trial IS 'Випробувальний строк';
36
36
  COMMENT ON COLUMN billing.subscriptions.start_date IS 'Дата початку дії підписки';
@@ -1,37 +1,37 @@
1
- create schema if not exists billing;
2
-
3
- CREATE TABLE if not exists billing.payments();
4
- alter table billing.payments drop constraint if exists billing_payments_payment_id_pkey cascade;
5
- alter table billing.payments drop constraint if exists billing_payments_payment_id_account_id_fkey cascade;
6
-
7
- alter table billing.payments add column if not exists payment_id text NOT NULL default next_id();
8
- alter table billing.payments add column if not exists account_id text;
9
- alter table billing.payments alter column account_id drop NOT NULL;
10
- alter table billing.payments add column if not exists payment_status text NOT NULL DEFAULT 'inprogress'::text;
11
- alter table billing.payments add column if not exists success_date timestamp with time zone;
12
- alter table billing.payments add column if not exists payment_data json;
13
- alter table billing.payments add column if not exists payment_amount numeric;
14
- alter table billing.payments add column if not exists total_balance numeric;
15
- alter table billing.payments add column if not exists referer_url text;
16
- alter table billing.payments add column if not exists cdate timestamp without time zone DEFAULT now();
17
- alter table billing.payments add column if not exists uid text NOT NULL;
18
- alter table billing.payments add column if not exists editor_id text;
19
- alter table billing.payments add column if not exists editor_date timestamp without time zone;
20
- alter table billing.payments add column if not exists files json;
21
-
22
- COMMENT ON TABLE billing.payments IS 'Платежі';
23
- COMMENT ON COLUMN billing.payments.payment_id IS 'ID';
24
- COMMENT ON COLUMN billing.payments.account_id IS 'ID акаунту клієнта';
25
- COMMENT ON COLUMN billing.payments.payment_status IS 'Статус транзації';
26
- COMMENT ON COLUMN billing.payments.success_date IS 'Дата успішного завершення транзакції';
27
- COMMENT ON COLUMN billing.payments.payment_data IS 'Дані від portmone';
28
- COMMENT ON COLUMN billing.payments.payment_amount IS 'Сума поповнення рахунку';
29
- COMMENT ON COLUMN billing.payments.total_balance IS 'Поточний баланс';
30
- COMMENT ON COLUMN billing.payments.referer_url IS 'Посилання';
31
-
32
- CREATE INDEX if not exists billing_payments_account_id_btree_idx ON billing.payments USING btree (account_id COLLATE pg_catalog."default");
33
- CREATE INDEX if not exists billing_payments_account_id_trgm_idx ON billing.payments USING gin (account_id COLLATE pg_catalog."default" gin_trgm_ops);
34
- CREATE INDEX if not exists billing_payments_payments_status_btree_idx ON billing.payments USING btree (payment_status COLLATE pg_catalog."default");
35
-
36
- alter table billing.payments add CONSTRAINT billing_payments_payment_id_pkey PRIMARY KEY (payment_id);
1
+ create schema if not exists billing;
2
+
3
+ CREATE TABLE if not exists billing.payments();
4
+ alter table billing.payments drop constraint if exists billing_payments_payment_id_pkey cascade;
5
+ alter table billing.payments drop constraint if exists billing_payments_payment_id_account_id_fkey cascade;
6
+
7
+ alter table billing.payments add column if not exists payment_id text NOT NULL default next_id();
8
+ alter table billing.payments add column if not exists account_id text;
9
+ alter table billing.payments alter column account_id drop NOT NULL;
10
+ alter table billing.payments add column if not exists payment_status text NOT NULL DEFAULT 'inprogress'::text;
11
+ alter table billing.payments add column if not exists success_date timestamp with time zone;
12
+ alter table billing.payments add column if not exists payment_data json;
13
+ alter table billing.payments add column if not exists payment_amount numeric;
14
+ alter table billing.payments add column if not exists total_balance numeric;
15
+ alter table billing.payments add column if not exists referer_url text;
16
+ alter table billing.payments add column if not exists cdate timestamp without time zone DEFAULT now();
17
+ alter table billing.payments add column if not exists uid text NOT NULL;
18
+ alter table billing.payments add column if not exists editor_id text;
19
+ alter table billing.payments add column if not exists editor_date timestamp without time zone;
20
+ alter table billing.payments add column if not exists files json;
21
+
22
+ COMMENT ON TABLE billing.payments IS 'Платежі';
23
+ COMMENT ON COLUMN billing.payments.payment_id IS 'ID';
24
+ COMMENT ON COLUMN billing.payments.account_id IS 'ID акаунту клієнта';
25
+ COMMENT ON COLUMN billing.payments.payment_status IS 'Статус транзації';
26
+ COMMENT ON COLUMN billing.payments.success_date IS 'Дата успішного завершення транзакції';
27
+ COMMENT ON COLUMN billing.payments.payment_data IS 'Дані від portmone';
28
+ COMMENT ON COLUMN billing.payments.payment_amount IS 'Сума поповнення рахунку';
29
+ COMMENT ON COLUMN billing.payments.total_balance IS 'Поточний баланс';
30
+ COMMENT ON COLUMN billing.payments.referer_url IS 'Посилання';
31
+
32
+ CREATE INDEX if not exists billing_payments_account_id_btree_idx ON billing.payments USING btree (account_id COLLATE pg_catalog."default");
33
+ CREATE INDEX if not exists billing_payments_account_id_trgm_idx ON billing.payments USING gin (account_id COLLATE pg_catalog."default" gin_trgm_ops);
34
+ CREATE INDEX if not exists billing_payments_payments_status_btree_idx ON billing.payments USING btree (payment_status COLLATE pg_catalog."default");
35
+
36
+ alter table billing.payments add CONSTRAINT billing_payments_payment_id_pkey PRIMARY KEY (payment_id);
37
37
  alter table billing.payments add CONSTRAINT billing_payments_payment_id_account_id_fkey FOREIGN KEY (account_id) REFERENCES billing.accounts (account_id);
@@ -1,55 +1,55 @@
1
- create schema if not exists billing;
2
-
3
- CREATE TABLE if not exists billing.invoices();
4
- alter table billing.invoices drop constraint if exists billing_invoices_invoice_id_pkey cascade;
5
- alter table billing.invoices drop constraint if exists billing_invoices_subscription_id_fkey cascade;
6
-
7
- alter table billing.invoices add column if not exists invoice_id text NOT NULL default next_id();
8
- alter table billing.invoices add column if not exists account_id text NOT NULL;
9
- alter table billing.invoices add column if not exists subscription_id text;
10
- alter table billing.invoices add column if not exists total_amount numeric;
11
- alter table billing.invoices add column if not exists cdate timestamp without time zone DEFAULT now();
12
- alter table billing.invoices add column if not exists uid text NOT NULL;
13
- alter table billing.invoices add column if not exists editor_id text;
14
- alter table billing.invoices add column if not exists editor_date timestamp without time zone;
15
- alter table billing.invoices add column if not exists files json;
16
-
17
- COMMENT ON TABLE billing.invoices IS 'Накладні (рахунки)';
18
- COMMENT ON COLUMN billing.invoices.invoice_id IS 'ID';
19
- COMMENT ON COLUMN billing.invoices.account_id IS 'ID акаунту клієнта';
20
- COMMENT ON COLUMN billing.invoices.total_amount IS 'Сума списання';
21
- COMMENT ON COLUMN billing.invoices.subscription_id IS 'ID підписки';
22
-
23
- CREATE TABLE if not exists billing.invoices_subscribe();
24
- alter table billing.invoices_subscribe drop constraint if exists billing_invoices_subscribe_id_pkey cascade;
25
- alter table billing.invoices_subscribe drop constraint if exists billing_invoices_subscribe_invoice_id_fkey cascade;
26
-
27
- alter table billing.invoices_subscribe add column if not exists is_id text NOT NULL default next_id();
28
- alter table billing.invoices_subscribe add column if not exists invoice_id text NOT NULL;
29
- alter table billing.invoices_subscribe add column if not exists list_price numeric not null default 0;
30
- alter table billing.invoices_subscribe add column if not exists dicsounts numeric not null default 0;
31
- alter table billing.invoices_subscribe add column if not exists amount_excl_tax numeric not null default 0;
32
- alter table billing.invoices_subscribe add column if not exists tax numeric not null default 0;
33
- alter table billing.invoices_subscribe add column if not exists amount numeric not null default 0;
34
- alter table billing.invoices_subscribe add column if not exists cdate timestamp without time zone DEFAULT now();
35
- alter table billing.invoices_subscribe add column if not exists uid text NOT NULL;
36
- alter table billing.invoices_subscribe add column if not exists editor_id text;
37
- alter table billing.invoices_subscribe add column if not exists editor_date timestamp without time zone;
38
- alter table billing.invoices_subscribe add column if not exists files json;
39
-
40
- COMMENT ON TABLE billing.invoices_subscribe IS 'Складові накладних (рахунків)';
41
- COMMENT ON COLUMN billing.invoices_subscribe.is_id IS 'ID';
42
- COMMENT ON COLUMN billing.invoices_subscribe.invoice_id IS 'ID накладної (рахунку)';
43
- COMMENT ON COLUMN billing.invoices_subscribe.list_price IS 'Встановлена вартість';
44
- COMMENT ON COLUMN billing.invoices_subscribe.dicsounts IS 'Знижка';
45
- COMMENT ON COLUMN billing.invoices_subscribe.amount_excl_tax IS 'Сума, без податків';
46
- COMMENT ON COLUMN billing.invoices_subscribe.tax IS 'Сума податків';
47
- COMMENT ON COLUMN billing.invoices_subscribe.amount IS 'Сума';
48
-
49
- alter table billing.invoices add CONSTRAINT billing_invoices_invoice_id_pkey PRIMARY KEY (invoice_id);
50
- alter table billing.invoices add CONSTRAINT billing_invoices_subscription_id_fkey FOREIGN KEY (subscription_id)
51
- REFERENCES billing.subscriptions (subscription_id);
52
-
53
- alter table billing.invoices_subscribe add CONSTRAINT billing_invoices_subscribe_id_pkey PRIMARY KEY (is_id);
54
- alter table billing.invoices_subscribe add CONSTRAINT billing_invoices_subscribe_invoice_id_fkey FOREIGN KEY (invoice_id)
1
+ create schema if not exists billing;
2
+
3
+ CREATE TABLE if not exists billing.invoices();
4
+ alter table billing.invoices drop constraint if exists billing_invoices_invoice_id_pkey cascade;
5
+ alter table billing.invoices drop constraint if exists billing_invoices_subscription_id_fkey cascade;
6
+
7
+ alter table billing.invoices add column if not exists invoice_id text NOT NULL default next_id();
8
+ alter table billing.invoices add column if not exists account_id text NOT NULL;
9
+ alter table billing.invoices add column if not exists subscription_id text;
10
+ alter table billing.invoices add column if not exists total_amount numeric;
11
+ alter table billing.invoices add column if not exists cdate timestamp without time zone DEFAULT now();
12
+ alter table billing.invoices add column if not exists uid text NOT NULL;
13
+ alter table billing.invoices add column if not exists editor_id text;
14
+ alter table billing.invoices add column if not exists editor_date timestamp without time zone;
15
+ alter table billing.invoices add column if not exists files json;
16
+
17
+ COMMENT ON TABLE billing.invoices IS 'Накладні (рахунки)';
18
+ COMMENT ON COLUMN billing.invoices.invoice_id IS 'ID';
19
+ COMMENT ON COLUMN billing.invoices.account_id IS 'ID акаунту клієнта';
20
+ COMMENT ON COLUMN billing.invoices.total_amount IS 'Сума списання';
21
+ COMMENT ON COLUMN billing.invoices.subscription_id IS 'ID підписки';
22
+
23
+ CREATE TABLE if not exists billing.invoices_subscribe();
24
+ alter table billing.invoices_subscribe drop constraint if exists billing_invoices_subscribe_id_pkey cascade;
25
+ alter table billing.invoices_subscribe drop constraint if exists billing_invoices_subscribe_invoice_id_fkey cascade;
26
+
27
+ alter table billing.invoices_subscribe add column if not exists is_id text NOT NULL default next_id();
28
+ alter table billing.invoices_subscribe add column if not exists invoice_id text NOT NULL;
29
+ alter table billing.invoices_subscribe add column if not exists list_price numeric not null default 0;
30
+ alter table billing.invoices_subscribe add column if not exists dicsounts numeric not null default 0;
31
+ alter table billing.invoices_subscribe add column if not exists amount_excl_tax numeric not null default 0;
32
+ alter table billing.invoices_subscribe add column if not exists tax numeric not null default 0;
33
+ alter table billing.invoices_subscribe add column if not exists amount numeric not null default 0;
34
+ alter table billing.invoices_subscribe add column if not exists cdate timestamp without time zone DEFAULT now();
35
+ alter table billing.invoices_subscribe add column if not exists uid text NOT NULL;
36
+ alter table billing.invoices_subscribe add column if not exists editor_id text;
37
+ alter table billing.invoices_subscribe add column if not exists editor_date timestamp without time zone;
38
+ alter table billing.invoices_subscribe add column if not exists files json;
39
+
40
+ COMMENT ON TABLE billing.invoices_subscribe IS 'Складові накладних (рахунків)';
41
+ COMMENT ON COLUMN billing.invoices_subscribe.is_id IS 'ID';
42
+ COMMENT ON COLUMN billing.invoices_subscribe.invoice_id IS 'ID накладної (рахунку)';
43
+ COMMENT ON COLUMN billing.invoices_subscribe.list_price IS 'Встановлена вартість';
44
+ COMMENT ON COLUMN billing.invoices_subscribe.dicsounts IS 'Знижка';
45
+ COMMENT ON COLUMN billing.invoices_subscribe.amount_excl_tax IS 'Сума, без податків';
46
+ COMMENT ON COLUMN billing.invoices_subscribe.tax IS 'Сума податків';
47
+ COMMENT ON COLUMN billing.invoices_subscribe.amount IS 'Сума';
48
+
49
+ alter table billing.invoices add CONSTRAINT billing_invoices_invoice_id_pkey PRIMARY KEY (invoice_id);
50
+ alter table billing.invoices add CONSTRAINT billing_invoices_subscription_id_fkey FOREIGN KEY (subscription_id)
51
+ REFERENCES billing.subscriptions (subscription_id);
52
+
53
+ alter table billing.invoices_subscribe add CONSTRAINT billing_invoices_subscribe_id_pkey PRIMARY KEY (is_id);
54
+ alter table billing.invoices_subscribe add CONSTRAINT billing_invoices_subscribe_invoice_id_fkey FOREIGN KEY (invoice_id)
55
55
  REFERENCES billing.invoices (invoice_id);
@@ -0,0 +1,22 @@
1
+ import { addCron, pgClients } from '@opengis/fastify-table/utils.js';
2
+
3
+ import updateTrxStatus from '../routes/utils/portmone.check.status.js';
4
+
5
+ async function updateOldTrxsStatus() {
6
+ const inprogress = pgClients.client.pk?.['billing.payments']
7
+ ? await pgClients.client.query(`select array_agg(payment_id) as inprogress from billing.payments
8
+ where payment_status = 'inprogress' and (now() - cdate) > '1 hour'::interval`).then(el => el.rows?.[0]?.inprogress || [])
9
+ : [];
10
+
11
+ if (!inprogress?.length) return 'empty rows';
12
+
13
+ const res = await Promise.all(inprogress.map(async (paymentId) => {
14
+ const data = await updateTrxStatus({ paymentId });
15
+ return { paymentId, data };
16
+ }));
17
+ return res;
18
+ }
19
+
20
+ export default async function cron() {
21
+ // addCron(updateOldTrxsStatus, 60 * 60 * 24);
22
+ }
@@ -88,13 +88,15 @@ export default async function PortmoneRedirect(req, reply) {
88
88
  return { message: 'payment not found', status: 404 };
89
89
  }
90
90
 
91
+ const protocol = headers?.referer.split('://').shift();
92
+
91
93
  const formData = {
92
94
  payee_id: payeeId,
93
95
  description: `Послуга - поповнення рахунку на суму ${paymentAmount} грн`,
94
96
  shop_order_number: paymentId,
95
97
  bill_amount: paymentAmount,
96
- success_url: `http://${domain}${config?.prefix || '/api'}/portmone/${paymentId}/success`,
97
- failure_url: `http://${domain}${config?.prefix || '/api'}/portmone/${paymentId}/error`,
98
+ success_url: `${protocol || 'https'}://${domain}${config?.prefix || '/api'}/portmone/${paymentId}/success`,
99
+ failure_url: `${protocol || 'https'}://${domain}${config?.prefix || '/api'}/portmone/${paymentId}/error`,
98
100
  lang: 'ua',
99
101
  };
100
102
 
@@ -23,7 +23,7 @@ import { sendNotification } from '@opengis/admin/utils.js';
23
23
 
24
24
  export default async function portmoneStatus(req, reply) {
25
25
  const {
26
- pg = pgClients.client, params = {}, headers = {}, body = {}, user = {},
26
+ pg = pgClients.client, params = {}, headers = {}, body = {}, user = {}, unittest,
27
27
  } = req;
28
28
  const { host } = config.integrations?.pay || {};
29
29
 
@@ -62,7 +62,7 @@ export default async function portmoneStatus(req, reply) {
62
62
  return { message: 'Transaction not found', status: 400 };
63
63
  }
64
64
 
65
- const refill = body?.billAmount || refillSum || 0;
65
+ const refill = responseStatus === 'success' ? (body?.billAmount || refillSum || 0) : 0;
66
66
 
67
67
  // request portmone trx info to recheck request data is valid?
68
68
  if (!origin?.startsWith(host)) {
@@ -89,7 +89,7 @@ export default async function portmoneStatus(req, reply) {
89
89
 
90
90
  // last trx contains total balance
91
91
  const { total_balance: totalBalance } = await pg.query(`select total_balance from billing.payments
92
- where account_id=$1 and total_balance is not null order by cdate desc limit 1`, [accountId])
92
+ where account_id=$1 and payment_status in ('success', 'error') and total_balance is not null order by cdate desc limit 1`, [accountId])
93
93
  .then(el => el.rows?.[0] || {});
94
94
 
95
95
  await dataUpdate({
@@ -97,13 +97,17 @@ export default async function portmoneStatus(req, reply) {
97
97
  data: {
98
98
  payment_data: body,
99
99
  payment_status: responseStatus,
100
- total_balance: +(refill || 0) + (+totalBalance || 0),
100
+ total_balance: +(refill) + (+totalBalance || 0),
101
101
  success_date: new Date(),
102
102
  },
103
103
  id: paymentId,
104
104
  uid: user?.uid || '0',
105
105
  });
106
106
 
107
+ if (unittest) {
108
+ console.log(`id:${trx}, status: ${responseStatus}, before: ${totalBalance || 0}, after: ${+(refill) + (+totalBalance || 0)} (${body?.billAmount || refillSum || 0})`);
109
+ }
110
+
107
111
  const { account_email: to } = await pg.query('select account_email from billing.accounts where account_id=$1', [accountId])
108
112
  .then(el => el.rows?.[0] || {});
109
113