-
Notifications
You must be signed in to change notification settings - Fork 15
org_category key cleanup #3928
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
base: Fyle-_num_files-clean-1
Are you sure you want to change the base?
org_category key cleanup #3928
Changes from all commits
bf6f35e
1fb65b8
f0ba56f
8db92ba
9d6df1e
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 |
|---|---|---|
|
|
@@ -606,7 +606,7 @@ export class TransactionService { | |
| spent_at: expense.spent_at, | ||
| categoryDisplayName: expense.category?.display_name, | ||
| files: expense.files, | ||
| org_category: expense.category?.name, | ||
| category: expense.category, | ||
|
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. 💡 Verification agent 🧩 Analysis chainCategory object mapping: solid move, boss. Switching to the full Run this quick scan to ensure there are no lingering references to 🏁 Script executed: #!/bin/bash
rg -n --type=ts -S '\borg_category\b|tx\.org_category\b' -g '!**/dist/**' -g '!**/node_modules/**'Length of output: 148 Boss, no files got scanned—let’s expand the search across all .ts files: 🏁 Script executed: #!/bin/bash
rg -n '\borg_category\b|tx\.org_category\b' -g '**/*.ts' -g '!**/dist/**' -g '!**/node_modules/**'Length of output: 8483 Replace all 🤖 Prompt for AI Agents |
||
| fyle_category: expense.category?.system_category, | ||
| state: expense.state, | ||
| admin_amount: expense.admin_amount, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2857,8 +2857,8 @@ export class AddEditExpensePage implements OnInit { | |||||||||||||||||||||||||||||||
| goToTransaction(expense: Partial<UnflattenedTransaction>, reviewList: string[], activeIndex: number): void { | ||||||||||||||||||||||||||||||||
| let category: string; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (expense.tx.org_category) { | ||||||||||||||||||||||||||||||||
| category = expense.tx.org_category.toLowerCase(); | ||||||||||||||||||||||||||||||||
| if (expense.tx.category?.name) { | ||||||||||||||||||||||||||||||||
| category = expense.tx.category.name.toLowerCase(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
2858
to
2862
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. 🧹 Nitpick (assertive) Simplify and harden category routing Inline with a fallback to Apply this diff: - let category: string;
-
- if (expense.tx.category?.name) {
- category = expense.tx.category.name.toLowerCase();
- }
+ const category = (expense.tx.category?.name ?? expense.tx.fyle_category)?.toLowerCase();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (category === 'mileage') { | ||||||||||||||||||||||||||||||||
|
|
@@ -4068,7 +4068,7 @@ export class AddEditExpensePage implements OnInit { | |||||||||||||||||||||||||||||||
| Type: 'Receipt', | ||||||||||||||||||||||||||||||||
| Amount: etxn.tx.amount, | ||||||||||||||||||||||||||||||||
| Currency: etxn.tx.currency, | ||||||||||||||||||||||||||||||||
| Category: etxn.tx.org_category, | ||||||||||||||||||||||||||||||||
| Category: etxn.tx.category?.name, | ||||||||||||||||||||||||||||||||
| Time_Spent: this.getTimeSpentOnPage() + ' secs', | ||||||||||||||||||||||||||||||||
| Used_Autofilled_Category: | ||||||||||||||||||||||||||||||||
| etxn.tx.category_id && this.presetCategoryId && etxn.tx.category_id === this.presetCategoryId, | ||||||||||||||||||||||||||||||||
|
|
@@ -4317,7 +4317,7 @@ export class AddEditExpensePage implements OnInit { | |||||||||||||||||||||||||||||||
| Type: 'Receipt', | ||||||||||||||||||||||||||||||||
| Amount: etxn.tx.amount, | ||||||||||||||||||||||||||||||||
| Currency: etxn.tx.currency, | ||||||||||||||||||||||||||||||||
| Category: etxn.tx.org_category, | ||||||||||||||||||||||||||||||||
| Category: etxn.tx.category?.name, | ||||||||||||||||||||||||||||||||
| Time_Spent: this.getTimeSpentOnPage() + ' secs', | ||||||||||||||||||||||||||||||||
| Used_Autofilled_Category: | ||||||||||||||||||||||||||||||||
| etxn.tx.category_id && this.presetCategoryId && etxn.tx.category_id === this.presetCategoryId, | ||||||||||||||||||||||||||||||||
|
Comment on lines
4317
to
4323
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. 🧹 Nitpick (assertive) Tracking on add: same fallback for Category Consistency, machi. Make the pipeline smile. Apply this diff: - Category: etxn.tx.category?.name,
+ Category: etxn.tx.category?.name ?? etxn.tx.fyle_category,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
|
|
@@ -4398,7 +4398,7 @@ export class AddEditExpensePage implements OnInit { | |||||||||||||||||||||||||||||||
| Type: 'Receipt', | ||||||||||||||||||||||||||||||||
| Amount: etxn.tx.amount, | ||||||||||||||||||||||||||||||||
| Currency: etxn.tx.currency, | ||||||||||||||||||||||||||||||||
| Category: etxn.tx.org_category, | ||||||||||||||||||||||||||||||||
| Category: etxn.tx.category?.name, | ||||||||||||||||||||||||||||||||
| Time_Spent: this.getTimeSpentOnPage() + ' secs', | ||||||||||||||||||||||||||||||||
| Used_Autofilled_Category: | ||||||||||||||||||||||||||||||||
| etxn.tx.category_id && this.presetCategoryId && etxn.tx.category_id === this.presetCategoryId, | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -468,8 +468,8 @@ export class AddEditMileagePage implements OnInit { | |||||||||||||||||||
| goToTransaction(expense: Partial<UnflattenedTransaction>, reviewList, activeIndex: number): void { | ||||||||||||||||||||
| let category: string; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (expense.tx.org_category) { | ||||||||||||||||||||
| category = expense.tx.org_category.toLowerCase(); | ||||||||||||||||||||
| if (expense.tx.category?.name) { | ||||||||||||||||||||
| category = expense.tx.category.name.toLowerCase(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
469
to
474
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 Style with substance: fallback routing for category. Mirror the per-diem hardening so navigation never guesses wrong. - let category: string;
-
- if (expense.tx.category?.name) {
- category = expense.tx.category.name.toLowerCase();
- }
+ const category =
+ (expense.tx.category?.name || expense.tx.fyle_category || expense.tx.sub_category)?.toLowerCase();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| if (category === 'mileage') { | ||||||||||||||||||||
|
|
@@ -970,7 +970,6 @@ export class AddEditMileagePage implements OnInit { | |||||||||||||||||||
| state: 'COMPLETE', | ||||||||||||||||||||
| spent_at: new Date(), | ||||||||||||||||||||
| category_id: mileageContainer.defaultMileageCategory && mileageContainer.defaultMileageCategory.id, | ||||||||||||||||||||
| org_category: mileageContainer.defaultMileageCategory && mileageContainer.defaultMileageCategory.name, | ||||||||||||||||||||
| sub_category: | ||||||||||||||||||||
| mileageContainer.defaultMileageCategory && mileageContainer.defaultMileageCategory.sub_category, | ||||||||||||||||||||
| currency: homeCurrency, | ||||||||||||||||||||
|
|
@@ -2458,7 +2457,7 @@ export class AddEditMileagePage implements OnInit { | |||||||||||||||||||
| Type: 'Mileage', | ||||||||||||||||||||
| Amount: etxn.tx.amount, | ||||||||||||||||||||
| Currency: etxn.tx.currency, | ||||||||||||||||||||
| Category: etxn.tx.org_category, | ||||||||||||||||||||
| Category: etxn.tx.category?.name, | ||||||||||||||||||||
|
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 Telemetry, kaboom! Never log an empty category. Add a robust default for Category in edit/create tracking. - Category: etxn.tx.category?.name,
+ Category: etxn.tx.category?.name || etxn.tx.fyle_category || 'Mileage',Also applies to: 2727-2727 🤖 Prompt for AI Agents |
||||||||||||||||||||
| Time_Spent: this.getTimeSpentOnPage() + ' secs', | ||||||||||||||||||||
| Used_Autofilled_Project: | ||||||||||||||||||||
| etxn.tx.project_id && this.presetProjectId && etxn.tx.project_id === this.presetProjectId, | ||||||||||||||||||||
|
|
@@ -2725,7 +2724,7 @@ export class AddEditMileagePage implements OnInit { | |||||||||||||||||||
| Type: 'Mileage', | ||||||||||||||||||||
| Amount: etxn.tx.amount, | ||||||||||||||||||||
| Currency: etxn.tx.currency, | ||||||||||||||||||||
| Category: etxn.tx.org_category, | ||||||||||||||||||||
| Category: etxn.tx.category?.name, | ||||||||||||||||||||
| Time_Spent: this.getTimeSpentOnPage() + ' secs', | ||||||||||||||||||||
| Used_Autofilled_Project: | ||||||||||||||||||||
| etxn.tx.project_id && this.presetProjectId && etxn.tx.project_id === this.presetProjectId, | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -459,8 +459,8 @@ export class AddEditPerDiemPage implements OnInit { | |||||||||||||||||
| goToTransaction(expense: Partial<UnflattenedTransaction>, reviewList: string[], activeIndex: number): void { | ||||||||||||||||||
| let category: string; | ||||||||||||||||||
|
|
||||||||||||||||||
| if (expense.tx.org_category) { | ||||||||||||||||||
| category = expense.tx.org_category.toLowerCase(); | ||||||||||||||||||
| if (expense.tx.category?.name) { | ||||||||||||||||||
| category = expense.tx.category.name.toLowerCase(); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
461
to
464
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 Good switch, but make it fail-proof, boss. Add a fallback for routing. If category object is missing, navigation silently falls back to generic expense. Use fyle_category/sub_category as backup so review flow doesn’t misroute. - let category: string;
-
- if (expense.tx.category?.name) {
- category = expense.tx.category.name.toLowerCase();
- }
+ const category =
+ (expense.tx.category?.name || expense.tx.fyle_category || expense.tx.sub_category)?.toLowerCase();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| if (category === 'mileage') { | ||||||||||||||||||
|
|
@@ -675,7 +675,6 @@ export class AddEditPerDiemPage implements OnInit { | |||||||||||||||||
| skip_reimbursement: false, | ||||||||||||||||||
| source: 'MOBILE', | ||||||||||||||||||
| category_id: categoryContainer.defaultPerDiemCategory && categoryContainer.defaultPerDiemCategory.id, | ||||||||||||||||||
| org_category: categoryContainer.defaultPerDiemCategory && categoryContainer.defaultPerDiemCategory.name, | ||||||||||||||||||
| sub_category: | ||||||||||||||||||
| categoryContainer.defaultPerDiemCategory && categoryContainer.defaultPerDiemCategory.sub_category, | ||||||||||||||||||
| amount: 0, | ||||||||||||||||||
|
|
@@ -1892,7 +1891,7 @@ export class AddEditPerDiemPage implements OnInit { | |||||||||||||||||
| Type: 'Receipt', | ||||||||||||||||||
| Amount: etxn.tx.amount, | ||||||||||||||||||
| Currency: etxn.tx.currency, | ||||||||||||||||||
| Category: etxn.tx.org_category, | ||||||||||||||||||
| Category: etxn.tx.category?.name, | ||||||||||||||||||
|
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 Telemetry shouldn’t go mute. Add a Category fallback. On fresh add/edit, category object can be absent; log a sensible default. - Category: etxn.tx.category?.name,
+ Category: etxn.tx.category?.name || etxn.tx.fyle_category || 'Per Diem',Also applies to: 2064-2064 🤖 Prompt for AI Agents |
||||||||||||||||||
| Time_Spent: this.getTimeSpentOnPage() + ' secs', | ||||||||||||||||||
| Used_Autofilled_Project: | ||||||||||||||||||
| etxn.tx.project_id && this.presetProjectId && etxn.tx.project_id === this.presetProjectId, | ||||||||||||||||||
|
|
@@ -2062,7 +2061,7 @@ export class AddEditPerDiemPage implements OnInit { | |||||||||||||||||
| Type: 'Per Diem', | ||||||||||||||||||
| Amount: etxn.tx.amount, | ||||||||||||||||||
| Currency: etxn.tx.currency, | ||||||||||||||||||
| Category: etxn.tx.org_category, | ||||||||||||||||||
| Category: etxn.tx.category?.name, | ||||||||||||||||||
| Time_Spent: this.getTimeSpentOnPage() + ' secs', | ||||||||||||||||||
| Used_Autofilled_Project: | ||||||||||||||||||
| etxn.tx.project_id && this.presetProjectId && etxn.tx.project_id === this.presetProjectId, | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -554,8 +554,8 @@ export class TasksComponent implements OnInit { | |||||||||||||||||
| .subscribe(({ initial, allExpenseIds }) => { | ||||||||||||||||||
| let category; | ||||||||||||||||||
|
|
||||||||||||||||||
| if (initial.tx.org_category) { | ||||||||||||||||||
| category = initial.tx.org_category.toLowerCase(); | ||||||||||||||||||
| if (initial.tx.category?.name) { | ||||||||||||||||||
| category = initial.tx.category.name.toLowerCase(); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
555
to
559
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. 🧹 Nitpick (assertive) Route robustly even if category.name is missing Make the route logic rock-solid by falling back to Apply this diff: - let category;
-
- if (initial.tx.category?.name) {
- category = initial.tx.category.name.toLowerCase();
- }
+ const category = (initial.tx.category?.name ?? initial.tx.fyle_category)?.toLowerCase();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| if (category === 'mileage') { | ||||||||||||||||||
|
|
||||||||||||||||||
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.
🧹 Nitpick (assertive)
Graceful fallback when category.name is absent
Some older/edge payloads might miss
category.name. Fall back tofyle_categoryto keep routing sharp.Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents