-
Notifications
You must be signed in to change notification settings - Fork 15
clean up fyle_category #3929
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-org_category-clean-1
Are you sure you want to change the base?
clean up fyle_category #3929
Changes from all commits
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -354,18 +354,18 @@ export class ExpensesService { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| transaction.fyle_category?.toLowerCase() === 'flight' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| transaction.fyle_category?.toLowerCase() === 'airlines' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| transaction.category?.system_category.toLowerCase() === 'flight' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| transaction.category?.system_category.toLowerCase() === 'airlines' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (transaction.flight_journey_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expense.travel_classes.push(transaction.flight_journey_travel_class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (transaction.flight_return_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expense.travel_classes.push(transaction.flight_return_travel_class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (transaction.fyle_category?.toLowerCase() === 'bus' && transaction.bus_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (transaction.category?.system_category.toLowerCase() === 'bus' && transaction.bus_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expense.travel_classes.push(transaction.bus_travel_class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (transaction.fyle_category?.toLowerCase() === 'train' && transaction.train_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (transaction.category?.system_category.toLowerCase() === 'train' && transaction.train_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expense.travel_classes.push(transaction.train_travel_class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
356
to
370
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. Normalize Same grenade here—defuse it with a single safe read. - if (
- transaction.category?.system_category.toLowerCase() === 'flight' ||
- transaction.category?.system_category.toLowerCase() === 'airlines'
- ) {
+ const sysCat = transaction.category?.system_category?.toLowerCase();
+ if (sysCat === 'flight' || sysCat === 'airlines') {
...
- } else if (transaction.category?.system_category.toLowerCase() === 'bus' && transaction.bus_travel_class) {
+ } else if (sysCat === 'bus' && transaction.bus_travel_class) {
...
- } else if (transaction.category?.system_category.toLowerCase() === 'train' && transaction.train_travel_class) {
+ } else if (sysCat === 'train' && transaction.train_travel_class) {
...
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,18 +67,18 @@ export class PolicyService { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| transaction.fyle_category?.toLowerCase() === 'flight' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| transaction.fyle_category?.toLowerCase() === 'airlines' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| transaction.category?.system_category.toLowerCase() === 'flight' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| transaction.category?.system_category.toLowerCase() === 'airlines' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (transaction.flight_journey_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| platformPolicyExpense.travel_classes.push(transaction.flight_journey_travel_class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (transaction.flight_return_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| platformPolicyExpense.travel_classes.push(transaction.flight_return_travel_class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (transaction.fyle_category?.toLowerCase() === 'bus' && transaction.bus_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (transaction.category?.system_category.toLowerCase() === 'bus' && transaction.bus_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| platformPolicyExpense.travel_classes.push(transaction.bus_travel_class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (transaction.fyle_category?.toLowerCase() === 'train' && transaction.train_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (transaction.category?.system_category.toLowerCase() === 'train' && transaction.train_travel_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| platformPolicyExpense.travel_classes.push(transaction.train_travel_class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
69
to
82
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. Guard If Apply: - if (
- transaction.category?.system_category.toLowerCase() === 'flight' ||
- transaction.category?.system_category.toLowerCase() === 'airlines'
- ) {
+ const sysCat = transaction.category?.system_category?.toLowerCase();
+ if (sysCat === 'flight' || sysCat === 'airlines') {
...
- } else if (transaction.category?.system_category.toLowerCase() === 'bus' && transaction.bus_travel_class) {
+ } else if (sysCat === 'bus' && transaction.bus_travel_class) {
...
- } else if (transaction.category?.system_category.toLowerCase() === 'train' && transaction.train_travel_class) {
+ } else if (sysCat === 'train' && transaction.train_travel_class) {
...
}Now the logic punches without missing. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -196,7 +196,7 @@ export class SplitExpenseService { | |||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| transformSplitFlightClasses(transaction: Transaction, platformSplitObject: SplitPayload): void { | ||||||||||||||||||||
| if (transaction.fyle_category?.toLowerCase() === 'airlines') { | ||||||||||||||||||||
| if (transaction.category?.system_category.toLowerCase() === 'airlines') { | ||||||||||||||||||||
| if (transaction.flight_journey_travel_class) { | ||||||||||||||||||||
| platformSplitObject.travel_classes.push(transaction.flight_journey_travel_class); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -207,13 +207,13 @@ export class SplitExpenseService { | |||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| tranformSplitBusClasses(transaction: Transaction, platformSplitObject: SplitPayload): void { | ||||||||||||||||||||
| if (transaction.fyle_category?.toLowerCase() === 'bus' && transaction.bus_travel_class) { | ||||||||||||||||||||
| if (transaction.category?.system_category.toLowerCase() === 'bus' && transaction.bus_travel_class) { | ||||||||||||||||||||
| platformSplitObject.travel_classes.push(transaction.bus_travel_class); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+210
to
213
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. Same safety net for Bus Mirror the safe normalization. - if (transaction.category?.system_category.toLowerCase() === 'bus' && transaction.bus_travel_class) {
+ const sysCat = transaction.category?.system_category?.toLowerCase();
+ if (sysCat === 'bus' && transaction.bus_travel_class) {
platformSplitObject.travel_classes.push(transaction.bus_travel_class);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| transformSplitTrainClasses(transaction: Transaction, platformSplitObject: SplitPayload): void { | ||||||||||||||||||||
| if (transaction.fyle_category?.toLowerCase() === 'train' && transaction.train_travel_class) { | ||||||||||||||||||||
| if (transaction.category?.system_category.toLowerCase() === 'train' && transaction.train_travel_class) { | ||||||||||||||||||||
| platformSplitObject.travel_classes.push(transaction.train_travel_class); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+216
to
219
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. Same safety net for Train Mirror the safe normalization. - if (transaction.category?.system_category.toLowerCase() === 'train' && transaction.train_travel_class) {
+ const sysCat = transaction.category?.system_category?.toLowerCase();
+ if (sysCat === 'train' && transaction.train_travel_class) {
platformSplitObject.travel_classes.push(transaction.train_travel_class);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
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.
🛠️ Refactor suggestion
Make
categoryoptional to match real payloads and avoid downstream crashesPublicPolicyExpensenow requirescategory, but several call-sites build tx without it (and even setcategory: nullin add-edit-mileage). This mismatches usage and amplifies NPE risk when services readcategory.system_category.Apply:
Superstar tip: optional here, swagger there—peace everywhere.
📝 Committable suggestion
🤖 Prompt for AI Agents