fix(qr-custom): ikon menu + disable sampai QRIS statis siap
All checks were successful
CI / test (push) Successful in 1m43s
All checks were successful
CI / test (push) Successful in 1m43s
- icon bi-qr-code - menu disembunyikan bila QRIS belum aktif/payload kosong - form & POST ditolak, tidak membuat data tanpa QR - versi 0.6.1
This commit is contained in:
@@ -7,9 +7,19 @@ const crypto = require('crypto');
|
||||
const db = require('../config/database');
|
||||
const { isQrisAmountTaken } = require('./invoiceQrisService');
|
||||
const { logger } = require('../config/logger');
|
||||
const { getSetting } = require('../config/settingsManager');
|
||||
|
||||
const DURATION_MINUTES = 20;
|
||||
|
||||
function isReady() {
|
||||
try {
|
||||
const enabled = getSetting('qris_static_enabled', true);
|
||||
const off = enabled === false || enabled === 'false' || enabled === 0 || enabled === '0';
|
||||
const payload = String(getSetting('qris_static_payload', '') || '').trim();
|
||||
return !off && payload.length > 0;
|
||||
} catch (e) { return false; }
|
||||
}
|
||||
|
||||
function nowIso() { return new Date().toISOString(); }
|
||||
|
||||
function sweepExpired() {
|
||||
@@ -27,6 +37,7 @@ function isTaken(amount, excludeId) {
|
||||
}
|
||||
|
||||
function create({ title, category, amount, note, createdBy }) {
|
||||
if (!isReady()) throw new Error('QRIS Statis (Semi-Otomatis) belum aktif/berisi payload. Atur dulu di Pengaturan → QRIS.');
|
||||
const base = Math.max(1, Math.floor(Number(amount) || 0));
|
||||
if (!title || !String(title).trim()) throw new Error('Judul wajib diisi.');
|
||||
if (!base) throw new Error('Nominal wajib diisi.');
|
||||
@@ -161,6 +172,7 @@ function isExpired(row) {
|
||||
|
||||
module.exports = {
|
||||
DURATION_MINUTES,
|
||||
isReady,
|
||||
create,
|
||||
list,
|
||||
stats,
|
||||
|
||||
Reference in New Issue
Block a user