feat: implement fiscal ID validation; replace fiscal code validator and update related components

This commit is contained in:
2026-05-19 20:34:20 +03:30
parent c135e1a85f
commit 2e1ad77946
26 changed files with 108 additions and 76 deletions
@@ -2,7 +2,7 @@
<p-select
[loading]="loading()"
[options]="items()"
optionLabel="name"
optionLabel="fullname"
[optionValue]="selectOptionValue"
placeholder="انتخاب شناسه کالا"
[formControl]="control"
@@ -3,11 +3,12 @@ import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { InputComponent } from '../input/input.component';
@Component({
selector: 'field-fiscal-code',
selector: 'field-fiscal-id',
template: `<app-input
label="کد مالیاتی"
label="شناسه یکتا"
[control]="control"
[name]="name"
[length]="6"
[isLtrInput]="true"
/>`,
imports: [ReactiveFormsModule, InputComponent],
@@ -10,6 +10,7 @@ import { InputComponent } from '../input/input.component';
[name]="name"
type="number"
[min]="min"
[maxLength]="9"
/>`,
imports: [ReactiveFormsModule, InputComponent],
})
@@ -4,12 +4,7 @@ import { InputComponent } from '../input/input.component';
@Component({
selector: 'field-partner-token',
template: `<app-input
label="توکن پارتنر"
[control]="control"
[name]="name"
[isLtrInput]="true"
/>`,
template: `<app-input label="توکن" [control]="control" [name]="name" [isLtrInput]="true" />`,
imports: [ReactiveFormsModule, InputComponent],
})
export class PartnerTokenComponent {
@@ -4,7 +4,7 @@ import { InputComponent } from '../input/input.component';
@Component({
selector: 'field-terminal',
template: `<app-input label="پرداخت با پایانه" [control]="control" [name]="name" type="price" />`,
template: `<app-input label="پرداخت با پوز" [control]="control" [name]="name" type="price" />`,
imports: [ReactiveFormsModule, InputComponent],
})
export class TerminalComponent {
@@ -66,6 +66,7 @@ export class InputComponent {
@Input() isLtrInput = false;
@Input() suffix: string = '';
@Input() maxLength?: number;
@Input() length?: number;
@Input() min?: number;
@Input() max?: number;
@Input() fixed?: number;
@@ -132,6 +133,8 @@ export class InputComponent {
}
get preparedMaxLength(): number | null {
const length = this.length || this.maxLength;
if (length) return length;
switch (this.type) {
case 'mobile':
return 11;
@@ -33,7 +33,7 @@
<app-key-value label="مجموع قابل پرداخت" [value]="invoice.total_amount" type="price" />
@for (payment of invoice.payments; track $index) {
<app-key-value
[label]="`${payment.payment_method === 'SET_OFF' ? 'تهاتر' : payment.payment_method === 'TERMINAL' ? 'پایانه' : 'نقدی'}`"
[label]="`${payment.payment_method === 'SET_OFF' ? 'تهاتر' : payment.payment_method === 'TERMINAL' ? 'پوز' : 'نقدی/ کارت‌خوان دیگر/ کارت به کارت'}`"
[value]="payment.amount"
type="price"
/>
@@ -11,8 +11,7 @@ import { Password } from 'primeng/password';
export class SharedPasswordInputComponent {
@Input({ required: true }) passwordControl = new FormControl<string>('');
@Input({ required: true }) confirmPasswordControl = new FormControl<string>('');
@Input() hint: string =
'رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد.';
@Input() hint: string = 'رمز باید حداقل ۶ کاراکتر باشد.';
@Input() fluid: boolean = true;
@Input() size: 'small' | 'large' = 'large';
}
+2 -11
View File
@@ -1,5 +1,5 @@
import {
fiscalCodeValidator,
fiscalIdValidator,
mobileValidator,
password,
postalCodeValidator,
@@ -30,15 +30,10 @@ export const fieldControl = {
value,
isRequired ? required() : [],
],
firstName: (value = '', isRequired = true): ControlConfig => [
value,
isRequired ? required() : [],
],
last_name: (value = '', isRequired = true): ControlConfig => [
value,
isRequired ? required() : [],
],
lastName: (value = '', isRequired = true): ControlConfig => [value, isRequired ? required() : []],
legal_name: (value = '', isRequired = true): ControlConfig => [
value,
isRequired ? required() : [],
@@ -55,10 +50,6 @@ export const fieldControl = {
value,
isRequired ? [Validators.required, mobileValidator()] : [mobileValidator()],
],
mobile: (value = '', isRequired = true): ControlConfig => [
value,
isRequired ? [Validators.required, mobileValidator()] : [mobileValidator()],
],
email: (value = '', isRequired = false): ControlConfig => [
value,
isRequired ? [Validators.required, Validators.email] : [Validators.email],
@@ -85,7 +76,7 @@ export const fieldControl = {
],
fiscal_id: (value = '', isRequired = true): ControlConfig => [
value,
isRequired ? [Validators.required, fiscalCodeValidator()] : [fiscalCodeValidator()],
isRequired ? [Validators.required, fiscalIdValidator()] : [fiscalIdValidator()],
],
partner_token: (value = '', isRequired = true): ControlConfig => [
value,