Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
only ccc export setting save bug fix (#238)
Browse files Browse the repository at this point in the history
* only ccc export setting save bug fix
* validity of export-form fixed
  • Loading branch information
vishalpandeynits authored Jan 13, 2023
1 parent 1b43b7a commit f7880c1
Showing 1 changed file with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,9 @@ export class ExportSettingsComponent implements OnInit, OnDestroy {

is_simplify_report_closure_enabled: boolean = false;

expenseStateOptions: ExportSettingFormOption[] = [
{
value: ExpenseState.PAYMENT_PROCESSING,
label: this.is_simplify_report_closure_enabled ? 'Processing' : 'Payment Processing'
},
{
label: this.is_simplify_report_closure_enabled ? 'Closed' : 'Paid',
value: ExpenseState.PAID
}
];
expenseStateOptions: ExportSettingFormOption[];

cccExpenseStateOptions: ExportSettingFormOption[] = [
{
label: this.is_simplify_report_closure_enabled ? 'Approved' : 'Payment Processing',
value: this.is_simplify_report_closure_enabled ? CCCExpenseState.APPROVED: CCCExpenseState.PAYMENT_PROCESSING
},
{
label: this.is_simplify_report_closure_enabled ? 'Closed' : 'Paid',
value: CCCExpenseState.PAID
}
];
cccExpenseStateOptions: ExportSettingFormOption[];

expenseGroupingFieldOptions: ExportSettingFormOption[] = [
{
Expand Down Expand Up @@ -283,7 +265,7 @@ export class ExportSettingsComponent implements OnInit, OnDestroy {
private exportSelectionValidator(): ValidatorFn {
return (control: AbstractControl): {[key: string]: object} | null => {
let forbidden = true;
if (this.exportSettingsForm && this.exportSettingsForm.value.expenseState) {
if (this.exportSettingsForm) {
if (typeof control.value === 'boolean') {
if (control.value) {
forbidden = false;
Expand All @@ -292,12 +274,14 @@ export class ExportSettingsComponent implements OnInit, OnDestroy {
forbidden = false;
}
}
} else if ((control.value === ExpenseState.PAID || control.value === ExpenseState.PAYMENT_PROCESSING) && (control.parent?.get('reimbursableExpense')?.value || control.parent?.get('creditCardExpense')?.value)) {
} else if ((control.value === ExpenseState.PAID || control.value === ExpenseState.PAYMENT_PROCESSING || control.value === CCCExpenseState.APPROVED)
&& (control.parent?.get('reimbursableExpense')?.value || control.parent?.get('creditCardExpense')?.value)) {
forbidden = false;
}

if (!forbidden) {
control.parent?.get('expenseState')?.setErrors(null);
control.parent?.get('cccExpenseState')?.setErrors(null);
control.parent?.get('reimbursableExpense')?.setErrors(null);
control.parent?.get('creditCardExpense')?.setErrors(null);
return null;
Expand Down Expand Up @@ -468,6 +452,29 @@ export class ExportSettingsComponent implements OnInit, OnDestroy {
this.vendors = response[1].VENDOR;
this.expenseAccounts = this.bankAccounts.concat(this.cccAccounts);
this.is_simplify_report_closure_enabled = response[2].is_simplify_report_closure_enabled;

this.cccExpenseStateOptions = [
{
label: this.is_simplify_report_closure_enabled ? 'Approved' : 'Payment Processing',
value: this.is_simplify_report_closure_enabled ? CCCExpenseState.APPROVED: CCCExpenseState.PAYMENT_PROCESSING
},
{
label: this.is_simplify_report_closure_enabled ? 'Closed' : 'Paid',
value: CCCExpenseState.PAID
}
];

this.expenseStateOptions = [
{
label: this.is_simplify_report_closure_enabled ? 'Approved' : 'Payment Processing',
value: this.is_simplify_report_closure_enabled ? CCCExpenseState.APPROVED: CCCExpenseState.PAYMENT_PROCESSING
},
{
label: this.is_simplify_report_closure_enabled ? 'Closed' : 'Paid',
value: CCCExpenseState.PAID
}
];

this.setupForm();
});
}
Expand Down

0 comments on commit f7880c1

Please sign in to comment.