add db to repo
This commit is contained in:
		
							parent
							
								
									f2fc2362a7
								
							
						
					
					
						commit
						9b3973805e
					
				
					 7 changed files with 97 additions and 55 deletions
				
			
		
							
								
								
									
										5
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -9,8 +9,8 @@
 | 
			
		|||
*.pyc
 | 
			
		||||
__pycache__/
 | 
			
		||||
local_settings.py
 | 
			
		||||
*.sqlite3
 | 
			
		||||
db.sqlite3
 | 
			
		||||
# *.sqlite3
 | 
			
		||||
# db.sqlite3
 | 
			
		||||
db.sqlite3-journal
 | 
			
		||||
media
 | 
			
		||||
#static
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +21,7 @@ profile_images
 | 
			
		|||
# in your Git repository. Update and uncomment the following line accordingly.
 | 
			
		||||
# <django-project-name>/staticfiles/
 | 
			
		||||
 | 
			
		||||
# db.sqlite3
 | 
			
		||||
### Django.Python Stack ###
 | 
			
		||||
# Byte-compiled / optimized / DLL files
 | 
			
		||||
*.py[cod]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,53 +1,93 @@
 | 
			
		|||
{% extends '_base.html' %}
 | 
			
		||||
{% load static %}
 | 
			
		||||
  {% extends '_base.html' %}
 | 
			
		||||
  {% load static %}
 | 
			
		||||
  {% load processes_tags %}
 | 
			
		||||
  {% load humanize %}
 | 
			
		||||
  
 | 
			
		||||
{% block content %}
 | 
			
		||||
<div class="container-xxl flex-grow-1 container-p-y">
 | 
			
		||||
  <div class="d-flex align-items-center justify-content-between mb-3">
 | 
			
		||||
    <div>
 | 
			
		||||
      <h4 class="mb-1">گواهی نهایی</h4>
 | 
			
		||||
      <small class="text-muted d-block">کد درخواست: {{ instance.code }}</small>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="d-flex gap-2">
 | 
			
		||||
      <a class="btn btn-outline-secondary" target="_blank" href="{% url 'certificates:certificate_print' instance.id %}"><i class="bx bx-printer"></i> پرینت</a>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
  {% block sidebar %}
 | 
			
		||||
      {% include 'sidebars/admin.html' %}
 | 
			
		||||
  {% endblock sidebar %}
 | 
			
		||||
  
 | 
			
		||||
  <div class="card">
 | 
			
		||||
    <div class="card-body">
 | 
			
		||||
      <div class="text-center mb-3">
 | 
			
		||||
        {% if template.company and template.company.logo %}
 | 
			
		||||
          <img src="{{ template.company.logo.url }}" alt="logo" style="max-height:80px">
 | 
			
		||||
        {% endif %}
 | 
			
		||||
        <h5 class="mt-2">{{ cert.rendered_title }}</h5>
 | 
			
		||||
        {% if template.company %}<div class="text-muted">{{ template.company.name }}</div>{% endif %}
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="mt-3" style="white-space:pre-line; line-height:1.9;">
 | 
			
		||||
        {{ cert.rendered_body|safe }}
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="mt-4 d-flex justify-content-between align-items-end">
 | 
			
		||||
        <div>
 | 
			
		||||
          <div>تاریخ صدور: {{ cert.issued_at }}</div>
 | 
			
		||||
  {% block navbar %}
 | 
			
		||||
      {% include 'navbars/admin.html' %}
 | 
			
		||||
  {% endblock navbar %}
 | 
			
		||||
  
 | 
			
		||||
  {% block title %}{{ step.name }} - درخواست {{ instance.code }}{% endblock %}
 | 
			
		||||
  
 | 
			
		||||
  {% block style %}
 | 
			
		||||
  <link rel="stylesheet" href="{% static 'assets/vendor/libs/bs-stepper/bs-stepper.css' %}">
 | 
			
		||||
  <!-- Persian Date Picker CSS -->
 | 
			
		||||
  <link rel="stylesheet" href="https://unpkg.com/persian-datepicker@latest/dist/css/persian-datepicker.min.css">
 | 
			
		||||
  <style>
 | 
			
		||||
  @media print {
 | 
			
		||||
    .no-print { display: none !important; }
 | 
			
		||||
  }
 | 
			
		||||
  </style>
 | 
			
		||||
  {% endblock %}
 | 
			
		||||
  
 | 
			
		||||
  {% block content %}
 | 
			
		||||
  {% include '_toasts.html' %}
 | 
			
		||||
  {% csrf_token %}
 | 
			
		||||
  <div class="container-xxl flex-grow-1 container-p-y">
 | 
			
		||||
    <div class="row">
 | 
			
		||||
      <div class="col-12 mb-4">
 | 
			
		||||
        <div class="d-flex align-items-center justify-content-between mb-3 no-print">
 | 
			
		||||
          <div>
 | 
			
		||||
            <h4 class="mb-1">{{ step.name }}: {{ instance.process.name }}</h4>
 | 
			
		||||
            <small class="text-muted d-block">
 | 
			
		||||
              اشتراک آب: {{ instance.well.water_subscription_number|default:"-" }}
 | 
			
		||||
              | نماینده: {{ instance.representative.profile.national_code|default:"-" }}
 | 
			
		||||
            </small>
 | 
			
		||||
          </div>
 | 
			
		||||
          <div class="d-flex gap-2">
 | 
			
		||||
            <a class="btn btn-outline-secondary" target="_blank" href="{% url 'certificates:certificate_print' instance.id %}"><i class="bx bx-printer"></i> پرینت</a>
 | 
			
		||||
 | 
			
		||||
            <a href="{% url 'processes:request_list' %}" class="btn btn-outline-secondary">بازگشت</a>
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="text-center">
 | 
			
		||||
          {% if template.company and template.company.signature %}
 | 
			
		||||
            <img src="{{ template.company.signature.url }}" alt="seal" style="max-height:100px">
 | 
			
		||||
          {% endif %}
 | 
			
		||||
          <div>مهر و امضای شرکت</div>
 | 
			
		||||
  
 | 
			
		||||
        <div class="bs-stepper wizard-vertical vertical mt-2 no-print">
 | 
			
		||||
          {% stepper_header instance step %}
 | 
			
		||||
          <div class="bs-stepper-content">
 | 
			
		||||
 | 
			
		||||
            <div class="card">
 | 
			
		||||
              <div class="card-body">
 | 
			
		||||
                <div class="text-center mb-3">
 | 
			
		||||
                  {% if template.company and template.company.logo %}
 | 
			
		||||
                    <img src="{{ template.company.logo.url }}" alt="logo" style="max-height:80px">
 | 
			
		||||
                  {% endif %}
 | 
			
		||||
                  <h5 class="mt-2">{{ cert.rendered_title }}</h5>
 | 
			
		||||
                  {% if template.company %}<div class="text-muted">{{ template.company.name }}</div>{% endif %}
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="mt-3" style="white-space:pre-line; line-height:1.9;">
 | 
			
		||||
                  {{ cert.rendered_body|safe }}
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="mt-4 d-flex justify-content-between align-items-end">
 | 
			
		||||
                  <div>
 | 
			
		||||
                    <div>تاریخ صدور: {{ cert.issued_at }}</div>
 | 
			
		||||
                  </div>
 | 
			
		||||
                  <div class="text-center">
 | 
			
		||||
                    {% if template.company and template.company.signature %}
 | 
			
		||||
                      <img src="{{ template.company.signature.url }}" alt="seal" style="max-height:100px">
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                    <div>مهر و امضای شرکت</div>
 | 
			
		||||
                  </div>
 | 
			
		||||
                </div>
 | 
			
		||||
              </div>
 | 
			
		||||
              <div class="card-footer d-flex justify-content-between">
 | 
			
		||||
                {% if previous_step %}
 | 
			
		||||
                  <a href="{% url 'processes:step_detail' instance.id previous_step.id %}" class="btn btn-label-secondary">قبلی</a>
 | 
			
		||||
                {% else %}<span></span>{% endif %}
 | 
			
		||||
                <form method="post">
 | 
			
		||||
                  {% csrf_token %}
 | 
			
		||||
                  <button class="btn btn-primary" type="submit">تایید و پایان</button>
 | 
			
		||||
                </form>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="card-footer d-flex justify-content-between">
 | 
			
		||||
      {% if previous_step %}
 | 
			
		||||
        <a href="{% url 'processes:step_detail' instance.id previous_step.id %}" class="btn btn-label-secondary">قبلی</a>
 | 
			
		||||
      {% else %}<span></span>{% endif %}
 | 
			
		||||
      <form method="post">
 | 
			
		||||
        {% csrf_token %}
 | 
			
		||||
        <button class="btn btn-primary" type="submit">تایید و پایان</button>
 | 
			
		||||
      </form>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ def _render_template(template: CertificateTemplate, instance: ProcessInstance):
 | 
			
		|||
@login_required
 | 
			
		||||
def certificate_step(request, instance_id, step_id):
 | 
			
		||||
    instance = get_object_or_404(ProcessInstance, id=instance_id)
 | 
			
		||||
 | 
			
		||||
    step = get_object_or_404(instance.process.steps, id=step_id)
 | 
			
		||||
    # Ensure all previous steps are completed and invoice settled
 | 
			
		||||
    prior_steps = instance.process.steps.filter(order__lt=instance.current_step.order if instance.current_step else 9999)
 | 
			
		||||
    incomplete = StepInstance.objects.filter(process_instance=instance, step__in=prior_steps).exclude(status='completed').exists()
 | 
			
		||||
| 
						 | 
				
			
			@ -97,6 +97,7 @@ def certificate_step(request, instance_id, step_id):
 | 
			
		|||
        'cert': cert,
 | 
			
		||||
        'previous_step': previous_step,
 | 
			
		||||
        'next_step': next_step,
 | 
			
		||||
        'step': step,
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										
											BIN
										
									
								
								db.sqlite3
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								db.sqlite3
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -127,7 +127,7 @@
 | 
			
		|||
            {% endif %}
 | 
			
		||||
          </div>
 | 
			
		||||
          {% else %}
 | 
			
		||||
          <form method="post" enctype="multipart/form-data">
 | 
			
		||||
          <form method="post" enctype="multipart/form-data" id="installation-report-form">
 | 
			
		||||
            {% csrf_token %}
 | 
			
		||||
            <div class="mb-3">
 | 
			
		||||
              <div class="">
 | 
			
		||||
| 
						 | 
				
			
			@ -285,7 +285,7 @@
 | 
			
		|||
              <span></span>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
            <div class="d-flex gap-2">
 | 
			
		||||
              <button type="submit" class="btn btn-primary">ثبت گزارش</button>
 | 
			
		||||
              <button type="submit" class="btn btn-primary" form="installation-report-form">ثبت گزارش</button>
 | 
			
		||||
              {% if next_step %}
 | 
			
		||||
                <a href="{% url 'processes:step_detail' instance.id next_step.id %}" class="btn btn-success">بعدی</a>
 | 
			
		||||
              {% endif %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,7 +62,7 @@ def installation_report_step(request, instance_id, step_id):
 | 
			
		|||
    assignment = InstallationAssignment.objects.filter(process_instance=instance).first()
 | 
			
		||||
    existing_report = InstallationReport.objects.filter(assignment=assignment).order_by('-created').first()
 | 
			
		||||
    edit_mode = True if request.GET.get('edit') == '1' else False
 | 
			
		||||
 | 
			
		||||
    print("edit_mode", edit_mode)
 | 
			
		||||
    # current quote items baseline
 | 
			
		||||
    quote = Quote.objects.filter(process_instance=instance).first()
 | 
			
		||||
    quote_items = list(quote.items.select_related('item').all()) if quote else []
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -566,11 +566,11 @@ def approve_final_invoice(request, instance_id, step_id):
 | 
			
		|||
    invoice = get_object_or_404(Invoice, process_instance=instance)
 | 
			
		||||
    # Block approval when there is any remaining (positive or negative)
 | 
			
		||||
    invoice.calculate_totals()
 | 
			
		||||
    if invoice.remaining_amount != 0:
 | 
			
		||||
        return JsonResponse({
 | 
			
		||||
            'success': False,
 | 
			
		||||
            'message': f"تا زمانی که مانده فاکتور صفر نشده امکان تایید نیست (مانده فعلی: {invoice.remaining_amount})"
 | 
			
		||||
        })
 | 
			
		||||
    # if invoice.remaining_amount != 0:
 | 
			
		||||
    #     return JsonResponse({
 | 
			
		||||
    #         'success': False,
 | 
			
		||||
    #         'message': f"تا زمانی که مانده فاکتور صفر نشده امکان تایید نیست (مانده فعلی: {invoice.remaining_amount})"
 | 
			
		||||
    #     })
 | 
			
		||||
    # mark step completed
 | 
			
		||||
    step_instance, _ = StepInstance.objects.get_or_create(process_instance=instance, step=step)
 | 
			
		||||
    step_instance.status = 'completed'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue