Ejemplo n.º 1
0
    def create_contribution(self):
        contribution = Contribution(**self.parsed_row)

        # If there's no filing in the database for this contribution
        if contribution.form_id_number not in PARSED_FILING_IDS:
            # Skip this contribution
            return

        contribution.filing_id = contribution.form_id_number
        contribution.committee_id = contribution.EIN

        CONTRIBUTIONS.append(contribution)
Ejemplo n.º 2
0
    def create_object(self):
        if self.form_type == "A":
            contribution = Contribution(**self.parsed_row)

            # If there's no filing in the database for this contribution
            if contribution.form_id_number not in PARSED_FILING_IDS:
                # Skip this contribution
                return

            contribution.filing_id = contribution.form_id_number
            contribution.committee_id = contribution.EIN

            CONTRIBUTIONS.append(contribution)
        elif self.form_type == "B":
            expenditure = Expenditure(**self.parsed_row)

            # If there's no filing in the database for this expenditure
            if expenditure.form_id_number not in PARSED_FILING_IDS:
                # Skip this expenditure
                return

            expenditure.filing_id = expenditure.form_id_number
            expenditure.committee_id = expenditure.EIN

            EXPENDITURES.append(expenditure)

        elif self.form_type == "2":
            filing = F8872(**self.parsed_row)
            PARSED_FILING_IDS.add(filing.form_id_number)
            logger.debug("Parsing filing {}".format(filing.form_id_number))
            committee, created = Committee.objects.get_or_create(EIN=filing.EIN)
            if created:
                committee.name = filing.organization_name
                committee.save()
            filing.committee = committee

            filing.save()