Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
dev/v7-production-failclosed-20261021
ci/public-windows-bridge-probe-20261017
ci/windows-dispatch-bootstrap-20261016
ci/windows-dual-app-lab-20261016
dev/v7-production-failclosed-20261021
feature/reconciliation-guard-20261013
main
phase-1-foundation
phase-1-implementation
phase-2-treasury-core
phase-3-banking-reconciliation
phase-4-operations-enterprise-ux
phase-5-hardening-release
phase-6-production-platform
phase-7-production-infrastructure-bank-golive
phase-7-sql-readonly-ux-20261015
transfer-exe-to-drive-20261006
| 1 | 'use server'; |
| 2 | |
| 3 | import {randomUUID} from 'node:crypto'; |
| 4 | import {redirect} from 'next/navigation'; |
| 5 | import {revalidatePath} from 'next/cache'; |
| 6 | import {getDesktopTreasuryService} from '../../platform/application/server-service'; |
| 7 | import {validatePaymentDraftInput} from './payment-components'; |
| 8 | |
| 9 | export async function createPaymentAction(formData:FormData){ |
| 10 | const input={ |
| 11 | sourceAccountId:String(formData.get('sourceAccountId')??''), |
| 12 | beneficiaryId:String(formData.get('beneficiaryId')??''), |
| 13 | amountIrr:Number(formData.get('amountIrr')??0), |
| 14 | paymentDate:String(formData.get('paymentDate')??''), |
| 15 | clientReference:String(formData.get('clientReference')??'').trim() |
| 16 | }; |
| 17 | const errors=validatePaymentDraftInput(input); |
| 18 | if(errors.length) redirect('/payments/new?error='+encodeURIComponent(errors.join(','))); |
| 19 | const service=getDesktopTreasuryService(); |
| 20 | const payment=service.createPayment({ |
| 21 | id:randomUUID(), |
| 22 | ...input, |
| 23 | description:String(formData.get('description')??'') |
| 24 | }); |
| 25 | revalidatePath('/dashboard'); |
| 26 | revalidatePath('/payments'); |
| 27 | redirect('/payments/'+payment.id); |
| 28 | } |
| 29 | |
| 30 | export async function submitPaymentAction(formData:FormData){ |
| 31 | const id=String(formData.get('id')??''); |
| 32 | getDesktopTreasuryService().submitPayment(id); |
| 33 | revalidatePath('/payments/'+id); |
| 34 | revalidatePath('/payments'); |
| 35 | } |
| 36 | |
| 37 | export async function approvePaymentAction(formData:FormData){ |
| 38 | const id=String(formData.get('id')??''); |
| 39 | getDesktopTreasuryService({tenantId:'local',userId:'local-checker',role:'CHECKER'}).approvePayment(id); |
| 40 | revalidatePath('/payments/'+id); |
| 41 | revalidatePath('/payments'); |
| 42 | } |