Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/fylein/fyle-mobile-app in…
Browse files Browse the repository at this point in the history
…to Fyle-86cup7bft-2
  • Loading branch information
howdysuraj committed Mar 4, 2024
2 parents 032c06b + c2422ff commit b34a454
Show file tree
Hide file tree
Showing 25 changed files with 307 additions and 33 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: AI Code Reviewer

on:
pull_request:
types: [opened, synchronize, edited]

permissions: write-all
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: AI Code Reviewer
uses: freeedcom/ai-codereviewer@v2.7.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_MODEL: 'gpt-4' # Optional: defaults to "gpt-4"
exclude: '**/*.json, **/*.md' # Optional: exclude patterns separated by commas
8 changes: 4 additions & 4 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ jobs:
branches=$(jq '.total.branches.pct' < coverage/coverage-summary.json)
functions=$(jq '.total.functions.pct' < coverage/coverage-summary.json)
if (( $(echo "$lines < 96.83" | bc -l) || \
$(echo "$statements < 96.8" | bc -l) || \
$(echo "$branches < 94.93" | bc -l) || \
$(echo "$functions < 95.77" | bc -l) )); then
if (( $(echo "$lines < 95.0" | bc -l) || \
$(echo "$statements < 95.0" | bc -l) || \
$(echo "$branches < 94.0" | bc -l) || \
$(echo "$functions < 94.0" | bc -l) )); then
echo "Code Coverage Percentage is below 95%"
exit 1
fi
2 changes: 2 additions & 0 deletions src/app/core/models/org-settings.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ export interface OrgSettingsResponse {
enable_org_creation?: boolean;
enable_auto_report?: boolean;

commute_deduction_settings?: CommonOrgSettings;
mileage_details?: MileageDetails;
policy_settings?: PolicySettings;
corporate_credit_card_settings?: CCCSettings;
Expand Down Expand Up @@ -487,6 +488,7 @@ export interface XeProviderSettings extends CommonOrgSettings {
export interface OrgSettings {
org_id?: string;
mileage?: MileageDetails;
commute_deduction_settings?: CommonOrgSettings;
advances?: CommonOrgSettings;
projects?: CommonOrgSettings;
advanced_projects?: AdvancedProjectSettings;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { CommuteDetails } from './v1/commute-details.model';

export interface CommuteDetailsResponse {
user_id: string;
full_name: string;
email: string;
commute_details: CommuteDetails;
}
9 changes: 9 additions & 0 deletions src/app/core/models/platform/v1/commute-details.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Location } from '../../location.model';

export interface CommuteDetails {
id?: number;
distance: number;
distance_unit: string;
home_location: Location;
work_location: Location;
}
2 changes: 1 addition & 1 deletion src/app/core/services/org-settings.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('OrgSettingsService', () => {
);
});

it('should be able to get the org settings properly for undefined amex feed enrollment values', (done) => {
xit('should be able to get the org settings properly for undefined amex feed enrollment values', (done) => {
apiService.get.and.returnValue(of(orgSettingsAmexFeedDataRequest));
orgSettingsService.get().subscribe((res) => {
expect(res).toEqual(orgSettingsAmexFeedDataResponse);
Expand Down
8 changes: 8 additions & 0 deletions src/app/core/services/org-settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export class OrgSettingsService {
enable_individual_mileage_rates:
incoming.mileage_details && incoming.mileage_details.enable_individual_mileage_rates,
},
commute_deduction_settings: {
allowed: incoming.commute_deduction_settings?.allowed,
enabled: incoming.commute_deduction_settings?.enabled,
},
advances: {
allowed: incoming.advances_settings && incoming.advances_settings.allowed,
enabled: incoming.advances_settings && incoming.advances_settings.enabled,
Expand Down Expand Up @@ -457,6 +461,10 @@ export class OrgSettingsService {
enabled: outgoing.mileage.enabled,
mileage_location_enabled: outgoing.mileage.location_mandatory,
},
commute_deduction_settings: {
allowed: outgoing.commute_deduction_settings?.allowed,
enabled: outgoing.commute_deduction_settings?.enabled,
},
multi_org_settings: {
allowed: outgoing.org_creation.allowed,
enabled: outgoing.org_creation.enabled,
Expand Down
8 changes: 8 additions & 0 deletions src/app/core/test-data/org-settings.service.spec.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ export const orgSettingsGetData: OrgSettings = {
enabled: true,
virtual_card_settings_enabled: true,
},
commute_deduction_settings: {
allowed: true,
enabled: true,
},
};

export const orgSettingsPostData: OrgSettingsResponse = {
Expand Down Expand Up @@ -874,6 +878,10 @@ export const orgSettingsPostData: OrgSettingsResponse = {
enabled: true,
virtual_card_settings_enabled: true,
},
commute_deduction_settings: {
allowed: true,
enabled: true,
},
};

export const orgSettingsAmexFeedDataRequest: OrgSettingsResponse = {
Expand Down
2 changes: 1 addition & 1 deletion src/app/fyle/add-edit-expense/add-edit-expense-2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ export function TestCases2(getTestBed) {
fixture.detectChanges();

const result = component.getTimeSpentOnPage();
expect(result).toEqual((new Date().getTime() - component.expenseStartTime) / 1000);
expect(result).toBeCloseTo((new Date().getTime() - component.expenseStartTime) / 1000, 2);
});

it('closeAddEditExpenses(): should close the form and navigate back to my_expenses page', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/fyle/add-edit-mileage/add-edit-mileage-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ export function TestCases1(getTestBed) {

const result = component.getTimeSpentOnPage();
const time = (new Date().getTime() - component.expenseStartTime) / 1000;
expect(result).toEqual(time);
expect(result).toBeCloseTo(time, 2);
});

it('reloadCurrentRoute(): should reload the current load', fakeAsync(() => {
Expand Down
28 changes: 14 additions & 14 deletions src/app/fyle/add-edit-per-diem/add-edit-per-diem-2.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ export function TestCases2(getTestBed) {
});
}));

it('getNewExpense(): should return new expense object', () => {
xit('getNewExpense(): should return new expense object', () => {
spyOn(component, 'getPerDiemCategories').and.returnValue(
of({
defaultPerDiemCategory: perDiemCategory,
perDiemCategories: [perDiemCategory],
}),
})
);
currencyService.getHomeCurrency.and.returnValue(of('USD'));
authService.getEou.and.resolveTo(apiEouRes);
Expand Down Expand Up @@ -240,7 +240,7 @@ export function TestCases2(getTestBed) {

const result = component.getTimeSpentOnPage();
const endTime = (new Date().getTime() - component.expenseStartTime) / 1000;
expect(result).toEqual(endTime);
expect(result).toBeCloseTo(endTime, 2);
});

describe('getCustomInputs():', () => {
Expand All @@ -257,7 +257,7 @@ export function TestCases2(getTestBed) {
of({
defaultPerDiemCategory: perDiemCategory,
perDiemCategories: [perDiemCategory],
}),
})
);
component.etxn$ = of(unflattenedTxnData);
categoriesService.getAll.and.returnValue(of([mockCategoryData]));
Expand All @@ -280,7 +280,7 @@ export function TestCases2(getTestBed) {
expect(categoriesService.getAll).toHaveBeenCalledTimes(1);
expect(customFieldsService.standardizeCustomFields).toHaveBeenCalledOnceWith(
dependentCustomProperties,
expenseFieldResponse,
expenseFieldResponse
);
expect(customInputsService.filterByCategory).toHaveBeenCalledOnceWith(expenseFieldResponse, 16577);
const expenseFieldWithoutControl = res.map(({ control, ...otherProps }) => ({ ...otherProps }));
Expand Down Expand Up @@ -322,7 +322,7 @@ export function TestCases2(getTestBed) {
expect(categoriesService.getAll).not.toHaveBeenCalled();
expect(customFieldsService.standardizeCustomFields).toHaveBeenCalledOnceWith(
dependentCustomProperties,
expenseFieldResponse,
expenseFieldResponse
);
expect(component.getPerDiemCategories).not.toHaveBeenCalled();
expect(customInputsService.filterByCategory).toHaveBeenCalledOnceWith(expenseFieldResponse, 247980);
Expand All @@ -348,7 +348,7 @@ export function TestCases2(getTestBed) {
expect(categoriesService.getAll).not.toHaveBeenCalled();
expect(customFieldsService.standardizeCustomFields).toHaveBeenCalledOnceWith(
dependentCustomProperties,
expenseFieldResponse,
expenseFieldResponse
);
expect(component.getPerDiemCategories).toHaveBeenCalledTimes(1);
expect(customInputsService.filterByCategory).toHaveBeenCalledOnceWith(expenseFieldResponse, 38912);
Expand Down Expand Up @@ -415,7 +415,7 @@ export function TestCases2(getTestBed) {
of({
defaultPerDiemCategory: perDiemCategory,
perDiemCategories: [perDiemCategory],
}),
})
);
spyOn(component, 'getEditExpense').and.returnValue(of(unflattenedTxnData));
spyOn(component, 'getNewExpense').and.returnValue(of(unflattenedTxnDataPerDiem));
Expand Down Expand Up @@ -445,7 +445,7 @@ export function TestCases2(getTestBed) {
expect(dateService.addDaysToDate).toHaveBeenCalledOnceWith(today, 1);
expect(platform.backButton.subscribeWithPriority).toHaveBeenCalledOnceWith(
BackButtonActionPriority.MEDIUM,
jasmine.any(Function),
jasmine.any(Function)
);
expect(tokenService.getClusterDomain).toHaveBeenCalledTimes(1);
expect(component.clusterDomain).toEqual('https://staging.fyle.tech');
Expand Down Expand Up @@ -519,7 +519,7 @@ export function TestCases2(getTestBed) {
.pipe(
finalize(() => {
expect(loaderService.hideLoader).toHaveBeenCalledTimes(3);
}),
})
)
.subscribe((res) => {
// 3 times because it is called in initializing allowedPerDiemRates$, canCreatePerDiem$ and setting up form value
Expand All @@ -538,7 +538,7 @@ export function TestCases2(getTestBed) {
.pipe(
finalize(() => {
expect(loaderService.hideLoader).toHaveBeenCalledTimes(3);
}),
})
)
.subscribe((res) => {
expect(loaderService.showLoader).toHaveBeenCalledTimes(3);
Expand All @@ -557,7 +557,7 @@ export function TestCases2(getTestBed) {
.pipe(
finalize(() => {
expect(loaderService.hideLoader).toHaveBeenCalledTimes(3);
}),
})
)
.subscribe((res) => {
expect(loaderService.showLoader).toHaveBeenCalledTimes(3);
Expand All @@ -578,7 +578,7 @@ export function TestCases2(getTestBed) {
.pipe(
finalize(() => {
expect(loaderService.hideLoader).toHaveBeenCalledTimes(3);
}),
})
)
.subscribe((res) => {
expect(loaderService.showLoader).toHaveBeenCalledTimes(3);
Expand Down Expand Up @@ -688,7 +688,7 @@ export function TestCases2(getTestBed) {
component.recentlyUsedCostCenters$.subscribe((res) => {
expect(recentlyUsedItemsService.getRecentCostCenters).toHaveBeenCalledOnceWith(
expectedCCdata3,
recentlyUsedRes,
recentlyUsedRes
);
expect(res).toEqual(expectedCCdata2);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MockAddCardComponent {
@Input() showZeroStateMessage: boolean;
}

describe('CardStatsComponent', () => {
xdescribe('CardStatsComponent', () => {
const cards = [mastercardRTFCard];
const cardStats = mastercardCCCStats;
const cardDetails = cardDetailsRes;
Expand Down Expand Up @@ -301,7 +301,7 @@ describe('CardStatsComponent', () => {
expect(addCardPopoverSpy.present).toHaveBeenCalledTimes(1);
}));

it('should open the card added modal on successful card addition and reload the cards', fakeAsync(() => {
xit('should open the card added modal on successful card addition and reload the cards', fakeAsync(() => {
addCardPopoverSpy.onDidDismiss.and.resolveTo({ data: { success: true } });

const spentCardsComponent = fixture.debugElement.query(By.directive(MockAddCardComponent));
Expand Down Expand Up @@ -364,7 +364,7 @@ describe('CardStatsComponent', () => {
expect(addCardPopoverSpy.present).toHaveBeenCalledTimes(1);
}));

it('should open the card added modal on successful card addition and reload the cards', fakeAsync(() => {
xit('should open the card added modal on successful card addition and reload the cards', fakeAsync(() => {
addCardPopoverSpy.onDidDismiss.and.resolveTo({ data: { success: true } });

component.isVirtualCardsEnabled$ = of({ enabled: false });
Expand Down
79 changes: 79 additions & 0 deletions src/app/fyle/my-profile/my-profile.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,85 @@
</div>
</ng-container>

<!-- TODO - Re-enable again at the time of release -->
<ng-container *ngIf="false && isMileageEnabled && isCommuteDeductionEnabled">
<div class="my-profile__section-header">Commute Details</div>
<div
*ngIf="!isCommuteDetailsPresent"
class="my-profile__card"
[routerLink]="[ '/', 'enterprise', 'add_commute_details' ]"
matRipple
>
<div class="my-profile__card__title">Add Location</div>
<ion-icon
class="my-profile__navigate-icon"
src="../../../assets/svg/arrow-right.svg"
slot="icon-only"
></ion-icon>
</div>
<div *ngIf="commuteDetails" class="my-profile__card">
<div class="my-profile__card__content-container">
<div class="my-profile__card__location-detail-card">
<div class="my-profile__card__location-icon-container">
<ion-icon
class="my-profile__icon"
src="../../../assets/svg/house-outline.svg"
slot="icon-only"
></ion-icon>
</div>
<div>
<div class="my-profile__card__location-detail-card__header">Home</div>
<div class="my-profile__card__location-detail-card__content">
{{ commuteDetails.home_location.formatted_address }}
</div>
</div>
</div>
<div class="my-profile__card__location-detail-card">
<div class="my-profile__card__location-icon-container">
<ion-icon class="my-profile__icon" src="../../../assets/svg/building.svg" slot="icon-only"></ion-icon>
</div>
<div>
<div class="my-profile__card__location-detail-card__header">Work</div>
<div class="my-profile__card__location-detail-card__content">
{{ commuteDetails.work_location.formatted_address }}
</div>
</div>
</div>
<div class="my-profile__card__edit-commute-button">
<ion-icon
class="my-profile__card__edit-commute-button__icon"
src="../../../assets/svg/edit.svg"
slot="icon-only"
></ion-icon>
<span class="my-profile__card__edit-commute-button__text">Edit Location</span>
</div>
<div class="my-profile__card__emphasized-content">Commute Distance:</div>
<div class="my-profile__card__commute-distance-row">
<ion-icon
class="my-profile__icon"
src="../../../assets/svg/arrow-tail-up.svg"
slot="icon-only"
></ion-icon>
<span>One way distance - </span>
<span class="my-profile__card__emphasized-content"
>{{commuteDetails.distance.toFixed(2) + ' ' + mileageDistanceUnit}}</span
>
</div>
<div class="my-profile__card__commute-distance-row">
<ion-icon
class="my-profile__icon"
src="../../../assets/svg/arrow-tail-up-down.svg"
slot="icon-only"
></ion-icon>
<span>Round trip distance - </span>
<span class="my-profile__card__emphasized-content"
>{{ (commuteDetails.distance * 2).toFixed(2) + ' ' + mileageDistanceUnit}}</span
>
</div>
</div>
</div>
</ng-container>

<div class="my-profile__section-header">Notifications</div>
<div class="my-profile__card" [routerLink]="[ '/', 'enterprise', 'notifications' ]" matRipple>
<div class="my-profile__card__title">Manage Notifications</div>
Expand Down
Loading

0 comments on commit b34a454

Please sign in to comment.