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 5cf2e572de..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 @@ -204,7 +204,7 @@ *ngIf="fg.controls.commuteDeduction.touched && !fg.controls.commuteDeduction.valid" class="add-edit-mileage--error" > - Select Commute Deduction. + 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 5b9d29fb83..f97df02f4e 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 @@ -1028,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, }); @@ -1059,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, }); 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 f1fae3d843..45d2ce94b2 100644 --- a/src/app/shared/components/route-selector/route-selector.component.ts +++ b/src/app/shared/components/route-selector/route-selector.component.ts @@ -87,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,