Example #1
0
def printTop10BudgetSubcontractors():
    # the method name is a lie, this ignores subprojects which have multiple contractors
    allOfThem = {}
    ignoredBecauseOfCount = 0
    budgetOfIgnored = 0
    for sub in SubProject.objects.all():
        contractors = sub.contractor.strip()
        if len(contractors) == 0:
            continue
        contractors = contractors.split(",")
        if len(contractors) != 1:
            ignoredBecauseOfCount += 1
            budgetOfIgnored += convertAmountStringToInteger(sub.budget)
        for singleContractor in contractors:
            singleContractor = singleContractor.strip().lower()
            if singleContractor in allOfThem:
                allOfThem[singleContractor] += convertAmountStringToInteger(
                    sub.budget)
            else:
                allOfThem[singleContractor] = convertAmountStringToInteger(
                    sub.budget)

    topToPrint = 10
    for top in sorted(allOfThem, key=lambda k: allOfThem[k], reverse=True):
        print("Subcontractor %s had budget %s" % (top, allOfThem[top]))
        topToPrint -= 1
        if topToPrint == 0:
            break

    print("Ignored %d of the projects, with total budget %d" %
          (ignoredBecauseOfCount, budgetOfIgnored))
def printTop10BudgetSubcontractors():
    # the method name is a lie, this ignores subprojects which have multiple contractors
    allOfThem = {}
    ignoredBecauseOfCount = 0
    budgetOfIgnored = 0
    for sub in SubProject.objects.all():
        contractors = sub.contractor.strip()
        if len(contractors) == 0:
            continue
        contractors = contractors.split(",")
        if len(contractors) != 1:
            ignoredBecauseOfCount += 1
            budgetOfIgnored += convertAmountStringToInteger(sub.budget)
        for singleContractor in contractors:
            singleContractor = singleContractor.strip().lower()
            if singleContractor in allOfThem:
                allOfThem[singleContractor] += convertAmountStringToInteger(sub.budget)
            else:
                allOfThem[singleContractor] = convertAmountStringToInteger(sub.budget)

    topToPrint = 10
    for top in sorted(allOfThem, key=lambda k: allOfThem[k], reverse=True):
        print("Subcontractor %s had budget %s" % (top, allOfThem[top]))
        topToPrint -= 1
        if topToPrint == 0:
            break

    print("Ignored %d of the projects, with total budget %d" % (ignoredBecauseOfCount, budgetOfIgnored))
def budgetSumForPrioProjectsFallingBehind():
    fallingBehindBudgetTotal = 0
    totalBudget = 0
    inProgressBudget = 0
    for project in PriorityProject.objects.all():
        totalBudget += convertAmountStringToInteger(project.budget)
        if project.completedStatus == "ΑΠΑΙΤΟΥΝΤΑΙ ΠΡΟΣΘΕΤΑ ΜΕΤΡΑ" or project.completedStatus == "ΕΡΓΑ ΣΕ ΚΙΝΔΥΝΟ":
            fallingBehindBudgetTotal += convertAmountStringToInteger(project.budget)
        elif project.completedStatus == "ΣΕ ΕΞΕΛΙΞΗ":
            inProgressBudget += convertAmountStringToInteger(project.budget)

    print("total budget is %d, of that falling behind is %d, in progress %d" % (
        totalBudget, fallingBehindBudgetTotal, inProgressBudget))
Example #4
0
def budgetSumForPrioProjectsFallingBehind():
    fallingBehindBudgetTotal = 0
    totalBudget = 0
    inProgressBudget = 0
    for project in PriorityProject.objects.all():
        totalBudget += convertAmountStringToInteger(project.budget)
        if project.completedStatus == "ΑΠΑΙΤΟΥΝΤΑΙ ΠΡΟΣΘΕΤΑ ΜΕΤΡΑ" or project.completedStatus == "ΕΡΓΑ ΣΕ ΚΙΝΔΥΝΟ":
            fallingBehindBudgetTotal += convertAmountStringToInteger(
                project.budget)
        elif project.completedStatus == "ΣΕ ΕΞΕΛΙΞΗ":
            inProgressBudget += convertAmountStringToInteger(project.budget)

    print("total budget is %d, of that falling behind is %d, in progress %d" %
          (totalBudget, fallingBehindBudgetTotal, inProgressBudget))
Example #5
0
def searchTitleForString():
    count = 0
    totalBudget = 0
    for subproject in SubProject.objects.all():
        lowerTitle = subproject.title.lower()
        if titleContains(lowerTitle) and titleNotContains(lowerTitle):
            count += 1
            currentBudget = convertAmountStringToInteger(subproject.budget)
            totalBudget += currentBudget
            if currentBudget > 1000000:
                print("%s has budget %d (belonging to %s)" % (lowerTitle, currentBudget, subproject.owningProject.codeNumber))

    print("Total count is %d, budget sum is %d" % (count, totalBudget))
Example #6
0
def searchTitleForString():
    count = 0
    totalBudget = 0
    for subproject in SubProject.objects.all():
        lowerTitle = subproject.title.lower()
        if titleContains(lowerTitle) and titleNotContains(lowerTitle):
            count += 1
            currentBudget = convertAmountStringToInteger(subproject.budget)
            totalBudget += currentBudget
            if currentBudget > 1000000:
                print("%s has budget %d (belonging to %s)" %
                      (lowerTitle, currentBudget,
                       subproject.owningProject.codeNumber))

    print("Total count is %d, budget sum is %d" % (count, totalBudget))
Example #7
0
def municipalityAnalysis():
    prefectureSums = {}

    for code in prefectures.keys():
        prefectureSums[code] = {}
        for i in range(1996, 2016):  # we magically know that project years are in this range
            prefectureSums[code][i] = 0

    totalBudgetSum = 0  # for checking
    countOfProjects = 0
    ignoredBecauseOfDateBudgetSum = 0

    for project in Project.objects.all():
        countOfProjects += 1
        prefTotalWeight = 0
        projectBudget = convertAmountStringToInteger(project.budget)
        totalBudgetSum += projectBudget
        if project.startDate == "-":
            ignoredBecauseOfDateBudgetSum += projectBudget
            continue
        for prefecture in project.prefecturesOwning.all():
            if prefecture.code != "14":
                prefTotalWeight += ratioToBudgetForEachPrefecture[prefecture.code]

        localPrefectureSum = 0
        for prefecture in project.prefecturesOwning.all():
            if prefecture.code != "14":
                currentPrefWeight = ratioToBudgetForEachPrefecture[prefecture.code] / prefTotalWeight
                currentPrefectureAllocation = projectBudget * currentPrefWeight
                projectYear = datetime.strptime(project.startDate, "%d/%m/%Y").year
                prefectureSums[prefecture.code][projectYear] += currentPrefectureAllocation
                localPrefectureSum += currentPrefectureAllocation
        if abs(localPrefectureSum - projectBudget) > 1:
            print(
                "project %s has prefectures %s but the budget does not equal the allocation (%d vs %d)"
                % (project, project.prefecturesOwning.all(), projectBudget, localPrefectureSum)
            )
    print(totalBudgetSum)
    valuesSum = 0
    for yearValue in prefectureSums.values():
        for value in yearValue.values():
            valuesSum += value
    prettyPrintBudgets(prefectureSums)
    print(valuesSum)
    print(totalBudgetSum - valuesSum)
    print("ignored because of date sum up to %d " % ignoredBecauseOfDateBudgetSum)
def municipalityAnalysis():
    prefectureSums = {}

    for code in prefectures.keys():
        prefectureSums[code] = {}
        for i in range(1996, 2016):  # we magically know that project years are in this range
            prefectureSums[code][i] = 0

    totalBudgetSum = 0  # for checking
    countOfProjects = 0
    ignoredBecauseOfDateBudgetSum = 0

    for project in Project.objects.all():
        countOfProjects += 1
        prefTotalWeight = 0
        projectBudget = convertAmountStringToInteger(project.budget)
        totalBudgetSum += projectBudget
        if project.startDate == "-":
            ignoredBecauseOfDateBudgetSum += projectBudget
            continue
        for prefecture in project.prefecturesOwning.all():
            if prefecture.code != "14":
                prefTotalWeight += ratioToBudgetForEachPrefecture[prefecture.code]

        localPrefectureSum = 0
        for prefecture in project.prefecturesOwning.all():
            if prefecture.code != "14":
                currentPrefWeight = ratioToBudgetForEachPrefecture[prefecture.code] / prefTotalWeight
                currentPrefectureAllocation = projectBudget * currentPrefWeight
                projectYear = datetime.strptime(project.startDate, "%d/%m/%Y").year
                prefectureSums[prefecture.code][projectYear] += currentPrefectureAllocation
                localPrefectureSum += currentPrefectureAllocation
        if abs(localPrefectureSum - projectBudget) > 1:
            print("project %s has prefectures %s but the budget does not equal the allocation (%d vs %d)"
                  % (project, project.prefecturesOwning.all(), projectBudget, localPrefectureSum))
    print(totalBudgetSum)
    valuesSum = 0
    for yearValue in prefectureSums.values():
        for value in yearValue.values():
            valuesSum += value
    prettyPrintBudgets(prefectureSums)
    print(valuesSum)
    print(totalBudgetSum - valuesSum)
    print("ignored because of date sum up to %d " % ignoredBecauseOfDateBudgetSum)