-
-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: update financial data for current year #2687
Merged
asyncapi-bot
merged 22 commits into
asyncapi:master
from
JeelRajodiya:auto-year-detection
Sep 29, 2024
Merged
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e31f020
Auto update financial data
JeelRajodiya 676ccab
update indention
JeelRajodiya 1d98305
remove comment
JeelRajodiya 2fdf27b
Move the current year inside the components
JeelRajodiya 929a814
Merge branch 'master' into auto-year-detection
JeelRajodiya 72b7190
Merge branch 'master' into auto-year-detection
JeelRajodiya 9063550
Merge branch 'master' into auto-year-detection
JeelRajodiya a21b8dc
chore: add logic to find the foldername with latest year
JeelRajodiya e346334
chore: add error handling when the finance files are not present
JeelRajodiya f31af6a
new method to detect latest year
JeelRajodiya 124209f
update indention
JeelRajodiya 5f4ecd1
update path in the test
JeelRajodiya 80b1702
remove unused import
JeelRajodiya 1179dd7
fix formatting
JeelRajodiya 28ea995
fix formatting
JeelRajodiya 09ad54f
Merge branch 'master' into auto-year-detection
JeelRajodiya fddb7d6
Merge branch 'master' into auto-year-detection
JeelRajodiya 4ea0a2e
Merge branch 'master' into auto-year-detection
JeelRajodiya ef8e8c8
Merge branch 'master' into auto-year-detection
JeelRajodiya b8c692b
Merge branch 'master' into auto-year-detection
JeelRajodiya 555b5e5
Merge branch 'master' into auto-year-detection
JeelRajodiya be79285
Merge branch 'master' into auto-year-detection
akshatnema File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import Expenses from '../config/finance/json-data/2024/Expenses.json'; | ||
|
||
/** | ||
* Retrieves unique expense categories from the Expenses data. | ||
* | ||
* @param {Object} expenses - The expenses data. | ||
* @returns {string[]} An array of unique expense categories. | ||
*/ | ||
export const getUniqueCategories = (): string[] => { | ||
export const getUniqueCategories = async (): Promise<string[]> => { | ||
const currentYear = new Date().getFullYear(); | ||
const allCategories: string[] = []; | ||
const Expenses = (await import(`../config/finance/json-data/${currentYear}/Expenses.json`)).default; | ||
|
||
JeelRajodiya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (const month in Expenses) { | ||
Expenses[month as keyof typeof Expenses].forEach((entry: { Category: string }) => { | ||
if (!allCategories.includes(entry.Category)) { | ||
allCategories.push(entry.Category); | ||
} | ||
}); | ||
} | ||
|
||
return allCategories; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if Expenses Files of current are not present? In that case this import will lead to error and a deadlock situation will be created. Provide some fallback for these imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added some logic for checking whether we have any financial data or not, please view scripts/index.js. If we do not have any financial data, it will throw an error on the build. Also, I have moved those imports on the top level now.