feat: configurable DTO login/password per KKT device

- Equipment page: add login/password fields in KKT fiscal mode form
- Stored in device config JSON (dto_user, dto_pass)
- Backend passes credentials to agent in test_device command
- Agent uses per-device credentials for all ATOL DTO API calls

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-27 16:20:36 +03:00
parent 8eb83a5189
commit c081ab5c74
2 changed files with 37 additions and 9 deletions

View File

@@ -300,6 +300,8 @@ const workstationRoutes: FastifyPluginAsync = async (fastify) => {
com_port: device.com_port,
fiscal_mode: device.fiscal_mode,
dto_port: device.dto_port,
dto_user: device.config?.dto_user,
dto_pass: device.config?.dto_pass,
},
}) as { ok: boolean; error?: string; message?: string }
return result

View File

@@ -201,6 +201,8 @@ function DeviceForm({
const [purpose, setPurpose] = useState(initial?.purpose ?? 'receipt')
const [fiscalMode, setFiscalMode] = useState(initial?.fiscalMode !== false)
const [dtoPort, setDtoPort] = useState(String(initial?.dtoPort ?? 16732))
const [dtoUser, setDtoUser] = useState(String(initial?.config?.dto_user ?? '30'))
const [dtoPass, setDtoPass] = useState(String(initial?.config?.dto_pass ?? '30'))
const [saving, setSaving] = useState(false)
const [availablePorts, setAvailablePorts] = useState<{ port: string; description?: string }[] | null>(null)
const [portsLoading, setPortsLoading] = useState(false)
@@ -228,6 +230,7 @@ function DeviceForm({
purpose: purpose as WorkstationDevice['purpose'],
fiscalMode: type === 'kkt' ? fiscalMode : undefined,
dtoPort: type === 'kkt' && fiscalMode ? Number(dtoPort) : undefined,
config: type === 'kkt' && fiscalMode ? { dto_user: dtoUser, dto_pass: dtoPass } : undefined,
})
setSaving(false)
}
@@ -291,15 +294,38 @@ function DeviceForm({
</div>
</div>
{fiscalMode && (
<div>
<label className="block text-xs font-medium text-slate-500 mb-1">Порт АТОЛ ДТО</label>
<input
value={dtoPort}
onChange={e => setDtoPort(e.target.value)}
className="w-32 input text-sm font-mono"
placeholder="16732"
/>
<p className="text-xs text-slate-400 mt-1">Порт АТОЛ ДТО 10 (по умолчанию 16732). Для нескольких касс разные порты.</p>
<div className="space-y-3">
<div>
<label className="block text-xs font-medium text-slate-500 mb-1">Порт АТОЛ ДТО</label>
<input
value={dtoPort}
onChange={e => setDtoPort(e.target.value)}
className="w-32 input text-sm font-mono"
placeholder="16732"
/>
<p className="text-xs text-slate-400 mt-1">По умолчанию 16732. Для нескольких касс разные порты.</p>
</div>
<div className="grid grid-cols-2 gap-3">
<div>
<label className="block text-xs font-medium text-slate-500 mb-1">Логин ДТО</label>
<input
value={dtoUser}
onChange={e => setDtoUser(e.target.value)}
className="w-full input text-sm"
placeholder="30"
/>
</div>
<div>
<label className="block text-xs font-medium text-slate-500 mb-1">Пароль ДТО</label>
<input
type="password"
value={dtoPass}
onChange={e => setDtoPass(e.target.value)}
className="w-full input text-sm"
placeholder="30"
/>
</div>
</div>
</div>
)}
</div>