From 7b14c61c1b03bbeff0ce3eab3c2eadea74c9778e Mon Sep 17 00:00:00 2001 From: suyashpatil78 Date: Mon, 11 Mar 2024 11:56:00 +0530 Subject: [PATCH 1/3] feat: popover confirmation once commute is updated from form --- .../add-edit-mileage/add-edit-mileage.page.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts index 6b707899bc..a192b7154e 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts @@ -2986,6 +2986,30 @@ export class AddEditMileagePage implements OnInit { this.onPageExit$.complete(); } + getCommuteUpdatedTextBody(): string { + return `
+

Your Commute Details have been successfully added to your Profile + Settings.

+

You can now easily deduct commute from your Mileage expenses.

+

`; + } + + async showCommuteUpdatedPopover(): Promise { + const sizeLimitExceededPopover = await this.popoverController.create({ + component: PopupAlertComponent, + componentProps: { + title: 'Commute Updated!', + message: this.getCommuteUpdatedTextBody(), + primaryCta: { + text: 'Proceed', + }, + }, + cssClass: 'pop-up-in-center', + }); + + await sizeLimitExceededPopover.present(); + } + async openCommuteDetailsModal(): Promise { const commuteDetailsModal = await this.modalController.create({ component: FySelectCommuteDetailsComponent, @@ -3008,6 +3032,7 @@ export class AddEditMileagePage implements OnInit { this.commuteDeductionOptions = this.getCommuteDeductionOptions(this.commuteDetails?.distance); // If the user has saved the commute details, update the commute deduction field to no deduction this.fg.patchValue({ commuteDeduction: 'NO_DEDUCTION' }); + this.showCommuteUpdatedPopover(); }); } } From 547239ff20312c5b6cdcaa09ca27313b22978610 Mon Sep 17 00:00:00 2001 From: Suyash Patil <127177049+suyashpatil78@users.noreply.github.com> Date: Thu, 14 Mar 2024 10:54:01 +0530 Subject: [PATCH 2/3] fix: mandatory as per txnFields (#2823) * fix: mandatory as per txnFields * for round trip disabling * fix: distance can be zero and fix for commute deduction mandatory message (#2826) * fix: distance can be zero and fix for commute deduction mandatory message * minor --- .../add-edit-mileage.page.html | 105 +++++++++--------- .../add-edit-mileage/add-edit-mileage.page.ts | 20 +++- .../route-selector-modal.component.html | 8 +- .../route-selector.component.html | 8 +- .../route-selector.component.ts | 8 +- 5 files changed, 88 insertions(+), 61 deletions(-) diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.html b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.html index 2203bffffc..053c0baaa1 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.html +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.html @@ -151,59 +151,62 @@ -
- - - +
-
-
{{label}}
-
- {{distance.toFixed(2) + ' ' + distanceUnit}} -
-
- {{distance + ' ' + distanceUnit}} -
-
- - Add Location + + + +
+
{{label}}
+
+ {{distance.toFixed(2) + ' ' + distanceUnit}} +
+
+ {{distance + ' ' + distanceUnit}} +
+
+ + Add Location +
-
- check - -
-
- Select Commute Deduction. -
+ check + +
+
+ Please select commute deduction. +
+ diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts index a192b7154e..145da47d5c 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts @@ -550,7 +550,15 @@ export class AddEditMileagePage implements OnInit { }).pipe( switchMap(({ expenseFieldsMap, mileageCategoriesContainer }) => { // skipped distance unit, location 1 and location 2 - confirm this these are not used at all - const fields = ['purpose', 'txn_dt', 'cost_center_id', 'project_id', 'distance', 'billable']; + const fields = [ + 'purpose', + 'txn_dt', + 'cost_center_id', + 'project_id', + 'distance', + 'billable', + 'commute_deduction', + ]; return this.expenseFieldsService.filterByOrgCategoryId( expenseFieldsMap, @@ -1020,11 +1028,12 @@ export class AddEditMileagePage implements OnInit { txn_dt: this.fg.controls.dateOfSpend, project_id: this.fg.controls.project, billable: this.fg.controls.billable, + commute_deduction: this.fg.controls.commuteDeduction, }; for (const [key, control] of Object.entries(keyToControlMap)) { control.clearValidators(); - if (key === 'project_id') { + if (key === 'project_id' || key === 'commute_deduction') { control.updateValueAndValidity({ emitEvent: false, }); @@ -1051,11 +1060,13 @@ export class AddEditMileagePage implements OnInit { ? null : Validators.required ); + } else if (txnFieldKey === 'commute_deduction') { + control.setValidators(orgSettings.commute_deduction_settings.enabled ? Validators.required : null); } else { control.setValidators(isConnected ? Validators.required : null); } } - if (txnFieldKey === 'project_id') { + if (txnFieldKey === 'project_id' || txnFieldKey === 'commute_deduction') { control.updateValueAndValidity({ emitEvent: false, }); @@ -2369,7 +2380,8 @@ export class AddEditMileagePage implements OnInit { cost_center_name: formValue.costCenter && formValue.costCenter.name, cost_center_code: formValue.costCenter && formValue.costCenter.code, commute_deduction: this.showCommuteDeductionField ? formValue.commuteDeduction : null, - commute_details_id: this.showCommuteDeductionField ? this.commuteDetails?.id : null, + commute_details_id: + this.showCommuteDeductionField && formValue.commuteDeduction ? this.commuteDetails?.id : null, }, dataUrls: [], ou: etxn.ou, diff --git a/src/app/shared/components/route-selector/route-selector-modal/route-selector-modal.component.html b/src/app/shared/components/route-selector/route-selector-modal/route-selector-modal.component.html index a1a89db62a..4b9c1a27a3 100644 --- a/src/app/shared/components/route-selector/route-selector-modal/route-selector-modal.component.html +++ b/src/app/shared/components/route-selector/route-selector-modal/route-selector-modal.component.html @@ -90,8 +90,12 @@ > -
- +
+ Round Trip
diff --git a/src/app/shared/components/route-selector/route-selector.component.html b/src/app/shared/components/route-selector/route-selector.component.html index 381a8042e6..c046330784 100644 --- a/src/app/shared/components/route-selector/route-selector.component.html +++ b/src/app/shared/components/route-selector/route-selector.component.html @@ -127,8 +127,12 @@
-
- +
+ Round Trip
diff --git a/src/app/shared/components/route-selector/route-selector.component.ts b/src/app/shared/components/route-selector/route-selector.component.ts index 1d59f231f6..45d2ce94b2 100644 --- a/src/app/shared/components/route-selector/route-selector.component.ts +++ b/src/app/shared/components/route-selector/route-selector.component.ts @@ -71,6 +71,10 @@ export class RouteSelectorComponent implements OnInit, ControlValueAccessor, OnD return this.form.controls.mileageLocations as FormArray; } + get isRoundTripEnabled(): boolean { + return this.isAmountDisabled || !this.form.controls.distance?.value; + } + onTouched = () => {}; ngDoCheck() { @@ -83,10 +87,10 @@ export class RouteSelectorComponent implements OnInit, ControlValueAccessor, OnD this.onChangeSub.unsubscribe(); } - customDistanceValidator(control: AbstractControl) { + customDistanceValidator(control: AbstractControl): { invalidDistance: boolean } { const passedInDistance = control.value && +control.value; if (passedInDistance !== null) { - return passedInDistance > 0 + return passedInDistance >= 0 ? null : { invalidDistance: true, From 62eb436892228b809bb97596d4eb7fabff7da401 Mon Sep 17 00:00:00 2001 From: suyashpatil78 Date: Thu, 14 Mar 2024 10:56:15 +0530 Subject: [PATCH 3/3] minor --- src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts index 145da47d5c..8f3429d3b2 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts @@ -3010,7 +3010,7 @@ export class AddEditMileagePage implements OnInit { const sizeLimitExceededPopover = await this.popoverController.create({ component: PopupAlertComponent, componentProps: { - title: 'Commute Updated!', + title: 'Commute Updated', message: this.getCommuteUpdatedTextBody(), primaryCta: { text: 'Proceed',