예제 #1
0
    def to_evars_direct(self):
        """
        Get stored data as a dict of evars following defined evar maps.
        Raises an error on conflicting calculations.
        Converts field values stored as strings to int/float.
        """
        results = {}

        if self._EVAR_MAP_BY_YEAR:
            year_evar_map = self._EVAR_MAP_BY_YEAR.get(self.year)
        else:
            year_evar_map = None

        for key, value in self._fields.items():
            if self._EVAR_MAP and key in self._EVAR_MAP:
                evar = self._EVAR_MAP[key]
            elif year_evar_map and key in year_evar_map:
                evar = year_evar_map[key]
            else:
                continue  # pragma: no cover
            if evar in results and results[evar] != value:
                raise ValueError('Different calc for same evar.')
            results[evar] = value

        # convert results to value types
        for key, value in results.items():
            if isinstance(value, six.string_types):
                results[key] = string_to_number(value)

        return results
예제 #2
0
    def to_evars_indirect(self):
        results = {}
        fields = self._fields

        # MARS - Marital (filing) status
        for i in [1, 2, 3, 4, 5]:
            line = 'line{}'.format(i)
            if line in fields and fields[line]:
                results['MARS'] = i
                break

        # DSI - 1 if claimed as a dependent on another tax return, else 0
        if 'line6a' in fields:
            results['DSI'] = 0 if fields['line6a'] else 1

        # e01100 - Capital gain Distrib. not reported on Sch D
        if fields.get('line13') and fields.get('line13_no_sch_d'):
            results['e01100'] = string_to_number(fields['line13'])

        # blind_head & blind_spouse
        if 'line39a_blind' in fields:
            results['blind_head'] = 1 if fields['line39a_blind'] else 0
        if 'line39a_blind_spouse' in fields:
            if fields['line39a_blind_spouse']:
                results['blind_spouse'] = 1
            else:
                results['blind_spouse'] = 0

        # MIDR - Separately filing spouse itemizing
        if 'line39b' in fields:
            results['MIDR'] = 1 if fields['line39b'] else 0

        # e07600 - Prior year minimum tax credit
        line = self.__EVAR_INDIRECT_FIELDS[self.year]['e07600']
        if fields.get(line) and fields.get(line + 'b') and \
                not (fields.get(line + 'a') or fields.get(line + 'c')):
            results['e07600'] = string_to_number(fields[line])

        # e09800 - Social security tax on tip income
        line = self.__EVAR_INDIRECT_FIELDS[self.year]['e09800']
        if fields.get(line) and fields.get(line + 'a') and \
                not fields.get(line + 'b'):
            results['e09800'] = string_to_number(fields[line])

        return results
예제 #3
0
    def to_evars_indirect(self):
        results = {}
        fields = self._fields

        # e18400 - State and local income taxes
        if (fields.get('line5') and fields.get('line5a') and
                not fields.get('line5b')):
            results['e18400'] = string_to_number(fields['line5'])

        return results
예제 #4
0
    def to_evars_indirect(self):
        results = {}
        fields = self._fields

        # p25470 - Royalty depletion
        p25470_fields = ['line18a', 'line18b', 'line18c']
        if any(key in fields for key in p25470_fields):
            results['p25470'] = sum(string_to_number(fields.get(key, 0))
                                    for key in p25470_fields)

        return results
예제 #5
0
 def example_to_evars_indirect(self):
     fields = self._fields
     if 'field_2' in fields and 'field_2_checked' in fields:
         return {'e00002': string_to_number(fields['field_2'])}
     else:
         return None
예제 #6
0
 def example_to_evars_indirect(self):
     fields = self._fields
     if "field_2" in fields and "field_2_checked" in fields:
         return {"e00002": string_to_number(fields["field_2"])}
     else:
         return None