Skip to content
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

feat: removed old my-expenses page (deprecation) #2814

Merged
merged 5 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
if (( $(echo "$lines < 95.0" | bc -l) || \
$(echo "$statements < 95.0" | bc -l) || \
$(echo "$branches < 94.0" | bc -l) || \
$(echo "$branches < 91.0" | bc -l) || \
$(echo "$functions < 94.0" | bc -l) )); then
echo "Code Coverage Percentage is below 95%"
exit 1
Expand Down
78 changes: 0 additions & 78 deletions src/app/core/guards/my-expenses-guard.guard.spec.ts

This file was deleted.

28 changes: 0 additions & 28 deletions src/app/core/guards/my-expenses-guard.guard.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/core/mock-data/expense-filters.data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExpenseFilters } from 'src/app/fyle/my-expenses/expense-filters.model';
import { DateFilters } from 'src/app/shared/components/fy-filters/date-filters.enum';
import { ExpenseType } from '../enums/expense-type.enum';
import { FilterState } from '../enums/filter-state.enum';
import { ExpenseFilters } from '../models/expense-filters.model';

export const expenseFiltersData1: Partial<ExpenseFilters> = {
state: ['DRAFT', 'READY_TO_REPORT'],
Expand Down
12 changes: 1 addition & 11 deletions src/app/core/mock-data/modal-controller.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { CreateNewReportComponent as createReportV2 } from 'src/app/shared/compo
import { CreateNewReportComponent } from 'src/app/shared/components/create-new-report/create-new-report.component';
import { Mode } from '@ionic/core';
import { fyModalProperties } from './model-properties.data';
import { AddTxnToReportDialogComponent } from 'src/app/fyle/my-expenses/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { AddTxnToReportDialogComponent as v2 } from 'src/app/fyle/my-expenses-v2/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { AddTxnToReportDialogComponent as v2 } from 'src/app/fyle/my-expenses/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { PopupAlertComponent } from 'src/app/shared/components/popup-alert/popup-alert.component';
import { FilterOptions } from 'src/app/shared/components/fy-filters/filter-options.interface';
import { DateFilters } from 'src/app/shared/components/fy-filters/date-filters.enum';
Expand Down Expand Up @@ -75,15 +74,6 @@ export const newReportModalParams2 = {
...fyModalProperties,
};

export const addExpenseToReportModalParams = {
component: AddTxnToReportDialogComponent,
componentProps: {
txId: '12345',
},
mode: <Mode>'ios',
...fyModalProperties,
};

export const addExpenseToReportModalParams2 = {
component: v2,
componentProps: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Filters } from './my-expenses-filters.model';
import { Filters } from 'src/app/fyle/my-expenses/my-expenses-filters.model';

export interface ExpenseFilters extends Omit<Filters, 'state'> {
state: string | string[];
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/models/platform/expense-filters.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Filters } from 'src/app/fyle/my-expenses-v2/my-expenses-filters.model';
import { Filters } from 'src/app/fyle/my-expenses/my-expenses-filters.model';

export interface ExpenseFilters extends Omit<Filters, 'state'> {
state: string | string[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
export type Filters = Partial<{
state: string[];
date: string;
customDateStart: Date;
customDateEnd: Date;
receiptsAttached: string;
type: string[];
sortParam: string;
sortDir: string;
cardNumbers: string[];
splitExpense: string;
}>;

export type ReportFilters = Partial<{
state: string | string[];
date: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
import { ExpenseState } from 'src/app/core/models/expense-state.enum';
import { AccountType } from 'src/app/core/models/platform/v1/account.model';
import { Expense } from 'src/app/core/models/platform/v1/expense.model';
import { GetExpenseQueryParam } from 'src/app/core/models/platform/v1/get-expenses-query.model';
import { DateFilters } from 'src/app/shared/components/fy-filters/date-filters.enum';
import { ExpensesService } from './expenses.service';
import { cloneDeep } from 'lodash';
import { DateService } from '../../../date.service';
Expand Down Expand Up @@ -470,7 +472,7 @@ describe('ExpensesService', () => {
const result = service.generateCardNumberParams({}, expenseFiltersData1);

expect(result).toEqual({
'matched_corporate_card_transactions->0->corporate_card_number': 'in.(1234,5678)',
'matched_corporate_card_transactions->0->corporate_card_number': 'in.("1234","5678")',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { PaymentModeSummary } from 'src/app/core/models/payment-mode-summary.mod
import { AccountType } from 'src/app/core/models/platform/v1/account.model';
import { Expense } from 'src/app/core/models/platform/v1/expense.model';
import { GetExpenseQueryParam } from 'src/app/core/models/platform/v1/get-expenses-query.model';
import { ExpenseFilters } from 'src/app/fyle/my-expenses/expense-filters.model';
import { DateFilters } from 'src/app/shared/components/fy-filters/date-filters.enum';
import { DateService } from '../../../date.service';
import { ExpenseFilters } from 'src/app/core/models/expense-filters.model';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -200,11 +200,8 @@ export class ExpensesService {
): Record<string, string | string[] | boolean> {
const newQueryParamsCopy = cloneDeep(newQueryParams);
if (filters.cardNumbers?.length > 0) {
let cardNumberString = '';
cardNumberString = filters.cardNumbers.join(',');
cardNumberString = cardNumberString.slice(0, cardNumberString.length);
newQueryParamsCopy['matched_corporate_card_transactions->0->corporate_card_number'] =
'in.(' + cardNumberString + ')';
const cardNumberString = filters.cardNumbers.map((cardNumber) => `"${cardNumber}"`).join(',');
newQueryParamsCopy['matched_corporate_card_transactions->0->corporate_card_number'] = `in.(${cardNumberString})`;
}

return newQueryParamsCopy;
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/tracking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import {
EnrollingNonRTFCardProperties,
} from '../models/tracking-properties.model';
import { ExpenseView } from '../models/expense-view.enum';
import { ExpenseFilters } from 'src/app/fyle/my-expenses/expense-filters.model';
import { ReportFilters } from 'src/app/fyle/my-expenses-v2/my-expenses-filters.model';
import { TaskFilters } from '../models/task-filters.model';
import { OrgCategory } from '../models/v1/org-category.model';
import { TeamReportsFilters } from '../models/team-reports-filters.model';
import { forkJoin, from } from 'rxjs';
import { ExpenseFilters } from '../models/expense-filters.model';
import { ReportFilters } from '../models/report-filters.model';

@Injectable({
providedIn: 'root',
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/transaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { UserEventService } from './user-event.service';
import { UndoMerge } from '../models/undo-merge.model';
import { cloneDeep } from 'lodash';
import { DateFilters } from 'src/app/shared/components/fy-filters/date-filters.enum';
import { ExpenseFilters } from 'src/app/fyle/my-expenses/expense-filters.model';
import { PAGINATION_SIZE } from 'src/app/constants';
import { PaymentModesService } from './payment-modes.service';
import { OrgSettingsService } from './org-settings.service';
Expand All @@ -42,6 +41,7 @@ import { PlatformMissingMandatoryFieldsResponse } from '../models/platform/platf
import { AccountType } from '../enums/account-type.enum';
import { Expense as PlatformExpense } from '../models/platform/v1/expense.model';
import { CorporateCardTransactionRes } from '../models/platform/v1/corporate-card-transaction-res.model';
import { ExpenseFilters } from '../models/expense-filters.model';

enum FilterState {
READY_TO_REPORT = 'READY_TO_REPORT',
Expand Down
26 changes: 0 additions & 26 deletions src/app/fyle/dashboard/stats/stats.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ describe('StatsComponent', () => {

describe('goToExpensesPage():', () => {
it('goToExpensesPage(): should navigate to expenses page with query params', () => {
component.redirectToNewPage$ = of(false);
component.goToExpensesPage('COMPLETE');

expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_expenses'], {
Expand All @@ -368,7 +367,6 @@ describe('StatsComponent', () => {
});

it('goToExpensesPage(): should navigate to expenses page with query params', () => {
component.redirectToNewPage$ = of(false);
component.goToExpensesPage('INCOMPLETE');

expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_expenses'], {
Expand All @@ -378,30 +376,6 @@ describe('StatsComponent', () => {
});
expect(trackingService.dashboardOnIncompleteExpensesClick).toHaveBeenCalledTimes(1);
});

it('goToExpensesPage(): should navigate to v2 expenses page with query params', () => {
component.redirectToNewPage$ = of(true);
component.goToExpensesPage('COMPLETE');

expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_expenses_v2'], {
queryParams: {
filters: JSON.stringify({ state: ['READY_TO_REPORT'] }),
},
});
expect(trackingService.dashboardOnUnreportedExpensesClick).toHaveBeenCalledTimes(1);
});

it('goToExpensesPage(): should navigate to v2 expenses page with query params', () => {
component.redirectToNewPage$ = of(true);
component.goToExpensesPage('INCOMPLETE');

expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_expenses_v2'], {
queryParams: {
filters: JSON.stringify({ state: ['DRAFT'] }),
},
});
expect(trackingService.dashboardOnIncompleteExpensesClick).toHaveBeenCalledTimes(1);
});
});

describe('trackDashboardLaunchTime():', () => {
Expand Down
29 changes: 13 additions & 16 deletions src/app/fyle/dashboard/stats/stats.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,23 +200,20 @@ export class StatsComponent implements OnInit {
}

goToExpensesPage(state: string): void {
this.redirectToNewPage$.subscribe((redirect) => {
const endpoint = redirect ? 'my_expenses_v2' : 'my_expenses';
if (state === 'COMPLETE') {
const queryParams: Params = { filters: JSON.stringify({ state: ['READY_TO_REPORT'] }) };
this.router.navigate(['/', 'enterprise', endpoint], {
queryParams,
});
if (state === 'COMPLETE') {
const queryParams: Params = { filters: JSON.stringify({ state: ['READY_TO_REPORT'] }) };
this.router.navigate(['/', 'enterprise', 'my_expenses'], {
queryParams,
});

this.trackingService.dashboardOnUnreportedExpensesClick();
} else {
const queryParams: Params = { filters: JSON.stringify({ state: ['DRAFT'] }) };
this.router.navigate(['/', 'enterprise', endpoint], {
queryParams,
});
this.trackingService.dashboardOnIncompleteExpensesClick();
}
});
this.trackingService.dashboardOnUnreportedExpensesClick();
} else {
const queryParams: Params = { filters: JSON.stringify({ state: ['DRAFT'] }) };
this.router.navigate(['/', 'enterprise', 'my_expenses'], {
queryParams,
});
this.trackingService.dashboardOnIncompleteExpensesClick();
}
}

private trackDashboardLaunchTime(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/fyle/dashboard/tasks/tasks-3.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { cloneDeep, noop } from 'lodash';
import { snackbarPropertiesRes2 } from 'src/app/core/mock-data/snackbar-properties.data';
import { ToastMessageComponent } from 'src/app/shared/components/toast-message/toast-message.component';
import { ToastType } from 'src/app/core/enums/toast-type.enum';
import { AddTxnToReportDialogComponent } from '../../my-expenses-v2/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { AddTxnToReportDialogComponent } from '../../my-expenses/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { ExpensesService } from 'src/app/core/services/platform/v1/spender/expenses.service';
import { expenseData } from 'src/app/core/mock-data/platform/v1/expense.data';
import { unreportedExpensesQueryParams } from 'src/app/core/mock-data/platform/v1/expenses-query-params.data';
Expand Down
2 changes: 1 addition & 1 deletion src/app/fyle/dashboard/tasks/tasks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { FilterOptionType } from 'src/app/shared/components/fy-filters/filter-op
import { FilterOptions } from 'src/app/shared/components/fy-filters/filter-options.interface';
import { FyFiltersComponent } from 'src/app/shared/components/fy-filters/fy-filters.component';
import { ToastMessageComponent } from 'src/app/shared/components/toast-message/toast-message.component';
import { AddTxnToReportDialogComponent } from '../../my-expenses-v2/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { AddTxnToReportDialogComponent } from '../../my-expenses/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { FilterPill } from 'src/app/shared/components/fy-filter-pills/filter-pill.interface';
import { SelectedFilters } from 'src/app/shared/components/fy-filters/selected-filters.interface';
import { ExpensesService } from 'src/app/core/services/platform/v1/spender/expenses.service';
Expand Down
11 changes: 0 additions & 11 deletions src/app/fyle/fyle-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MyExpensesGuardGuard } from '../core/guards/my-expenses-guard.guard';
import { BetaPageFeatureFlagGuard } from '../core/guards/beta-page-feature-flag.guard';

const routes: Routes = [
{
path: 'my_dashboard',
loadChildren: () => import('./dashboard/dashboard.module').then((m) => m.DashboardPageModule),
},
{
path: 'my_expenses_v2',
loadChildren: () => import('./my-expenses-v2/my-expenses-v2.module').then((m) => m.MyExpensesV2PageModule),
},
{
path: 'my_expenses',
loadChildren: () => import('./my-expenses/my-expenses.module').then((m) => m.MyExpensesPageModule),
canActivate: [MyExpensesGuardGuard],
},
{
path: 'my_advances',
Expand Down Expand Up @@ -142,10 +135,6 @@ const routes: Routes = [
loadChildren: () =>
import('./manage-corporate-cards/manage-corporate-cards.module').then((m) => m.ManageCorporateCardsPageModule),
},
{
path: 'my-expenses',
loadChildren: () => import('./my-expenses/my-expenses.module').then((m) => m.MyExpensesPageModule),
},
];

export const fyleRoutes = routes;
Expand Down
Loading
Loading