def summarize_nonquarterly_f5(new_filing):
    filing_ies = SkedE.objects.filter(filing_number=new_filing.filing_number)
    
    results = filing_ies.aggregate(start_date=Min('expenditure_date_formatted'), end_date=Max('expenditure_date_formatted'))
    new_filing.coverage_from_date = results['start_date']
    new_filing.coverage_to_date = results['end_date']
    new_filing.save()
def summarize_f6(new_filing):
    filing_skeda = SkedA.objects.filter(filing_number=new_filing.filing_number)

    results = filing_skeda.aggregate(tot_raised=Sum('contribution_amount'), start_date=Min('contribution_date_formatted'), end_date=Max('contribution_date_formatted'))
    if results:
        new_filing.tot_raised = results['tot_raised']
        new_filing.coverage_from_date = results['start_date']
        new_filing.coverage_to_date = results['end_date']
        new_filing.save()
def summarize_f24(new_filing):
    filing_ies = SkedE.objects.filter(filing_number=new_filing.filing_number)
    
    results = filing_ies.aggregate(tot_spent=Sum('expenditure_amount'), start_date=Min('expenditure_date_formatted'), end_date=Max('expenditure_date_formatted'))
    if results:
        new_filing.tot_spent = results['tot_spent']
        new_filing.tot_ies = results['tot_spent']
        new_filing.coverage_from_date = results['start_date']
        new_filing.coverage_to_date = results['end_date']
        new_filing.save()