Skip to content

Commit

Permalink
fix: advanced settings validators (#929)
Browse files Browse the repository at this point in the history
* fix: advanced settings validators

* !==

* fix for qbo

* fix for netsuite

* [isFieldMandatory]

* [mandatoryErrorListName]="'payment account'"
  • Loading branch information
anishfyle committed Aug 28, 2024
1 parent 3a2b763 commit 22f671d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FormControl, FormGroup } from "@angular/forms";
import { EmailOption, SelectFormOption } from "../../common/select-form-option.model";
import { DefaultDestinationAttribute } from "../../db/destination-attribute.model";
import { NetsuiteDefaultLevelOptions, NetsuitePaymentSyncDirection, QBOPaymentSyncDirection } from "../../enum/enum.model";
import { NetsuiteDefaultLevelOptions, NetsuitePaymentSyncDirection, PaymentSyncDirection } from "../../enum/enum.model";
import { AdvancedSettingValidatorRule, AdvancedSettingsModel } from "../../common/advanced-settings.model";
import { HelperUtility } from "../../common/helper.model";
import { brandingConfig } from "src/app/branding/branding-config";
Expand Down Expand Up @@ -101,7 +101,7 @@ export class NetsuiteAdvancedSettingModel extends HelperUtility {

static getValidators(): AdvancedSettingValidatorRule {
return {
paymentSync: 'billPaymentAccount',
paymentSync: 'paymentAccount',
exportSchedule: 'exportScheduleFrequency'
};
}
Expand All @@ -112,7 +112,7 @@ export class NetsuiteAdvancedSettingModel extends HelperUtility {

Object.values(validatorRule).forEach((value, index) => {
form.controls[keys[index]].valueChanges.subscribe((selectedValue) => {
if (selectedValue) {
if (selectedValue && ((keys[index] === 'paymentSync' && selectedValue === NetsuitePaymentSyncDirection.FYLE_TO_NETSUITE) || (keys[index] !== 'paymentSync'))) {
this.markControllerAsRequired(form, value);
} else {
this.clearValidatorAndResetValue(form, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class QBOAdvancedSettingModel extends HelperUtility {

Object.values(validatorRule).forEach((value, index) => {
form.controls[keys[index]].valueChanges.subscribe((selectedValue) => {
if (selectedValue) {
if (selectedValue && ((keys[index] === 'paymentSync' && selectedValue === QBOPaymentSyncDirection.FYLE_TO_QBO) || (keys[index] !== 'paymentSync'))) {
this.markControllerAsRequired(form, value);
} else {
this.clearValidatorAndResetValue(form, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
<app-configuration-select-field *ngIf="this.advancedSettingForm.controls.paymentSync.value === 'fyle_to_netsuite' && isPaymentSyncFieldVisible() && brandingFeatureConfig.featureFlags.advancedSettings.paymentsSync"
[form]="advancedSettingForm"
[destinationAttributes]="paymentAccounts"
[isFieldMandatory]="true"
[mandatoryErrorListName]="'payment account'"
[optionLabel]="'name'"
[iconPath]="'arrow-rotate'"
[label]="brandingContent.defaultPaymentAccount"
Expand Down

0 comments on commit 22f671d

Please sign in to comment.