class SpltCd(CalAccessBaseModel):
    """
    Split records
    """
    UNIQUE_KEY = ("FILING_ID", "AMEND_ID", "LINE_ITEM", "PFORM_TYPE")
    amend_id = fields.IntegerField(
        db_column='AMEND_ID',
        db_index=True,
        help_text="Amendment identification number. A number of 0 is the \
original filing and 1 to 999 amendments.",
        verbose_name="amendment ID")
    elec_amount = fields.DecimalField(max_digits=16,
                                      decimal_places=2,
                                      db_column='ELEC_AMOUNT',
                                      help_text="This field is undocumented")
    elec_code = fields.CharField(
        max_length=2,
        db_column='ELEC_CODE',
        blank=True,
        help_text='This field is undocumented',
    )
    elec_date = fields.DateField(db_column='ELEC_DATE',
                                 null=True,
                                 help_text="This field is undocumented")
    filing_id = fields.IntegerField(
        db_column='FILING_ID',
        db_index=True,
        verbose_name='filing ID',
        help_text="Unique filing identificiation number")
    line_item = fields.IntegerField(
        db_column='LINE_ITEM',
        help_text="Line item number of this record",
        db_index=True,
    )
    PFORM_TYPE_CHOICES = (
        ('A', ''),
        ('B1', ''),
        ('B2', ''),
        ('C', ''),
        ('D', ''),
        ('F450P5', ''),
        ('H', ''),
    )
    pform_type = fields.CharField(
        max_length=7,
        db_column='PFORM_TYPE',
        db_index=True,
        choices=PFORM_TYPE_CHOICES,
        help_text='This field is undocumented',
    )
    ptran_id = fields.CharField(
        verbose_name='transaction ID',
        max_length=32,
        db_column='PTRAN_ID',
        blank=True,
        help_text='Permanent value unique to this item',
    )

    class Meta:
        app_label = 'calaccess_raw'
        db_table = 'SPLT_CD'
        verbose_name = 'SPLT_CD'
        verbose_name_plural = 'SPLT_CD'

    def __str__(self):
        return str(self.filing_id)
class SmryCd(CalAccessBaseModel):
    """
    Summary totals from filings.
    """
    UNIQUE_KEY = (
        "FILING_ID",
        "AMEND_ID",
        "LINE_ITEM",
        "REC_TYPE",
        "FORM_TYPE",
    )
    DOCUMENTCLOUD_PAGES = [
        DocumentCloud(id='2711614-CalAccessTablesWeb',
                      start_page=131,
                      end_page=132),
    ]
    filing_id = fields.IntegerField(
        db_column='FILING_ID',
        db_index=True,
        verbose_name='filing ID',
        help_text="Unique filing identificiation number")
    amend_id = fields.IntegerField(
        db_column='AMEND_ID',
        db_index=True,
        help_text="Amendment identification number. A number of 0 is the \
original filing and 1 to 999 amendments.",
        verbose_name="amendment ID")
    line_item = fields.CharField(max_length=8,
                                 db_column='LINE_ITEM',
                                 db_index=True,
                                 help_text="Line item number of this record")
    REC_TYPE_CHOICES = (('SMRY', 'SMRY'), )
    rec_type = fields.CharField(
        max_length=4,
        db_column='REC_TYPE',
        db_index=True,
        choices=REC_TYPE_CHOICES,
        verbose_name='record type',
    )
    FORM_TYPE_CHOICES = (
        ('401A', 'Form 401 (Slate mailer organization campaign statement): \
Schedule A, payments received'),
        ('401B', 'Form 401 (Slate mailer organization campaign statement): \
Schedule B, payments made'),
        ('401B-1', 'Form 401 (Slate mailer organization campaign statement): \
Schedule B1, payments made by agent or independent contractor'),
        ('A', 'Form 460 (Recipient committee campaign statement): \
Schedule A, '),
        ('B1', 'Form 460 (Recipient committee campaign statement): \
Schedule B1, '),
        ('B2', 'Form 460 (Recipient committee campaign statement): \
Schedule B2, '),
        ('B3', 'Form 460 (Recipient committee campaign statement): \
Schedule B3, '),
        ('C', 'Form 460 (Recipient committee campaign statement): \
Schedule C, '),
        ('D', 'Form 460 (Recipient committee campaign statement): \
Schedule D, '),
        ('E', 'Form 460 (Recipient committee campaign statement): \
Schedule E, '),
        ('F', 'Form 460 (Recipient committee campaign statement): \
Schedule F, '),
        ('G', 'Form 460 (Recipient committee campaign statement): \
Schedule G, '),
        ('H', 'Form 460 (Recipient committee campaign statement): \
Schedule H, '),
        ('H1', 'Form 460 (Recipient committee campaign statement): \
Schedule H1, '),
        ('H2', 'Form 460 (Recipient committee campaign statement): \
Schedule H2, '),
        ('H3', 'Form 460 (Recipient committee campaign statement): \
Schedule H3, '),
        ('I', 'Form 460 (Recipient committee campaign statement): \
Schedule I, '),
        ('F401', 'Form 401 (Slate mailer organization campaign statement)'),
        ('F450', 'Form 450 (Recipient committee campaign statement, \
short form)'),
        ('F460', 'Form 460 (Recipient committee campaign statement)'),
        ('F461', 'Form 461 (Independent expenditure and major donor \
committee campaign statement)'),
        ('F465', 'Form 465 ()'),
        ('F625', 'Form 625 (Report of lobbying firm)'),
        ('F625P2', 'Form 625 (Report of lobbying firm): \
Part 2, payments received in connection with lobbying activity'),
        ('F625P3A', 'Form 625 (Report of lobbying firm): \
Part 3A, payments for activity expenses made in connection with \
lobbying activities'),
        ('F625P3B', 'Form 625 (Report of lobbying firm): \
Part 3B, payments to other lobbying firms made in connection with \
lobbying activities'),
        ('F635', 'Form 635 (Report of lobbyist employer and lobbying \
coalition)'),
        ('F635P3A', 'Form 635 (Report of lobbyist employer and lobbying \
coalition): Part 3A, payments in in-house employee lobbyists'),
        ('F635P3B', 'Form 635 (Report of lobbyist employer and lobbying \
coalition): Part 3B, payments to lobbying firms'),
        ('F635P3C', 'Form 635 (Report of lobbyist employer and lobbying \
coalition): Part 3C, activity expenses'),
        ('F635P3D', 'Form 635 (Report of lobbyist employer and lobbying \
coalition): Part 3D, other payments to influence legislative or \
administrative action'),
        ('F635P3E', 'Form 635 (Report of lobbyist employer and lobbying \
coalition): Part 3E, payments in connection with administrative testimony \
in ratemaking proceedings before the California Public Utilities Commission'),
        ('F645', 'Form 645 (Report of person spending $5,000 or more to \
influence legislative or administrative action)'),
        ('F645P2A', 'Form 645 (Report of person spending $5,000 or more to \
influence legislative or administrative action): Part 2A, activity expenses'),
        ('F645P2B', 'Form 645 (Report of person spending $5,000 or more to \
influence legislative or administrative action): Part 2B, \
other payments to influence legislative or administrative action'),
        ('F645P2C', 'Form 645 (Report of person spending $5,000 or more to \
influence legislative or administrative action): Part 2C, \
payments in connection with administrative testimony in ratemaking \
proceedings before the California Public Utilities Commission'),
        ('F900', 'Form 900 (Form 900 (Public Employee\'s Retirement Board \
         Candidate Campaign Statement)'),
        ('S640', 'Form 640 (Governmental agencies reporting ther payments to \
influence legislative or administrative action attachment)'),
    )
    form_type = fields.CharField(
        max_length=8,
        db_column='FORM_TYPE',
        db_index=True,
        choices=FORM_TYPE_CHOICES,
        help_text='Name of the source filing form or schedule')
    amount_a = fields.DecimalField(decimal_places=2,
                                   null=True,
                                   max_digits=14,
                                   db_column='AMOUNT_A',
                                   blank=True,
                                   help_text='Summary amount from column A',
                                   verbose_name='amount A')
    amount_b = fields.DecimalField(decimal_places=2,
                                   null=True,
                                   max_digits=14,
                                   db_column='AMOUNT_B',
                                   blank=True,
                                   help_text='Summary amount from column B',
                                   verbose_name='amount B')
    amount_c = fields.DecimalField(decimal_places=2,
                                   null=True,
                                   max_digits=14,
                                   db_column='AMOUNT_C',
                                   blank=True,
                                   help_text='Summary amount from column C',
                                   verbose_name='amount C')
    elec_dt = fields.DateField(db_column='ELEC_DT',
                               null=True,
                               blank=True,
                               verbose_name='election date')

    class Meta:
        app_label = 'calaccess_raw'
        db_table = 'SMRY_CD'
        verbose_name = 'SMRY_CD'
        verbose_name_plural = 'SMRY_CD'
        ordering = ("filing_id", "-amend_id", 'form_type', "line_item")

    def __str__(self):
        return str(self.filing_id)

    def pretty_amount_a(self):
        if self.amount_a is None:
            return None
        return "$%s" % intcomma(floatformat(self.amount_a, 0))

    pretty_amount_a.short_description = 'amount A'

    def pretty_amount_b(self):
        if self.amount_b is None:
            return None
        return "$%s" % intcomma(floatformat(self.amount_b, 0))

    pretty_amount_b.short_description = 'amount B'

    def pretty_amount_c(self):
        if self.amount_c is None:
            return None
        return "$%s" % intcomma(floatformat(self.amount_c, 0))

    pretty_amount_c.short_description = 'amount C'