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,