فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
docs/a02-pr108-ten-tests-20261019
a02/strict-export-preflight-20261018
audit/a01-readonly-invoice-metadata-20261101
ci/a06-require-trusted-issuer-for-release
ci/main-postmerge-phase-a-validation-20261020
ci/phase-a-controlled-public-release
design/issue-5-commercial-corrections-adr
docs/a01-a02-a05-oct23-verified-evidence
docs/a01-cheque-endorsement-evidence-20261022
docs/a01-cheque-event-date-evidence-20261021
docs/a01-explicit-refund-reason-evidence-20261021
docs/a01-refund-auth-status-20261020
docs/a01-refund-trace-evidence-20261020
docs/a02-102-evidence-20261018
docs/a02-pr104-evidence-20261018
docs/a02-pr106-evidence-20261019
docs/a02-pr108-ten-tests-20261019
docs/a02-private-sql-backup-evidence-20261111
docs/a03-merge-status-sync-20261020
docs/a04-software-gate-acceptance-20261020
docs/feature-matrix-20261014
docs/finora-master-execution-playbook
docs/four-phase-execution-20261014
docs/four-phase-roadmap-20261014
docs/holoo-lab-stabilization-phase1-20261111
docs/holoo-runtime-schema-audit-20261111
docs/ops-142-governance-5-1-3-20261030
docs/phase-a-a01-a02-a06-a08-verified-evidence-20261023
docs/phase-a-a01-a05-a06-evidence-20261023
docs/phase-a-independent-acceptance-evidence
docs/phase-a-pr110-evidence-20261019
docs/project-status-phase-a-20261014
feat/a01-referenced-return-corrections
feat/a01-referenced-returns-on-main
feat/a02-atomic-opening-ledger-preflight
feat/a02-holoo-compatibility-preflight
feat/a02-holoo-declared-control-totals
feat/a02-holoo-explicit-csv-gate
feat/a02-holoo-safe-zip-intake-offline-webview2-20261030
feat/a02-offline-sql-server-provisioning-20261030
feat/a02-opening-balance-dry-run
feat/a02-opening-ledger-admin-ui
feat/a02-opt-in-isolated-sql-restore-executor-20261030
feat/a02-private-holoo-zip-staging-20261030
feat/a02-safe-isolated-restore-plan-20261030
feat/a02-sql-backup-header-verifyonly-20261030
feat/a03-audit-schema-atomic-events
feat/a03-complete-manual-journal-audit
feat/a05-cheque-treasury-reconciliation
feat/a06-signed-offline-license-activation
feat/a08-synthetic-performance-baseline
feat/phase-a-accounting-benchmark-return-preview
feat/phase-a-ledger-settlement-diagnostics
feature/v2-reconciliation-20261013
fix/a01-atomic-confirm-ui-one-shot-20261031
fix/a01-cheque-clearance-explicit-account-20261023
fix/a01-cheque-contractual-due-date-validity-20261023
fix/a01-cheque-endorsement-counterparty-20261022
fix/a01-cheque-event-date-open-period-20261021
fix/a01-cumulative-return-amount-cap
fix/a01-explicit-refund-reason-approval-20261021
fix/a01-manager-authorized-customer-refunds-20261020
fix/a01-no-implicit-refund
fix/a01-one-shot-confirm-on-atomic-import-20261031
fix/a01-refund-and-overcollection-net-cash
fix/a01-refund-correction-trace-20261020
fix/a02-atomic-excel-master-merge-20261031
fix/a02-canonical-mapping-contract-20261018
fix/a02-disable-destructive-excel-replace-20261031
fix/a02-holoo-invoice-line-coverage-20261023
fix/a02-holoo-preflight-required-invoice-lines-20261023
fix/a02-mapping-contract-20261018
fix/a02-opening-preflight-unbalanced-report
fix/a02-orphan-mapping-20261018
fix/a02-private-excel-import-session-20261031
fix/a02-strict-export-input-20261019
fix/a03-append-only-full-backup-import
fix/a03-append-only-write-guard
fix/a03-block-transaction-clear-append-only-20261016
fix/a03-chain-validation-20261020
fix/a03-company-scoped-audit-data-access
fix/a03-deny-direct-audit-write-20261019
fix/a03-escaped-expense-list-20261031
fix/a03-escaped-financial-record-ids-20261031
fix/a03-financial-ledger-actions-and-print-20261031
fix/a04-backup-checksum-preflight
fix/a04-company-audit-replay-stable-compare
fix/a04-company-backup-source-isolation-20261020
fix/a04-full-restore-posted-financial-integrity
fix/a04-reject-mixed-company-backup-20261019
fix/a04-replace-immutable-posted-ledger
fix/a04-restore-financial-journal-references
fix/a04-service-source-company-boundary-20261020
fix/a05-block-inactive-treasury-settlements
fix/a05-cheque-cash-evidence-reconciliation-20261023
fix/a05-cheque-ledger-and-bank-reconciliation-20261023
fix/a05-fiscal-close-invariant-gates
fix/a06-backup-restore-user-privileges
fix/a06-license-user-company-quota-20261023
fix/a06-malformed-trial-state-fail-closed
fix/a06-offline-clock-fail-closed-20261019
fix/a07-indexeddb-blocked-startup
fix/a07-offline-bundled-assets
fix/a07-version-and-startup-banner
fix/issue-7-company-backup-isolation
fix/p0-deterministic-fractional-invoice-money-20261031
fix/p0-fractional-quantity-input-20261031
fix/p0-fractional-quantity-integrated-20261031
fix/p0-invoice-posting-invariants-20261031
fix/p0-legacy-stock-and-product-inputs-20261031
fix/p0-reports-immutable-cogs-20261101
fix/p0-verified-financial-percent-20261031
fix/p0-zero-discount-report-revenue-20261101
fix/phase-a-backup-app-version
fix/phase-a-backup-integrity-checksum
fix/phase-a-backup-record-id-validation-20261014
fix/phase-a-backup-version-validation-20261014
fix/phase-a-closure-pack3-20261101
fix/phase-a-entitlement-payload-validation
fix/phase-a-gate-exact-evidence-20261019
fix/phase-a-pack4-stock-scope-20261101
fix/phase-a-pack5-integrated-evidence-20261101
fix/phase-a-pack6-atomic-legacy-20261101
fix/phase-a-restore-envelope-and-rollback
fix/phase-a-settings-admin-gate
fix/print-browser-header-footer-20261014
fix/q01-expense-security-probe-exact-option-20261031
fix/q01-financial-grid-labels-20261031
fix/q01-form-label-association-20261031
fix/q01-native-evidence-integrity-20261030
fix/q01-number-input-persian-decimal-20261031
fix/q01-responsive-dashboard-and-cheque-table-20261031
fix/q01-safe-ui-action-audit-coverage-20261031
fix/q01-visible-desktop-sidebar-and-safe-confirm-20261030
fix/roadmap-metadata-sync-20261014
gate/a03-audit-metadata-validation-20261019
integration/a02-windows-holoo-setup-candidate-20261030
license-server
main
perf/a07-lazy-load-excel
perf/a08-cheque-reconciliation-account-index-20261023
perf/a08-paginated-reports-20261101
phase1-restore-hardening
planning/holoo-execution-20261013
planning/roadmap-project-management-20261014
qa/native-click-coverage-audit-20261030
release/v2.0.0
test/a01-native-endorsement-mandatory-20261023
test/a01-native-purchase-return-guardrails
test/a01-native-sale-return-financial-guardrails
test/a01-safe-integer-boundary-20261019
test/a02-native-opening-dry-run-rejections
test/a02-native-positive-opening-ledger
test/a04-native-corrupt-fbackup-20261016
test/a04-native-encrypted-company-backup
test/a04-native-encrypted-company-backup-main
test/a04-native-late-transaction-rollback
test/a04-native-windows-backup-recovery
test/a04-real-edge-v6-v7-migration
test/a04-real-native-interrupted-restore
test/a05-native-draft-ledger-and-repeat-close-20261016
test/a05-native-fiscal-close-guardrails
test/a07-native-multipage-print-engine
test/a07-native-origin-provenance
test/a07-native-webview2-offline-routes
test/a07-windows-offline-startup-smoke
test/a08-installed-webview2-60k-baseline
test/a08-native-webview2-heap-metrics
test/a08-windows-synthetic-performance-baseline
test/github-write-access-20261009
test/native-win-ui-routes-after-finance-backup
test/phase-a-combined-a01-a05-a08-final-evidence
test/phase-a-combined-native-acceptance-matrix
test/phase-a-ledger-invariants-20261014
test/phase-a-native-all-routes-on-merged-lab
test/phase-a-native-encrypted-backup
test/phase-a-native-finance-backup-matrix
test/phase-a-native-ui-and-backup-smoke
test/phase-a-windows-native-installer-lab
work/a08-dispatch-activation-20261123
work/a08-memory-stability-20261123
work/finance-curated-20261123
| 1 | // ============================================================ |
| 2 | // StockKardexModal — مودال کاردکس کالا و اصلاح موجودی |
| 3 | // ============================================================ |
| 4 | |
| 5 | import { ProductController } from '../controllers/ProductController.js'; |
| 6 | import { Modal } from '../core/Modal.js'; |
| 7 | import { Toast } from '../core/Toast.js'; |
| 8 | import { Formatters } from '../utils/Formatters.js'; |
| 9 | import { NumberInput } from '../utils/NumberInput.js'; |
| 10 | import { Jalali } from '../utils/Jalali.js'; |
| 11 | |
| 12 | class StockKardexModalImpl { |
| 13 | /** |
| 14 | * باز کردن مودال کاردکس برای یک کالا |
| 15 | */ |
| 16 | async open(productId) { |
| 17 | const product = await ProductController.getProduct(productId); |
| 18 | if (!product) { Toast.error('کالا یافت نشد'); return; } |
| 19 | |
| 20 | const kardex = await ProductController.getKardex(productId); |
| 21 | |
| 22 | const body = this._buildBody(product, kardex); |
| 23 | const footer = this._buildFooter(product); |
| 24 | |
| 25 | Modal.open({ |
| 26 | title: `📊 کاردکس کالا: ${product.name}`, |
| 27 | body, |
| 28 | footer, |
| 29 | size: 'lg' |
| 30 | }); |
| 31 | |
| 32 | window.__kardexProductId = productId; |
| 33 | } |
| 34 | |
| 35 | _buildBody(product, kardex) { |
| 36 | const isService = product.trackInventory === false; |
| 37 | const minStock = Number(product.minStock) || 0; |
| 38 | const currentStock = kardex.finalBalance; |
| 39 | const isLow = !isService && currentStock <= minStock && currentStock > 0; |
| 40 | const isOut = !isService && currentStock <= 0; |
| 41 | |
| 42 | let statusBadge = ''; |
| 43 | if (isService) statusBadge = '<span class="badge badge-muted">خدمت</span>'; |
| 44 | else if (isOut) statusBadge = '<span class="badge badge-danger">تمامشده</span>'; |
| 45 | else if (isLow) statusBadge = '<span class="badge badge-warning">کمموجود</span>'; |
| 46 | else statusBadge = '<span class="badge badge-success">موجود</span>'; |
| 47 | |
| 48 | const rowsHtml = kardex.rows.length === 0 |
| 49 | ? `<tr><td colspan="7" style="text-align:center;padding:30px;color:var(--text-muted)"> |
| 50 | <div style="font-size:40px;margin-bottom:8px;opacity:.4">📭</div> |
| 51 | هیچ حرکتی برای این کالا ثبت نشده |
| 52 | </td></tr>` |
| 53 | : [...kardex.rows].reverse().map(r => { |
| 54 | const typeInfo = { |
| 55 | in: { label: '📥 ورود', cls: 'badge-success', color: 'var(--success)' }, |
| 56 | out: { label: '📤 خروج', cls: 'badge-danger', color: 'var(--danger)' }, |
| 57 | adjust: { label: '⚙️ اصلاح', cls: 'badge-warning', color: 'var(--warning)' } |
| 58 | }[r.type] || { label: r.type, cls: 'badge-muted', color: 'var(--text-muted)' }; |
| 59 | |
| 60 | const isIn = r.type === 'in'; |
| 61 | const isOut = r.type === 'out'; |
| 62 | const isAdjust = r.type === 'adjust'; |
| 63 | |
| 64 | const refLabel = this._refLabel(r.refType, r.refId); |
| 65 | |
| 66 | return ` |
| 67 | <tr> |
| 68 | <td style="width:110px;font-size:11.5px">${this._formatDate(r.date)}</td> |
| 69 | <td><span class="badge ${typeInfo.cls}">${typeInfo.label}</span></td> |
| 70 | <td style="width:80px;text-align:center;font-weight:700;color:var(--success)"> |
| 71 | ${isIn ? Formatters.number(r.qty) : '—'} |
| 72 | </td> |
| 73 | <td style="width:80px;text-align:center;font-weight:700;color:var(--danger)"> |
| 74 | ${isOut ? Formatters.number(r.qty) : '—'} |
| 75 | </td> |
| 76 | <td style="width:100px;text-align:center;font-weight:800;color:${r.balance > 0 ? 'var(--primary)' : 'var(--text-muted)'}"> |
| 77 | ${Formatters.number(r.balance)} |
| 78 | </td> |
| 79 | <td style="width:140px;font-size:11.5px;color:var(--text-muted)"> |
| 80 | ${refLabel} |
| 81 | </td> |
| 82 | <td style="font-size:11.5px;color:var(--text-muted)"> |
| 83 | ${this._esc(r.note || '—')} |
| 84 | </td> |
| 85 | </tr> |
| 86 | `; |
| 87 | }).join(''); |
| 88 | |
| 89 | return ` |
| 90 | <div class="grid-kpi" style="margin-bottom:14px"> |
| 91 | <div class="card" style="margin:0;padding:12px 14px;border-top:3px solid var(--primary)"> |
| 92 | <div style="font-size:11px;color:var(--text-muted);margin-bottom:4px">موجودی فعلی</div> |
| 93 | <div style="font-size:18px;font-weight:800;color:${isOut ? 'var(--danger)' : isLow ? 'var(--warning)' : 'var(--success)'}"> |
| 94 | ${isService ? '—' : Formatters.number(currentStock)} |
| 95 | <span style="font-size:11px;font-weight:500;color:var(--text-muted)">${product.unit || 'عدد'}</span> |
| 96 | </div> |
| 97 | <div style="margin-top:4px">${statusBadge}</div> |
| 98 | </div> |
| 99 | |
| 100 | <div class="card" style="margin:0;padding:12px 14px;border-top:3px solid var(--success)"> |
| 101 | <div style="font-size:11px;color:var(--text-muted);margin-bottom:4px">جمع ورودیها</div> |
| 102 | <div style="font-size:16px;font-weight:800;color:var(--success)">${Formatters.number(kardex.totalIn)}</div> |
| 103 | <div style="font-size:10.5px;color:var(--text-muted);margin-top:4px">${product.unit || 'عدد'}</div> |
| 104 | </div> |
| 105 | |
| 106 | <div class="card" style="margin:0;padding:12px 14px;border-top:3px solid var(--danger)"> |
| 107 | <div style="font-size:11px;color:var(--text-muted);margin-bottom:4px">جمع خروجیها</div> |
| 108 | <div style="font-size:16px;font-weight:800;color:var(--danger)">${Formatters.number(kardex.totalOut)}</div> |
| 109 | <div style="font-size:10.5px;color:var(--text-muted);margin-top:4px">${product.unit || 'عدد'}</div> |
| 110 | </div> |
| 111 | |
| 112 | <div class="card" style="margin:0;padding:12px 14px;border-top:3px solid var(--warning)"> |
| 113 | <div style="font-size:11px;color:var(--text-muted);margin-bottom:4px">نقطه سفارش</div> |
| 114 | <div style="font-size:16px;font-weight:800;color:var(--warning)">${Formatters.number(minStock)}</div> |
| 115 | <div style="font-size:10.5px;color:var(--text-muted);margin-top:4px">${product.unit || 'عدد'}</div> |
| 116 | </div> |
| 117 | </div> |
| 118 | |
| 119 | <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;flex-wrap:wrap;gap:8px"> |
| 120 | <div style="font-size:12.5px;color:var(--text-muted)"> |
| 121 | ریز حرکات انبار (${Formatters.toPersianDigits(kardex.rows.length)} مورد) |
| 122 | </div> |
| 123 | <button class="btn btn-secondary btn-inline" style="font-size:12px;min-height:34px;padding:4px 12px" onclick="window.StockKardexModal.openAdjustModal('${product.id}')"> |
| 124 | ⚙️ اصلاح دستی موجودی |
| 125 | </button> |
| 126 | </div> |
| 127 | |
| 128 | <div class="table-wrap" style="max-height:400px;overflow-y:auto"> |
| 129 | <table style="min-width:700px"> |
| 130 | <thead style="position:sticky;top:0;z-index:2"> |
| 131 | <tr> |
| 132 | <th>تاریخ</th> |
| 133 | <th style="width:90px">نوع</th> |
| 134 | <th style="width:80px;text-align:center">ورودی</th> |
| 135 | <th style="width:80px;text-align:center">خروجی</th> |
| 136 | <th style="width:100px;text-align:center">موجودی</th> |
| 137 | <th style="width:140px">مرجع</th> |
| 138 | <th>یادداشت</th> |
| 139 | </tr> |
| 140 | </thead> |
| 141 | <tbody>${rowsHtml}</tbody> |
| 142 | </table> |
| 143 | </div> |
| 144 | `; |
| 145 | } |
| 146 | |
| 147 | _buildFooter(product) { |
| 148 | return ` |
| 149 | <button class="btn btn-secondary" onclick="FINORA.Modal.close()">بستن</button> |
| 150 | <button class="btn" onclick="window.StockKardexModal._printKardex('${product.id}')">🖨️ چاپ کاردکس</button> |
| 151 | `; |
| 152 | } |
| 153 | |
| 154 | // ============================================================ |
| 155 | // فرم اصلاح موجودی |
| 156 | // ============================================================ |
| 157 | async openAdjustModal(productId) { |
| 158 | const product = await ProductController.getProduct(productId); |
| 159 | if (!product) return; |
| 160 | const currentStock = await ProductController.getStock(productId); |
| 161 | |
| 162 | const body = ` |
| 163 | <div style="background:#fffbeb;border:1px solid #fcd34d;border-radius:10px;padding:12px 14px;margin-bottom:14px;font-size:12.5px;color:#78350f;line-height:1.7"> |
| 164 | ⚠️ <strong>توجه:</strong> این کار برای اصلاح موجودی انبار استفاده میشه — مثلاً وقتی که انبارگردانی کردی و موجودی واقعی با سیستم فرق داره. |
| 165 | <br> |
| 166 | موجودی ثبتشده در سیستم: <strong>${Formatters.number(currentStock)} ${this._esc(product.unit || 'عدد')}</strong> |
| 167 | </div> |
| 168 | |
| 169 | <div class="form-group"> |
| 170 | <label class="form-label">موجودی واقعی جدید <span class="req">*</span></label> |
| 171 | <input type="text" inputmode="numeric" class="form-control" id="adjQty" value="${NumberInput.format(currentStock)}" /> |
| 172 | <small style="color:var(--text-muted);font-size:11.5px;display:block;margin-top:4px"> |
| 173 | عددی که اینجا وارد میکنی، بهعنوان موجودی نهایی تنظیم میشه. |
| 174 | </small> |
| 175 | </div> |
| 176 | |
| 177 | <div class="form-group"> |
| 178 | <label class="form-label">دلیل / یادداشت</label> |
| 179 | <textarea class="form-control" id="adjNote" rows="2" placeholder="مثلاً: انبارگردانی پایان ماه، مغایرت در شمارش"></textarea> |
| 180 | </div> |
| 181 | `; |
| 182 | |
| 183 | const footer = ` |
| 184 | <button class="btn btn-secondary" onclick="FINORA.Modal.close()">انصراف</button> |
| 185 | <button class="btn btn-warning" onclick="window.StockKardexModal.saveAdjust('${productId}')">⚙️ ثبت اصلاح</button> |
| 186 | `; |
| 187 | |
| 188 | Modal.open({ title: '⚙️ اصلاح دستی موجودی', body, footer, size: 'sm' }); |
| 189 | } |
| 190 | |
| 191 | async saveAdjust(productId) { |
| 192 | const newQty = NumberInput.parse(document.getElementById('adjQty').value); |
| 193 | const note = (document.getElementById('adjNote').value || '').trim(); |
| 194 | |
| 195 | if (isNaN(newQty) || newQty < 0) { |
| 196 | Toast.warning('موجودی معتبر نیست'); |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | try { |
| 201 | await ProductController.addStockMovement( |
| 202 | productId, |
| 203 | 'adjust', |
| 204 | newQty, |
| 205 | 'manual', |
| 206 | null, |
| 207 | note || 'اصلاح دستی موجودی' |
| 208 | ); |
| 209 | |
| 210 | Toast.success('موجودی اصلاح شد'); |
| 211 | |
| 212 | // بستن و باز کردن مجدد کاردکس |
| 213 | Modal.close(); |
| 214 | setTimeout(() => this.open(productId), 300); |
| 215 | |
| 216 | // رفرش جدول کالاها اگه بازه |
| 217 | if (window.ProductsView && window.ProductsView.reload) { |
| 218 | window.ProductsView.reload().then(() => { |
| 219 | const el = document.getElementById('products-tab-content'); |
| 220 | if (el && window.ProductsView.renderTabContent) { |
| 221 | el.innerHTML = window.ProductsView.renderTabContent(); |
| 222 | } |
| 223 | }); |
| 224 | } |
| 225 | } catch (err) { |
| 226 | console.error(err); |
| 227 | Toast.error('خطا: ' + err.message); |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | // ============================================================ |
| 232 | // چاپ کاردکس |
| 233 | // ============================================================ |
| 234 | async _printKardex(productId) { |
| 235 | const product = await ProductController.getProduct(productId); |
| 236 | if (!product) return; |
| 237 | const kardex = await ProductController.getKardex(productId); |
| 238 | |
| 239 | const rowsHtml = [...kardex.rows].reverse().map(r => { |
| 240 | const isIn = r.type === 'in'; |
| 241 | const isOut = r.type === 'out'; |
| 242 | const typeLabel = isIn ? 'ورود' : isOut ? 'خروج' : 'اصلاح'; |
| 243 | return ` |
| 244 | <tr> |
| 245 | <td>${this._formatDate(r.date)}</td> |
| 246 | <td>${typeLabel}</td> |
| 247 | <td>${isIn ? Formatters.number(r.qty) : '—'}</td> |
| 248 | <td>${isOut ? Formatters.number(r.qty) : '—'}</td> |
| 249 | <td>${Formatters.number(r.balance)}</td> |
| 250 | <td>${this._refLabel(r.refType, r.refId)}</td> |
| 251 | <td>${this._esc(r.note || '')}</td> |
| 252 | </tr> |
| 253 | `; |
| 254 | }).join(''); |
| 255 | |
| 256 | const printWin = window.open('', '_blank', 'width=900,height=700'); |
| 257 | if (!printWin) { Toast.error('پاپآپ را فعال کنید'); return; } |
| 258 | |
| 259 | printWin.document.write(` |
| 260 | <!DOCTYPE html> |
| 261 | <html lang="fa" dir="rtl"> |
| 262 | <head> |
| 263 | <meta charset="UTF-8" /> |
| 264 | <title>کاردکس ${product.name}</title> |
| 265 | <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/misc/Farsi-Digits/Vazirmatn-FD-font-face.css" /> |
| 266 | <style> |
| 267 | @page { size: A4 portrait; margin: 10mm; } |
| 268 | * { box-sizing: border-box; margin: 0; padding: 0; } |
| 269 | html, body { direction: rtl; text-align: right; font-family: 'Vazirmatn FD', Tahoma, sans-serif; background: #fff; color: #000; } |
| 270 | body { padding: 10px; } |
| 271 | h1 { font-size: 18px; color: #0d9488; text-align: center; margin-bottom: 6px; } |
| 272 | .info { text-align: center; font-size: 12px; color: #64748b; margin-bottom: 16px; } |
| 273 | .summary { display: flex; gap: 10px; margin-bottom: 16px; } |
| 274 | .summary > div { flex: 1; border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px; text-align: center; } |
| 275 | .summary .val { font-size: 18px; font-weight: 800; color: #0d9488; margin-top: 4px; } |
| 276 | .summary .lbl { font-size: 11px; color: #64748b; } |
| 277 | table { width: 100%; border-collapse: collapse; } |
| 278 | th, td { padding: 7px 9px; border: 1px solid #cbd5e1; text-align: right; font-size: 11.5px; } |
| 279 | th { background: #f1f5f9; font-weight: 700; } |
| 280 | .footer { margin-top: 20px; text-align: center; font-size: 10px; color: #94a3b8; padding-top: 10px; border-top: 1px dashed #cbd5e1; } |
| 281 | </style> |
| 282 | </head> |
| 283 | <body> |
| 284 | <h1>کاردکس کالا</h1> |
| 285 | <div class="info"> |
| 286 | ${this._esc(product.name)}${product.code ? ' - کد: ' + Formatters.toPersianDigits(product.code) : ''} | تاریخ چاپ: ${Jalali.today()} |
| 287 | </div> |
| 288 | <div class="summary"> |
| 289 | <div> |
| 290 | <div class="lbl">موجودی فعلی</div> |
| 291 | <div class="val">${Formatters.number(kardex.finalBalance)}</div> |
| 292 | </div> |
| 293 | <div> |
| 294 | <div class="lbl">جمع ورودی</div> |
| 295 | <div class="val" style="color: #059669">${Formatters.number(kardex.totalIn)}</div> |
| 296 | </div> |
| 297 | <div> |
| 298 | <div class="lbl">جمع خروجی</div> |
| 299 | <div class="val" style="color: #dc2626">${Formatters.number(kardex.totalOut)}</div> |
| 300 | </div> |
| 301 | </div> |
| 302 | <table> |
| 303 | <thead> |
| 304 | <tr> |
| 305 | <th>تاریخ</th> |
| 306 | <th>نوع</th> |
| 307 | <th>ورودی</th> |
| 308 | <th>خروجی</th> |
| 309 | <th>موجودی</th> |
| 310 | <th>مرجع</th> |
| 311 | <th>یادداشت</th> |
| 312 | </tr> |
| 313 | </thead> |
| 314 | <tbody>${rowsHtml}</tbody> |
| 315 | </table> |
| 316 | <div class="footer">Factor-easyPro - سامانه مدیریت کسبوکار</div> |
| 317 | </body> |
| 318 | </html> |
| 319 | `); |
| 320 | printWin.document.close(); |
| 321 | setTimeout(() => { printWin.focus(); printWin.print(); }, 500); |
| 322 | } |
| 323 | |
| 324 | // ============================================================ |
| 325 | // Helpers |
| 326 | // ============================================================ |
| 327 | _formatDate(isoStr) { |
| 328 | if (!isoStr) return '—'; |
| 329 | try { |
| 330 | const d = new Date(isoStr); |
| 331 | const jalali = Jalali.fromDate(d); |
| 332 | const time = `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`; |
| 333 | return Formatters.toPersianDigits(`${jalali.year}/${String(jalali.month).padStart(2, '0')}/${String(jalali.day).padStart(2, '0')} - ${time}`); |
| 334 | } catch (e) { |
| 335 | return '—'; |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | _refLabel(refType, refId) { |
| 340 | if (!refType || refType === 'manual') return '<span style="color:var(--text-muted)">دستی</span>'; |
| 341 | if (refType === 'invoice') return `فاکتور`; |
| 342 | if (refType === 'purchase') return `خرید`; |
| 343 | return refType; |
| 344 | } |
| 345 | |
| 346 | _esc(s) { |
| 347 | if (!s) return ''; |
| 348 | return String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | export const StockKardexModal = new StockKardexModalImpl(); |
| 353 | window.StockKardexModal = StockKardexModal; |