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 | export type PaymentGuardInput={sourceAccountId:string;beneficiaryId:string;iban:string;amountIrr:number;clientReference:string;paymentDate:string}; |
| 2 | export type PaymentGuardResult={ok:true}|{ok:false;code:'INVALID_IBAN'|'DUPLICATE_REFERENCE'|'DUPLICATE_PAYMENT'}; |
| 3 | const normalized=(v:string)=>v.replace(/\s+/g,'').toUpperCase(); |
| 4 | export function isValidIranianIban(v:string){const iban=normalized(v);if(!/^IR\d{24}$/.test(iban))return false;const rearranged=iban.slice(4)+iban.slice(0,4);let rem=0;for(const ch of rearranged){const part=/\d/.test(ch)?ch:String(ch.charCodeAt(0)-55);for(const digit of part)rem=(rem*10+Number(digit))%97}return rem===1} |
| 5 | export function evaluatePaymentGuard(next:PaymentGuardInput,existing:PaymentGuardInput[]):PaymentGuardResult{ |
| 6 | if(!isValidIranianIban(next.iban)) return {ok:false,code:'INVALID_IBAN'}; |
| 7 | if(existing.some(p=>p.clientReference.trim()===next.clientReference.trim())) return {ok:false,code:'DUPLICATE_REFERENCE'}; |
| 8 | const fingerprint=(p:PaymentGuardInput)=>[p.sourceAccountId,p.beneficiaryId,normalized(p.iban),p.amountIrr,p.paymentDate].join('|'); |
| 9 | if(existing.some(p=>fingerprint(p)===fingerprint(next))) return {ok:false,code:'DUPLICATE_PAYMENT'}; |
| 10 | return {ok:true}; |
| 11 | } |