فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

A01: choose endorsee and explicitly confirm irreversible cheque endorsement in UI

davoodmehraban89 committed Oct 22, 2026 at 23:15 UTC 57f7fba0995d962284429aca3ab6edc62743a707
1 file changed +47 -8
src/views/ChequesView.js
+47 -8
@@ -319,17 +319,30 @@ class ChequesViewImpl {
319 { value: 'cleared', label: 'وصول شده' },
320 { value: 'bounced', label: 'برگشتی' },
321 { value: 'returned', label: 'عودت داده شده' },
322 - { value: 'spent', label: 'خرج شده (به شخص دیگر واگذار شد)' }
322 + ...(cheque.direction === 'inbound'
323 + ? [{ value: 'spent', label: 'خرج شده (به شخص دیگر واگذار شد)' }] : [])
324 ];
325 + const eligibleEndorsees=cache.contacts.filter(c=>c.id!==cheque.contactId);
326 + const endorseeOptions=eligibleEndorsees.map(c=>
327 + `<option value="${this._esc(c.id)}">${this._esc(c.name)}</option>`).join('');
328
329 const body = `
330 <p style="font-size:13px;margin-bottom:14px;color:var(--text-muted)">وضعیت فعلی: <strong>${ChequeController.getStatusLabel(cheque.status)}</strong></p>
331 <div class="form-group">
332 <label class="form-label">وضعیت جدید</label>
329 - <select class="form-control" id="newStatus">
333 + <select class="form-control" id="newStatus" onchange="window.ChequesView._onChequeStatusSelection()">
334 ${statuses.map(s => `<option value="${s.value}" ${cheque.status === s.value ? 'selected' : ''}>${s.label}</option>`).join('')}
335 </select>
336 </div>
337 + ${cheque.financePosted && cheque.direction === 'inbound' ? `
338 + <div class="form-group" id="chqEndorseeGroup" style="display:none">
339 + <label class="form-label">دریافت‌کننده واگذاری <span class="req">*</span></label>
340 + <select class="form-control" id="chqEndorsee">
341 + <option value="">— شخص ثالث را انتخاب کنید —</option>
342 + ${endorseeOptions}
343 + </select>
344 + <small class="form-hint">سند حساب‌های پرداختنی به نام این شخص ثبت می‌شود، نه صادرکننده چک.</small>
345 + </div>` : ''}
346 ${cheque.financePosted ? `
347 <div class="form-group">
348 <label class="form-label">تاریخ ثبت رویداد مالی <span class="req">*</span></label>
@@ -343,20 +356,46 @@ class ChequesViewImpl {
356 <button class="btn" onclick="window.ChequesView._applyStatusChange('${id}')">اعمال</button>
357 `;
358 Modal.open({ title: 'تغییر وضعیت چک', body, footer, size: 'sm' });
359 + this._onChequeStatusSelection();
360 + }
361 +
362 + _onChequeStatusSelection() {
363 + const group=document.getElementById('chqEndorseeGroup');
364 + if(group) group.style.display=document.getElementById('newStatus')?.value==='spent'?'':'none';
365 }
366
367 async _applyStatusChange(id) {
349 - const status = document.getElementById('newStatus').value;
368 + const status=document.getElementById('newStatus').value;
369 const eventDate=document.getElementById('chqEventDate')?.value.trim();
370 + const options=eventDate===undefined?{}:{date:eventDate};
371 + if(status==='spent' && document.getElementById('chqEndorsee')) {
372 + const endorseeContactId=document.getElementById('chqEndorsee').value;
373 + if(!endorseeContactId) { Toast.warning('دریافت‌کننده واگذاری چک را انتخاب کنید'); return; }
374 + const recipient=cache.contacts.find(c=>c.id===endorseeContactId);
375 + const cheque=cache.cheques.find(c=>c.id===id);
376 + Modal.confirm({
377 + title:'تأیید واگذاری چک',
378 + message:`واگذاری چک ${this._esc(cheque?.chequeNumber||cheque?.sayadNumber||id)} به «${this._esc(recipient?.name||'')}» به مبلغ ${Formatters.money(cheque?.amount||0)} ثبت شود؟ این ثبت مالی قطعی است.`,
379 + confirmText:'تأیید و ثبت واگذاری',
380 + danger:true,
381 + onConfirm:()=>this._commitStatusChange(id,status,{
382 + ...options,endorseeContactId,explicitlyApproved:true
383 + })
384 + });
385 + return;
386 + }
387 + await this._commitStatusChange(id,status,options);
388 + }
389 +
390 + async _commitStatusChange(id,status,options) {
391 try {
352 - await ChequeController.changeStatus(id, status,
353 - eventDate === undefined ? {} : { date: eventDate });
392 + await ChequeController.changeStatus(id,status,options);
393 Toast.success('وضعیت چک تغییر کرد');
394 Modal.close();
395 await this.reload();
357 - document.getElementById('cheques-content').innerHTML = this.renderContent();
358 - } catch (err) {
359 - Toast.error('خطا: ' + err.message);
396 + document.getElementById('cheques-content').innerHTML=this.renderContent();
397 + } catch(err) {
398 + Toast.error('خطا: '+err.message);
399 }
400 }
401