-
Notifications
You must be signed in to change notification settings - Fork 1
Enhance Weekly Financial Report functionality and sorting #95
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ff7c757
Update ESLint configuration and dependencies
anatolyshipitz ef180af
Update ESLint configuration and dependencies
anatolyshipitz 2094277
Merge branch 'main' into feature/eslint-naming-conventions
anatolyshipitz a2893db
Add comprehensive ESLint naming conventions and update configuration
anatolyshipitz c3a1c33
Enhance ESLint naming conventions and configuration
anatolyshipitz 061120b
Merge branch 'main' into feature/eslint-naming-conventions
anatolyshipitz 16a3ad1
Update ESLint naming conventions and configuration
anatolyshipitz 6d8930f
Enhance Weekly Financial Report functionality and sorting
anatolyshipitz 335c183
Add Effective Financial Parameters to Weekly Financial Reports
anatolyshipitz 084e73c
Merge branch 'main' into feature/add_marginality_level
anatolyshipitz 3a3d9be
Fix/weekly reports effective revenue calculation (#97)
anatolyshipitz fe3b6c9
Refactor WeeklyFinancialReportRepository to Preserve Group Order
anatolyshipitz cf413a0
Refactor effectiveRevenueMonths calculation in qboConfig
anatolyshipitz c57099e
Enhance date calculation logic in WeeklyFinancialReportFormatter
anatolyshipitz 24c143d
Refactor fetchFinancialAppData to Integrate QBO Effective Revenue
anatolyshipitz b1daa10
Refactor Tests and Improve Effective Revenue Calculation in Weekly Fi…
anatolyshipitz 000890b
Update FinAppRepository Tests and Project Interface
anatolyshipitz b768575
Refactor Weekly Financial Report Tests and Sorting Logic
anatolyshipitz 8afbad0
Enhance Weekly Financial Report Tests and Repository Structure
anatolyshipitz afe4e22
Refactor QBORepository Mocking in Financial App Data Tests
anatolyshipitz 3f5492f
Fix Type Handling in Financial App Data Fetching
anatolyshipitz b4c01c4
Enhance Weekly Financial Report Structure with Total Hours
anatolyshipitz 410826e
Update FinApp and Weekly Financial Report Tests for Consistency
anatolyshipitz 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
76 changes: 76 additions & 0 deletions
76
memory-bank/archive/archive-TargetUnit-Effective-Params-20250811.md
This file contains hidden or 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,76 @@ | ||
# Enhancement Archive: Add Effective Financial Parameters to Target Units | ||
|
||
## Summary | ||
Implemented integration of effective financial parameters (Effective Revenue, Effective Margin, Effective Marginality) into the Weekly Financial Reports system through QuickBooks Online (QBO) integration. | ||
|
||
## Date Completed | ||
2025-08-11 | ||
|
||
## Key Files Modified | ||
- `workers/main/src/activities/weeklyFinancialReports/fetchFinancialAppData.ts` - QBO integration for effective revenue fetching | ||
- `workers/main/src/configs/qbo.ts` - QBO configuration with effective revenue parameters | ||
- `workers/main/src/services/FinApp/types.ts` - added effectiveRevenue field to Project interface | ||
- `workers/main/src/services/WeeklyFinancialReport/WeeklyFinancialReportFormatter.ts` - formatting new metrics in reports | ||
- `workers/main/src/services/WeeklyFinancialReport/WeeklyFinancialReportRepository.ts` - core business logic for calculations | ||
- `workers/main/src/services/WeeklyFinancialReport/WeeklyFinancialReportRepository.test.ts` - extended testing | ||
- `workers/main/src/services/WeeklyFinancialReport/WeeklyFinancialReportSorting.test.ts` - new sorting tests | ||
|
||
## Requirements Addressed | ||
- Add Effective Revenue as Target Unit parameter | ||
- Add Effective Margin as Target Unit parameter | ||
- Add Effective Marginality as Target Unit parameter | ||
- Integrate data from QuickBooks Online for accurate calculations | ||
- Implement group sorting by marginality levels (High → Medium → Low) | ||
- Ensure display of new metrics in financial reports | ||
|
||
## Implementation Details | ||
**QBO Integration:** | ||
- Added `qboRepo.getEffectiveRevenue()` call in `fetchFinancialAppData` | ||
- Configured with `effectiveRevenueMonths` parameter (default 4 months) | ||
- Effective revenue linked to projects through `quick_books_id` | ||
|
||
**Calculations and Sorting:** | ||
- Implemented effectiveRevenue, effectiveMargin, effectiveMarginality calculations in `aggregateGroupData` | ||
- Added advanced sorting: first by marginality levels, then by effective marginality | ||
- `compareMarginalityLevels` method for sorting order determination (High: 3, Medium: 2, Low: 1) | ||
|
||
**Formatting:** | ||
- Updated `formatDetail` to display Effective Revenue, Effective Margin, Effective Marginality | ||
- Added explanations in footer about effective revenue calculation period | ||
- Support for marginality indicators in reports | ||
|
||
## Testing Performed | ||
- Unit tests for new `aggregateGroupData` method with effective metrics calculations | ||
- Comprehensive sorting tests in `WeeklyFinancialReportSorting.test.ts` (100+ lines) | ||
- Verification of correct sorting by marginality levels: High → Medium → Low | ||
- Testing secondary sorting by effective marginality within same level | ||
- Validation of new field formatting in reports | ||
|
||
## Lessons Learned | ||
- **QBO integration**: Repository pattern is effective for external services and scales well | ||
- **Financial calculations**: Require particularly detailed testing due to critical importance of accuracy | ||
- **Level 2 complexity**: Tasks with external service integration can be more complex than expected (+401 lines for Level 2) | ||
- **Code organization**: Proper separation of responsibilities between data, business, and presentation layers is critical | ||
- **Optimization**: The `compareMarginalityLevels` method can be inlined for simplification (~15 lines savings) | ||
|
||
## Related Work | ||
- Related to general Weekly Financial Reports system | ||
- Based on existing QBORepository infrastructure | ||
- Complements marginality system (MarginalityCalculator, MarginalityLevel) | ||
- PR #95: https://github.com/speedandfunction/automatization/pull/95 | ||
|
||
## Notes | ||
**Technical Architecture:** | ||
- Used Repository pattern for QBO integration | ||
- Preserved backward compatibility when adding new fields | ||
- Efficient design: minimal changes in types, focused changes in business logic | ||
|
||
**Potential Improvements:** | ||
- Inline `compareMarginalityLevels` method | ||
- Extract marginality thresholds to configuration constants | ||
- More strict typing for financial calculations | ||
|
||
**Time Estimates:** | ||
- Planned: 1-2 days (Level 2) | ||
- Actual: 2-3 days | ||
- Variance reason: underestimation of QBO integration complexity and testing volume required |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.