Skip to content
This repository was archived by the owner on Mar 15, 2020. It is now read-only.
This repository was archived by the owner on Mar 15, 2020. It is now read-only.

Remaining senior funds ambiguity #6

@gluxon

Description

@gluxon

We have a few travel requests for FY19 that don't have a "yearOfTerminalDegree" field.

The spreadsheet export will default these to "senior" standing.

SELECT
    CAST(FLOOR("Budgets".amount * "Budgets"."seniorAllocationLimit" * 100) / 100 AS DECIMAL (10, 2)) - SUM(COALESCE("Grants".amount, 0)) AS amount
FROM
    "Budgets"
    LEFT JOIN "Grants" ON "Budgets".id = "Grants"."BudgetId"
    LEFT JOIN "Costs" ON "Costs".id = "Grants"."CostId"
    LEFT JOIN "Trips" ON "Trips".id = "Costs"."TripId"
WHERE
    "Budgets".id = 7
    AND ("Trips"."yearOfTerminalDegree" <= (extract(year FROM CURRENT_DATE)::int - 8)
        OR "Trips"."yearOfTerminalDegree" IS NULL)
GROUP BY
    "Budgets".id

But they'll be counted towards junior standing for "remaining funds" calculation.

SELECT
    CAST(FLOOR("Budgets".amount * "Budgets"."seniorAllocationLimit" * 100) / 100 AS DECIMAL (10, 2)) - SUM(COALESCE("Grants".amount, 0)) AS amount
FROM
    "Budgets"
    LEFT JOIN "Grants" ON "Budgets".id = "Grants"."BudgetId"
    LEFT JOIN "Costs" ON "Costs".id = "Grants"."CostId"
    LEFT JOIN "Trips" ON "Trips".id = "Costs"."TripId"
WHERE
    "Budgets".id = 7
    AND "Trips"."yearOfTerminalDegree" <= (extract(year FROM CURRENT_DATE)::int - 8)
GROUP BY
    "Budgets".id

Asked Matt how to resolve this best.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions