@javalabs/prisma-client 1.0.19 → 1.0.21
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/.github/CODEOWNERS +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/add_reserved_amount.sql +8 -0
- package/package.json +4 -5
- package/prisma/schema.prisma +601 -600
- package/.dockerignore +0 -14
- package/Dockerfile +0 -23
- package/prisma/migrations/add_accepts_partial_payments_to_users.sql +0 -19
- package/prisma/migrations/add_amount_received_to_manual_payments.sql +0 -19
- package/prisma/migrations/add_commission_fields.sql +0 -33
- package/prisma/migrations/complete_partial_payments_migration.sql +0 -53
- package/prisma/migrations/create_settlements_table.sql +0 -60
package/.dockerignore
DELETED
package/Dockerfile
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Dockerfile para el cliente de Prisma compartido
|
|
2
|
-
FROM node:18-alpine
|
|
3
|
-
|
|
4
|
-
WORKDIR /app
|
|
5
|
-
|
|
6
|
-
# Copiar archivos de configuración
|
|
7
|
-
COPY package*.json ./
|
|
8
|
-
COPY prisma ./prisma/
|
|
9
|
-
|
|
10
|
-
# Instalar dependencias
|
|
11
|
-
RUN npm ci --only=production
|
|
12
|
-
|
|
13
|
-
# Generar el cliente de Prisma
|
|
14
|
-
RUN npx prisma generate
|
|
15
|
-
|
|
16
|
-
# Copiar el código fuente
|
|
17
|
-
COPY . .
|
|
18
|
-
|
|
19
|
-
# Construir el proyecto
|
|
20
|
-
RUN npm run build
|
|
21
|
-
|
|
22
|
-
# Comando por defecto (este contenedor solo genera el cliente)
|
|
23
|
-
CMD ["echo", "Prisma client generated successfully"]
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
-- Migration: add_accepts_partial_payments_to_users
|
|
2
|
-
-- Description: Agrega el campo accepts_partial_payments a la tabla users
|
|
3
|
-
-- Date: 2025-10-27
|
|
4
|
-
-- Agregar columna accepts_partial_payments a la tabla users
|
|
5
|
-
ALTER TABLE
|
|
6
|
-
users
|
|
7
|
-
ADD
|
|
8
|
-
COLUMN IF NOT EXISTS accepts_partial_payments BOOLEAN DEFAULT FALSE;
|
|
9
|
-
|
|
10
|
-
-- Agregar comentario a la columna
|
|
11
|
-
COMMENT ON COLUMN users.accepts_partial_payments IS 'Indica si el usuario acepta pagos parciales';
|
|
12
|
-
|
|
13
|
-
-- Actualizar usuarios existentes con valor por defecto
|
|
14
|
-
UPDATE
|
|
15
|
-
users
|
|
16
|
-
SET
|
|
17
|
-
accepts_partial_payments = FALSE
|
|
18
|
-
WHERE
|
|
19
|
-
accepts_partial_payments IS NULL;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
-- Migration: add_amount_received_to_manual_payments
|
|
2
|
-
-- Description: Agrega el campo amount_received a la tabla manual_payments para almacenar el monto real recibido en pagos parciales
|
|
3
|
-
-- Date: 2025-10-27
|
|
4
|
-
-- Agregar columna amount_received a la tabla manual_payments
|
|
5
|
-
ALTER TABLE
|
|
6
|
-
manual_payments
|
|
7
|
-
ADD
|
|
8
|
-
COLUMN IF NOT EXISTS amount_received DECIMAL(10, 2);
|
|
9
|
-
|
|
10
|
-
-- Agregar comentario a la columna
|
|
11
|
-
COMMENT ON COLUMN manual_payments.amount_received IS 'Monto real recibido en caso de pago parcial';
|
|
12
|
-
|
|
13
|
-
-- Actualizar registros existentes: por defecto, amount_received será igual a amount
|
|
14
|
-
UPDATE
|
|
15
|
-
manual_payments
|
|
16
|
-
SET
|
|
17
|
-
amount_received = amount
|
|
18
|
-
WHERE
|
|
19
|
-
amount_received IS NULL;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
ALTER TABLE
|
|
2
|
-
users
|
|
3
|
-
ADD
|
|
4
|
-
COLUMN IF NOT EXISTS payin_commission_percent DECIMAL(5, 2) DEFAULT 0,
|
|
5
|
-
ADD
|
|
6
|
-
COLUMN IF NOT EXISTS payin_fixed_fee DECIMAL(10, 2) DEFAULT 0,
|
|
7
|
-
ADD
|
|
8
|
-
COLUMN IF NOT EXISTS payout_fixed_fee DECIMAL(10, 2) DEFAULT 0;
|
|
9
|
-
|
|
10
|
-
ALTER TABLE
|
|
11
|
-
transactions
|
|
12
|
-
ADD
|
|
13
|
-
COLUMN IF NOT EXISTS commission DECIMAL(10, 2) DEFAULT 0,
|
|
14
|
-
ADD
|
|
15
|
-
COLUMN IF NOT EXISTS fixed_fee DECIMAL(10, 2) DEFAULT 0,
|
|
16
|
-
ADD
|
|
17
|
-
COLUMN IF NOT EXISTS total_commission_fee DECIMAL(10, 2) DEFAULT 0,
|
|
18
|
-
ADD
|
|
19
|
-
COLUMN IF NOT EXISTS total_operation DECIMAL(10, 2) DEFAULT 0;
|
|
20
|
-
|
|
21
|
-
COMMENT ON COLUMN users.payin_commission_percent IS 'Percentage commission for payin transactions (0-100)';
|
|
22
|
-
|
|
23
|
-
COMMENT ON COLUMN users.payin_fixed_fee IS 'Fixed fee for payin transactions';
|
|
24
|
-
|
|
25
|
-
COMMENT ON COLUMN users.payout_fixed_fee IS 'Fixed fee for payout transactions';
|
|
26
|
-
|
|
27
|
-
COMMENT ON COLUMN transactions.commission IS 'Commission amount calculated from percentage';
|
|
28
|
-
|
|
29
|
-
COMMENT ON COLUMN transactions.fixed_fee IS 'Fixed fee amount applied to the transaction';
|
|
30
|
-
|
|
31
|
-
COMMENT ON COLUMN transactions.total_commission_fee IS 'Total of commission + fixed_fee';
|
|
32
|
-
|
|
33
|
-
COMMENT ON COLUMN transactions.total_operation IS 'Total amount including transaction amount + total_commission_fee';
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
-- ============================================
|
|
2
|
-
-- MIGRACIÓN COMPLETA: SISTEMA DE PAGOS PARCIALES
|
|
3
|
-
-- Fecha: 2025-10-27
|
|
4
|
-
-- Descripción: Agrega soporte para pagos parciales
|
|
5
|
-
-- ============================================
|
|
6
|
-
-- 1. Agregar columna accepts_partial_payments a la tabla users
|
|
7
|
-
-- --------------------------------------------
|
|
8
|
-
ALTER TABLE
|
|
9
|
-
users
|
|
10
|
-
ADD
|
|
11
|
-
COLUMN IF NOT EXISTS accepts_partial_payments BOOLEAN DEFAULT FALSE;
|
|
12
|
-
|
|
13
|
-
-- Agregar comentario descriptivo
|
|
14
|
-
COMMENT ON COLUMN users.accepts_partial_payments IS 'Indica si el usuario acepta pagos parciales';
|
|
15
|
-
|
|
16
|
-
-- Actualizar usuarios existentes con valor por defecto
|
|
17
|
-
UPDATE
|
|
18
|
-
users
|
|
19
|
-
SET
|
|
20
|
-
accepts_partial_payments = FALSE
|
|
21
|
-
WHERE
|
|
22
|
-
accepts_partial_payments IS NULL;
|
|
23
|
-
|
|
24
|
-
-- 2. Agregar columna amount_received a la tabla manual_payments
|
|
25
|
-
-- --------------------------------------------
|
|
26
|
-
ALTER TABLE
|
|
27
|
-
manual_payments
|
|
28
|
-
ADD
|
|
29
|
-
COLUMN IF NOT EXISTS amount_received DECIMAL(10, 2);
|
|
30
|
-
|
|
31
|
-
-- Agregar comentario descriptivo
|
|
32
|
-
COMMENT ON COLUMN manual_payments.amount_received IS 'Monto real recibido en caso de pago parcial';
|
|
33
|
-
|
|
34
|
-
-- Actualizar registros existentes: por defecto, amount_received será igual a amount
|
|
35
|
-
UPDATE
|
|
36
|
-
manual_payments
|
|
37
|
-
SET
|
|
38
|
-
amount_received = amount
|
|
39
|
-
WHERE
|
|
40
|
-
amount_received IS NULL;
|
|
41
|
-
|
|
42
|
-
-- ============================================
|
|
43
|
-
-- VERIFICACIÓN (OPCIONAL)
|
|
44
|
-
-- ============================================
|
|
45
|
-
-- Ejecuta estas consultas para verificar que las columnas fueron creadas:
|
|
46
|
-
-- Verificar columna en users:
|
|
47
|
-
-- SELECT column_name, data_type, column_default
|
|
48
|
-
-- FROM information_schema.columns
|
|
49
|
-
-- WHERE table_name = 'users' AND column_name = 'accepts_partial_payments';
|
|
50
|
-
-- Verificar columna en manual_payments:
|
|
51
|
-
-- SELECT column_name, data_type, column_default
|
|
52
|
-
-- FROM information_schema.columns
|
|
53
|
-
-- WHERE table_name = 'manual_payments' AND column_name = 'amount_received';
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
CREATE TYPE enum_settlements_status AS ENUM ('pending', 'completed', 'cancelled');
|
|
2
|
-
|
|
3
|
-
CREATE TABLE IF NOT EXISTS settlements (
|
|
4
|
-
id SERIAL PRIMARY KEY,
|
|
5
|
-
user_id INTEGER NOT NULL,
|
|
6
|
-
settlement_date TIMESTAMPTZ(6) NOT NULL,
|
|
7
|
-
period_start TIMESTAMPTZ(6) NOT NULL,
|
|
8
|
-
period_end TIMESTAMPTZ(6) NOT NULL,
|
|
9
|
-
payin_count INTEGER DEFAULT 0 NOT NULL,
|
|
10
|
-
payin_total_amount DECIMAL(15, 2) DEFAULT 0 NOT NULL,
|
|
11
|
-
payin_total_commission DECIMAL(15, 2) DEFAULT 0 NOT NULL,
|
|
12
|
-
payin_net_amount DECIMAL(15, 2) DEFAULT 0 NOT NULL,
|
|
13
|
-
payout_count INTEGER DEFAULT 0 NOT NULL,
|
|
14
|
-
payout_total_amount DECIMAL(15, 2) DEFAULT 0 NOT NULL,
|
|
15
|
-
payout_total_commission DECIMAL(15, 2) DEFAULT 0 NOT NULL,
|
|
16
|
-
payout_total_with_commission DECIMAL(15, 2) DEFAULT 0 NOT NULL,
|
|
17
|
-
total_commission DECIMAL(15, 2) DEFAULT 0 NOT NULL,
|
|
18
|
-
balance_before DECIMAL(15, 2) DEFAULT 0 NOT NULL,
|
|
19
|
-
settlement_amount DECIMAL(15, 2) DEFAULT 0 NOT NULL,
|
|
20
|
-
balance_after DECIMAL(15, 2) DEFAULT 0 NOT NULL,
|
|
21
|
-
status enum_settlements_status DEFAULT 'pending' NOT NULL,
|
|
22
|
-
notes TEXT,
|
|
23
|
-
currency VARCHAR(3) DEFAULT 'USD' NOT NULL,
|
|
24
|
-
created_at TIMESTAMPTZ(6) DEFAULT NOW() NOT NULL,
|
|
25
|
-
updated_at TIMESTAMPTZ(6) DEFAULT NOW() NOT NULL,
|
|
26
|
-
CONSTRAINT fk_settlements_user FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
CREATE INDEX idx_settlements_user_id ON settlements(user_id);
|
|
30
|
-
|
|
31
|
-
CREATE INDEX idx_settlements_period ON settlements(period_start, period_end);
|
|
32
|
-
|
|
33
|
-
CREATE INDEX idx_settlements_date ON settlements(settlement_date);
|
|
34
|
-
|
|
35
|
-
COMMENT ON TABLE settlements IS 'Stores user settlement records including commission calculations';
|
|
36
|
-
|
|
37
|
-
COMMENT ON COLUMN settlements.payin_count IS 'Number of payin transactions in the period';
|
|
38
|
-
|
|
39
|
-
COMMENT ON COLUMN settlements.payin_total_amount IS 'Total amount of payin transactions';
|
|
40
|
-
|
|
41
|
-
COMMENT ON COLUMN settlements.payin_total_commission IS 'Total commission charged on payin transactions';
|
|
42
|
-
|
|
43
|
-
COMMENT ON COLUMN settlements.payin_net_amount IS 'Net amount received after payin commissions (total - commission)';
|
|
44
|
-
|
|
45
|
-
COMMENT ON COLUMN settlements.payout_count IS 'Number of payout transactions in the period';
|
|
46
|
-
|
|
47
|
-
COMMENT ON COLUMN settlements.payout_total_amount IS 'Total amount of payout transactions';
|
|
48
|
-
|
|
49
|
-
COMMENT ON COLUMN settlements.payout_total_commission IS 'Total commission charged on payout transactions';
|
|
50
|
-
|
|
51
|
-
COMMENT ON COLUMN settlements.payout_total_with_commission IS 'Total payout including commissions (total + commission)';
|
|
52
|
-
|
|
53
|
-
COMMENT ON COLUMN settlements.total_commission IS 'Sum of all commissions (payin + payout)';
|
|
54
|
-
|
|
55
|
-
COMMENT ON COLUMN settlements.balance_before IS 'User balance before settlement';
|
|
56
|
-
|
|
57
|
-
COMMENT ON COLUMN settlements.settlement_amount IS 'Amount settled/withdrawn';
|
|
58
|
-
|
|
59
|
-
COMMENT ON COLUMN settlements.balance_after IS 'User balance after settlement';
|
|
60
|
-
|