main flow checked
This commit is contained in:
		
							parent
							
								
									b5bf3a5dbe
								
							
						
					
					
						commit
						f853ad9784
					
				
					 21 changed files with 365 additions and 89 deletions
				
			
		| 
						 | 
				
			
			@ -507,13 +507,22 @@ def instance_summary(request, instance_id):
 | 
			
		|||
 | 
			
		||||
    # Collect final invoice, payments, and certificate if any
 | 
			
		||||
    from invoices.models import Invoice
 | 
			
		||||
    from installations.models import InstallationReport
 | 
			
		||||
    from installations.models import InstallationReport, InstallationAssignment
 | 
			
		||||
    from certificates.models import CertificateInstance
 | 
			
		||||
    invoice = Invoice.objects.filter(process_instance=instance).first()
 | 
			
		||||
    payments = invoice.payments.filter(is_deleted=False).all() if invoice else []
 | 
			
		||||
    latest_report = InstallationReport.objects.filter(assignment__process_instance=instance).order_by('-created').first()
 | 
			
		||||
    certificate = CertificateInstance.objects.filter(process_instance=instance).order_by('-created').first()
 | 
			
		||||
 | 
			
		||||
    # Calculate installation delay
 | 
			
		||||
    installation_assignment = InstallationAssignment.objects.filter(process_instance=instance).first()
 | 
			
		||||
    installation_delay_days = 0
 | 
			
		||||
    if installation_assignment and latest_report:
 | 
			
		||||
        scheduled_date = installation_assignment.scheduled_date
 | 
			
		||||
        visited_date = latest_report.visited_date
 | 
			
		||||
        if scheduled_date and visited_date and visited_date > scheduled_date:
 | 
			
		||||
            installation_delay_days = (visited_date - scheduled_date).days
 | 
			
		||||
 | 
			
		||||
    # Build rows like final invoice step
 | 
			
		||||
    rows = []
 | 
			
		||||
    if invoice:
 | 
			
		||||
| 
						 | 
				
			
			@ -527,6 +536,8 @@ def instance_summary(request, instance_id):
 | 
			
		|||
        'rows': rows,
 | 
			
		||||
        'latest_report': latest_report,
 | 
			
		||||
        'certificate': certificate,
 | 
			
		||||
        'installation_assignment': installation_assignment,
 | 
			
		||||
        'installation_delay_days': installation_delay_days,
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -653,12 +664,11 @@ def export_requests_excel(request):
 | 
			
		|||
            # Get the approval that completed this step
 | 
			
		||||
            approval = StepApproval.objects.filter(
 | 
			
		||||
                step_instance=step_instance,
 | 
			
		||||
                decision='approved',
 | 
			
		||||
                is_deleted=False
 | 
			
		||||
            ).select_related('approved_by').order_by('-created').first()
 | 
			
		||||
            ).select_related('approved_by').order_by('-created_at').first()
 | 
			
		||||
            
 | 
			
		||||
            if approval:
 | 
			
		||||
                approval_dates_map[step_instance.process_instance_id] = approval.created
 | 
			
		||||
                approval_dates_map[step_instance.process_instance_id] = approval.created_at
 | 
			
		||||
                approval_users_map[step_instance.process_instance_id] = approval.approved_by
 | 
			
		||||
    
 | 
			
		||||
    # Calculate progress and installation data
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue