feat: implement invoice number sequence field and enhance tax provider status handling across components
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<app-key-value label="تاریخ فاکتور" [value]="invoice.invoice_date" type="dateTime" />
|
||||
<app-key-value label="تاریخ ایجاد فاکتور" [value]="invoice.created_at" type="dateTime" />
|
||||
<app-key-value label="وضعیت صدور به سامانهی مودیان">
|
||||
<p-badge value="ارسال نشده" severity="danger" />
|
||||
<catalog-tax-provider-status-tag [status]="invoice.status.value" [translate]="invoice.status.translate" />
|
||||
</app-key-value>
|
||||
<div class="col-span-3">
|
||||
<app-key-value label="توضیحات" [value]="invoice.notes" />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Maybe } from '@/core';
|
||||
import { NativeBridgeService } from '@/core/services';
|
||||
import { CatalogTaxProviderStatusTagComponent } from '@/shared/catalog';
|
||||
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
||||
import {
|
||||
@@ -9,8 +10,15 @@ import {
|
||||
import { PriceMaskDirective } from '@/shared/directives';
|
||||
import { UikitEmptyStateComponent } from '@/uikit';
|
||||
import { getGoodUnitTypeProperties } from '@/utils';
|
||||
import { Component, EventEmitter, inject, Input, Output, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { Badge } from 'primeng/badge';
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
inject,
|
||||
Input,
|
||||
Output,
|
||||
TemplateRef,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import { Divider } from 'primeng/divider';
|
||||
import { TableModule } from 'primeng/table';
|
||||
@@ -24,7 +32,6 @@ export type TConsumerSaleInvoice = 'full' | 'customer' | 'pos';
|
||||
imports: [
|
||||
AppCardComponent,
|
||||
KeyValueComponent,
|
||||
Badge,
|
||||
Divider,
|
||||
ButtonDirective,
|
||||
PageDataListComponent,
|
||||
@@ -32,6 +39,7 @@ export type TConsumerSaleInvoice = 'full' | 'customer' | 'pos';
|
||||
PageLoadingComponent,
|
||||
UikitEmptyStateComponent,
|
||||
PriceMaskDirective,
|
||||
CatalogTaxProviderStatusTagComponent,
|
||||
],
|
||||
})
|
||||
export class ConsumerSaleInvoiceSharedComponent {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import ISummary from '@/core/models/summary';
|
||||
import { TspProviderResponseStatus } from '@/shared/catalog';
|
||||
import { IEnumTranslate } from '@/shared/models/enum_translate.type';
|
||||
|
||||
export interface ISaleInvoiceFullRawResponse {
|
||||
id: string;
|
||||
@@ -13,6 +15,7 @@ export interface ISaleInvoiceFullRawResponse {
|
||||
notes?: string;
|
||||
customer?: Customer;
|
||||
unknown_customer?: UnknownCustomer;
|
||||
status: IEnumTranslate<TspProviderResponseStatus>;
|
||||
}
|
||||
|
||||
export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<field-economic-code [control]="form.controls.economic_code" />
|
||||
<field-fiscal-code [control]="form.controls.fiscal_id" />
|
||||
<field-partner-token [control]="form.controls.partner_token" />
|
||||
<field-invoice-number-sequence [control]="form.controls.invoice_number_sequence" [min]="1" />
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</shared-dialog>
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
PartnerTokenComponent,
|
||||
} from '@/shared/components';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
import { InvoiceNumberSequenceComponent } from '@/shared/components/fields/invoice_number_sequence.component';
|
||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||
import { fieldControl } from '@/shared/constants/fields';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
@@ -22,8 +23,9 @@ import { BusinessActivitiesService } from '../services/main.service';
|
||||
FormFooterActionsComponent,
|
||||
NameComponent,
|
||||
EconomicCodeComponent,
|
||||
FiscalIdComponent,
|
||||
PartnerTokenComponent,
|
||||
InvoiceNumberSequenceComponent,
|
||||
FiscalIdComponent,
|
||||
],
|
||||
})
|
||||
export class ConsumerBusinessActivityFormComponent extends AbstractFormDialog<
|
||||
@@ -38,6 +40,9 @@ export class ConsumerBusinessActivityFormComponent extends AbstractFormDialog<
|
||||
economic_code: fieldControl.economic_code(this.initialValues?.economic_code || ''),
|
||||
fiscal_id: fieldControl.fiscal_id(this.initialValues?.fiscal_id || ''),
|
||||
partner_token: fieldControl.partner_token(this.initialValues?.partner_token || ''),
|
||||
invoice_number_sequence: fieldControl.invoice_number_sequence(
|
||||
this.initialValues?.invoice_number_sequence || 1,
|
||||
),
|
||||
});
|
||||
|
||||
override submitForm(payload: IBusinessActivityRequest) {
|
||||
|
||||
@@ -10,10 +10,13 @@
|
||||
(onRefresh)="refresh()"
|
||||
>
|
||||
</app-page-data-list>
|
||||
<consumer-businessActivity-form
|
||||
[(visible)]="visibleForm"
|
||||
[editMode]="editMode()"
|
||||
[businessId]="selectedItemForEdit()?.id || ''"
|
||||
[initialValues]="selectedItemForEdit() || undefined"
|
||||
(onSubmit)="refresh()"
|
||||
/>
|
||||
|
||||
@if (visibleForm()) {
|
||||
<consumer-businessActivity-form
|
||||
[(visible)]="visibleForm"
|
||||
[editMode]="editMode()"
|
||||
[businessId]="selectedItemForEdit()?.id || ''"
|
||||
[initialValues]="selectedItemForEdit() || undefined"
|
||||
(onSubmit)="refresh()"
|
||||
/>
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface IBusinessActivityRawResponse {
|
||||
partner_token: string;
|
||||
guild: ISummary;
|
||||
created_at: string;
|
||||
invoice_number_sequence: number;
|
||||
license_info: LicenseInfo;
|
||||
}
|
||||
export interface IBusinessActivityResponse extends IBusinessActivityRawResponse {}
|
||||
@@ -17,6 +18,7 @@ export interface IBusinessActivityRequest {
|
||||
fiscal_id: string;
|
||||
partner_token: string;
|
||||
name: string;
|
||||
invoice_number_sequence: number;
|
||||
}
|
||||
|
||||
interface LicenseInfo {
|
||||
|
||||
+1
-5
@@ -1,11 +1,7 @@
|
||||
<p-card class="border border-surface-border p-0! relative overflow-visible">
|
||||
<div class="flex items-center gap-4 justify-between w-full">
|
||||
<span> {{ saleInvoice.invoice_number }} - {{ saleInvoice.code }} </span>
|
||||
<p-tag
|
||||
[severity]="saleInvoice.status.value.toLowerCase() === 'not_send' ? 'warn' : 'success'"
|
||||
size="large"
|
||||
[value]="saleInvoice.status.translate"
|
||||
></p-tag>
|
||||
<catalog-tax-provider-status-tag [status]="saleInvoice.status.value" [translate]="saleInvoice.status.translate" />
|
||||
</div>
|
||||
<hr />
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ToastService } from '@/core/services/toast.service';
|
||||
import { CatalogTaxProviderStatusTagComponent } from '@/shared/catalog/taxProviderStatus';
|
||||
import { KeyValueComponent } from '@/shared/components';
|
||||
import { Component, computed, EventEmitter, inject, Input, Output, signal } from '@angular/core';
|
||||
import { RouterLink } from '@angular/router';
|
||||
@@ -13,7 +14,15 @@ import { PosSaleInvoicesService } from '../services/main.service';
|
||||
@Component({
|
||||
selector: 'pos-saleInvoice-card',
|
||||
templateUrl: './sale-invoice-card.component.html',
|
||||
imports: [Button, KeyValueComponent, Tag, Card, RouterLink, ButtonDirective],
|
||||
imports: [
|
||||
Button,
|
||||
KeyValueComponent,
|
||||
Tag,
|
||||
Card,
|
||||
RouterLink,
|
||||
ButtonDirective,
|
||||
CatalogTaxProviderStatusTagComponent,
|
||||
],
|
||||
})
|
||||
export class SaleInvoiceCardComponent {
|
||||
private readonly service = inject(PosSaleInvoicesService);
|
||||
@@ -62,7 +71,7 @@ export class SaleInvoiceCardComponent {
|
||||
getStatus() {
|
||||
this.gettingStatusLoading.set(true);
|
||||
this.service
|
||||
.refreshFiscalStatus(this.saleInvoice.id)
|
||||
.getInquiry(this.saleInvoice.id)
|
||||
.pipe(finalize(() => this.gettingStatusLoading.set(false)))
|
||||
.subscribe((res) => {
|
||||
this.toastService.info({
|
||||
|
||||
@@ -4,10 +4,10 @@ export const POS_SALE_INVOICES_API_ROUTES = {
|
||||
list: () => baseUrl(),
|
||||
single: (invoiceId: string) => `${baseUrl()}/${invoiceId}`,
|
||||
fiscal: {
|
||||
send: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/send`,
|
||||
send: (invoiceId: string) => `${baseUrl()}/${invoiceId}/send`,
|
||||
retry: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/retry`,
|
||||
status: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/status`,
|
||||
refreshStatus: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/status/refresh`,
|
||||
getInquiry: (invoiceId: string) => `${baseUrl()}/${invoiceId}/inquiry`,
|
||||
attempts: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/attempts`,
|
||||
},
|
||||
};
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ export interface IPosSaleInvoicesSummaryRawResponse {
|
||||
total_amount: string;
|
||||
customer: Customer;
|
||||
fiscal: null;
|
||||
status: IEnumTranslate;
|
||||
status: IEnumTranslate<TspProviderResponseStatus>;
|
||||
}
|
||||
export interface IPosSaleInvoicesSummaryResponse extends IPosSaleInvoicesSummaryRawResponse {}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { POS_SALE_INVOICES_API_ROUTES } from '../constants';
|
||||
import {
|
||||
IPosSaleInvoicesFilterDto,
|
||||
IPosSaleInvoiceFiscalActionResponse,
|
||||
IPosSaleInvoiceFiscalAttemptsResponse,
|
||||
IPosSaleInvoiceFiscalStatusResponse,
|
||||
IPosSaleInvoicesFilterDto,
|
||||
IPosSaleInvoicesSummaryRawResponse,
|
||||
IPosSaleInvoicesSummaryResponse,
|
||||
} from '../models';
|
||||
@@ -19,7 +19,9 @@ export class PosSaleInvoicesService {
|
||||
|
||||
private apiRoutes = POS_SALE_INVOICES_API_ROUTES;
|
||||
|
||||
getAll(query: IPosSaleInvoicesFilterDto = {}): Observable<IPaginatedResponse<IPosSaleInvoicesSummaryResponse>> {
|
||||
getAll(
|
||||
query: IPosSaleInvoicesFilterDto = {},
|
||||
): Observable<IPaginatedResponse<IPosSaleInvoicesSummaryResponse>> {
|
||||
return this.http.get<IPaginatedResponse<IPosSaleInvoicesSummaryRawResponse>>(
|
||||
this.apiRoutes.list(),
|
||||
{ params: query as Record<string, string | number | boolean> },
|
||||
@@ -31,25 +33,35 @@ export class PosSaleInvoicesService {
|
||||
}
|
||||
|
||||
sendFiscal(invoiceId: string): Observable<IPosSaleInvoiceFiscalActionResponse> {
|
||||
return this.http.post<IPosSaleInvoiceFiscalActionResponse>(this.apiRoutes.fiscal.send(invoiceId), {});
|
||||
return this.http.post<IPosSaleInvoiceFiscalActionResponse>(
|
||||
this.apiRoutes.fiscal.send(invoiceId),
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
retryFiscal(invoiceId: string): Observable<IPosSaleInvoiceFiscalActionResponse> {
|
||||
return this.http.post<IPosSaleInvoiceFiscalActionResponse>(this.apiRoutes.fiscal.retry(invoiceId), {});
|
||||
return this.http.post<IPosSaleInvoiceFiscalActionResponse>(
|
||||
this.apiRoutes.fiscal.retry(invoiceId),
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
getFiscalStatus(invoiceId: string): Observable<IPosSaleInvoiceFiscalStatusResponse> {
|
||||
return this.http.get<IPosSaleInvoiceFiscalStatusResponse>(this.apiRoutes.fiscal.status(invoiceId));
|
||||
return this.http.get<IPosSaleInvoiceFiscalStatusResponse>(
|
||||
this.apiRoutes.fiscal.status(invoiceId),
|
||||
);
|
||||
}
|
||||
|
||||
refreshFiscalStatus(invoiceId: string): Observable<IPosSaleInvoiceFiscalStatusResponse> {
|
||||
return this.http.post<IPosSaleInvoiceFiscalStatusResponse>(
|
||||
this.apiRoutes.fiscal.refreshStatus(invoiceId),
|
||||
getInquiry(invoiceId: string): Observable<IPosSaleInvoiceFiscalStatusResponse> {
|
||||
return this.http.get<IPosSaleInvoiceFiscalStatusResponse>(
|
||||
this.apiRoutes.fiscal.getInquiry(invoiceId),
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
getFiscalAttempts(invoiceId: string): Observable<IPosSaleInvoiceFiscalAttemptsResponse> {
|
||||
return this.http.get<IPosSaleInvoiceFiscalAttemptsResponse>(this.apiRoutes.fiscal.attempts(invoiceId));
|
||||
return this.http.get<IPosSaleInvoiceFiscalAttemptsResponse>(
|
||||
this.apiRoutes.fiscal.attempts(invoiceId),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,11 @@ export class AppLayout {
|
||||
this.router.navigateByUrl('super_admin');
|
||||
break;
|
||||
case 'CONSUMER':
|
||||
this.router.navigateByUrl('consumer');
|
||||
if (this.authService.currentAccount()?.role === 'OWNER')
|
||||
this.router.navigateByUrl('consumer');
|
||||
else {
|
||||
this.router.navigateByUrl('pos');
|
||||
}
|
||||
break;
|
||||
case 'PARTNER':
|
||||
this.router.navigateByUrl('partner');
|
||||
|
||||
@@ -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