|
|
@ -19,41 +19,41 @@ OverviewBudgetEntry = namedtuple( |
|
|
|
|
|
|
|
|
|
|
|
class ProjectOverview: |
|
|
|
class ProjectOverview: |
|
|
|
def __init__(self, budget_data): |
|
|
|
def __init__(self, budget_data): |
|
|
|
""" initializes the class """ |
|
|
|
"""initializes the class""" |
|
|
|
self.budget_data = budget_data |
|
|
|
self.budget_data = budget_data |
|
|
|
self.entries = [] |
|
|
|
self.entries = [] |
|
|
|
self.found = False |
|
|
|
self.found = False |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
@property |
|
|
|
def project(self): |
|
|
|
def project(self): |
|
|
|
""" returns the project number """ |
|
|
|
"""returns the project number""" |
|
|
|
return self.budget_data.project |
|
|
|
return self.budget_data.project |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
@property |
|
|
|
def row(self): |
|
|
|
def row(self): |
|
|
|
""" returns the excel row number """ |
|
|
|
"""returns the excel row number""" |
|
|
|
return self.budget_data.row |
|
|
|
return self.budget_data.row |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
@property |
|
|
|
def expenses(self): |
|
|
|
def expenses(self): |
|
|
|
""" returns the accumulated expenses """ |
|
|
|
"""returns the accumulated expenses""" |
|
|
|
numbers = (excel_value_as_number(e.amount) for e in self.entries) |
|
|
|
numbers = (excel_value_as_number(e.amount) for e in self.entries) |
|
|
|
values = (abs(entry) for entry in numbers) |
|
|
|
values = (abs(entry) for entry in numbers) |
|
|
|
return sum(values) |
|
|
|
return sum(values) |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
@property |
|
|
|
def available(self): |
|
|
|
def available(self): |
|
|
|
""" returns the still available budget """ |
|
|
|
"""returns the still available budget""" |
|
|
|
return self.budget_data.budget - self.expenses |
|
|
|
return self.budget_data.budget - self.expenses |
|
|
|
|
|
|
|
|
|
|
|
def add(self, description, kind, amount): |
|
|
|
def add(self, description, kind, amount): |
|
|
|
""" adds an entry that modifies the available budget """ |
|
|
|
"""adds an entry that modifies the available budget""" |
|
|
|
entry = OverviewBudgetEntry(description, kind, amount) |
|
|
|
entry = OverviewBudgetEntry(description, kind, amount) |
|
|
|
self.entries.append(entry) |
|
|
|
self.entries.append(entry) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _create_overview_map(budget_list): |
|
|
|
def _create_overview_map(budget_list): |
|
|
|
""" returns a dictonary with project as key and overview as value """ |
|
|
|
"""returns a dictonary with project as key and overview as value""" |
|
|
|
map = {} |
|
|
|
map = {} |
|
|
|
for budget_data in budget_list: |
|
|
|
for budget_data in budget_list: |
|
|
|
overview = ProjectOverview(budget_data) |
|
|
|
overview = ProjectOverview(budget_data) |
|
|
@ -62,12 +62,12 @@ def _create_overview_map(budget_list): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _filter_superx_material_expenses(superx_export): |
|
|
|
def _filter_superx_material_expenses(superx_export): |
|
|
|
""" filters superx data to only contain material entries """ |
|
|
|
"""filters superx data to only contain material entries""" |
|
|
|
return (i for i in superx_export.data if i.kind in VALID_MATERIAL_IDS) |
|
|
|
return (i for i in superx_export.data if i.kind in VALID_MATERIAL_IDS) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _create_entries_from_superx(overview_map, superx_export_data): |
|
|
|
def _create_entries_from_superx(overview_map, superx_export_data): |
|
|
|
""" adds overview entries from superx data """ |
|
|
|
"""adds overview entries from superx data""" |
|
|
|
for line in superx_export_data: |
|
|
|
for line in superx_export_data: |
|
|
|
if line.project in overview_map: |
|
|
|
if line.project in overview_map: |
|
|
|
overview = overview_map[line.project] |
|
|
|
overview = overview_map[line.project] |
|
|
@ -85,7 +85,7 @@ def _set_found_state(overview_map, superx_export): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_overview(budget_list, superx_export): |
|
|
|
def create_overview(budget_list, superx_export): |
|
|
|
""" create a overview map with budget entries from the parsed raw data """ |
|
|
|
"""create a overview map with budget entries from the parsed raw data""" |
|
|
|
tmp_map = _create_overview_map(budget_list) |
|
|
|
tmp_map = _create_overview_map(budget_list) |
|
|
|
overview_map = _set_found_state(tmp_map, superx_export) |
|
|
|
overview_map = _set_found_state(tmp_map, superx_export) |
|
|
|
material_expenses = _filter_superx_material_expenses(superx_export) |
|
|
|
material_expenses = _filter_superx_material_expenses(superx_export) |
|
|
|