-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FFT-152 Commit payroll figures into forecast (#610)
- Loading branch information
Showing
34 changed files
with
751 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Returns a feature flag checker. | ||
* | ||
* @example | ||
* // <meta name="app:features:foo" content="true"> | ||
* const FEATURES = FeatureFlags("app:features"); | ||
* FEATURES.foo === true; | ||
* FEATURES.bar === false; | ||
* | ||
* @param {string} namespace - Prefix for the meta tag names. | ||
* @returns {object} Proxy object to check feature flags. | ||
*/ | ||
export default function FeatureFlags(namespace) { | ||
const cache = new Map(); | ||
|
||
const featureFlagHandler = { | ||
get(target, prop, receiver) { | ||
const selector = `meta[name="${namespace}:${prop}"]`; | ||
|
||
const el = document.querySelector(selector); | ||
|
||
if (!el) { | ||
return false; | ||
} | ||
|
||
if (cache.has(prop)) { | ||
return cache.get(prop); | ||
} | ||
|
||
const value = el.content.toLowerCase() === "true"; | ||
|
||
cache.set(prop, value); | ||
|
||
return value; | ||
}, | ||
}; | ||
|
||
const featureFlagProxy = new Proxy({}, featureFlagHandler); | ||
|
||
return featureFlagProxy; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from core.constants import MONTHS | ||
from core.models import FinancialYear | ||
from forecast.models import FinancialCode, FinancialPeriod, ForecastMonthlyFigure | ||
|
||
|
||
class FinancialCodeForecastService: | ||
def __init__( | ||
self, | ||
*, | ||
financial_code: FinancialCode, | ||
year: FinancialYear, | ||
override_locked: bool = False, | ||
): | ||
self.financial_code = financial_code | ||
self.year = year | ||
self.override_locked = override_locked | ||
|
||
def update_period(self, *, period: int | FinancialPeriod, amount: int): | ||
if isinstance(period, int): | ||
period = FinancialPeriod.objects.get(pk=period) | ||
|
||
assert isinstance(period, FinancialPeriod) | ||
|
||
if period.actual_loaded: | ||
return | ||
|
||
if self.financial_code.is_locked and not self.override_locked: | ||
return | ||
|
||
figure, _ = ForecastMonthlyFigure.objects.get_or_create( | ||
financial_code=self.financial_code, | ||
financial_year=self.year, | ||
financial_period=period, | ||
archived_status=None, | ||
) | ||
|
||
# NOTE: Not deleting the figure if the amount is 0 like in other places. | ||
|
||
figure.amount = amount | ||
figure.save() | ||
|
||
def update(self, forecast: list[int]): | ||
assert len(forecast) == len(MONTHS) | ||
|
||
for i, _ in enumerate(MONTHS): | ||
self.update_period(period=i + 1, amount=forecast[i]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.