-
Notifications
You must be signed in to change notification settings - Fork 1
Enhance financial reporting with contract type integration #99
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 5 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e7143e3
Enhance financial reporting with contract type integration
anatolyshipitz dbe678c
fix: Improve date comparison in getContractTypeByDate function
anatolyshipitz f27b1e6
Add unit tests for getContractTypeByDate function
anatolyshipitz b0d69d6
Update Dockerfile.n8n to use n8n version 1.109.2 and install addition…
anatolyshipitz 8096856
Add weekly financial report workflow and enhance marginality calculat…
anatolyshipitz 3748744
Refactor date handling in financial queries and clean up code
anatolyshipitz a0b30f0
Add docker-compose.override.yml and update package dependencies
anatolyshipitz 9931950
Resolve merge conflict in Dockerfile.n8n - use versioned git package
anatolyshipitz bd8a9d6
Refactor MarginalityResult and EffectiveMarginalityResult interfaces …
anatolyshipitz b0f6e76
Refactor date handling and contract type resolution in financial repo…
anatolyshipitz 4201e4e
Remove docker-compose.override.yml file to streamline configuration a…
anatolyshipitz 658fbc1
Refactor weekly report workflow initiation in launchWeeklyReport.ts
anatolyshipitz ad33549
Implement WeeklyFinancialReportCalculations class for improved financ…
anatolyshipitz 4eea60f
Remove unused EffectiveMarginalityCalculator import from WeeklyFinanc…
anatolyshipitz b966818
Enhance tests for handleRunError function by adding process.exit mocking
anatolyshipitz 595485c
Update WeeklyFinancialReportFormatter to improve notes formatting and…
anatolyshipitz 623c9c9
Add project_hours to TargetUnit and update related calculations
anatolyshipitz 84fda2d
Merge branch 'main' into feature/add-contract-type
anatolyshipitz e42cb38
Add project_hours to test data in WeeklyFinancialReport and TargetUni…
anatolyshipitz 5fee636
Merge branch 'feature/add-contract-type' of github.com:speedandfuncti…
anatolyshipitz 24bf804
Refactor test data in WeeklyFinancialReportSorting tests
anatolyshipitz ac509e6
Refactor sorting tests in WeeklyFinancialReportSorting
anatolyshipitz 1b1fb88
Update TargetUnit interfaces and repository for optional project_hour…
anatolyshipitz 24833df
Fix revenue calculation in WeeklyFinancialReportCalculations to handl…
anatolyshipitz 9b8c5b1
Refactor EffectiveMarginalityCalculator and MarginalityCalculator for…
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { Client, Connection } from '@temporalio/client'; | ||
|
|
||
| import { temporalConfig } from './configs/temporal'; | ||
| import { workerConfig } from './configs/worker'; | ||
| import { weeklyFinancialReportsWorkflow } from './workflows'; | ||
|
|
||
| async function run() { | ||
| const connection = await Connection.connect(temporalConfig); | ||
| const client = new Client({ connection }); | ||
|
|
||
| const handle = await client.workflow.start(weeklyFinancialReportsWorkflow, { | ||
| ...workerConfig, | ||
| workflowId: 'weekly-financial-report-' + Date.now(), | ||
| }); | ||
|
|
||
| try { | ||
| await handle.result(); | ||
| } catch (err) { | ||
| console.error('Workflow failed:', err); | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| run().catch((err) => { | ||
| console.error(err); | ||
| process.exit(1); | ||
| }); | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { getContractTypeByDate } from './FinAppUtils'; | ||
|
|
||
| describe('getContractTypeByDate', () => { | ||
| it('should return undefined when contractTypeHistory is undefined', () => { | ||
| const result = getContractTypeByDate(undefined, '2024-01-01'); | ||
|
|
||
| expect(result).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should return undefined when contractTypeHistory is empty', () => { | ||
| const result = getContractTypeByDate({}, '2024-01-01'); | ||
|
|
||
| expect(result).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should return undefined when input date is invalid', () => { | ||
| const contractTypeHistory = { | ||
| '2024-01-01': 'Full-time', | ||
| '2024-06-01': 'Part-time', | ||
| }; | ||
| const result = getContractTypeByDate(contractTypeHistory, 'invalid-date'); | ||
|
|
||
| expect(result).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should return the correct contract type for a date that matches exactly', () => { | ||
| const contractTypeHistory = { | ||
| '2024-01-01': 'Full-time', | ||
| '2024-06-01': 'Part-time', | ||
| }; | ||
| const result = getContractTypeByDate(contractTypeHistory, '2024-01-01'); | ||
|
|
||
| expect(result).toBe('Full-time'); | ||
| }); | ||
|
|
||
| it('should return the most recent contract type for a date between entries', () => { | ||
| const contractTypeHistory = { | ||
| '2024-01-01': 'Full-time', | ||
| '2024-06-01': 'Part-time', | ||
| }; | ||
| const result = getContractTypeByDate(contractTypeHistory, '2024-03-15'); | ||
|
|
||
| expect(result).toBe('Full-time'); | ||
| }); | ||
|
|
||
| it('should return the latest contract type for a date after all entries', () => { | ||
| const contractTypeHistory = { | ||
| '2024-01-01': 'Full-time', | ||
| '2024-06-01': 'Part-time', | ||
| }; | ||
| const result = getContractTypeByDate(contractTypeHistory, '2024-12-01'); | ||
|
|
||
| expect(result).toBe('Part-time'); | ||
| }); | ||
|
|
||
| it('should handle dates in different formats correctly', () => { | ||
| const contractTypeHistory = { | ||
| '2024-01-01': 'Full-time', | ||
| '2024-06-01': 'Part-time', | ||
| }; | ||
| const result = getContractTypeByDate( | ||
| contractTypeHistory, | ||
| '2024-01-01T00:00:00.000Z', | ||
| ); | ||
|
|
||
| expect(result).toBe('Full-time'); | ||
| }); | ||
|
|
||
| it('should filter out invalid dates from contractTypeHistory', () => { | ||
| const contractTypeHistory = { | ||
| '2024-01-01': 'Full-time', | ||
| 'definitely-not-a-date': 'Should-be-ignored', | ||
| '2024-06-01': 'Part-time', | ||
| }; | ||
| const result = getContractTypeByDate(contractTypeHistory, '2024-03-15'); | ||
|
|
||
| expect(result).toBe('Full-time'); | ||
| }); | ||
|
|
||
| it('should handle multiple invalid dates in contractTypeHistory', () => { | ||
| const contractTypeHistory = { | ||
| 'definitely-not-a-date': 'Should-be-ignored-1', | ||
| '2024-01-01': 'Full-time', | ||
| 'invalid-date-string': 'Should-be-ignored-2', | ||
| '2024-06-01': 'Part-time', | ||
| }; | ||
| const result = getContractTypeByDate(contractTypeHistory, '2024-12-01'); | ||
|
|
||
| expect(result).toBe('Part-time'); | ||
| }); | ||
|
|
||
| it('should return undefined when all dates in contractTypeHistory are invalid', () => { | ||
| const contractTypeHistory = { | ||
| 'definitely-not-a-date': 'Should-be-ignored-1', | ||
| 'invalid-date-string': 'Should-be-ignored-2', | ||
| }; | ||
| const result = getContractTypeByDate(contractTypeHistory, '2024-01-01'); | ||
|
|
||
| expect(result).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should handle single entry correctly', () => { | ||
| const contractTypeHistory = { | ||
| '2024-01-01': 'Full-time', | ||
| }; | ||
| const result = getContractTypeByDate(contractTypeHistory, '2024-06-01'); | ||
|
|
||
| expect(result).toBe('Full-time'); | ||
| }); | ||
|
|
||
| it('should handle date before first entry correctly', () => { | ||
| const contractTypeHistory = { | ||
| '2024-06-01': 'Part-time', | ||
| '2024-12-01': 'Contract', | ||
| }; | ||
| const result = getContractTypeByDate(contractTypeHistory, '2024-01-01'); | ||
|
|
||
| expect(result).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should handle ISO date strings correctly', () => { | ||
| const contractTypeHistory = { | ||
| '2024-01-01T00:00:00.000Z': 'Full-time', | ||
| '2024-06-01T00:00:00.000Z': 'Part-time', | ||
| }; | ||
| const result = getContractTypeByDate( | ||
| contractTypeHistory, | ||
| '2024-03-15T00:00:00.000Z', | ||
| ); | ||
|
|
||
| expect(result).toBe('Full-time'); | ||
| }); | ||
|
|
||
| it('should handle edge case with only invalid dates and valid input date', () => { | ||
| const contractTypeHistory = { | ||
| 'definitely-not-a-date': 'Invalid-entry-1', | ||
| 'invalid-date-string': 'Invalid-entry-2', | ||
| }; | ||
| const result = getContractTypeByDate(contractTypeHistory, '2024-01-01'); | ||
|
|
||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); |
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,25 @@ | ||
| export function getContractTypeByDate( | ||
| contractTypeHistory: { [date: string]: string } | undefined, | ||
| date: string, | ||
| ): string | undefined { | ||
| if (!contractTypeHistory) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const targetTs = Date.parse(date); | ||
|
|
||
| if (Number.isNaN(targetTs)) return undefined; | ||
|
|
||
| const sorted = Object.keys(contractTypeHistory) | ||
| .map((d) => ({ d, ts: Date.parse(d) })) | ||
| .filter(({ ts }) => !Number.isNaN(ts)) | ||
| .sort((a, b) => a.ts - b.ts); | ||
| let lastContractType: string | undefined; | ||
|
|
||
| for (const { d, ts } of sorted) { | ||
| if (ts <= targetTs) lastContractType = contractTypeHistory[d]; | ||
| else break; | ||
| } | ||
|
|
||
| return lastContractType; | ||
| } | ||
|
anatolyshipitz marked this conversation as resolved.
|
||
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.
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.