Implement audited credit offers disbursement collateral repayments and refinancing

This commit is contained in:
unimatrixgit 2026-11-14 17:07:32 +01:00
commit b75cbc43d7

View file

@ -101,7 +101,7 @@ CREATE TABLE IF NOT EXISTS pb_credit_loans (
reviewed_by CHAR(36) NULL, motivation TEXT NOT NULL, decision_reason TEXT NULL,
quote_json TEXT NOT NULL, score_json TEXT NOT NULL, refinance_json TEXT NULL,
replaced_by CHAR(36) NULL, created_at BIGINT NOT NULL, updated_at BIGINT NOT NULL,
accepted_at BIGINT NULL, next_due_at BIGINT NULL, version INT NOT NULL DEFAULT 1,
accepted_at BIGINT NULL, accepted_by CHAR(36) NULL, queued_at BIGINT NULL, offer_expires_at BIGINT NULL, borrower_hold_minor BIGINT NOT NULL DEFAULT 0, next_due_at BIGINT NULL, version INT NOT NULL DEFAULT 1,
FOREIGN KEY(client_number) REFERENCES pb_clients(client_number), FOREIGN KEY(entity_id) REFERENCES pb_entities(id),
FOREIGN KEY(account_id) REFERENCES pb_accounts(id), FOREIGN KEY(collateral_account_id) REFERENCES pb_accounts(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@ -147,3 +147,15 @@ CREATE TABLE IF NOT EXISTS pb_project_accounts (
FOREIGN KEY(entity_id) REFERENCES pb_entities(id), FOREIGN KEY(client_number) REFERENCES pb_clients(client_number),
FOREIGN KEY(account_id) REFERENCES pb_accounts(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS pb_credit_actions (
id CHAR(36) PRIMARY KEY, loan_id CHAR(36) NOT NULL, actor_id CHAR(36) NOT NULL,
kind VARCHAR(16) NOT NULL, amount_minor BIGINT NOT NULL, state VARCHAR(16) NOT NULL,
fingerprint CHAR(64) NOT NULL, reason VARCHAR(500) NOT NULL,
created_at BIGINT NOT NULL, processed_at BIGINT NULL, failure VARCHAR(200) NULL,
FOREIGN KEY(loan_id) REFERENCES pb_credit_loans(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS pb_credit_concessions (
event_key VARCHAR(96) PRIMARY KEY, loan_id CHAR(36) NOT NULL UNIQUE, created_at BIGINT NOT NULL,
FOREIGN KEY(loan_id) REFERENCES pb_credit_loans(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;