{"id":1911,"date":"2025-11-18T19:07:54","date_gmt":"2025-11-18T19:07:54","guid":{"rendered":"https:\/\/nerkhcast.ir\/?page_id=1911"},"modified":"2025-11-18T20:01:15","modified_gmt":"2025-11-18T20:01:15","slug":"loanpayment","status":"publish","type":"page","link":"http:\/\/nerkhcast.ir\/index.php\/loanpayment\/","title":{"rendered":"\u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0627\u0642\u0633\u0627\u0637 \u0648\u0627\u0645"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"1911\" class=\"elementor elementor-1911\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-6b85f4c e-flex e-con-boxed e-con e-parent\" data-id=\"6b85f4c\" data-element_type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-6316d25 elementor-widget elementor-widget-html\" data-id=\"6316d25\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<link href=\"https:\/\/cdn.jsdelivr.net\/gh\/rastikerdar\/vazir-font@v30.0.0\/dist\/font-face.css\" rel=\"stylesheet\" type=\"text\/css\" \/>\r\n\r\n<div style=\"font-family: 'Vazir', sans-serif; direction: rtl; max-width: 900px; margin: 40px auto; padding: 20px;\">\r\n  <div style=\"background: #ffffff; border-radius: 20px; padding: 40px; box-shadow: 0 10px 40px rgba(0,0,0,0.08); border: 1px solid #e0f2e9;\">\r\n    <h2 style=\"text-align: center; margin: 0 0 40px 0; font-size: 28px; color: #0d6042; font-weight: 600;\">\u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0627\u0642\u0633\u0627\u0637 \u0648\u0627\u0645<\/h2>\r\n\r\n    <!-- \u0641\u0631\u0645 \u0648\u0631\u0648\u062f\u06cc -->\r\n    <div style=\"display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; margin-bottom: 40px;\">\r\n      <!-- \u0645\u0628\u0644\u063a \u0648\u0627\u0645 \u0628\u0627 \u062c\u062f\u0627\u06a9\u0646\u0646\u062f\u0647 \u062e\u0648\u062f\u06a9\u0627\u0631 -->\r\n      <div>\r\n        <label style=\"display: block; margin-bottom: 10px; color: #0d6042; font-weight: 500; font-size: 15px;\">\u0645\u0628\u0644\u063a \u0648\u0627\u0645 (\u062a\u0648\u0645\u0627\u0646)<\/label>\r\n        <input type=\"text\" id=\"loanAmountDisplay\" placeholder=\"\u0645\u062b\u0627\u0644: \u06f5\u06f0\u06f0,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0\" value=\"\u06f1\u06f0\u06f0,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0\"\r\n          style=\"width:100%; padding:16px; border-radius:12px; border:2px solid #bbf7d0; font-size:18px; text-align:left; direction:ltr; font-family:monospace;\"\r\n          oninput=\"formatAmount(this)\">\r\n        <input type=\"hidden\" id=\"loanAmount\" value=\"100000000\">\r\n      <\/div>\r\n\r\n      <div>\r\n        <label style=\"display: block; margin-bottom: 10px; color: #0d6042; font-weight: 500; font-size: 15px;\">\u0646\u0631\u062e \u0633\u0648\u062f \u0633\u0627\u0644\u06cc\u0627\u0646\u0647 (%)<\/label>\r\n        <input type=\"number\" step=\"0.01\" id=\"annualRate\" value=\"18\" style=\"width:100%; padding:16px; border-radius:12px; border:2px solid #bbf7d0; font-size:17px;\">\r\n      <\/div>\r\n\r\n      <div>\r\n        <label style=\"display: block; margin-bottom: 10px; color: #0d6042; font-weight: 500; font-size: 15px;\">\u0646\u0648\u0639 \u062f\u0648\u0631\u0647 \u0628\u0627\u0632\u067e\u0631\u062f\u0627\u062e\u062a<\/label>\r\n        <select id=\"periodType\" style=\"width:100%; padding:16px; border-radius:12px; border:2px solid #bbf7d0; font-size:17px; background:#fff;\">\r\n          <option value=\"monthly\">\u0645\u0627\u0647\u06cc\u0627\u0646\u0647<\/option>\r\n          <option value=\"weekly\">\u0647\u0641\u062a\u06af\u06cc<\/option>\r\n          <option value=\"quarterly\">\u0641\u0635\u0644\u06cc (\u0647\u0631 \u06f3 \u0645\u0627\u0647)<\/option>\r\n          <option value=\"yearly\">\u0633\u0627\u0644\u0627\u0646\u0647<\/option>\r\n        <\/select>\r\n      <\/div>\r\n\r\n      <div>\r\n        <label style=\"display: block; margin-bottom: 10px; color: #0d6042; font-weight: 500; font-size: 15px;\">\u062a\u0639\u062f\u0627\u062f \u062f\u0648\u0631\u0647<\/label>\r\n        <input type=\"number\" id=\"periodCount\" value=\"36\" min=\"1\" style=\"width:100%; padding:16px; border-radius:12px; border:2px solid #bbf7d0; font-size:17px;\">\r\n      <\/div>\r\n\r\n      <div style=\"display: flex; align-items: end;\">\r\n        <button onclick=\"calculateLoan()\" style=\"width:100%; padding:18px; background:#16a34a; color:white; border:none; border-radius:12px; font-size:18px; font-weight:600; cursor:pointer; box-shadow:0 8px 20px rgba(22,163,74,0.25);\">\r\n          \u0645\u062d\u0627\u0633\u0628\u0647 \u0627\u0642\u0633\u0627\u0637\r\n        <\/button>\r\n      <\/div>\r\n    <\/div>\r\n\r\n    <!-- \u062e\u0644\u0627\u0635\u0647 \u0646\u062a\u0627\u06cc\u062c -->\r\n    <div id=\"summary\" style=\"display:none; margin:40px 0; padding:30px; background:#f8fffb; border-radius:16px; border-right:5px solid #22c55e;\">\r\n      <div style=\"margin-bottom:28px;\">\r\n        <div style=\"color:#4b5563; font-size:15px; margin-bottom:8px;\">\u0642\u0633\u0637 \u0647\u0631 <span id=\"periodLabel\">\u062f\u0648\u0631\u0647<\/span><\/div>\r\n        <div id=\"monthlyPayment\" style=\"font-size:32px; font-weight:400; color:#0d6042;\">\u06f0 \u062a\u0648\u0645\u0627\u0646<\/div>\r\n      <\/div>\r\n      <div style=\"margin-bottom:28px; padding-top:20px; border-top:1px solid #e0f2e9;\">\r\n        <div style=\"color:#4b5563; font-size:15px; margin-bottom:8px;\">\u0645\u062c\u0645\u0648\u0639 \u0633\u0648\u062f \u067e\u0631\u062f\u0627\u062e\u062a\u06cc<\/div>\r\n        <div id=\"totalInterest\" style=\"font-size:32px; font-weight:400; color:#dc2626;\">\u06f0 \u062a\u0648\u0645\u0627\u0646<\/div>\r\n      <\/div>\r\n      <div style=\"padding-top:20px; border-top:1px solid #e0f2e9;\">\r\n        <div style=\"color:#4b5563; font-size:15px; margin-bottom:8px;\">\u0645\u062c\u0645\u0648\u0639 \u067e\u0631\u062f\u0627\u062e\u062a\u06cc \u06a9\u0644<\/div>\r\n        <div id=\"totalPayment\" style=\"font-size:32px; font-weight:400; color:#0d6042;\">\u06f0 \u062a\u0648\u0645\u0627\u0646<\/div>\r\n      <\/div>\r\n    <\/div>\r\n\r\n    <!-- \u062c\u062f\u0648\u0644 \u0627\u0642\u0633\u0627\u0637 -->\r\n    <div id=\"amortizationSection\" style=\"display:none; margin-top:50px;\">\r\n      <div style=\"display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; flex-wrap:wrap; gap:10px;\">\r\n        <h3 style=\"margin:0; color:#0d6042; font-size:22px;\">\u062c\u062f\u0648\u0644 \u06a9\u0627\u0645\u0644 \u0627\u0642\u0633\u0627\u0637<\/h3>\r\n        <div>\r\n          <button onclick=\"copyTable()\" style=\"padding:10px 20px; background:#e0f2e9; color:#0d6042; border:none; border-radius:8px; margin-left:12px; cursor:pointer; font-size:14px;\">\u06a9\u067e\u06cc \u062c\u062f\u0648\u0644<\/button>\r\n          <button onclick=\"exportToExcel()\" style=\"padding:10px 20px; background:#16a34a; color:white; border:none; border-radius:8px; cursor:pointer; font-size:14px;\">\u062f\u0627\u0646\u0644\u0648\u062f \u0627\u06a9\u0633\u0644<\/button>\r\n        <\/div>\r\n      <\/div>\r\n      <div style=\"overflow-x:auto; border-radius:12px; box-shadow:0 4px 20px rgba(0,0,0,0.06);\">\r\n        <table id=\"amortizationTable\" style=\"width:100%; border-collapse:collapse; background:white; font-size:15px;\">\r\n          <thead style=\"background:#f0fdf4; color:#0d6042;\">\r\n            <tr>\r\n              <th style=\"padding:16px; text-align:center;\">\u062f\u0648\u0631\u0647<\/th>\r\n              <th style=\"padding:16px; text-align:center;\">\u0645\u0628\u0644\u063a \u0642\u0633\u0637<\/th>\r\n              <th style=\"padding:16px; text-align:center;\">\u0633\u0648\u062f<\/th>\r\n              <th style=\"padding:16px; text-align:center;\">\u0627\u0635\u0644 \u0648\u0627\u0645<\/th>\r\n              <th style=\"padding:16px; text-align:center;\">\u0645\u0627\u0646\u062f\u0647 \u0628\u062f\u0647\u06cc<\/th>\r\n            <\/tr>\r\n          <\/thead>\r\n          <tbody style=\"text-align:center;\"><\/tbody>\r\n        <\/table>\r\n      <\/div>\r\n    <\/div>\r\n  <\/div>\r\n<\/div>\r\n\r\n<script>\r\n\/\/ \u062c\u062f\u0627\u06a9\u0646\u0646\u062f\u0647 \u062e\u0648\u062f\u06a9\u0627\u0631 \u0645\u0628\u0644\u063a \u0648\u0627\u0645\r\nfunction formatAmount(input) {\r\n  let value = input.value.replace(\/[^\\d]\/g, '');\r\n  if (value === '') {\r\n    document.getElementById('loanAmount').value = '';\r\n    input.value = '';\r\n    return;\r\n  }\r\n  input.value = Number(value).toLocaleString('en-US');\r\n  document.getElementById('loanAmount').value = value;\r\n}\r\n\r\nfunction numberWithCommas(x) {\r\n  return parseInt(x).toLocaleString('fa-IR');\r\n}\r\n\r\nfunction getPeriodName(type, num) {\r\n  const names = { weekly: '\u0647\u0641\u062a\u0647', monthly: '\u0645\u0627\u0647', quarterly: '\u0641\u0635\u0644', yearly: '\u0633\u0627\u0644' };\r\n  return `${num} ${names[type] || '\u0645\u0627\u0647'}`;\r\n}\r\n\r\nfunction calculateLoan() {\r\n  const principal = parseFloat(document.getElementById('loanAmount').value) || 0;\r\n  const annualRate = parseFloat(document.getElementById('annualRate').value) || 0;\r\n  const periodType = document.getElementById('periodType').value;\r\n  const periodCount = parseInt(document.getElementById('periodCount').value) || 0;\r\n\r\n  \/\/ \u0627\u06af\u0631 \u0645\u0642\u0627\u062f\u06cc\u0631 \u0646\u0627\u0645\u0639\u062a\u0628\u0631 \u0628\u0648\u062f \u2192 \u0628\u062f\u0648\u0646 \u0647\u06cc\u0686 \u067e\u06cc\u063a\u0627\u0645\u06cc \u0641\u0642\u0637 \u0645\u062d\u0627\u0633\u0628\u0647 \u0646\u06a9\u0646\r\n  if (principal === 0 || annualRate === 0 || periodCount === 0) {\r\n    return;\r\n  }\r\n\r\n  const periodsInYear = periodType === 'weekly' ? 52 : periodType === 'quarterly' ? 4 : periodType === 'yearly' ? 1 : 12;\r\n  const ratePerPeriod = annualRate \/ 100 \/ periodsInYear;\r\n\r\n  const payment = principal * (ratePerPeriod * Math.pow(1 + ratePerPeriod, periodCount)) \/ (Math.pow(1 + ratePerPeriod, periodCount) - 1);\r\n  const totalPayment = payment * periodCount;\r\n  const totalInterest = totalPayment - principal;\r\n\r\n  const periodText = periodType === 'weekly' ? '\u0647\u0641\u062a\u06af\u06cc' : periodType === 'quarterly' ? '\u0641\u0635\u0644\u06cc' : periodType === 'yearly' ? '\u0633\u0627\u0644\u0627\u0646\u0647' : '\u0645\u0627\u0647\u06cc\u0627\u0646\u0647';\r\n  document.querySelector('#periodLabel').textContent = periodText;\r\n\r\n  document.getElementById('monthlyPayment').textContent = numberWithCommas(payment) + ' \u062a\u0648\u0645\u0627\u0646';\r\n  document.getElementById('totalInterest').textContent = numberWithCommas(totalInterest) + ' \u062a\u0648\u0645\u0627\u0646';\r\n  document.getElementById('totalPayment').textContent = numberWithCommas(totalPayment) + ' \u062a\u0648\u0645\u0627\u0646';\r\n\r\n  document.getElementById('summary').style.display = 'block';\r\n  document.getElementById('amortizationSection').style.display = 'block';\r\n\r\n  let balance = principal;\r\n  const tbody = document.querySelector('#amortizationTable tbody');\r\n  tbody.innerHTML = '';\r\n\r\n  for (let i = 1; i <= periodCount; i++) {\r\n    const interestPayment = balance * ratePerPeriod;\r\n    const principalPayment = payment - interestPayment;\r\n    balance -= principalPayment;\r\n    if (balance < 0) balance = 0;\r\n\r\n    const row = document.createElement('tr');\r\n    row.style.background = i % 2 === 0 ? '#fdfdfb' : 'white';\r\n    row.innerHTML = `\r\n      <td style=\"padding:14px;\">${getPeriodName(periodType, i)}<\/td>\r\n      <td style=\"padding:14px; font-weight:500;\">${numberWithCommas(payment)}<\/td>\r\n      <td style=\"padding:14px; color:#dc2626;\">${numberWithCommas(interestPayment)}<\/td>\r\n      <td style=\"padding:14px; color:#16a34a;\">${numberWithCommas(principalPayment)}<\/td>\r\n      <td style=\"padding:14px; font-weight:600; color:#0d6042;\">${numberWithCommas(balance)}<\/td>\r\n    `;\r\n    tbody.appendChild(row);\r\n  }\r\n}\r\n\r\nfunction copyTable() {\r\n  let text = '\u062f\u0648\u0631\u0647\\t\u0645\u0628\u0644\u063a \u0642\u0633\u0637\\t\u0633\u0648\u062f\\t\u0627\u0635\u0644 \u0648\u0627\u0645\\t\u0645\u0627\u0646\u062f\u0647 \u0628\u062f\u0647\u06cc\\n';\r\n  document.querySelectorAll('#amortizationTable tr').forEach(row => {\r\n    row.querySelectorAll('td, th').forEach(cell => text += (cell.innerText || '') + '\\t');\r\n    text += '\\n';\r\n  });\r\n  navigator.clipboard.writeText(text);\r\n  alert('\u062c\u062f\u0648\u0644 \u0628\u0627 \u0645\u0648\u0641\u0642\u06cc\u062a \u06a9\u067e\u06cc \u0634\u062f!');\r\n}\r\n\r\nfunction exportToExcel() {\r\n  const principal = document.getElementById('loanAmount').value || 0;\r\n  if (principal === 0) return;\r\n\r\n  const rate = document.getElementById('annualRate').value;\r\n  const periodType = document.getElementById('periodType').value;\r\n  const periodCount = document.getElementById('periodCount').value;\r\n  const periodsInYear = periodType === 'weekly' ? 52 : periodType === 'quarterly' ? 4 : periodType === 'yearly' ? 1 : 12;\r\n  const ratePerPeriod = parseFloat(rate) \/ 100 \/ periodsInYear;\r\n  const payment = parseFloat(principal) * (ratePerPeriod * Math.pow(1 + ratePerPeriod, periodCount)) \/ (Math.pow(1 + ratePerPeriod, periodCount) - 1);\r\n\r\n  let csv = '\u062f\u0648\u0631\u0647,\u0645\u0628\u0644\u063a \u0642\u0633\u0637,\u0633\u0648\u062f,\u0627\u0635\u0644 \u0648\u0627\u0645,\u0645\u0627\u0646\u062f\u0647 \u0628\u062f\u0647\u06cc\\n';\r\n  let balance = parseFloat(principal);\r\n\r\n  for (let i = 1; i <= periodCount; i++) {\r\n    const interest = balance * ratePerPeriod;\r\n    const prin = payment - interest;\r\n    balance -= prin;\r\n    if (balance < 0) balance = 0;\r\n    csv += `${getPeriodName(periodType, i)},${payment.toFixed(0)},${interest.toFixed(0)},${prin.toFixed(0)},${balance.toFixed(0)}\\n`;\r\n  }\r\n\r\n  const blob = new Blob(['\\uFEFF' + csv], { type: 'text\/csv;charset=utf-8;' });\r\n  const link = document.createElement('a');\r\n  link.href = URL.createObjectURL(blob);\r\n  link.download = `\u0627\u0642\u0633\u0627\u0637 \u0648\u0627\u0645 - ${numberWithCommas(principal)} \u062a\u0648\u0645\u0627\u0646.csv`;\r\n  link.click();\r\n}\r\n\r\n\/\/ \u0627\u062c\u0631\u0627\u06cc \u062e\u0648\u062f\u06a9\u0627\u0631 \u062f\u0631 \u0628\u0627\u0631\u06af\u0630\u0627\u0631\u06cc\r\nwindow.onload = () => {\r\n  formatAmount(document.getElementById('loanAmountDisplay'));\r\n  calculateLoan();\r\n};\r\n<\/script>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0627\u0642\u0633\u0627\u0637 \u0648\u0627\u0645 \u0645\u0628\u0644\u063a \u0648\u0627\u0645 (\u062a\u0648\u0645\u0627\u0646) \u0646\u0631\u062e \u0633\u0648\u062f \u0633\u0627\u0644\u06cc\u0627\u0646\u0647 (%) \u0646\u0648\u0639 \u062f\u0648\u0631\u0647 \u0628\u0627\u0632\u067e\u0631\u062f\u0627\u062e\u062a \u0645\u0627\u0647\u06cc\u0627\u0646\u0647\u0647\u0641\u062a\u06af\u06cc\u0641\u0635\u0644\u06cc (\u0647\u0631 \u06f3 \u0645\u0627\u0647)\u0633\u0627\u0644\u0627\u0646\u0647 \u062a\u0639\u062f\u0627\u062f \u062f\u0648\u0631\u0647 \u0645\u062d\u0627\u0633\u0628\u0647 \u0627\u0642\u0633\u0627\u0637 \u0642\u0633\u0637 \u0647\u0631 \u062f\u0648\u0631\u0647 \u06f0 \u062a\u0648\u0645\u0627\u0646 \u0645\u062c\u0645\u0648\u0639 \u0633\u0648\u062f \u067e\u0631\u062f\u0627\u062e\u062a\u06cc \u06f0 \u062a\u0648\u0645\u0627\u0646 \u0645\u062c\u0645\u0648\u0639 \u067e\u0631\u062f\u0627\u062e\u062a\u06cc \u06a9\u0644 \u06f0 \u062a\u0648\u0645\u0627\u0646 \u062c\u062f\u0648\u0644 \u06a9\u0627\u0645\u0644 \u0627\u0642\u0633\u0627\u0637 \u06a9\u067e\u06cc \u062c\u062f\u0648\u0644 \u062f\u0627\u0646\u0644\u0648\u062f \u0627\u06a9\u0633\u0644 \u062f\u0648\u0631\u0647 \u0645\u0628\u0644\u063a \u0642\u0633\u0637 \u0633\u0648\u062f \u0627\u0635\u0644 \u0648\u0627\u0645 \u0645\u0627\u0646\u062f\u0647 \u0628\u062f\u0647\u06cc<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_kad_post_transparent":"","_kad_post_title":"hide","_kad_post_layout":"fullwidth","_kad_post_sidebar_id":"","_kad_post_content_style":"unboxed","_kad_post_vertical_padding":"hide","_kad_post_feature":"hide","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"class_list":["post-1911","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/nerkhcast.ir\/index.php\/wp-json\/wp\/v2\/pages\/1911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/nerkhcast.ir\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/nerkhcast.ir\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/nerkhcast.ir\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nerkhcast.ir\/index.php\/wp-json\/wp\/v2\/comments?post=1911"}],"version-history":[{"count":26,"href":"http:\/\/nerkhcast.ir\/index.php\/wp-json\/wp\/v2\/pages\/1911\/revisions"}],"predecessor-version":[{"id":1941,"href":"http:\/\/nerkhcast.ir\/index.php\/wp-json\/wp\/v2\/pages\/1911\/revisions\/1941"}],"wp:attachment":[{"href":"http:\/\/nerkhcast.ir\/index.php\/wp-json\/wp\/v2\/media?parent=1911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}