feat: implement invoice number sequence field and enhance tax provider status handling across components
This commit is contained in:
@@ -38,6 +38,9 @@ export abstract class AbstractForm<
|
||||
|
||||
ngOnInit() {
|
||||
this.form.patchValue(this.initialValues ?? {});
|
||||
// Object.entries(this.form.controls).forEach(([key, control]) => {
|
||||
// console.log(key, control);
|
||||
// });
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
|
||||
@@ -19,5 +19,5 @@ export const ENUMS_API_ROUTES = {
|
||||
unitType: `${baseUrl}/unit_type`,
|
||||
goodPricingModel: `${baseUrl}/good_pricing_model`,
|
||||
consumerRole: `${baseUrl}/consumer_role`,
|
||||
fiscalResponseStatus: `${baseUrl}/fiscal_response_status`,
|
||||
fiscalResponseStatus: `${baseUrl}/tsp_provider_response_status`,
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './devices';
|
||||
export * from './guild';
|
||||
export * from './providers';
|
||||
export * from './taxProviderStatus';
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './tax-provider-status-tag.component';
|
||||
export * from './type';
|
||||
@@ -0,0 +1 @@
|
||||
<p-tag [severity]="severity" size="large" [value]="translate || label"></p-tag>
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Tag } from 'primeng/tag';
|
||||
import { TspProviderResponseStatus } from './type';
|
||||
|
||||
@Component({
|
||||
selector: 'catalog-tax-provider-status-tag',
|
||||
templateUrl: './tax-provider-status-tag.component.html',
|
||||
imports: [Tag],
|
||||
})
|
||||
export class CatalogTaxProviderStatusTagComponent {
|
||||
@Input({ required: true }) status!: TspProviderResponseStatus;
|
||||
@Input() translate!: string;
|
||||
|
||||
get severity() {
|
||||
switch (this.status) {
|
||||
case 'SUCCESS':
|
||||
return 'success';
|
||||
case 'FAILURE':
|
||||
return 'danger';
|
||||
case 'NOT_SEND':
|
||||
return 'warn';
|
||||
case 'QUEUED':
|
||||
return 'info';
|
||||
default:
|
||||
return 'secondary';
|
||||
}
|
||||
}
|
||||
|
||||
get label() {
|
||||
switch (this.status) {
|
||||
case 'SUCCESS':
|
||||
return 'موفق';
|
||||
case 'FAILURE':
|
||||
return 'ناموفق';
|
||||
case 'NOT_SEND':
|
||||
return 'ارسال نشده';
|
||||
case 'QUEUED':
|
||||
return 'در صف ارسال';
|
||||
default:
|
||||
return 'نامشخص';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export const TspProviderResponseStatus = {
|
||||
SUCCESS: 'SUCCESS',
|
||||
FAILURE: 'FAILURE',
|
||||
NOT_SEND: 'NOT_SEND',
|
||||
QUEUED: 'QUEUED',
|
||||
} as const;
|
||||
|
||||
export type TspProviderResponseStatus =
|
||||
(typeof TspProviderResponseStatus)[keyof typeof TspProviderResponseStatus];
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { InputComponent } from '../input/input.component';
|
||||
|
||||
@Component({
|
||||
selector: 'field-invoice-number-sequence',
|
||||
template: `<app-input
|
||||
label="شروع شماره فاکتور"
|
||||
[control]="control"
|
||||
[name]="name"
|
||||
type="number"
|
||||
[min]="min"
|
||||
/>`,
|
||||
imports: [ReactiveFormsModule, InputComponent],
|
||||
})
|
||||
export class InvoiceNumberSequenceComponent {
|
||||
@Input({ required: true }) control = new FormControl<number>(1);
|
||||
@Input() name = 'invoice_number_sequence';
|
||||
@Input() min? = 1;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { nationalIdValidator } from '@/core/validators/national-id.validator';
|
||||
import { ValidatorFn, Validators } from '@angular/forms';
|
||||
|
||||
const required = () => [Validators.required] as ValidatorFn[];
|
||||
type ControlConfig = [string, ValidatorFn[]];
|
||||
type ControlConfig = [any, ValidatorFn[]];
|
||||
|
||||
export const fieldControl = {
|
||||
name: (value = '', isRequired = true): ControlConfig => [value, isRequired ? required() : []],
|
||||
@@ -78,6 +78,10 @@ export const fieldControl = {
|
||||
value,
|
||||
isRequired ? required() : [],
|
||||
],
|
||||
invoice_number_sequence: (value = 1, isRequired = true): ControlConfig => [
|
||||
value,
|
||||
isRequired ? [Validators.required, Validators.min(1)] : [Validators.min(1)],
|
||||
],
|
||||
guild_id: (value = '', isRequired = true): ControlConfig => [value, isRequired ? required() : []],
|
||||
license_starts_at: (value = '', isRequired = true): ControlConfig => [
|
||||
value,
|
||||
|
||||
Reference in New Issue
Block a user