refactor: replace economic code fields with individual and legal variants, add equal length validation
This commit is contained in:
@@ -4,13 +4,14 @@ export * from './code.component';
|
||||
export * from './company_name.component';
|
||||
export * from './description.component';
|
||||
export * from './device_id.component';
|
||||
export * from './economic_code.component';
|
||||
export * from './email.component';
|
||||
export * from './first_name.component';
|
||||
export * from './fiscal_id.component';
|
||||
export * from './guild_id.component';
|
||||
export * from './individual_economic_code.component';
|
||||
export * from './invoice_templates.component';
|
||||
export * from './last_name.component';
|
||||
export * from './legal_economic_code.component';
|
||||
export * from './legal_name.component';
|
||||
export * from './license_starts_at.component';
|
||||
export * from './mobile.component';
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { InputComponent } from '../input/input.component';
|
||||
|
||||
@Component({
|
||||
selector: 'field-individual-economic-code',
|
||||
template: `<app-input
|
||||
label="شماره اقتصادی"
|
||||
[control]="control"
|
||||
[name]="name"
|
||||
type="number"
|
||||
[length]="14"
|
||||
/>`,
|
||||
imports: [ReactiveFormsModule, InputComponent],
|
||||
})
|
||||
export class IndividualEconomicCodeComponent {
|
||||
@Input({ required: true }) control = new FormControl<string>('');
|
||||
@Input() name = 'individual_economic_code';
|
||||
}
|
||||
+10
-4
@@ -3,11 +3,17 @@ import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { InputComponent } from '../input/input.component';
|
||||
|
||||
@Component({
|
||||
selector: 'field-economic-code',
|
||||
template: `<app-input label="کد اقتصادی" [control]="control" [name]="name" type="number" />`,
|
||||
selector: 'field-legal-economic-code',
|
||||
template: `<app-input
|
||||
label="شماره اقتصادی"
|
||||
[control]="control"
|
||||
[name]="name"
|
||||
type="number"
|
||||
[length]="11"
|
||||
/>`,
|
||||
imports: [ReactiveFormsModule, InputComponent],
|
||||
})
|
||||
export class EconomicCodeComponent {
|
||||
export class LegalEconomicCodeComponent {
|
||||
@Input({ required: true }) control = new FormControl<string>('');
|
||||
@Input() name = 'economic_code';
|
||||
@Input() name = 'legal_economic_code';
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { PosInfoStore } from '@/domains/pos/store';
|
||||
import {
|
||||
CatalogInvoiceTypeTagComponent,
|
||||
CatalogTaxProviderStatusTagComponent,
|
||||
TspProviderResponseStatus,
|
||||
} from '@/shared/catalog';
|
||||
import { CatalogInvoiceSettlementTypeTagComponent } from '@/shared/catalog/invoiceSettlementType';
|
||||
import {
|
||||
@@ -87,6 +88,7 @@ export class SharedSaleInvoiceSingleViewComponent {
|
||||
|
||||
@Output() onRefresh = new EventEmitter<void>();
|
||||
@Output() onSendToTsp = new EventEmitter<Observable<any>>();
|
||||
@Output() onResendToTsp = new EventEmitter<Observable<any>>();
|
||||
@Output() onInquiry = new EventEmitter<Observable<any>>();
|
||||
|
||||
@ViewChild('totalAmount', { static: false }) totalAmount!: TemplateRef<any>;
|
||||
@@ -102,6 +104,7 @@ export class SharedSaleInvoiceSingleViewComponent {
|
||||
this.showBackFromSale = this.showBackFromSale.bind(this);
|
||||
this.printInvoice = this.printInvoice.bind(this);
|
||||
this.send = this.send.bind(this);
|
||||
this.resend = this.resend.bind(this);
|
||||
this.inquiry = this.inquiry.bind(this);
|
||||
}
|
||||
|
||||
@@ -116,6 +119,9 @@ export class SharedSaleInvoiceSingleViewComponent {
|
||||
send() {
|
||||
this.onSendToTsp.emit();
|
||||
}
|
||||
resend() {
|
||||
this.onResendToTsp.emit();
|
||||
}
|
||||
async showRevokeConfirmation() {
|
||||
await this.confirmationService.ask({
|
||||
header: `ابطال صورتحساب شماره ${this.invoice!.invoice_number}`,
|
||||
@@ -146,40 +152,46 @@ export class SharedSaleInvoiceSingleViewComponent {
|
||||
if (changes['invoice'] && this.invoice) {
|
||||
const invoiceStatus = this.invoice.status.value;
|
||||
const actions: MenuItem[] = [
|
||||
{
|
||||
label: 'ارسال مجدد صورتحساب',
|
||||
icon: 'pi pi-send',
|
||||
neededStatus: TspProviderResponseStatus.SEND_FAILURE,
|
||||
command: this.resend,
|
||||
},
|
||||
{
|
||||
label: 'ارسال صورتحساب',
|
||||
icon: 'pi pi-send',
|
||||
neededStatus: 'NOT_SEND',
|
||||
neededStatus: TspProviderResponseStatus.NOT_SEND,
|
||||
command: this.send,
|
||||
},
|
||||
{
|
||||
label: 'استعلام وضعیت',
|
||||
icon: 'pi pi-info',
|
||||
neededStatus: 'FISCAL_QUEUED',
|
||||
neededStatus: TspProviderResponseStatus.FISCAL_QUEUED,
|
||||
command: this.inquiry,
|
||||
},
|
||||
{
|
||||
label: 'دلایل خطا',
|
||||
icon: 'pi pi-question',
|
||||
neededStatus: 'FAILURE',
|
||||
neededStatus: TspProviderResponseStatus.FAILURE,
|
||||
command: this.showErrors,
|
||||
},
|
||||
{
|
||||
label: 'ابطال',
|
||||
icon: 'pi pi-eraser',
|
||||
neededStatus: 'SUCCESS',
|
||||
neededStatus: TspProviderResponseStatus.SUCCESS,
|
||||
command: this.showRevokeConfirmation,
|
||||
},
|
||||
{
|
||||
label: 'اصلاح',
|
||||
icon: 'pi pi-file-edit',
|
||||
neededStatus: 'SUCCESS',
|
||||
neededStatus: TspProviderResponseStatus.SUCCESS,
|
||||
command: this.showCorrection,
|
||||
},
|
||||
{
|
||||
label: 'برگشت از فروش',
|
||||
icon: 'pi pi-cart-minus',
|
||||
neededStatus: 'SUCCESS',
|
||||
neededStatus: TspProviderResponseStatus.SUCCESS,
|
||||
command: this.showBackFromSale,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
equalLengthValidator,
|
||||
fiscalIdValidator,
|
||||
mobileValidator,
|
||||
password,
|
||||
@@ -70,9 +71,13 @@ export const fieldControl = {
|
||||
value,
|
||||
isRequired ? [...required(), usernameValidator()] : [usernameValidator()],
|
||||
],
|
||||
economic_code: (value = '', isRequired = true): ControlConfig => [
|
||||
legal_economic_code: (value = '', isRequired = true): ControlConfig => [
|
||||
value,
|
||||
isRequired ? required() : [],
|
||||
isRequired ? [...required(), equalLengthValidator(11)] : [equalLengthValidator(11)],
|
||||
],
|
||||
individual_economic_code: (value = '', isRequired = true): ControlConfig => [
|
||||
value,
|
||||
isRequired ? [...required(), equalLengthValidator(14)] : [equalLengthValidator(14)],
|
||||
],
|
||||
fiscal_id: (value = '', isRequired = true): ControlConfig => [
|
||||
value,
|
||||
|
||||
Reference in New Issue
Block a user