Inicio › Documentación › Instalación · origen_banking

Instalación · origen_banking

1. Base de datos

El recurso incluye un migrador automático (autodb). En el primer arranque lee database.sql desde la raíz del recurso y crea automáticamente las tablas que falten, así que no hace falta importar SQL a mano.

El migrador funciona en modo no destructivo: crea las tablas y columnas que faltan, pero nunca elimina nada que exista en tu base de datos y no esté en database.sql.

Si prefieres crear el esquema manualmente, ejecuta el siguiente SQL antes de arrancar el recurso:

sql
CREATE TABLE `origen_banking_banks` (
  `id` VARCHAR(64) NOT NULL,
  `name` VARCHAR(128) NOT NULL DEFAULT 'Banco',
  `balance` BIGINT NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
CREATE TABLE `origen_banking_accounts` (
  `id` VARCHAR(64) NOT NULL,
  `owner` VARCHAR(64) NOT NULL,
  `name` VARCHAR(128) NOT NULL DEFAULT 'Cuenta',
  `balance` BIGINT NOT NULL DEFAULT 0,
  `bank` VARCHAR(64) DEFAULT NULL,
  `default` TINYINT(1) NOT NULL DEFAULT 0,
  `shared` TINYINT(1) NOT NULL DEFAULT 0,
  `usersAccess` LONGTEXT DEFAULT '{}',
  `loans` LONGTEXT DEFAULT '[]',
  `cards` LONGTEXT DEFAULT '[]',
  PRIMARY KEY (`id`),
  KEY `idx_owner` (`owner`),
  KEY `idx_bank` (`bank`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
CREATE TABLE `origen_banking_transactions` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `account` VARCHAR(64) NOT NULL,
  `amount` BIGINT NOT NULL DEFAULT 0,
  `type` TINYINT UNSIGNED NOT NULL DEFAULT 0,
  `third` VARCHAR(64) DEFAULT NULL,
  `detail` VARCHAR(255) DEFAULT NULL,
  `initiated_by` VARCHAR(50) NULL DEFAULT 'system',
  `channel` VARCHAR(20) NULL DEFAULT 'banco',
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_account` (`account`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
CREATE TABLE `origen_banking_loans` (
  `id`                 VARCHAR(64)  NOT NULL,
  `account`            VARCHAR(64)  NOT NULL,
  `bank`               VARCHAR(64)  NOT NULL,
  `owner`              VARCHAR(64)  NOT NULL DEFAULT '',
  `type`               VARCHAR(24)  NOT NULL DEFAULT 'personal',
  `principal`          BIGINT       NOT NULL,
  `interest_rate`      DECIMAL(6,3) NOT NULL,
  `installments`       INT UNSIGNED NOT NULL,
  `paid`               INT UNSIGNED NOT NULL DEFAULT 0,
  `installment_amount` BIGINT       NOT NULL,
  `frequency`          INT UNSIGNED NOT NULL,
  `next_payment`       BIGINT       NOT NULL DEFAULT 0,
  `status`             VARCHAR(16)  NOT NULL DEFAULT 'active',
  `collateral`         VARCHAR(128) DEFAULT NULL,
  `missed`             INT UNSIGNED NOT NULL DEFAULT 0,
  `pending_disbursement` BIGINT     NOT NULL DEFAULT 0,
  `reject_reason`      VARCHAR(255) DEFAULT NULL,
  `created_at`         TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_account` (`account`),
  KEY `idx_owner` (`owner`),
  KEY `idx_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

2. server.cfg

Añade el recurso después de sus dependencias:

cfg
ensure ox_lib
ensure oxmysql
ensure origen_banking

3. Permisos de aprobación de préstamos

Los préstamos que superan Config.Loans.AutoApproveUnder pasan a una cola de aprobación manual. Hay dos vías de permisos independientes para aprobarlos:

Por trabajo — se configura en config/main.lua:

lua
Config.Loans.ApprovalJob   = 'banker'
Config.Loans.ApprovalGrade = 2

Por ACE — añade el permiso en tu server.cfg:

cfg
add_ace group.admin origen_banking.approve allow

Cualquiera que tenga alguno de los dos permisos puede ejecutar /loansadmin para abrir la NUI del banco directamente en la cola de aprobación. Pon Config.Loans.ApprovalCommand = '' para desactivar el comando.


4. Webhook de Discord (opcional)

Abre config/server/webhooks.lua y define la URL de tu webhook:

lua
Config.Webhook = {
    banking = "https://discord.com/api/webhooks/..."
}

Se registran los ingresos, las retiradas y las transferencias. Las transferencias superiores a $50,000 se envían con una mención @everyone.


5. Idioma

Define el idioma del recurso en config/main.lua. Los ficheros de traducción están en locales/.

lua
Config.Language = 'en' -- 'es' | 'en'