fix price seperation
This commit is contained in:
		
							parent
							
								
									0d48e7281a
								
							
						
					
					
						commit
						b406f1d7c4
					
				
					 3 changed files with 49 additions and 5 deletions
				
			
		| 
						 | 
					@ -224,7 +224,7 @@
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
          <div class="mb-3">
 | 
					          <div class="mb-3">
 | 
				
			||||||
            <label class="form-label">مبلغ (تومان)</label>
 | 
					            <label class="form-label">مبلغ (تومان)</label>
 | 
				
			||||||
            <input type="number" class="form-control" name="amount" id="id_charge_amount" min="1" required>
 | 
					            <input type="text" inputmode="numeric" pattern="\d*" class="form-control" name="amount" id="id_charge_amount" dir="ltr" autocomplete="off" required>
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
        </form>
 | 
					        </form>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
| 
						 | 
					@ -246,8 +246,17 @@
 | 
				
			||||||
    else { el.classList.add('show'); el.style.display = 'block'; }
 | 
					    else { el.classList.add('show'); el.style.display = 'block'; }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  function submitSpecialCharge(){
 | 
					  function submitSpecialCharge(){
 | 
				
			||||||
    const fd = new FormData(document.getElementById('specialChargeForm'));
 | 
					    const form = document.getElementById('specialChargeForm');
 | 
				
			||||||
 | 
					    const fd = new FormData(form);
 | 
				
			||||||
    fd.append('csrfmiddlewaretoken', document.querySelector('input[name=csrfmiddlewaretoken]').value);
 | 
					    fd.append('csrfmiddlewaretoken', document.querySelector('input[name=csrfmiddlewaretoken]').value);
 | 
				
			||||||
 | 
					    // Ensure raw numeric amount is sent
 | 
				
			||||||
 | 
					    (function ensureRawAmount(){
 | 
				
			||||||
 | 
					      const amountInput = document.getElementById('id_charge_amount');
 | 
				
			||||||
 | 
					      if (amountInput){
 | 
				
			||||||
 | 
					        const raw = (amountInput.getAttribute('data-raw-value') || amountInput.value.replace(/\D/g, ''));
 | 
				
			||||||
 | 
					        if (raw) fd.set('amount', raw);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    })();
 | 
				
			||||||
    fetch('{% url "invoices:add_special_charge" instance.id step.id %}', { method: 'POST', body: fd })
 | 
					    fetch('{% url "invoices:add_special_charge" instance.id step.id %}', { method: 'POST', body: fd })
 | 
				
			||||||
      .then(r=>r.json()).then(resp=>{
 | 
					      .then(r=>r.json()).then(resp=>{
 | 
				
			||||||
        if (resp.success){
 | 
					        if (resp.success){
 | 
				
			||||||
| 
						 | 
					@ -285,6 +294,8 @@
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }).catch(()=> showToast('خطا در ارتباط با سرور', 'danger'));
 | 
					      }).catch(()=> showToast('خطا در ارتباط با سرور', 'danger'));
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Number formatting is handled by number-formatter.js
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,7 +76,7 @@
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                <div class="mb-3">
 | 
					                <div class="mb-3">
 | 
				
			||||||
                  <label class="form-label">مبلغ (تومان)</label>
 | 
					                  <label class="form-label">مبلغ (تومان)</label>
 | 
				
			||||||
                  <input type="number" min="1" class="form-control" name="amount" id="id_amount" required>
 | 
					                  <input type="text" inputmode="numeric" pattern="\d*" class="form-control" name="amount" id="id_amount" dir="ltr" autocomplete="off" required>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                <div class="mb-3">
 | 
					                <div class="mb-3">
 | 
				
			||||||
                  <label class="form-label">تاریخ</label>
 | 
					                  <label class="form-label">تاریخ</label>
 | 
				
			||||||
| 
						 | 
					@ -405,6 +405,14 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function buildForm(){
 | 
					  function buildForm(){
 | 
				
			||||||
    const fd = new FormData(document.getElementById('formFinalPayment'));
 | 
					    const fd = new FormData(document.getElementById('formFinalPayment'));
 | 
				
			||||||
 | 
					    // Ensure raw numeric amount is sent
 | 
				
			||||||
 | 
					    (function ensureRawAmount(){
 | 
				
			||||||
 | 
					      const amountInput = document.getElementById('id_amount');
 | 
				
			||||||
 | 
					      if (amountInput){
 | 
				
			||||||
 | 
					        const raw = (amountInput.getAttribute('data-raw-value') || amountInput.value.replace(/\D/g, ''));
 | 
				
			||||||
 | 
					        if (raw) fd.set('amount', raw);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    })();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // تبدیل تاریخ شمسی به میلادی برای ارسال
 | 
					    // تبدیل تاریخ شمسی به میلادی برای ارسال
 | 
				
			||||||
    const persianDateValue = $('#id_payment_date').val();
 | 
					    const persianDateValue = $('#id_payment_date').val();
 | 
				
			||||||
| 
						 | 
					@ -465,6 +473,24 @@
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Legacy approve button removed; using modal forms below
 | 
					  // Legacy approve button removed; using modal forms below
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Handle AJAX form submission with number formatting
 | 
				
			||||||
 | 
					  $(document).ready(function() {
 | 
				
			||||||
 | 
					    // Override buildForm function for AJAX submission
 | 
				
			||||||
 | 
					    const originalBuildForm = window.buildForm;
 | 
				
			||||||
 | 
					    window.buildForm = function() {
 | 
				
			||||||
 | 
					      // Set raw values before creating FormData
 | 
				
			||||||
 | 
					      if (window.setRawValuesForSubmission) {
 | 
				
			||||||
 | 
					        window.setRawValuesForSubmission();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      const result = originalBuildForm ? originalBuildForm() : new FormData(document.querySelector('form'));
 | 
				
			||||||
 | 
					      // Restore formatted values for display
 | 
				
			||||||
 | 
					      if (window.restoreFormattedValues) {
 | 
				
			||||||
 | 
					        window.restoreFormattedValues();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      return result;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,7 +72,7 @@
 | 
				
			||||||
                    <div class="card-body">
 | 
					                    <div class="card-body">
 | 
				
			||||||
                      <div class="mb-3">
 | 
					                      <div class="mb-3">
 | 
				
			||||||
                        <label class="form-label">مبلغ (تومان)</label>
 | 
					                        <label class="form-label">مبلغ (تومان)</label>
 | 
				
			||||||
                        <input type="number" min="1" class="form-control" name="amount" id="id_amount" required>
 | 
					                        <input type="text" inputmode="numeric" pattern="\d*" class="form-control" name="amount" id="id_amount" dir="ltr" autocomplete="off" required>
 | 
				
			||||||
                      </div>
 | 
					                      </div>
 | 
				
			||||||
                      <div class="mb-3">
 | 
					                      <div class="mb-3">
 | 
				
			||||||
                        <label class="form-label">تاریخ پرداخت/سررسید چک</label>
 | 
					                        <label class="form-label">تاریخ پرداخت/سررسید چک</label>
 | 
				
			||||||
| 
						 | 
					@ -366,6 +366,12 @@
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const form = document.getElementById('formAddPayment');
 | 
					    const form = document.getElementById('formAddPayment');
 | 
				
			||||||
    const fd = buildFormData(form);
 | 
					    const fd = buildFormData(form);
 | 
				
			||||||
 | 
					    // Ensure raw numeric amount is sent
 | 
				
			||||||
 | 
					    (function ensureRawAmount(){
 | 
				
			||||||
 | 
					      const amountInput = document.getElementById('id_amount');
 | 
				
			||||||
 | 
					      const raw = (amountInput.getAttribute('data-raw-value') || amountInput.value.replace(/\D/g, ''));
 | 
				
			||||||
 | 
					      if (raw) fd.set('amount', raw);
 | 
				
			||||||
 | 
					    })();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // تبدیل تاریخ شمسی به میلادی برای ارسال
 | 
					    // تبدیل تاریخ شمسی به میلادی برای ارسال
 | 
				
			||||||
    const persianDateValue = $('#id_payment_date').val();
 | 
					    const persianDateValue = $('#id_payment_date').val();
 | 
				
			||||||
| 
						 | 
					@ -383,7 +389,7 @@
 | 
				
			||||||
          setTimeout(() => { window.location.href = resp.redirect; }, 700);
 | 
					          setTimeout(() => { window.location.href = resp.redirect; }, 700);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        showToast(resp.message + ':' + resp.error || 'خطا در ثبت فیش', 'danger');
 | 
					        showToast((resp.message || resp.error || 'خطا در ثبت فیش'), 'danger');
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }).catch(() => showToast('خطا در ارتباط با سرور', 'danger'));
 | 
					    }).catch(() => showToast('خطا در ارتباط با سرور', 'danger'));
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
| 
						 | 
					@ -460,6 +466,7 @@
 | 
				
			||||||
      } catch (e) { console.error('Error initializing Persian Date Picker:', e); }
 | 
					      } catch (e) { console.error('Error initializing Persian Date Picker:', e); }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  })();
 | 
					  })();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue