This commit is contained in:
aminhashemi92 2025-09-29 17:38:11 +03:30
parent 810c87e2e0
commit b5bf3a5dbe
51 changed files with 2397 additions and 326 deletions

View file

@ -96,9 +96,8 @@
<span></span>
{% endif %}
{% if next_step %}
{% if is_broker %}
<button type="submit" class="btn btn-primary">تایید و بعدی
<i class="bx bx-chevron-left bx-sm me-sm-n2"></i>
{% if is_broker and step_instance.status != 'completed' %}
<button type="submit" class="btn btn-primary">تایید
</button>
{% else %}
<a href="{% url 'processes:step_detail' instance.id next_step.id %}" class="btn btn-primary">

View file

@ -1,3 +1,4 @@
from django.db.models.query import FlatValuesListIterable
from django.shortcuts import render, get_object_or_404, redirect
from django.contrib.auth.decorators import login_required
from django.urls import reverse
@ -28,6 +29,9 @@ def build_contract_context(instance: ProcessInstance) -> dict:
except Exception:
latest_payment_date = None
individual = True if profile and profile.user_type == 'individual' else False
company_national_id = profile.company_national_id if profile and profile.user_type == 'legal' else None
company_name = profile.company_name if profile and profile.user_type == 'legal' else None
return {
'customer_full_name': mark_safe(f"<span class=\"fw-bold\">{representative.get_full_name() if representative else ''}</span>"),
'registration_number': mark_safe(f"<span class=\"fw-bold\">{instance.broker.company.registration_number if instance.broker and instance.broker.company else ''}</span>"),
@ -48,6 +52,11 @@ def build_contract_context(instance: ProcessInstance) -> dict:
'bank_name': mark_safe(f"<span class=\"fw-bold\">{instance.representative.profile.get_bank_name_display() if instance.representative else ''}</span>"),
'prepayment_amount': mark_safe(f"<span class=\"fw-bold\">{int(total_paid):,}</span>"),
'prepayment_date': mark_safe(f"<span class=\"fw-bold\">{jalali_converter2(latest_payment_date)}</span>") if latest_payment_date else '',
'user_type': mark_safe(f"<span>{profile.get_user_type_display() if profile else ''}</span>"),
'individual': individual,
'company_national_id': mark_safe(f"<span class=\"fw-bold\">{company_national_id if company_national_id else ''}</span>"),
'company_name': mark_safe(f"<span class=\"fw-bold\">{company_name if company_name else ''}</span>"),
}
@ -59,6 +68,8 @@ def contract_step(request, instance_id, step_id):
previous_step = instance.process.steps.filter(order__lt=step.order).last()
next_step = instance.process.steps.filter(order__gt=step.order).first()
step_instance = StepInstance.objects.filter(process_instance=instance, step=step).first()
profile = getattr(request.user, 'profile', None)
is_broker = False
can_view_contract_body = True
@ -93,15 +104,16 @@ def contract_step(request, instance_id, step_id):
if request.method == 'POST':
if not is_broker:
return JsonResponse({'success': False, 'message': 'شما مجوز تایید این مرحله را ندارید'}, status=403)
StepInstance.objects.update_or_create(
step_instance, _ = StepInstance.objects.update_or_create(
process_instance=instance,
step=step,
defaults={'status': 'completed', 'completed_at': timezone.now()}
)
if next_step:
instance.current_step = next_step
# instance.current_step = next_step
instance.save()
return redirect('processes:step_detail', instance_id=instance.id, step_id=next_step.id)
return redirect('processes:step_detail', instance_id=instance.id, step_id=step.id)
# return redirect('processes:step_detail', instance_id=instance.id, step_id=next_step.id)
return redirect('processes:request_list')
return render(request, 'contracts/contract_step.html', {
@ -113,6 +125,7 @@ def contract_step(request, instance_id, step_id):
'next_step': next_step,
'is_broker': is_broker,
'can_view_contract_body': can_view_contract_body,
'step_instance': step_instance,
})