Ejemplo n.º 1
0
 def test_micro_assessment_needed_missing(self):
     self.partner_organization.hact_values[
         "planned_cash_transfer"] = 10000.00
     self.partner_organization.save()
     PartnerOrganization.micro_assessment_needed(self.partner_organization)
     self.assertEqual(
         self.partner_organization.hact_values["micro_assessment_needed"],
         "Missing")
Ejemplo n.º 2
0
 def test_micro_assessment_needed_high_risk(self):
     year = datetime.date.today().year
     self.partner_organization.type_of_assessment = "High Risk Assumed"
     self.partner_organization.save()
     assessment = Assessment.objects.create(
         partner=self.partner_organization,
         type="Micro Assessment",
         completed_date=datetime.date(year, 1, 1))
     PartnerOrganization.micro_assessment_needed(self.partner_organization)
     self.assertEqual(
         self.partner_organization.hact_values["micro_assessment_needed"],
         "Yes")
Ejemplo n.º 3
0
 def test_micro_assessment_needed_no(self):
     year = datetime.date.today().year
     self.partner_organization.type_of_assessment = "Other"
     self.partner_organization.hact_values[
         "planned_cash_transfer"] = 100000.00
     self.partner_organization.save()
     assessment = Assessment.objects.create(
         partner=self.partner_organization,
         type="Micro Assessment",
         completed_date=datetime.date(year, 1, 1))
     PartnerOrganization.micro_assessment_needed(self.partner_organization)
     self.assertEqual(
         self.partner_organization.hact_values["micro_assessment_needed"],
         "No")
Ejemplo n.º 4
0
 def test_micro_assessment_needed_older_than_54m(self):
     year = datetime.date.today().year
     self.partner_organization.type_of_assessment = "Micro Assessment"
     self.partner_organization.rating = "low"
     self.partner_organization.hact_values[
         "planned_cash_transfer"] = 10000.00
     self.partner_organization.save()
     assessment = Assessment.objects.create(
         partner=self.partner_organization,
         type="Micro Assessment",
         completed_date=datetime.date.today() -
         datetime.timedelta(days=1643))
     PartnerOrganization.micro_assessment_needed(self.partner_organization)
     self.assertEqual(
         self.partner_organization.hact_values["micro_assessment_needed"],
         "Yes")
Ejemplo n.º 5
0
def update_partners(country_name=None):
    print 'Starting update HACT values for partners'
    countries = Country.objects.filter(vision_sync_enabled=True)
    if country_name is not None:
        countries = countries.filter(name=country_name)
    for country in countries:
        connection.set_tenant(country)
        print country.name
        partners = PartnerOrganization.objects.all()
        for partner in partners:
            try:
                PartnerOrganization.micro_assessment_needed(partner)
                if partner.total_ct_cp > 500000:
                    PartnerOrganization.audit_needed(partner)
            except Exception as e:
                print partner.name
                print partner.hact_values
                print e.message
Ejemplo n.º 6
0
def update_all_partners(country_name=None):
    print 'Starting update HACT values for partners'
    countries = Country.objects.filter(vision_sync_enabled=True)
    if country_name is not None:
        countries = countries.filter(name=country_name)
    for country in countries:
        connection.set_tenant(country)
        print country.name
        partners = PartnerOrganization.objects.all()
        for partner in partners:
            try:
                PartnerOrganization.planned_cash_transfers(partner)
                PartnerOrganization.micro_assessment_needed(partner)
                PartnerOrganization.audit_needed(partner)
                PartnerOrganization.planned_visits(partner)
                PartnerOrganization.programmatic_visits(partner)
                PartnerOrganization.spot_checks(partner)
                PartnerOrganization.follow_up_flags(partner)
                PartnerOrganization.audit_done(partner)
            except Exception as e:
                print partner.name
                print partner.hact_values
                print e.message