-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix: All the bug fixes listed #170
Changes from 1 commit
24614c4
ed15855
c12f413
26edc76
5efb93d
3228379
f5dc2eb
d419249
6029b23
b82d962
25b8c66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ def update_accounting_export_summary(workspace_id): | |
successful_exports = AccountingExport.objects.filter( | ||
~Q(type__in=['FETCHING_REIMBURSABLE_EXPENSES', 'FETCHING_CREDIT_CARD_EXPENSES']), | ||
workspace_id=workspace_id, status='COMPLETE', | ||
updated_at__gte=accounting_export_summary.last_exported_at | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add null check for last_exported_at. The code assumes Consider adding a null check: + last_exported_at = accounting_export_summary.last_exported_at or datetime.min
successful_exports = AccountingExport.objects.filter(
~Q(type__in=['FETCHING_REIMBURSABLE_EXPENSES', 'FETCHING_CREDIT_CARD_EXPENSES']),
workspace_id=workspace_id,
status='COMPLETE',
- updated_at__gte=accounting_export_summary.last_exported_at
+ updated_at__gte=last_exported_at
).count() Don't forget to add the import: from datetime import datetime Review the export counting logic for potential discrepancies. The new time-based filter is only applied to successful exports but not to failed ones. This inconsistency could lead to:
Consider applying consistent filtering: failed_exports = AccountingExport.objects.filter(
~Q(type__in=['FETCHING_REIMBURSABLE_EXPENSES', 'FETCHING_CREDIT_CARD_EXPENSES']),
- workspace_id=workspace_id, status__in=['FAILED', 'FATAL']
+ workspace_id=workspace_id,
+ status__in=['FAILED', 'FATAL'],
+ updated_at__gte=accounting_export_summary.last_exported_at
).count()
|
||
).count() | ||
|
||
accounting_export_summary.failed_accounting_export_count = failed_exports | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ def run_import_export(workspace_id: int, export_mode = None): | |
|
||
if accounting_export.status == 'COMPLETE': | ||
accounting_export_ids = AccountingExport.objects.filter( | ||
fund_source='PERSONAL', exported_at__isnull=True).values_list('id', flat=True) | ||
fund_source='PERSONAL', exported_at__isnull=True, workspace_id=workspace_id).values_list('id', flat=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical security fix: Proper workspace isolation added Adding the workspace filter is essential for maintaining proper data isolation between different workspaces. This fix prevents potential data leakage across workspaces. |
||
|
||
if len(accounting_export_ids): | ||
is_expenses_exported = True | ||
|
@@ -75,7 +75,7 @@ def run_import_export(workspace_id: int, export_mode = None): | |
) | ||
if accounting_export.status == 'COMPLETE': | ||
accounting_export_ids = AccountingExport.objects.filter( | ||
fund_source='CCC', exported_at__isnull=True).values_list('id', flat=True) | ||
fund_source='CCC', exported_at__isnull=True, workspace_id=workspace_id).values_list('id', flat=True) | ||
|
||
if len(accounting_export_ids): | ||
is_expenses_exported = True | ||
|
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.
This logic seems wrong
For example if date_field is 'current_date' and accounting_export[date_field] will be None, then it should be set to current date, but this way it will never reach to else block
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.
okay will revert this back, the previous code is good not issue then