Compare commits
4 Commits
eb671d5949
...
90c51edad4
| Author | SHA1 | Date | |
|---|---|---|---|
| 90c51edad4 | |||
| d678b6c699 | |||
| 550db47b88 | |||
| 9fdd5e451c |
@@ -1,17 +1,17 @@
|
|||||||
import { PwaInstallService } from '@/core/services/pwa-install.service';
|
import { PwaInstallService } from '@/core/services/pwa-install.service';
|
||||||
|
import { ConfirmationDialogComponent } from '@/shared/components/confirmationDialog/confirmation-dialog.component';
|
||||||
import { Component, HostListener } from '@angular/core';
|
import { Component, HostListener } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { ConfirmDialog } from 'primeng/confirmdialog';
|
|
||||||
import { ToastModule } from 'primeng/toast';
|
import { ToastModule } from 'primeng/toast';
|
||||||
import { brandingConfig } from './app/branding/branding.config';
|
import { brandingConfig } from './app/branding/branding.config';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [RouterModule, ToastModule, ConfirmDialog],
|
imports: [RouterModule, ToastModule, ConfirmationDialogComponent],
|
||||||
template: `
|
template: `
|
||||||
<p-toast [position]="toastPosition" [baseZIndex]="3000" />
|
<p-toast [position]="toastPosition" [baseZIndex]="3000" />
|
||||||
<p-confirmDialog />
|
<app-shared-confirmation-dialog />
|
||||||
<router-outlet />
|
<router-outlet />
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,9 +6,8 @@
|
|||||||
[loading]="loading()"
|
[loading]="loading()"
|
||||||
[perPage]="responseMetaData()?.perPage"
|
[perPage]="responseMetaData()?.perPage"
|
||||||
[currentPage]="responseMetaData()?.page"
|
[currentPage]="responseMetaData()?.page"
|
||||||
[totalRecords]="responseMetaData()?.totalRecords || items().length"
|
[totalPages]="responseMetaData()?.totalPages || 1"
|
||||||
[showDetails]="true"
|
[showDetails]="true"
|
||||||
(onDetails)="toSinglePage($event)"
|
(onDetails)="toSinglePage($event)"
|
||||||
(onRefresh)="refresh()"
|
(onRefresh)="refresh()"
|
||||||
(onChangePage)="changePage($event)"
|
(onChangePage)="changePage($event)" />
|
||||||
/>
|
|
||||||
|
|||||||
@@ -3,13 +3,12 @@
|
|||||||
[columns]="columns"
|
[columns]="columns"
|
||||||
emptyPlaceholderTitle="تا به حال لایسنسی نفروختهاید."
|
emptyPlaceholderTitle="تا به حال لایسنسی نفروختهاید."
|
||||||
[currentPage]="responseMetaData()?.page"
|
[currentPage]="responseMetaData()?.page"
|
||||||
[totalRecords]="responseMetaData()?.totalRecords || items().length"
|
[totalPages]="responseMetaData()?.totalPages"
|
||||||
[perPage]="responseMetaData()?.perPage"
|
[perPage]="responseMetaData()?.perPage"
|
||||||
[items]="items()"
|
[items]="items()"
|
||||||
[loading]="loading()"
|
[loading]="loading()"
|
||||||
(onRefresh)="refresh()"
|
(onRefresh)="refresh()"
|
||||||
(onChangePage)="changePage($event)"
|
(onChangePage)="changePage($event)">
|
||||||
>
|
|
||||||
<ng-template #filter>
|
<ng-template #filter>
|
||||||
<partner-licenses-filter (onSearch)="refresh()" />
|
<partner-licenses-filter (onSearch)="refresh()" />
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
[showCloseIcon]="true"
|
[showCloseIcon]="true"
|
||||||
header="فیلتر فاکتورها"
|
header="فیلتر فاکتورها"
|
||||||
styleClass="w-full md:w-[28rem]"
|
styleClass="w-full md:w-[28rem]"
|
||||||
(visibleChange)="visibleChange.emit($event)"
|
(visibleChange)="visibleChange.emit($event)">
|
||||||
>
|
<div class="flex h-full flex-col overflow-y-auto">
|
||||||
<form class="flex flex-col gap-4 h-full overflow-y-auto" [formGroup]="form" (ngSubmit)="submit()">
|
<hr />
|
||||||
<app-input label="کد فاکتور" [control]="form.controls.code" name="code" />
|
<form class="grow py-4" [formGroup]="form" (ngSubmit)="submit()">
|
||||||
|
<app-input label="شماره صورتحساب" [control]="form.controls.invoice_number" name="invoice_number" />
|
||||||
|
|
||||||
<app-enum-select type="fiscalResponseStatus" [control]="form.controls.status" />
|
<app-enum-select type="fiscalResponseStatus" [control]="form.controls.status" />
|
||||||
|
|
||||||
@@ -19,8 +20,7 @@
|
|||||||
label="کد ملی"
|
label="کد ملی"
|
||||||
[control]="form.controls.customer_national_id"
|
[control]="form.controls.customer_national_id"
|
||||||
name="customer_national_id"
|
name="customer_national_id"
|
||||||
type="nationalId"
|
type="nationalId" />
|
||||||
/>
|
|
||||||
<app-input label="شناسه اقتصادی" [control]="form.controls.customer_economic_code" name="customer_economic_code" />
|
<app-input label="شناسه اقتصادی" [control]="form.controls.customer_economic_code" name="customer_economic_code" />
|
||||||
|
|
||||||
<!-- <div class="grid grid-cols-2 gap-2">
|
<!-- <div class="grid grid-cols-2 gap-2">
|
||||||
@@ -37,10 +37,13 @@
|
|||||||
<app-input label="از مبلغ" [control]="form.controls.total_amount_from" name="total_amount_from" type="price" />
|
<app-input label="از مبلغ" [control]="form.controls.total_amount_from" name="total_amount_from" type="price" />
|
||||||
<app-input label="تا مبلغ" [control]="form.controls.total_amount_to" name="total_amount_to" type="price" />
|
<app-input label="تا مبلغ" [control]="form.controls.total_amount_to" name="total_amount_to" type="price" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-auto grid grid-cols-2 gap-2 pt-4">
|
|
||||||
<button pButton type="button" outlined label="حذف" (click)="clear()"></button>
|
|
||||||
<button pButton type="submit" label="اعمال"></button>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
|
<div class="bg-surface-card sticky bottom-0 mt-auto shrink-0">
|
||||||
|
<hr />
|
||||||
|
<div class="grid grid-cols-2 gap-2 pt-2">
|
||||||
|
<button pButton type="button" outlined label="حذف" (click)="clear()"></button>
|
||||||
|
<button pButton type="button" label="اعمال" (click)="submit()"></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</p-drawer>
|
</p-drawer>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { Maybe } from '@/core';
|
||||||
import { EnumSelectComponent } from '@/shared/apiEnum/select.component';
|
import { EnumSelectComponent } from '@/shared/apiEnum/select.component';
|
||||||
|
import { TspProviderResponseStatus } from '@/shared/catalog';
|
||||||
import { InputComponent } from '@/shared/components';
|
import { InputComponent } from '@/shared/components';
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
@@ -45,12 +47,12 @@ export class PosSaleInvoicesFilterDrawerComponent implements OnChanges {
|
|||||||
invoice_date_to: this.fb.control<string>(''),
|
invoice_date_to: this.fb.control<string>(''),
|
||||||
created_at_from: this.fb.control<string>(''),
|
created_at_from: this.fb.control<string>(''),
|
||||||
created_at_to: this.fb.control<string>(''),
|
created_at_to: this.fb.control<string>(''),
|
||||||
code: this.fb.control<string>(''),
|
invoice_number: this.fb.control<Maybe<number>>(null),
|
||||||
customer_name: this.fb.control<string>(''),
|
customer_name: this.fb.control<string>(''),
|
||||||
customer_mobile: this.fb.control<string>(''),
|
customer_mobile: this.fb.control<string>(''),
|
||||||
customer_national_id: this.fb.control<string>(''),
|
customer_national_id: this.fb.control<string>(''),
|
||||||
customer_economic_code: this.fb.control<string>(''),
|
customer_economic_code: this.fb.control<string>(''),
|
||||||
status: this.fb.control<'NOT_SEND' | 'SUCCESS' | 'FAILURE' | 'QUEUED' | null>(null),
|
status: this.fb.control<TspProviderResponseStatus>('NOT_SEND'),
|
||||||
total_amount_from: this.fb.control<number | null>(null),
|
total_amount_from: this.fb.control<number | null>(null),
|
||||||
total_amount_to: this.fb.control<number | null>(null),
|
total_amount_to: this.fb.control<number | null>(null),
|
||||||
});
|
});
|
||||||
@@ -65,7 +67,7 @@ export class PosSaleInvoicesFilterDrawerComponent implements OnChanges {
|
|||||||
invoice_date_to: this.value.invoice_date_to ?? '',
|
invoice_date_to: this.value.invoice_date_to ?? '',
|
||||||
created_at_from: this.value.created_at_from ?? '',
|
created_at_from: this.value.created_at_from ?? '',
|
||||||
created_at_to: this.value.created_at_to ?? '',
|
created_at_to: this.value.created_at_to ?? '',
|
||||||
code: this.value.code ?? '',
|
invoice_number: this.value.invoice_number ?? null,
|
||||||
customer_name: this.value.customer_name ?? '',
|
customer_name: this.value.customer_name ?? '',
|
||||||
customer_mobile: this.value.customer_mobile ?? '',
|
customer_mobile: this.value.customer_mobile ?? '',
|
||||||
customer_national_id: this.value.customer_national_id ?? '',
|
customer_national_id: this.value.customer_national_id ?? '',
|
||||||
@@ -91,7 +93,7 @@ export class PosSaleInvoicesFilterDrawerComponent implements OnChanges {
|
|||||||
invoice_date_to: '',
|
invoice_date_to: '',
|
||||||
created_at_from: '',
|
created_at_from: '',
|
||||||
created_at_to: '',
|
created_at_to: '',
|
||||||
code: '',
|
invoice_number: null,
|
||||||
customer_name: '',
|
customer_name: '',
|
||||||
customer_mobile: '',
|
customer_mobile: '',
|
||||||
customer_national_id: '',
|
customer_national_id: '',
|
||||||
@@ -113,7 +115,7 @@ export class PosSaleInvoicesFilterDrawerComponent implements OnChanges {
|
|||||||
invoice_date_to: raw.invoice_date_to || undefined,
|
invoice_date_to: raw.invoice_date_to || undefined,
|
||||||
created_at_from: raw.created_at_from || undefined,
|
created_at_from: raw.created_at_from || undefined,
|
||||||
created_at_to: raw.created_at_to || undefined,
|
created_at_to: raw.created_at_to || undefined,
|
||||||
code: raw.code?.trim() || undefined,
|
invoice_number: raw.invoice_number,
|
||||||
customer_name: raw.customer_name?.trim() || undefined,
|
customer_name: raw.customer_name?.trim() || undefined,
|
||||||
customer_mobile: raw.customer_mobile?.trim() || undefined,
|
customer_mobile: raw.customer_mobile?.trim() || undefined,
|
||||||
customer_national_id: raw.customer_national_id?.trim() || undefined,
|
customer_national_id: raw.customer_national_id?.trim() || undefined,
|
||||||
|
|||||||
@@ -7,21 +7,21 @@
|
|||||||
type="button"
|
type="button"
|
||||||
size="small"
|
size="small"
|
||||||
[outlined]="!activeFilters().length"
|
[outlined]="!activeFilters().length"
|
||||||
(click)="toggleFilterVisible()"
|
(click)="toggleFilterVisible()"></p-button>
|
||||||
></p-button>
|
|
||||||
<button pButton icon="pi pi-refresh" type="button" size="small" outlined (click)="refresh()"></button>
|
<button pButton icon="pi pi-refresh" type="button" size="small" outlined (click)="refresh()"></button>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</app-inner-pages-header>
|
</app-inner-pages-header>
|
||||||
@if (activeFilters().length) {
|
@if (activeFilters().length) {
|
||||||
<div class="px-4 pb-2 flex flex-wrap gap-2">
|
<div class="flex flex-wrap gap-2 px-4 pb-2">
|
||||||
@for (filter of activeFilters(); track filter.key) {
|
@for (filter of activeFilters(); track filter.key) {
|
||||||
|
@if (filter.key !== 'page') {
|
||||||
<p-chip
|
<p-chip
|
||||||
removable
|
removable
|
||||||
[label]="filter.label + ': ' + filter.value"
|
[label]="filter.label + ': ' + filter.value"
|
||||||
class="border border-surface-border"
|
class="border-surface-border border"
|
||||||
(onRemove)="removeFilter(filter.key)"
|
(onRemove)="removeFilter(filter.key)" />
|
||||||
/>
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
}
|
}
|
||||||
} @else if (!items() || items().length === 0) {
|
} @else if (!items() || items().length === 0) {
|
||||||
<div class="col-span-1">
|
<div class="col-span-1">
|
||||||
<p class="text-center text-muted-color">فاکتوری یافت نشد.</p>
|
<p class="text-muted-color text-center">فاکتوری یافت نشد.</p>
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
@for (item of items(); track item.id) {
|
@for (item of items(); track item.id) {
|
||||||
@@ -42,10 +42,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="">
|
||||||
|
<app-paginator
|
||||||
|
[perPage]="10"
|
||||||
|
[currentPage]="paginationMeta()?.page || 1"
|
||||||
|
[totalPages]="paginationMeta()?.totalPages || 1"
|
||||||
|
(onChange)="onChangePage($event)" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<pos-sale-invoices-filter-drawer
|
<pos-sale-invoices-filter-drawer
|
||||||
[visible]="filterVisible()"
|
[visible]="filterVisible()"
|
||||||
[value]="filters()"
|
[value]="filters()"
|
||||||
(visibleChange)="filterVisible.set($event)"
|
(visibleChange)="filterVisible.set($event)"
|
||||||
(apply)="onFilterApply($event)"
|
(apply)="onFilterApply($event)" />
|
||||||
/>
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import { Maybe } from '@/core';
|
||||||
|
import { IResponseMetadata } from '@/core/models/service.model';
|
||||||
import { POS_ROUTES } from '@/domains/pos/routes';
|
import { POS_ROUTES } from '@/domains/pos/routes';
|
||||||
|
import { TspProviderResponseStatus } from '@/shared/catalog';
|
||||||
|
import taxProviderStatusTranslatorUtil from '@/shared/catalog/taxProviderStatus/tax-provider-status-translator.util';
|
||||||
import { InnerPagesHeaderComponent } from '@/shared/components/innerPagesHeader/inner-pages-header.component';
|
import { InnerPagesHeaderComponent } from '@/shared/components/innerPagesHeader/inner-pages-header.component';
|
||||||
|
import { PaginatorComponent } from '@/uikit';
|
||||||
import { gregorianToJalali } from '@/utils';
|
import { gregorianToJalali } from '@/utils';
|
||||||
import { Component, computed, inject, signal } from '@angular/core';
|
import { Component, computed, inject, signal } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
@@ -28,6 +33,7 @@ import { SaleInvoiceCardComponent } from './sale-invoice-card.component';
|
|||||||
Button,
|
Button,
|
||||||
Chip,
|
Chip,
|
||||||
SaleInvoiceCardComponent,
|
SaleInvoiceCardComponent,
|
||||||
|
PaginatorComponent,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class PosSaleInvoiceListComponent {
|
export class PosSaleInvoiceListComponent {
|
||||||
@@ -37,6 +43,7 @@ export class PosSaleInvoiceListComponent {
|
|||||||
|
|
||||||
loading = signal(true);
|
loading = signal(true);
|
||||||
items = signal<IPosSaleInvoicesSummaryResponse[]>([]);
|
items = signal<IPosSaleInvoicesSummaryResponse[]>([]);
|
||||||
|
paginationMeta = signal<Maybe<IResponseMetadata>>(null);
|
||||||
filterVisible = signal(false);
|
filterVisible = signal(false);
|
||||||
filters = signal<IPosSaleInvoicesFilterDto>({});
|
filters = signal<IPosSaleInvoicesFilterDto>({});
|
||||||
activeFilters = computed(() => {
|
activeFilters = computed(() => {
|
||||||
@@ -45,7 +52,7 @@ export class PosSaleInvoiceListComponent {
|
|||||||
invoice_date_to: 'تا تاریخ فاکتور',
|
invoice_date_to: 'تا تاریخ فاکتور',
|
||||||
created_at_from: 'از تاریخ ایجاد',
|
created_at_from: 'از تاریخ ایجاد',
|
||||||
created_at_to: 'تا تاریخ ایجاد',
|
created_at_to: 'تا تاریخ ایجاد',
|
||||||
code: 'کد',
|
invoice_number: 'شماره صورتحساب',
|
||||||
customer_name: 'نام مشتری',
|
customer_name: 'نام مشتری',
|
||||||
customer_mobile: 'موبایل',
|
customer_mobile: 'موبایل',
|
||||||
customer_national_id: 'کد ملی',
|
customer_national_id: 'کد ملی',
|
||||||
@@ -61,16 +68,7 @@ export class PosSaleInvoiceListComponent {
|
|||||||
const typedKey = key as keyof IPosSaleInvoicesFilterDto;
|
const typedKey = key as keyof IPosSaleInvoicesFilterDto;
|
||||||
let formattedValue = '';
|
let formattedValue = '';
|
||||||
if (typedKey === 'status') {
|
if (typedKey === 'status') {
|
||||||
formattedValue =
|
formattedValue = taxProviderStatusTranslatorUtil(value as TspProviderResponseStatus);
|
||||||
value === 'NOT_SEND'
|
|
||||||
? 'ارسال نشده'
|
|
||||||
: value === 'SUCCESS'
|
|
||||||
? 'موفق'
|
|
||||||
: value === 'FAILURE'
|
|
||||||
? 'ناموفق'
|
|
||||||
: value === 'QUEUED'
|
|
||||||
? 'در انتظار ارسال'
|
|
||||||
: String(value);
|
|
||||||
} else if (
|
} else if (
|
||||||
key === 'invoice_date_from' ||
|
key === 'invoice_date_from' ||
|
||||||
key === 'invoice_date_to' ||
|
key === 'invoice_date_to' ||
|
||||||
@@ -92,12 +90,17 @@ export class PosSaleInvoiceListComponent {
|
|||||||
this.getData();
|
this.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChangePage(page: number) {
|
||||||
|
this.onFilterApply({ ...this.filters(), page });
|
||||||
|
}
|
||||||
|
|
||||||
getData() {
|
getData() {
|
||||||
this.loading.set(true);
|
this.loading.set(true);
|
||||||
this.service
|
this.service
|
||||||
.getAll(this.filters())
|
.getAll(this.filters())
|
||||||
.pipe(finalize(() => this.loading.set(false)))
|
.pipe(finalize(() => this.loading.set(false)))
|
||||||
.subscribe((res) => {
|
.subscribe((res) => {
|
||||||
|
this.paginationMeta.set(res.meta);
|
||||||
this.items.set(res.data ?? []);
|
this.items.set(res.data ?? []);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -134,7 +137,7 @@ export class PosSaleInvoiceListComponent {
|
|||||||
'invoice_date_to',
|
'invoice_date_to',
|
||||||
'created_at_from',
|
'created_at_from',
|
||||||
'created_at_to',
|
'created_at_to',
|
||||||
'code',
|
'invoice_number',
|
||||||
'customer_name',
|
'customer_name',
|
||||||
'customer_mobile',
|
'customer_mobile',
|
||||||
'customer_national_id',
|
'customer_national_id',
|
||||||
@@ -142,6 +145,7 @@ export class PosSaleInvoiceListComponent {
|
|||||||
'status',
|
'status',
|
||||||
'total_amount_from',
|
'total_amount_from',
|
||||||
'total_amount_to',
|
'total_amount_to',
|
||||||
|
'page',
|
||||||
];
|
];
|
||||||
|
|
||||||
const parsed = keys.reduce<IPosSaleInvoicesFilterDto>((acc, key) => {
|
const parsed = keys.reduce<IPosSaleInvoicesFilterDto>((acc, key) => {
|
||||||
|
|||||||
+14
-16
@@ -1,5 +1,5 @@
|
|||||||
<p-card class="border border-surface-border p-0! relative overflow-visible">
|
<p-card class="border-surface-border relative overflow-visible border p-0!">
|
||||||
<div class="flex items-center gap-4 justify-between w-full">
|
<div class="flex w-full items-center justify-between gap-4">
|
||||||
<span> {{ saleInvoice.invoice_number }} - {{ saleInvoice.code }} </span>
|
<span> {{ saleInvoice.invoice_number }} - {{ saleInvoice.code }} </span>
|
||||||
<catalog-tax-provider-status-tag [status]="saleInvoice.status.value" [translate]="saleInvoice.status.translate" />
|
<catalog-tax-provider-status-tag [status]="saleInvoice.status.value" [translate]="saleInvoice.status.translate" />
|
||||||
</div>
|
</div>
|
||||||
@@ -9,48 +9,46 @@
|
|||||||
{{ preparedInvoiceType() }}
|
{{ preparedInvoiceType() }}
|
||||||
</app-key-value>
|
</app-key-value>
|
||||||
<app-key-value alignment="end" label="مبلغ کل" [value]="saleInvoice.total_amount" type="price" />
|
<app-key-value alignment="end" label="مبلغ کل" [value]="saleInvoice.total_amount" type="price" />
|
||||||
|
<app-key-value alignment="end" label="نوع فاکتور">
|
||||||
|
<catalog-invoice-type-tag [status]="saleInvoice.type.value" />
|
||||||
|
</app-key-value>
|
||||||
<app-key-value alignment="end" label="تاریخ فاکتور" [value]="saleInvoice.created_at" type="dateTime" />
|
<app-key-value alignment="end" label="تاریخ فاکتور" [value]="saleInvoice.created_at" type="dateTime" />
|
||||||
<app-key-value alignment="end" label="تاریخ ایجاد" [value]="saleInvoice.created_at" type="dateTime" />
|
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<div class="flex items-center justify-center gap-4">
|
<div class="flex items-center justify-center gap-4">
|
||||||
@if (["success", "failure"].includes(saleInvoice.status.value.toLowerCase())) {
|
@if (['success'].includes(saleInvoice.status.value.toLowerCase())) {
|
||||||
<p-button
|
<p-button
|
||||||
label="ابطال"
|
label="ابطال"
|
||||||
type="button"
|
type="button"
|
||||||
severity="danger"
|
severity="danger"
|
||||||
(click)="revokeInvoice()"
|
(click)="revokeInvoice()"
|
||||||
[loading]="revokingInvoiceLoading()"
|
[loading]="revokingInvoiceLoading()"
|
||||||
[disabled]="onAction()"
|
[disabled]="onAction()"></p-button>
|
||||||
></p-button>
|
|
||||||
}
|
}
|
||||||
@if (saleInvoice.status.value.toLowerCase() === "not_send") {
|
@if (saleInvoice.status.value.toLowerCase() === 'not_send') {
|
||||||
<p-button
|
<p-button
|
||||||
label="ارسال فاکتور"
|
label="ارسال فاکتور"
|
||||||
type="button"
|
type="button"
|
||||||
(click)="sendInvoice()"
|
(click)="sendInvoice()"
|
||||||
[loading]="sendingLoading()"
|
[loading]="sendingLoading()"
|
||||||
[disabled]="onAction()"
|
[disabled]="onAction()"></p-button>
|
||||||
></p-button>
|
|
||||||
}
|
}
|
||||||
@if (saleInvoice.status.value.toLowerCase() === "queued") {
|
@if (['queued', 'fiscal_queued'].includes(saleInvoice.status.value.toLowerCase())) {
|
||||||
<p-button
|
<p-button
|
||||||
label="استعلام وضعیت ارسال"
|
label="استعلام وضعیت"
|
||||||
type="button"
|
type="button"
|
||||||
severity="info"
|
severity="info"
|
||||||
(click)="getStatus()"
|
(click)="getStatus()"
|
||||||
[loading]="gettingStatusLoading()"
|
[loading]="gettingStatusLoading()"
|
||||||
[disabled]="onAction()"
|
[disabled]="onAction()"></p-button>
|
||||||
></p-button>
|
|
||||||
}
|
}
|
||||||
@if (saleInvoice.status.value.toLowerCase() === "failure") {
|
@if (saleInvoice.status.value.toLowerCase() === 'send_failure') {
|
||||||
<p-button
|
<p-button
|
||||||
label="ارسال مجدد"
|
label="ارسال مجدد"
|
||||||
type="button"
|
type="button"
|
||||||
(click)="resendInvoice()"
|
(click)="resendInvoice()"
|
||||||
[loading]="resendingLoading()"
|
[loading]="resendingLoading()"
|
||||||
[disabled]="onAction()"
|
[disabled]="onAction()"></p-button>
|
||||||
></p-button>
|
|
||||||
}
|
}
|
||||||
<a [routerLink]="singlePageRoute()" pButton type="button" (click)="viewDetails()" outlined>مشاهده جزییات</a>
|
<a [routerLink]="singlePageRoute()" pButton type="button" (click)="viewDetails()" outlined>مشاهده جزییات</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { ToastService } from '@/core/services/toast.service';
|
import { ToastService } from '@/core/services/toast.service';
|
||||||
|
import { CatalogInvoiceTypeTagComponent } from '@/shared/catalog';
|
||||||
import { CatalogTaxProviderStatusTagComponent } from '@/shared/catalog/taxProviderStatus';
|
import { CatalogTaxProviderStatusTagComponent } from '@/shared/catalog/taxProviderStatus';
|
||||||
|
import taxProviderStatusTranslatorUtil from '@/shared/catalog/taxProviderStatus/tax-provider-status-translator.util';
|
||||||
import { KeyValueComponent } from '@/shared/components';
|
import { KeyValueComponent } from '@/shared/components';
|
||||||
import { Component, computed, EventEmitter, inject, Input, Output, signal } from '@angular/core';
|
import { Component, computed, EventEmitter, inject, Input, Output, signal } from '@angular/core';
|
||||||
import { RouterLink } from '@angular/router';
|
import { RouterLink } from '@angular/router';
|
||||||
@@ -20,6 +22,7 @@ import { PosSaleInvoicesService } from '../services/main.service';
|
|||||||
RouterLink,
|
RouterLink,
|
||||||
ButtonDirective,
|
ButtonDirective,
|
||||||
CatalogTaxProviderStatusTagComponent,
|
CatalogTaxProviderStatusTagComponent,
|
||||||
|
CatalogInvoiceTypeTagComponent,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class SaleInvoiceCardComponent {
|
export class SaleInvoiceCardComponent {
|
||||||
@@ -39,11 +42,11 @@ export class SaleInvoiceCardComponent {
|
|||||||
this.sendingLoading() ||
|
this.sendingLoading() ||
|
||||||
this.gettingStatusLoading() ||
|
this.gettingStatusLoading() ||
|
||||||
this.resendingLoading() ||
|
this.resendingLoading() ||
|
||||||
this.revokingInvoiceLoading(),
|
this.revokingInvoiceLoading()
|
||||||
);
|
);
|
||||||
|
|
||||||
singlePageRoute = computed(() =>
|
singlePageRoute = computed(() =>
|
||||||
posSaleInvoicesNamedRoutes.saleInvoice.meta.pagePath!(this.saleInvoice?.id),
|
posSaleInvoicesNamedRoutes.saleInvoice.meta.pagePath!(this.saleInvoice?.id)
|
||||||
);
|
);
|
||||||
preparedInvoiceType = computed(() => {
|
preparedInvoiceType = computed(() => {
|
||||||
if (!this.saleInvoice) return '';
|
if (!this.saleInvoice) return '';
|
||||||
@@ -69,14 +72,14 @@ export class SaleInvoiceCardComponent {
|
|||||||
.sendToTsp(this.saleInvoice.id)
|
.sendToTsp(this.saleInvoice.id)
|
||||||
.pipe(finalize(() => this.sendingLoading.set(false)))
|
.pipe(finalize(() => this.sendingLoading.set(false)))
|
||||||
.subscribe((res) => {
|
.subscribe((res) => {
|
||||||
if (res.status === 'FAILURE') {
|
if (res.status === 'SEND_FAILURE') {
|
||||||
this.toastService.error({
|
this.toastService.error({
|
||||||
text: res.message || 'خطا در ارسال فاکتور رخ داده است.',
|
text: res.message || 'خطا در ارسال فاکتور رخ داده است.',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.toastService.success({ text: 'ارسال فاکتور با موفقیت انجام شد.' });
|
this.toastService.success({ text: 'ارسال فاکتور با موفقیت انجام شد.' });
|
||||||
}
|
}
|
||||||
this.toastService.success({ text: 'ارسال فاکتور با موفقیت انجام شد.' });
|
// this.toastService.success({ text: 'ارسال فاکتور با موفقیت انجام شد.' });
|
||||||
this.refreshRequested.emit();
|
this.refreshRequested.emit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -87,6 +90,9 @@ export class SaleInvoiceCardComponent {
|
|||||||
.getInquiry(this.saleInvoice.id)
|
.getInquiry(this.saleInvoice.id)
|
||||||
.pipe(finalize(() => this.gettingStatusLoading.set(false)))
|
.pipe(finalize(() => this.gettingStatusLoading.set(false)))
|
||||||
.subscribe((res) => {
|
.subscribe((res) => {
|
||||||
|
this.toastService.info({
|
||||||
|
text: `وضعیت فعلی فاکتور شمارهی ${this.saleInvoice.invoice_number}، ${taxProviderStatusTranslatorUtil(res.status)} میباشد.`,
|
||||||
|
});
|
||||||
this.refreshRequested.emit();
|
this.refreshRequested.emit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { Maybe } from '@/core';
|
||||||
|
import { TspProviderResponseStatus } from '@/shared/catalog';
|
||||||
|
|
||||||
export interface IPosSaleInvoicesFilterDto {
|
export interface IPosSaleInvoicesFilterDto {
|
||||||
page?: number | null;
|
page?: number | null;
|
||||||
perPage?: number | null;
|
perPage?: number | null;
|
||||||
@@ -5,12 +8,12 @@ export interface IPosSaleInvoicesFilterDto {
|
|||||||
invoice_date_to?: string;
|
invoice_date_to?: string;
|
||||||
created_at_from?: string;
|
created_at_from?: string;
|
||||||
created_at_to?: string;
|
created_at_to?: string;
|
||||||
code?: string;
|
invoice_number?: Maybe<number>;
|
||||||
customer_name?: string;
|
customer_name?: string;
|
||||||
customer_mobile?: string;
|
customer_mobile?: string;
|
||||||
customer_national_id?: string;
|
customer_national_id?: string;
|
||||||
customer_economic_code?: string;
|
customer_economic_code?: string;
|
||||||
status?: 'NOT_SEND' | 'SUCCESS' | 'FAILURE' | 'QUEUED';
|
status?: TspProviderResponseStatus;
|
||||||
total_amount?: number | null;
|
total_amount?: number | null;
|
||||||
total_amount_from?: number | null;
|
total_amount_from?: number | null;
|
||||||
total_amount_to?: number | null;
|
total_amount_to?: number | null;
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
|
import { TspProviderResponseStatus } from '@/shared/catalog';
|
||||||
|
|
||||||
export interface IPosSaleInvoiceFiscalActionResponse {
|
export interface IPosSaleInvoiceFiscalActionResponse {
|
||||||
message?: string;
|
message?: string;
|
||||||
status?: string;
|
status: TspProviderResponseStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPosSaleInvoiceFiscalStatusResponse {
|
export interface IPosSaleInvoiceFiscalStatusResponse {
|
||||||
status?: string;
|
status: TspProviderResponseStatus;
|
||||||
tracking_id?: string;
|
tracking_id?: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
|
|||||||
+18
-18
@@ -1,22 +1,8 @@
|
|||||||
|
import { Maybe } from '@/core';
|
||||||
import ISummary from '@/core/models/summary';
|
import ISummary from '@/core/models/summary';
|
||||||
import { TspProviderResponseStatus } from '@/shared/catalog';
|
import { InvoiceTypes, TspProviderResponseStatus } from '@/shared/catalog';
|
||||||
import { IEnumTranslate } from '@/shared/models/enum_translate.type';
|
import { IEnumTranslate } from '@/shared/models/enum_translate.type';
|
||||||
|
|
||||||
export interface IPosSaleInvoicesRawResponse {
|
|
||||||
id: string;
|
|
||||||
code: string;
|
|
||||||
invoice_date: string;
|
|
||||||
notes?: string;
|
|
||||||
total_amount: string;
|
|
||||||
pos: Pos;
|
|
||||||
consumer_account: ConsumerAccount;
|
|
||||||
created_at: string;
|
|
||||||
items_count: number;
|
|
||||||
payments: Payments[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IPosSaleInvoicesResponse extends IPosSaleInvoicesRawResponse {}
|
|
||||||
|
|
||||||
export interface IPosSaleInvoicesSummaryRawResponse {
|
export interface IPosSaleInvoicesSummaryRawResponse {
|
||||||
id: string;
|
id: string;
|
||||||
code: string;
|
code: string;
|
||||||
@@ -24,12 +10,26 @@ export interface IPosSaleInvoicesSummaryRawResponse {
|
|||||||
invoice_date: string;
|
invoice_date: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
total_amount: string;
|
total_amount: string;
|
||||||
customer: Customer;
|
customer: Maybe<Customer>;
|
||||||
fiscal: null;
|
|
||||||
status: IEnumTranslate<TspProviderResponseStatus>;
|
status: IEnumTranslate<TspProviderResponseStatus>;
|
||||||
|
type: IEnumTranslate<InvoiceTypes>;
|
||||||
|
main_id: Maybe<string>;
|
||||||
|
tax_id: Maybe<string>;
|
||||||
|
reference_invoice: Maybe<string>;
|
||||||
|
notes: Maybe<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPosSaleInvoicesSummaryResponse extends IPosSaleInvoicesSummaryRawResponse {}
|
export interface IPosSaleInvoicesSummaryResponse extends IPosSaleInvoicesSummaryRawResponse {}
|
||||||
|
|
||||||
|
export interface IPosSaleInvoicesRawResponse extends IPosSaleInvoicesSummaryRawResponse {
|
||||||
|
pos: Pos;
|
||||||
|
consumer_account: ConsumerAccount;
|
||||||
|
items_count: number;
|
||||||
|
payments: Payments[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IPosSaleInvoicesResponse extends IPosSaleInvoicesRawResponse {}
|
||||||
|
|
||||||
interface ConsumerAccount {
|
interface ConsumerAccount {
|
||||||
role: string;
|
role: string;
|
||||||
account: Account;
|
account: Account;
|
||||||
|
|||||||
@@ -49,17 +49,17 @@ export class PosOrderSectionComponent {
|
|||||||
customerNameToShow = computed(() => {
|
customerNameToShow = computed(() => {
|
||||||
const type = this.store.customer().type;
|
const type = this.store.customer().type;
|
||||||
const info = this.store.customer().info;
|
const info = this.store.customer().info;
|
||||||
let customerNameToShow = 'نامشخص';
|
let customerNameToShow = 'رهگذر';
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'UNKNOWN':
|
case 'UNKNOWN':
|
||||||
customerNameToShow = `${info?.customer_unknown?.name || 'نامشخص'} (نوع دوم)`;
|
customerNameToShow = `${info?.customer_unknown?.name || 'رهگذر'} (نوع دوم)`;
|
||||||
break;
|
break;
|
||||||
case 'INDIVIDUAL':
|
case 'INDIVIDUAL':
|
||||||
customerNameToShow = `${info?.customer_individual ? info?.customer_individual.first_name + ' ' + info?.customer_individual.last_name : 'نامشخص'} (نوع اول)`;
|
customerNameToShow = `${info?.customer_individual ? info?.customer_individual.first_name + ' ' + info?.customer_individual.last_name : '-----'} (نوع اول)`;
|
||||||
break;
|
break;
|
||||||
case 'LEGAL':
|
case 'LEGAL':
|
||||||
customerNameToShow = `${info?.customer_legal?.company_name || 'نامشخص'} (نوع اول)`;
|
customerNameToShow = `${info?.customer_legal?.company_name || '-----'} (نوع اول)`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ export class PosOrderSubmittedDialogComponent extends AbstractDialog {
|
|||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toastService.success({ text: 'ارسال فاکتور با موفقیت انجام شد.' });
|
this.toastService.success({ text: 'ارسال فاکتور با موفقیت انجام شد.' });
|
||||||
this.sended.set(true);
|
this.sended.set(true);
|
||||||
|
this.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
name="wages"
|
name="wages"
|
||||||
label="اجرت" />
|
label="اجرت" />
|
||||||
|
|
||||||
{{ initialValues?.payload?.profit }}
|
|
||||||
<app-amount-percentage-input
|
<app-amount-percentage-input
|
||||||
[percentageControl]="form.controls.payload.controls.commission_percentage"
|
[percentageControl]="form.controls.payload.controls.commission_percentage"
|
||||||
[amountControl]="form.controls.payload.controls.commission"
|
[amountControl]="form.controls.payload.controls.commission"
|
||||||
@@ -34,11 +33,11 @@
|
|||||||
|
|
||||||
<app-amount-percentage-input
|
<app-amount-percentage-input
|
||||||
[percentageControl]="form.controls.discount_percentage"
|
[percentageControl]="form.controls.discount_percentage"
|
||||||
[amountControl]="form.controls.discount"
|
[amountControl]="form.controls.discount_amount"
|
||||||
[baseAmount]="baseAmountForDiscountCalculation()"
|
[baseAmount]="baseAmountForDiscountCalculation()"
|
||||||
[minAmount]="0"
|
[minAmount]="0"
|
||||||
[maxAmount]="baseAmountForDiscountCalculation()"
|
[maxAmount]="baseAmountForDiscountCalculation()"
|
||||||
name="discount"
|
name="discount_amount"
|
||||||
label="تخفیف">
|
label="تخفیف">
|
||||||
<ng-template #labelSuffix>
|
<ng-template #labelSuffix>
|
||||||
<p-selectButton
|
<p-selectButton
|
||||||
@@ -56,7 +55,7 @@
|
|||||||
<pos-form-dialog-amount-card-template
|
<pos-form-dialog-amount-card-template
|
||||||
[totalAmount]="totalAmount()"
|
[totalAmount]="totalAmount()"
|
||||||
[baseTotalAmount]="baseTotalAmount()"
|
[baseTotalAmount]="baseTotalAmount()"
|
||||||
[discountAmount]="form.controls.discount.value || 0"
|
[discountAmount]="form.controls.discount_amount.value || 0"
|
||||||
[taxAmount]="taxAmount()" />
|
[taxAmount]="taxAmount()" />
|
||||||
<button pButton class="w-full sm:w-auto" (click)="submit()">{{ preparedCTAText() }}</button>
|
<button pButton class="w-full sm:w-auto" (click)="submit()">{{ preparedCTAText() }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
|||||||
baseTotalAmount = signal<number>(0);
|
baseTotalAmount = signal<number>(0);
|
||||||
baseAmountForDiscountCalculation = signal<number>(0);
|
baseAmountForDiscountCalculation = signal<number>(0);
|
||||||
taxAmount = signal<number>(0);
|
taxAmount = signal<number>(0);
|
||||||
|
discountAmount = signal<number>(0);
|
||||||
totalAmount = signal<number>(0);
|
totalAmount = signal<number>(0);
|
||||||
|
|
||||||
goldDefaultUnitPrice = signal<number>(0);
|
goldDefaultUnitPrice = signal<number>(0);
|
||||||
@@ -87,7 +88,7 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
|||||||
[Validators.required, greaterThanValidator(0)],
|
[Validators.required, greaterThanValidator(0)],
|
||||||
],
|
],
|
||||||
quantity: [this.initialValues?.quantity || 0, [Validators.required, greaterThanValidator(0)]],
|
quantity: [this.initialValues?.quantity || 0, [Validators.required, greaterThanValidator(0)]],
|
||||||
discount: [this.initialValues?.discount || 0],
|
discount_amount: [this.initialValues?.discount_amount || 0],
|
||||||
discount_percentage: [0, [Validators.max(100), Validators.min(0)]],
|
discount_percentage: [0, [Validators.max(100), Validators.min(0)]],
|
||||||
payload: this.fb.group({
|
payload: this.fb.group({
|
||||||
commission: [this.initialValues?.payload?.commission || 0, [Validators.required]],
|
commission: [this.initialValues?.payload?.commission || 0, [Validators.required]],
|
||||||
@@ -106,13 +107,13 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
|||||||
|
|
||||||
form.controls.payload.controls.profit.valueChanges.pipe(takeUntilDestroyed()).subscribe(() => {
|
form.controls.payload.controls.profit.valueChanges.pipe(takeUntilDestroyed()).subscribe(() => {
|
||||||
// if ((form.controls.discount_amount.value || 0) > (value || 0)) {
|
// if ((form.controls.discount_amount.value || 0) > (value || 0)) {
|
||||||
form.controls.discount.setValue(0, { emitEvent: false });
|
form.controls.discount_amount.setValue(0, { emitEvent: false });
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
form.controls.payload.controls.profit_percentage.valueChanges
|
form.controls.payload.controls.profit_percentage.valueChanges
|
||||||
.pipe(takeUntilDestroyed())
|
.pipe(takeUntilDestroyed())
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
form.controls.discount.setValue(0, { emitEvent: false });
|
form.controls.discount_amount.setValue(0, { emitEvent: false });
|
||||||
});
|
});
|
||||||
|
|
||||||
return form;
|
return form;
|
||||||
@@ -126,6 +127,7 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
|||||||
total_amount: this.totalAmount(),
|
total_amount: this.totalAmount(),
|
||||||
base_total_amount: this.baseTotalAmount(),
|
base_total_amount: this.baseTotalAmount(),
|
||||||
tax_amount: this.taxAmount(),
|
tax_amount: this.taxAmount(),
|
||||||
|
discount_amount: this.form.value.discount_amount || 0,
|
||||||
payload: {
|
payload: {
|
||||||
commission: this.form.controls.payload.controls.commission.value || 0,
|
commission: this.form.controls.payload.controls.commission.value || 0,
|
||||||
karat: this.form.controls.payload.controls.karat.value as TGoldKarat,
|
karat: this.form.controls.payload.controls.karat.value as TGoldKarat,
|
||||||
@@ -138,7 +140,7 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
|||||||
updateCalculateAmount(payload: Partial<IPosOrderItem<any>>) {
|
updateCalculateAmount(payload: Partial<IPosOrderItem<any>>) {
|
||||||
const commissionAmount = Number(payload.payload?.commission ?? '0');
|
const commissionAmount = Number(payload.payload?.commission ?? '0');
|
||||||
const wageAmount = Number(payload.payload?.wages ?? '0');
|
const wageAmount = Number(payload.payload?.wages ?? '0');
|
||||||
const discountAmount = Number(payload.discount ?? '0');
|
const discountAmount = Number(payload.discount_amount ?? '0');
|
||||||
const profitAmount = Number(payload.payload?.profit ?? '0');
|
const profitAmount = Number(payload.payload?.profit ?? '0');
|
||||||
const unitPrice = Number(payload.unit_price ?? '0');
|
const unitPrice = Number(payload.unit_price ?? '0');
|
||||||
const quantity = Number(payload.quantity ?? '0');
|
const quantity = Number(payload.quantity ?? '0');
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export class PosStandardPayloadFormComponent extends AbstractForm<
|
|||||||
[Validators.required, greaterThanValidator(0)],
|
[Validators.required, greaterThanValidator(0)],
|
||||||
],
|
],
|
||||||
quantity: [this.initialValues?.quantity || 0, [Validators.required, greaterThanValidator(0)]],
|
quantity: [this.initialValues?.quantity || 0, [Validators.required, greaterThanValidator(0)]],
|
||||||
discount_amount: [this.initialValues?.discount || 0, [Validators.min(0)]],
|
discount_amount: [this.initialValues?.discount_amount || 0, [Validators.min(0)]],
|
||||||
discount_percentage: [0, [Validators.min(0), Validators.max(100)]],
|
discount_percentage: [0, [Validators.min(0), Validators.max(100)]],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@if (!isUnknownCustomer()) {
|
||||||
<div class="flex items-center justify-between gap-3">
|
<div class="flex items-center justify-between gap-3">
|
||||||
<uikit-label> نوع تسویهحساب </uikit-label>
|
<uikit-label> نوع تسویهحساب </uikit-label>
|
||||||
<p-selectButton
|
<p-selectButton
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
optionLabel="label"
|
optionLabel="label"
|
||||||
optionValue="value" />
|
optionValue="value" />
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<uikit-field label="تعداد مراحل پرداخت با پوز" name="pay_by_terminal_steps">
|
<uikit-field label="تعداد مراحل پرداخت با پوز" name="pay_by_terminal_steps">
|
||||||
<p-select
|
<p-select
|
||||||
[options]="payByTerminalSteps()"
|
[options]="payByTerminalSteps()"
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ export class PosPaymentFormDialogComponent extends AbstractFormDialog<IPayment,
|
|||||||
|
|
||||||
readonly submitOrderLoading = computed(() => this.store.submitOrderLoading());
|
readonly submitOrderLoading = computed(() => this.store.submitOrderLoading());
|
||||||
readonly isGoldGuild = computed(() => this.posInfo.entity()?.guild.code.toLowerCase() === 'gold');
|
readonly isGoldGuild = computed(() => this.posInfo.entity()?.guild.code.toLowerCase() === 'gold');
|
||||||
|
readonly isUnknownCustomer = computed(() => this.store.customer().type === 'UNKNOWN');
|
||||||
|
|
||||||
payByTerminalSteps = signal(
|
payByTerminalSteps = signal(
|
||||||
Array.from({ length: 10 }, (_, i) => ({
|
Array.from({ length: 10 }, (_, i) => ({
|
||||||
|
|||||||
+5
-1
@@ -7,6 +7,8 @@ import { IPosOrderItem } from './types';
|
|||||||
|
|
||||||
export interface IPosOrderRequest {
|
export interface IPosOrderRequest {
|
||||||
total_amount: number;
|
total_amount: number;
|
||||||
|
discount_amount: number;
|
||||||
|
tax_amount: number;
|
||||||
invoice_date: string;
|
invoice_date: string;
|
||||||
settlement_type: 'CASH' | 'CREDIT' | 'MIXED';
|
settlement_type: 'CASH' | 'CREDIT' | 'MIXED';
|
||||||
payments: IPayment;
|
payments: IPayment;
|
||||||
@@ -23,7 +25,9 @@ export interface IPosOrderRawResponse {
|
|||||||
invoice_number: number;
|
invoice_number: number;
|
||||||
invoice_date: string;
|
invoice_date: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
total_amount: string;
|
total_amount: strung;
|
||||||
|
discount_amount: strung;
|
||||||
|
tax_amount: strung;
|
||||||
customer: ICustomer;
|
customer: ICustomer;
|
||||||
unknown_customer: IUnknownCustomer;
|
unknown_customer: IUnknownCustomer;
|
||||||
status: IEnumTranslate;
|
status: IEnumTranslate;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export interface IPosOrderItem<T = TPosOrderGoodPayload> {
|
|||||||
quantity: number;
|
quantity: number;
|
||||||
total_amount: number;
|
total_amount: number;
|
||||||
discount_amount: number;
|
discount_amount: number;
|
||||||
|
tax_amount: number;
|
||||||
measure_unit: ISummary;
|
measure_unit: ISummary;
|
||||||
good_id?: string;
|
good_id?: string;
|
||||||
service_id?: string;
|
service_id?: string;
|
||||||
@@ -15,8 +16,6 @@ export interface IPosOrderItem<T = TPosOrderGoodPayload> {
|
|||||||
payload: T;
|
payload: T;
|
||||||
|
|
||||||
base_total_amount: number;
|
base_total_amount: number;
|
||||||
discount: number;
|
|
||||||
tax_amount: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPosInOrderGood extends Omit<IPosOrderItem, 'good_id' | 'service_id' | 'notes'> {
|
export interface IPosInOrderGood extends Omit<IPosOrderItem, 'good_id' | 'service_id' | 'notes'> {
|
||||||
|
|||||||
@@ -272,6 +272,8 @@ export class PosLandingStore {
|
|||||||
payments: this.payments(),
|
payments: this.payments(),
|
||||||
settlement_type: this.state$().settlement_type,
|
settlement_type: this.state$().settlement_type,
|
||||||
total_amount: this.orderPricingInfo().totalAmount,
|
total_amount: this.orderPricingInfo().totalAmount,
|
||||||
|
discount_amount: this.orderPricingInfo().discountAmount,
|
||||||
|
tax_amount: this.orderPricingInfo().taxAmount,
|
||||||
};
|
};
|
||||||
|
|
||||||
// this.toastServices.info({
|
// this.toastServices.info({
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import taxProviderStatusTranslatorUtil from '@/shared/catalog/taxProviderStatus/tax-provider-status-translator.util';
|
||||||
import { formatWithCurrency } from '@/utils';
|
import { formatWithCurrency } from '@/utils';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Component, computed, EventEmitter, Input, Output } from '@angular/core';
|
import { Component, computed, EventEmitter, Input, Output } from '@angular/core';
|
||||||
@@ -8,7 +9,7 @@ import { Component, computed, EventEmitter, Input, Output } from '@angular/core'
|
|||||||
imports: [CommonModule],
|
imports: [CommonModule],
|
||||||
})
|
})
|
||||||
export class PosStatisticsInvoiceTypeCardComponent {
|
export class PosStatisticsInvoiceTypeCardComponent {
|
||||||
@Input() type: 'all' | 'success' | 'failure' | 'notSended' | 'pending' | 'credit' = 'all';
|
@Input() type: 'all' | 'success' | 'failure' | 'not_sended' | 'pending' | 'not_original' = 'all';
|
||||||
@Input() count?: number = 0;
|
@Input() count?: number = 0;
|
||||||
@Input() totalAmount?: number = 0;
|
@Input() totalAmount?: number = 0;
|
||||||
@Input() totalTaxAmount?: number = 0;
|
@Input() totalTaxAmount?: number = 0;
|
||||||
@@ -35,21 +36,21 @@ export class PosStatisticsInvoiceTypeCardComponent {
|
|||||||
};
|
};
|
||||||
case 'success':
|
case 'success':
|
||||||
return {
|
return {
|
||||||
title: 'تایید شده',
|
title: taxProviderStatusTranslatorUtil('SUCCESS'),
|
||||||
icon: 'check',
|
icon: 'check-circle',
|
||||||
bgColor: '#22C55E1A',
|
bgColor: '#22C55E1A',
|
||||||
borderColor: '#22C55E',
|
borderColor: '#22C55E',
|
||||||
};
|
};
|
||||||
case 'failure':
|
case 'failure':
|
||||||
return {
|
return {
|
||||||
title: 'خطادار',
|
title: taxProviderStatusTranslatorUtil('FAILURE'),
|
||||||
icon: 'times',
|
icon: 'ban',
|
||||||
bgColor: '#EF44441A',
|
bgColor: '#EF44441A',
|
||||||
borderColor: '#EF4444',
|
borderColor: '#EF4444',
|
||||||
};
|
};
|
||||||
case 'notSended':
|
case 'not_sended':
|
||||||
return {
|
return {
|
||||||
title: 'ارسال نشده',
|
title: taxProviderStatusTranslatorUtil('NOT_SEND'),
|
||||||
icon: 'clock',
|
icon: 'clock',
|
||||||
bgColor: '#F59E0B1A',
|
bgColor: '#F59E0B1A',
|
||||||
borderColor: '#F59E0B',
|
borderColor: '#F59E0B',
|
||||||
@@ -61,9 +62,9 @@ export class PosStatisticsInvoiceTypeCardComponent {
|
|||||||
bgColor: '#3B82F61A',
|
bgColor: '#3B82F61A',
|
||||||
borderColor: '#3B82F6',
|
borderColor: '#3B82F6',
|
||||||
};
|
};
|
||||||
case 'credit':
|
case 'not_original':
|
||||||
return {
|
return {
|
||||||
title: 'اعتبار',
|
title: 'ارجاعی',
|
||||||
icon: 'credit-card',
|
icon: 'credit-card',
|
||||||
bgColor: '#8B5CF61A',
|
bgColor: '#8B5CF61A',
|
||||||
borderColor: '#8B5CF6',
|
borderColor: '#8B5CF6',
|
||||||
|
|||||||
+2
-2
@@ -3,8 +3,8 @@ export interface IPosStatisticsRawResponse {
|
|||||||
success: IPosStatisticsItem;
|
success: IPosStatisticsItem;
|
||||||
failure: IPosStatisticsItem;
|
failure: IPosStatisticsItem;
|
||||||
pending: IPosStatisticsItem;
|
pending: IPosStatisticsItem;
|
||||||
notSended: IPosStatisticsItem;
|
not_sended: IPosStatisticsItem;
|
||||||
credit: IPosStatisticsItem;
|
not_original: IPosStatisticsItem;
|
||||||
}
|
}
|
||||||
export interface IPosStatisticsResponse extends IPosStatisticsRawResponse {}
|
export interface IPosStatisticsResponse extends IPosStatisticsRawResponse {}
|
||||||
|
|
||||||
|
|||||||
@@ -30,12 +30,12 @@
|
|||||||
[count]="item()?.failure?.count"
|
[count]="item()?.failure?.count"
|
||||||
(onClick)="toInvoicesPage('failure')" />
|
(onClick)="toInvoicesPage('failure')" />
|
||||||
<pos-statistics-invoice-type-card
|
<pos-statistics-invoice-type-card
|
||||||
type="notSended"
|
type="not_sended"
|
||||||
[loading]="loading()"
|
[loading]="loading()"
|
||||||
[totalAmount]="item()?.notSended?.total_amount"
|
[totalAmount]="item()?.not_sended?.total_amount"
|
||||||
[totalTaxAmount]="item()?.notSended?.total_tax"
|
[totalTaxAmount]="item()?.not_sended?.total_tax"
|
||||||
[count]="item()?.notSended?.count"
|
[count]="item()?.not_sended?.count"
|
||||||
(onClick)="toInvoicesPage('notSended')" />
|
(onClick)="toInvoicesPage('not_sended')" />
|
||||||
<pos-statistics-invoice-type-card
|
<pos-statistics-invoice-type-card
|
||||||
type="pending"
|
type="pending"
|
||||||
[loading]="loading()"
|
[loading]="loading()"
|
||||||
@@ -44,11 +44,11 @@
|
|||||||
[count]="item()?.pending?.count"
|
[count]="item()?.pending?.count"
|
||||||
(onClick)="toInvoicesPage('pending')" />
|
(onClick)="toInvoicesPage('pending')" />
|
||||||
<pos-statistics-invoice-type-card
|
<pos-statistics-invoice-type-card
|
||||||
type="credit"
|
type="not_original"
|
||||||
[loading]="loading()"
|
[loading]="loading()"
|
||||||
[totalAmount]="item()?.credit?.total_amount"
|
[totalAmount]="item()?.not_original?.total_amount"
|
||||||
[totalTaxAmount]="item()?.credit?.total_tax"
|
[totalTaxAmount]="item()?.not_original?.total_tax"
|
||||||
[count]="item()?.credit?.count" />
|
[count]="item()?.not_original?.count" />
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="fixed inset-x-0 bottom-0 p-4">
|
<div class="fixed inset-x-0 bottom-0 p-4">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export * from './devices';
|
export * from './devices';
|
||||||
export * from './guild';
|
export * from './guild';
|
||||||
|
export * from './invoiceTypes';
|
||||||
export * from './providers';
|
export * from './providers';
|
||||||
export * from './taxProviderStatus';
|
export * from './taxProviderStatus';
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './invoice-type-tag.component';
|
||||||
|
export * from './type';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<p-tag [severity]="severity" size="large" [value]="translate || label"></p-tag>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { Component, Input } from '@angular/core';
|
||||||
|
import { Tag } from 'primeng/tag';
|
||||||
|
import { InvoiceTypes } from './type';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'catalog-invoice-type-tag',
|
||||||
|
templateUrl: './invoice-type-tag.component.html',
|
||||||
|
imports: [Tag],
|
||||||
|
})
|
||||||
|
export class CatalogInvoiceTypeTagComponent {
|
||||||
|
@Input({ required: true }) status!: InvoiceTypes;
|
||||||
|
@Input() translate!: string;
|
||||||
|
|
||||||
|
get severity() {
|
||||||
|
switch (this.status) {
|
||||||
|
case 'ORIGINAL':
|
||||||
|
return 'success';
|
||||||
|
case 'CORRECTION':
|
||||||
|
return 'warn';
|
||||||
|
case 'REVOKE':
|
||||||
|
return 'danger';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get label() {
|
||||||
|
switch (this.status) {
|
||||||
|
case 'ORIGINAL':
|
||||||
|
return 'اصلی';
|
||||||
|
case 'CORRECTION':
|
||||||
|
return 'اصلاحی';
|
||||||
|
case 'REVOKE':
|
||||||
|
return 'ابطالی';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export const InvoiceTypes = {
|
||||||
|
ORIGINAL: 'ORIGINAL',
|
||||||
|
CORRECTION: 'CORRECTION',
|
||||||
|
REVOKE: 'REVOKE',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type InvoiceTypes = (typeof InvoiceTypes)[keyof typeof InvoiceTypes];
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from './tax-provider-status-tag.component';
|
export * from './tax-provider-status-tag.component';
|
||||||
|
export * from './tax-provider-status-translator.util';
|
||||||
export * from './type';
|
export * from './type';
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { Tag } from 'primeng/tag';
|
import { Tag } from 'primeng/tag';
|
||||||
|
import taxProviderStatusTranslatorUtil from './tax-provider-status-translator.util';
|
||||||
import { TspProviderResponseStatus } from './type';
|
import { TspProviderResponseStatus } from './type';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -16,10 +17,12 @@ export class CatalogTaxProviderStatusTagComponent {
|
|||||||
case 'SUCCESS':
|
case 'SUCCESS':
|
||||||
return 'success';
|
return 'success';
|
||||||
case 'FAILURE':
|
case 'FAILURE':
|
||||||
|
case 'SEND_FAILURE':
|
||||||
return 'danger';
|
return 'danger';
|
||||||
case 'NOT_SEND':
|
case 'NOT_SEND':
|
||||||
return 'warn';
|
return 'warn';
|
||||||
case 'QUEUED':
|
case 'QUEUED':
|
||||||
|
case 'FISCAL_QUEUED':
|
||||||
return 'info';
|
return 'info';
|
||||||
default:
|
default:
|
||||||
return 'secondary';
|
return 'secondary';
|
||||||
@@ -27,17 +30,6 @@ export class CatalogTaxProviderStatusTagComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get label() {
|
get label() {
|
||||||
switch (this.status) {
|
return taxProviderStatusTranslatorUtil(this.status);
|
||||||
case 'SUCCESS':
|
|
||||||
return 'موفق';
|
|
||||||
case 'FAILURE':
|
|
||||||
return 'ناموفق';
|
|
||||||
case 'NOT_SEND':
|
|
||||||
return 'ارسال نشده';
|
|
||||||
case 'QUEUED':
|
|
||||||
return 'در صف ارسال';
|
|
||||||
default:
|
|
||||||
return 'نامشخص';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { TspProviderResponseStatus } from './type';
|
||||||
|
|
||||||
|
export default (status: TspProviderResponseStatus) => {
|
||||||
|
switch (status) {
|
||||||
|
case 'SUCCESS':
|
||||||
|
return 'موفق';
|
||||||
|
case 'FAILURE':
|
||||||
|
return 'ناموفق';
|
||||||
|
case 'NOT_SEND':
|
||||||
|
return 'ارسال نشده';
|
||||||
|
case 'QUEUED':
|
||||||
|
return 'در صف ارسال';
|
||||||
|
case 'FISCAL_QUEUED':
|
||||||
|
return 'در انتظار تایید سازمان';
|
||||||
|
case 'SEND_FAILURE':
|
||||||
|
return 'خطا در ارسال';
|
||||||
|
default:
|
||||||
|
return 'نامشخص';
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -3,6 +3,8 @@ export const TspProviderResponseStatus = {
|
|||||||
FAILURE: 'FAILURE',
|
FAILURE: 'FAILURE',
|
||||||
NOT_SEND: 'NOT_SEND',
|
NOT_SEND: 'NOT_SEND',
|
||||||
QUEUED: 'QUEUED',
|
QUEUED: 'QUEUED',
|
||||||
|
FISCAL_QUEUED: 'FISCAL_QUEUED',
|
||||||
|
SEND_FAILURE: 'SEND_FAILURE',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type TspProviderResponseStatus =
|
export type TspProviderResponseStatus =
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
<p-confirmdialog #cd>
|
<p-confirmdialog #cd>
|
||||||
<ng-template #headless let-message let-onAccept="onAccept" let-onReject="onReject">
|
<ng-template #headless let-message let-onAccept="onAccept" let-onReject="onReject">
|
||||||
@if (message) {
|
@if (message) {
|
||||||
<div class="flex flex-col items-center p-8 bg-surface-0 dark:bg-surface-900 rounded">
|
<div class="bg-surface-0 dark:bg-surface-900 flex flex-col items-center rounded p-8">
|
||||||
<div
|
<div
|
||||||
class="rounded-full bg-primary text-primary-contrast inline-flex justify-center items-center h-24 w-24 -mt-20"
|
class="bg-primary text-primary-contrast -mt-20 inline-flex h-24 w-24 items-center justify-center rounded-full">
|
||||||
>
|
|
||||||
<i class="pi pi-question text-5xl!"></i>
|
<i class="pi pi-question text-5xl!"></i>
|
||||||
</div>
|
</div>
|
||||||
<span class="font-bold text-2xl block mb-2 mt-6">{{ message.header }}</span>
|
<span class="mt-6 mb-2 block text-2xl font-bold">{{ message.header }}</span>
|
||||||
<p class="mb-0">{{ message.message }}</p>
|
<p class="mb-0">{{ message.message }}</p>
|
||||||
<div class="flex items-center gap-2 mt-6">
|
<div class="mt-6 flex items-center gap-2">
|
||||||
<p-button label="{{ acceptLabel }}" (onClick)="onAccept()" styleClass="w-32"></p-button>
|
<p-button [label]="message.acceptLabel" type="button" (onClick)="onAccept()" styleClass="w-32"></p-button>
|
||||||
<p-button label="{{ rejectLabel }}" [outlined]="true" (onClick)="onReject()" styleClass="w-32"></p-button>
|
<p-button
|
||||||
|
[label]="message.rejectLabel"
|
||||||
|
type="button"
|
||||||
|
[outlined]="true"
|
||||||
|
(onClick)="onReject()"
|
||||||
|
styleClass="w-32"></p-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +1,11 @@
|
|||||||
import { Component, EventEmitter, Input, OnDestroy, Output } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ConfirmationService } from 'primeng/api';
|
|
||||||
import { Button } from 'primeng/button';
|
import { Button } from 'primeng/button';
|
||||||
import { ConfirmDialog } from 'primeng/confirmdialog';
|
import { ConfirmDialog } from 'primeng/confirmdialog';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-shared-confirmation-dialog',
|
selector: 'app-shared-confirmation-dialog',
|
||||||
templateUrl: './confirmation-dialog.component.html',
|
templateUrl: './confirmation-dialog.component.html',
|
||||||
providers: [ConfirmationService],
|
standalone: true,
|
||||||
imports: [ConfirmDialog, Button],
|
imports: [ConfirmDialog, Button],
|
||||||
})
|
})
|
||||||
export class ConfirmationDialogComponent implements OnDestroy {
|
export class ConfirmationDialogComponent {}
|
||||||
@Input() message!: string;
|
|
||||||
@Input() header: string = 'تأیید عملیات';
|
|
||||||
@Input() acceptLabel: string = 'بله';
|
|
||||||
@Input() rejectLabel: string = 'خیر';
|
|
||||||
@Output() onAccept = new EventEmitter<void>();
|
|
||||||
@Output() onReject = new EventEmitter<void>();
|
|
||||||
|
|
||||||
constructor(private confirmationService: ConfirmationService) {}
|
|
||||||
|
|
||||||
show() {
|
|
||||||
this.confirmationService.confirm({
|
|
||||||
header: this.header,
|
|
||||||
message: this.message,
|
|
||||||
acceptLabel: this.acceptLabel,
|
|
||||||
rejectLabel: this.rejectLabel,
|
|
||||||
accept: () => {
|
|
||||||
this.accept();
|
|
||||||
},
|
|
||||||
reject: () => {
|
|
||||||
this.reject();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
accept() {
|
|
||||||
this.onAccept.emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
reject() {
|
|
||||||
this.onReject.emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
// Cleanup if needed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,78 +1,32 @@
|
|||||||
import {
|
import { Injectable, inject } from '@angular/core';
|
||||||
ApplicationRef,
|
import { Confirmation, ConfirmationService } from 'primeng/api';
|
||||||
ComponentFactoryResolver,
|
|
||||||
ComponentRef,
|
|
||||||
Injectable,
|
|
||||||
Injector,
|
|
||||||
} from '@angular/core';
|
|
||||||
import { ConfirmationDialogComponent } from './confirmation-dialog.component';
|
|
||||||
|
|
||||||
@Injectable({
|
export interface AppConfirmOptions {
|
||||||
providedIn: 'root',
|
header: string;
|
||||||
})
|
|
||||||
export class ConfirmationDialogService {
|
|
||||||
private componentRef: ComponentRef<ConfirmationDialogComponent> | null = null;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private componentFactoryResolver: ComponentFactoryResolver,
|
|
||||||
private appRef: ApplicationRef,
|
|
||||||
private injector: Injector,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
confirm(options: {
|
|
||||||
message: string;
|
message: string;
|
||||||
header?: string;
|
|
||||||
acceptLabel?: string;
|
acceptLabel?: string;
|
||||||
rejectLabel?: string;
|
rejectLabel?: string;
|
||||||
accept?: () => void;
|
accept?: () => void;
|
||||||
reject?: () => void;
|
reject?: () => void;
|
||||||
}) {
|
}
|
||||||
// Create the component dynamically
|
|
||||||
const factory = this.componentFactoryResolver.resolveComponentFactory(
|
|
||||||
ConfirmationDialogComponent,
|
|
||||||
);
|
|
||||||
this.componentRef = factory.create(this.injector);
|
|
||||||
|
|
||||||
// Set inputs
|
@Injectable({
|
||||||
this.componentRef.instance.message = options.message;
|
providedIn: 'root',
|
||||||
if (options.header) this.componentRef.instance.header = options.header;
|
})
|
||||||
if (options.acceptLabel) this.componentRef.instance.acceptLabel = options.acceptLabel;
|
export class AppConfirmationService {
|
||||||
if (options.rejectLabel) this.componentRef.instance.rejectLabel = options.rejectLabel;
|
private confirmationService = inject(ConfirmationService);
|
||||||
|
|
||||||
// Subscribe to outputs and close after
|
ask(options: Confirmation): Promise<boolean> {
|
||||||
if (options.accept) {
|
return new Promise((resolve) => {
|
||||||
this.componentRef.instance.onAccept.subscribe(() => {
|
this.confirmationService.confirm({
|
||||||
options.accept!();
|
position: 'bottom',
|
||||||
this.close();
|
acceptLabel: 'تایید',
|
||||||
|
rejectLabel: 'لغو',
|
||||||
|
...options,
|
||||||
|
closeOnEscape: true,
|
||||||
|
accept: () => options.accept?.() || resolve(true),
|
||||||
|
reject: () => resolve(false),
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
this.componentRef.instance.onAccept.subscribe(() => this.close());
|
|
||||||
}
|
|
||||||
if (options.reject) {
|
|
||||||
this.componentRef.instance.onReject.subscribe(() => {
|
|
||||||
options.reject!();
|
|
||||||
this.close();
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
this.componentRef.instance.onReject.subscribe(() => this.close());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach to the app
|
|
||||||
this.appRef.attachView(this.componentRef.hostView);
|
|
||||||
|
|
||||||
// Append to body
|
|
||||||
document.body.appendChild(this.componentRef.location.nativeElement);
|
|
||||||
|
|
||||||
// Trigger change detection and show
|
|
||||||
this.componentRef.changeDetectorRef.detectChanges();
|
|
||||||
this.componentRef.instance.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
close() {
|
|
||||||
if (this.componentRef) {
|
|
||||||
this.appRef.detachView(this.componentRef.hostView);
|
|
||||||
this.componentRef.destroy();
|
|
||||||
this.componentRef = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ export class SharedLightBottomsheetComponent implements OnInit, OnDestroy, OnCha
|
|||||||
this.syncZIndex();
|
this.syncZIndex();
|
||||||
}
|
}
|
||||||
if (changes['visible']) {
|
if (changes['visible']) {
|
||||||
console.log('changed', this.visible);
|
|
||||||
|
|
||||||
this.toggleBodyScrollLock(this.visible);
|
this.toggleBodyScrollLock(this.visible);
|
||||||
}
|
}
|
||||||
@@ -140,8 +139,6 @@ export class SharedLightBottomsheetComponent implements OnInit, OnDestroy, OnCha
|
|||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.toggleBodyScrollLock(false);
|
this.toggleBodyScrollLock(false);
|
||||||
console.log('destroyed');
|
|
||||||
|
|
||||||
this.removeDrawer();
|
this.removeDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,8 +168,6 @@ export class SharedLightBottomsheetComponent implements OnInit, OnDestroy, OnCha
|
|||||||
}
|
}
|
||||||
|
|
||||||
private toggleBodyScrollLock(locked: boolean) {
|
private toggleBodyScrollLock(locked: boolean) {
|
||||||
console.log('locked', locked);
|
|
||||||
|
|
||||||
const body = this.document.body;
|
const body = this.document.body;
|
||||||
if (!body) return;
|
if (!body) return;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<div class="flex justify-end gap-2">
|
<div class="flex justify-end gap-2">
|
||||||
<p-button [label]="cancelLabel" severity="secondary" (click)="cancel()" />
|
<button pButton [label]="cancelLabel" severity="secondary" (click)="cancel()"></button>
|
||||||
<p-button [label]="submitLabel" type="submit" [disabled]="disabled" [loading]="loading" (onClick)="submit()" />
|
<button
|
||||||
|
pButton
|
||||||
|
[label]="submitLabel"
|
||||||
|
type="submit"
|
||||||
|
class="min-w-28"
|
||||||
|
[disabled]="disabled"
|
||||||
|
[loading]="loading"
|
||||||
|
(onClick)="submit()"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||||
import { Button } from 'primeng/button';
|
import { ButtonDirective } from 'primeng/button';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-form-footer-actions',
|
selector: 'app-form-footer-actions',
|
||||||
templateUrl: './form-footer-actions.component.html',
|
templateUrl: './form-footer-actions.component.html',
|
||||||
imports: [Button],
|
imports: [ButtonDirective],
|
||||||
})
|
})
|
||||||
export class FormFooterActionsComponent {
|
export class FormFooterActionsComponent {
|
||||||
@Input() submitLabel = 'تایید';
|
@Input() submitLabel = 'تایید';
|
||||||
|
|||||||
@@ -1,21 +1,29 @@
|
|||||||
|
import { Maybe } from '@/core';
|
||||||
import ISummary from '@/core/models/summary';
|
import ISummary from '@/core/models/summary';
|
||||||
import { TspProviderResponseStatus } from '@/shared/catalog';
|
import { InvoiceTypes, TspProviderResponseStatus } from '@/shared/catalog';
|
||||||
import { IEnumTranslate } from '@/shared/models/enum_translate.type';
|
import { IEnumTranslate } from '@/shared/models/enum_translate.type';
|
||||||
|
|
||||||
export interface ISaleInvoiceFullRawResponse {
|
export interface ISaleInvoiceFullRawResponse {
|
||||||
id: string;
|
id: string;
|
||||||
code: string;
|
code: string;
|
||||||
total_amount: string;
|
total_amount: string;
|
||||||
|
discount_amount: string;
|
||||||
|
tax_amount: string;
|
||||||
invoice_date: string;
|
invoice_date: string;
|
||||||
consumer_account: ConsumerAccount;
|
consumer_account: ConsumerAccount;
|
||||||
pos: Pos;
|
pos: Pos;
|
||||||
payments: Payment[];
|
payments: Payment[];
|
||||||
items: Item[];
|
items: Item[];
|
||||||
|
invoice_number: number;
|
||||||
|
type: IEnumTranslate<InvoiceTypes>;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
notes?: string;
|
|
||||||
customer?: Customer;
|
customer?: Customer;
|
||||||
unknown_customer?: UnknownCustomer;
|
unknown_customer?: UnknownCustomer;
|
||||||
status: IEnumTranslate<TspProviderResponseStatus>;
|
status: IEnumTranslate<TspProviderResponseStatus>;
|
||||||
|
main_id: Maybe<string>;
|
||||||
|
tax_id: Maybe<string>;
|
||||||
|
reference_invoice: Maybe<string>;
|
||||||
|
notes: Maybe<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {}
|
export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {}
|
||||||
|
|||||||
@@ -6,30 +6,32 @@
|
|||||||
<div class="flex flex-col gap-6">
|
<div class="flex flex-col gap-6">
|
||||||
<app-card-data cardTitle="اطلاعات فاکتور" [editable]="false" [backRoute]="backRoute">
|
<app-card-data cardTitle="اطلاعات فاکتور" [editable]="false" [backRoute]="backRoute">
|
||||||
<ng-template #moreActions>
|
<ng-template #moreActions>
|
||||||
<button
|
<div class="">
|
||||||
pButton
|
<p-menu #menu [model]="moreActionMenuItems()" [popup]="true" appendTo="body" />
|
||||||
type="button"
|
<p-button (click)="menu.toggle($event)" icon="pi pi-ellipsis-v" outlined size="small" />
|
||||||
label="چاپ"
|
</div>
|
||||||
icon="pi pi-print"
|
|
||||||
outlined
|
|
||||||
size="small"
|
|
||||||
(click)="printInvoice()"></button>
|
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<div class="listKeyValue">
|
<div class="listKeyValue">
|
||||||
<app-key-value label="کد رهگیری" [value]="invoice.code" />
|
<app-key-value label="شماره صورتحساب" [value]="invoice.invoice_number" />
|
||||||
<app-key-value label="تاریخ فاکتور" [value]="invoice.invoice_date" type="dateTime" />
|
<app-key-value label="تاریخ فاکتور" [value]="invoice.invoice_date" type="dateTime" />
|
||||||
<app-key-value label="تاریخ ایجاد فاکتور" [value]="invoice.created_at" type="dateTime" />
|
<app-key-value label="تاریخ ایجاد فاکتور" [value]="invoice.created_at" type="dateTime" />
|
||||||
|
<app-key-value label="نوع صورتحساب">
|
||||||
|
<catalog-invoice-type-tag [status]="invoice.type.value" />
|
||||||
|
</app-key-value>
|
||||||
<app-key-value label="وضعیت صدور به سامانهی مودیان">
|
<app-key-value label="وضعیت صدور به سامانهی مودیان">
|
||||||
<catalog-tax-provider-status-tag [status]="invoice.status.value" [translate]="invoice.status.translate" />
|
<catalog-tax-provider-status-tag [status]="invoice.status.value" [translate]="invoice.status.translate" />
|
||||||
</app-key-value>
|
</app-key-value>
|
||||||
<div class="col-span-full">
|
<div class="col-span-full">
|
||||||
<app-key-value label="توضیحات" [value]="invoice.notes" />
|
<app-key-value label="توضیحات" [value]="invoice.notes || '----'" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p-divider align="center"> اطلاعات پرداخت </p-divider>
|
<p-divider align="center"> اطلاعات پرداخت </p-divider>
|
||||||
<div class="grid items-center gap-3 sm:grid-cols-2 sm:gap-4 md:grid-cols-3">
|
<div class="grid items-center gap-3 sm:grid-cols-2 sm:gap-4 md:grid-cols-3">
|
||||||
<app-key-value label="مجموع قابل پرداخت" [value]="invoice.total_amount" type="price" />
|
<app-key-value label="مجموع قابل پرداخت" [value]="invoice.total_amount" type="price" />
|
||||||
|
<app-key-value label="مبلغ تخفیف" [value]="invoice.discount_amount" type="price" />
|
||||||
|
<app-key-value label="مبلغ مالیات" [value]="invoice.tax_amount" type="price" />
|
||||||
|
|
||||||
@for (payment of invoice.payments; track $index) {
|
@for (payment of invoice.payments; track $index) {
|
||||||
<app-key-value
|
<app-key-value
|
||||||
[label]="`${payment.payment_method === 'SET_OFF' ? 'تهاتر' : payment.payment_method === 'TERMINAL' ? 'پوز' : 'نقدی/ کارتخوان دیگر/ کارت به کارت'}`"
|
[label]="`${payment.payment_method === 'SET_OFF' ? 'تهاتر' : payment.payment_method === 'TERMINAL' ? 'پوز' : 'نقدی/ کارتخوان دیگر/ کارت به کارت'}`"
|
||||||
@@ -82,9 +84,6 @@
|
|||||||
<app-card-data cardTitle="کالاهای خریداری شده" [editable]="false">
|
<app-card-data cardTitle="کالاهای خریداری شده" [editable]="false">
|
||||||
<app-page-data-list
|
<app-page-data-list
|
||||||
[columns]="columns"
|
[columns]="columns"
|
||||||
[expandColumns]="expandableColumns"
|
|
||||||
[expandable]="true"
|
|
||||||
expandableItemKey="payload"
|
|
||||||
[items]="invoice.items"
|
[items]="invoice.items"
|
||||||
[loading]="loading"
|
[loading]="loading"
|
||||||
pageTitle=""
|
pageTitle=""
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ import { NativeBridgeService } from '@/core/services';
|
|||||||
import { ToastService } from '@/core/services/toast.service';
|
import { ToastService } from '@/core/services/toast.service';
|
||||||
import { PosConfigPrintService } from '@/domains/pos/modules/configs/components/print/services/main.service';
|
import { PosConfigPrintService } from '@/domains/pos/modules/configs/components/print/services/main.service';
|
||||||
import { PosInfoStore } from '@/domains/pos/store';
|
import { PosInfoStore } from '@/domains/pos/store';
|
||||||
import { CatalogTaxProviderStatusTagComponent } from '@/shared/catalog';
|
import {
|
||||||
|
CatalogInvoiceTypeTagComponent,
|
||||||
|
CatalogTaxProviderStatusTagComponent,
|
||||||
|
} from '@/shared/catalog';
|
||||||
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||||
import { ISaleInvoiceFullResponse } from '@/shared/components/invoices/sale-invoice-full-response.model';
|
import { ISaleInvoiceFullResponse } from '@/shared/components/invoices/sale-invoice-full-response.model';
|
||||||
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
||||||
@@ -21,13 +24,18 @@ import {
|
|||||||
inject,
|
inject,
|
||||||
Input,
|
Input,
|
||||||
Output,
|
Output,
|
||||||
|
signal,
|
||||||
|
SimpleChanges,
|
||||||
TemplateRef,
|
TemplateRef,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { UrlTree } from '@angular/router';
|
import { UrlTree } from '@angular/router';
|
||||||
import { ButtonDirective } from 'primeng/button';
|
import { MenuItem } from 'primeng/api';
|
||||||
|
import { Button } from 'primeng/button';
|
||||||
import { Divider } from 'primeng/divider';
|
import { Divider } from 'primeng/divider';
|
||||||
|
import { Menu } from 'primeng/menu';
|
||||||
import { TableModule } from 'primeng/table';
|
import { TableModule } from 'primeng/table';
|
||||||
|
import { AppConfirmationService } from '../confirmationDialog/confirmation-dialog.service';
|
||||||
|
|
||||||
export type TSaleInvoiceSingleViewVariant = 'full' | 'customer' | 'pos';
|
export type TSaleInvoiceSingleViewVariant = 'full' | 'customer' | 'pos';
|
||||||
|
|
||||||
@@ -38,13 +46,15 @@ export type TSaleInvoiceSingleViewVariant = 'full' | 'customer' | 'pos';
|
|||||||
AppCardComponent,
|
AppCardComponent,
|
||||||
KeyValueComponent,
|
KeyValueComponent,
|
||||||
Divider,
|
Divider,
|
||||||
ButtonDirective,
|
|
||||||
PageDataListComponent,
|
PageDataListComponent,
|
||||||
TableModule,
|
TableModule,
|
||||||
PageLoadingComponent,
|
PageLoadingComponent,
|
||||||
UikitEmptyStateComponent,
|
UikitEmptyStateComponent,
|
||||||
PriceMaskDirective,
|
PriceMaskDirective,
|
||||||
CatalogTaxProviderStatusTagComponent,
|
CatalogTaxProviderStatusTagComponent,
|
||||||
|
CatalogInvoiceTypeTagComponent,
|
||||||
|
Menu,
|
||||||
|
Button,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class SharedSaleInvoiceSingleViewComponent {
|
export class SharedSaleInvoiceSingleViewComponent {
|
||||||
@@ -53,6 +63,7 @@ export class SharedSaleInvoiceSingleViewComponent {
|
|||||||
private readonly toastService = inject(ToastService);
|
private readonly toastService = inject(ToastService);
|
||||||
//TODO: below service Must be transform from pos to shared.
|
//TODO: below service Must be transform from pos to shared.
|
||||||
private readonly service = inject(PosConfigPrintService);
|
private readonly service = inject(PosConfigPrintService);
|
||||||
|
private readonly confirmationService = inject(AppConfirmationService);
|
||||||
|
|
||||||
@Input({ required: true }) loading!: boolean;
|
@Input({ required: true }) loading!: boolean;
|
||||||
@Input() invoice!: Maybe<ISaleInvoiceFullResponse>;
|
@Input() invoice!: Maybe<ISaleInvoiceFullResponse>;
|
||||||
@@ -63,6 +74,88 @@ export class SharedSaleInvoiceSingleViewComponent {
|
|||||||
|
|
||||||
@ViewChild('totalAmount', { static: false }) totalAmount!: TemplateRef<any>;
|
@ViewChild('totalAmount', { static: false }) totalAmount!: TemplateRef<any>;
|
||||||
|
|
||||||
|
moreActionMenuItems = signal<MenuItem[]>([]);
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.showErrors = this.showErrors.bind(this);
|
||||||
|
this.showRevokeConfirmation = this.showRevokeConfirmation.bind(this);
|
||||||
|
this.showCorrection = this.showCorrection.bind(this);
|
||||||
|
this.showBackFromSale = this.showBackFromSale.bind(this);
|
||||||
|
this.printInvoice = this.printInvoice.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
showErrors() {}
|
||||||
|
showRevokeConfirmation() {
|
||||||
|
console.log('this.confirmationService', this.confirmationService);
|
||||||
|
|
||||||
|
this.confirmationService.ask({
|
||||||
|
header: `ابطال فاکتور شماره ${this.invoice!.invoice_number}`,
|
||||||
|
message: `در صورت تایید ابطال فاکتور شماره ${this.invoice!.invoice_number} بر روی دکمهی ابطال کلیک کنید.`,
|
||||||
|
acceptLabel: 'ابطال',
|
||||||
|
acceptButtonProps: {
|
||||||
|
severity: 'dangerdock',
|
||||||
|
},
|
||||||
|
|
||||||
|
accept: () => {
|
||||||
|
console.log('here');
|
||||||
|
// this.deferredInstallPrompt.prompt();
|
||||||
|
// this.deferredInstallPrompt.userChoice.finally(() => {
|
||||||
|
// this.deferredInstallPrompt = null;
|
||||||
|
// this.canInstall.set(false);
|
||||||
|
// window.location.reload();
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
showCorrection() {}
|
||||||
|
showBackFromSale() {}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
if (changes['invoice'] && this.invoice) {
|
||||||
|
const invoiceStatus = this.invoice.status.value;
|
||||||
|
const actions: MenuItem[] = [
|
||||||
|
{
|
||||||
|
label: 'دلایل خطا',
|
||||||
|
icon: 'pi pi-question',
|
||||||
|
neededStatus: 'FAILURE',
|
||||||
|
command: this.showErrors,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'ابطال',
|
||||||
|
icon: 'pi pi-eraser',
|
||||||
|
neededStatus: 'SUCCESS',
|
||||||
|
command: this.showRevokeConfirmation,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'اصلاح',
|
||||||
|
icon: 'pi pi-file-edit',
|
||||||
|
neededStatus: 'SUCCESS',
|
||||||
|
command: this.showCorrection,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'برگشت از فروش',
|
||||||
|
icon: 'pi pi-cart-minus',
|
||||||
|
neededStatus: 'SUCCESS',
|
||||||
|
command: this.showBackFromSale,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'چاپ',
|
||||||
|
icon: 'pi pi-print',
|
||||||
|
neededStatus: '',
|
||||||
|
command: this.printInvoice,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
this.moreActionMenuItems.set(
|
||||||
|
actions.filter(
|
||||||
|
// @ts-ignore
|
||||||
|
(action) => !action.neededStatus || action.neededStatus === invoiceStatus
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
readonly posName = computed(() => {
|
readonly posName = computed(() => {
|
||||||
if (this.posInfoStore.entity()) {
|
if (this.posInfoStore.entity()) {
|
||||||
const { name, businessActivity, complex } = this.posInfoStore.entity()!;
|
const { name, businessActivity, complex } = this.posInfoStore.entity()!;
|
||||||
@@ -269,33 +362,50 @@ export class SharedSaleInvoiceSingleViewComponent {
|
|||||||
return `${item.quantity} ${item.measure_unit_text}`;
|
return `${item.quantity} ${item.measure_unit_text}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
field: 'total_amount',
|
|
||||||
header: 'قیمت نهایی',
|
|
||||||
type: 'price',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
expandableColumns: IColumn[] = [
|
|
||||||
{
|
{
|
||||||
field: 'commission',
|
field: 'commission',
|
||||||
header: 'کارمزد',
|
header: 'کارمزد',
|
||||||
|
type: 'nested',
|
||||||
|
nestedOption: {
|
||||||
|
path: 'payload.commission',
|
||||||
type: 'price',
|
type: 'price',
|
||||||
},
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'wages',
|
field: 'wages',
|
||||||
header: 'اجرت',
|
header: 'اجرت',
|
||||||
|
type: 'nested',
|
||||||
|
nestedOption: {
|
||||||
|
path: 'payload.wages',
|
||||||
type: 'price',
|
type: 'price',
|
||||||
},
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'profit',
|
field: 'profit',
|
||||||
header: 'سود',
|
header: 'سود',
|
||||||
|
type: 'nested',
|
||||||
|
nestedOption: {
|
||||||
|
path: 'payload.profit',
|
||||||
|
type: 'price',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'discount_amount',
|
||||||
|
header: 'مبلغ تخفیف',
|
||||||
|
type: 'price',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'tax_amount',
|
||||||
|
header: 'مبلغ مالیات',
|
||||||
|
type: 'price',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'total_amount',
|
||||||
|
header: 'مبلغ قابل پرداخت',
|
||||||
type: 'price',
|
type: 'price',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
expandedRows: { [key: string]: boolean } = {};
|
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.onRefresh.emit();
|
this.onRefresh.emit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,12 +88,12 @@ export class KeyValueComponent {
|
|||||||
}
|
}
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case 'simple':
|
case 'simple':
|
||||||
return this.value || '-';
|
return this.value || '-----';
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType = computed(() =>
|
valueType = computed(() =>
|
||||||
this.variant || ['boolean', 'has', 'active'].includes(this.type) ? 'tag' : 'text',
|
this.variant || ['boolean', 'has', 'active'].includes(this.type) ? 'tag' : 'text'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
<ng-template #paginatorTemplate>
|
<ng-template #paginatorTemplate>
|
||||||
<app-paginator
|
<app-paginator
|
||||||
[currentPage]="currentPage || 1"
|
[currentPage]="currentPage || 1"
|
||||||
[totalRecords]="totalRecords"
|
[totalPages]="totalPages || 1"
|
||||||
[perPage]="perPage || 10"
|
[perPage]="perPage || 10"
|
||||||
[loading]="loading"
|
[loading]="loading"
|
||||||
(onChange)="onPage($event)" />
|
(onChange)="onPage($event)" />
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export class PageDataListComponent<I = any> {
|
|||||||
@Input() emptyPlaceholderTitle: string = 'موردی برای نمایش وجود ندارد';
|
@Input() emptyPlaceholderTitle: string = 'موردی برای نمایش وجود ندارد';
|
||||||
@Input() emptyPlaceholderDescription?: string = '';
|
@Input() emptyPlaceholderDescription?: string = '';
|
||||||
@Input() emptyPlaceholderCtaLabel?: string;
|
@Input() emptyPlaceholderCtaLabel?: string;
|
||||||
@Input() totalRecords!: number;
|
@Input() totalPages?: number = 1;
|
||||||
@Input() perPage?: number = 10;
|
@Input() perPage?: number = 10;
|
||||||
@Input() currentPage?: number = 1;
|
@Input() currentPage?: number = 1;
|
||||||
@Input() showEdit: boolean = false;
|
@Input() showEdit: boolean = false;
|
||||||
@@ -191,7 +191,7 @@ export class PageDataListComponent<I = any> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
get showPaginator() {
|
get showPaginator() {
|
||||||
return !!(this.totalRecords && this.perPage && this.totalRecords > this.perPage);
|
return !!(this.totalPages && this.perPage && this.totalPages > this.perPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPreviewClasses(item: Record<string, any>, column: IColumn): any {
|
getPreviewClasses(item: Record<string, any>, column: IColumn): any {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Maybe } from '@/core';
|
import { Maybe } from '@/core';
|
||||||
import { jalaliToGregorian, nowJalali } from '@/utils';
|
import { nowJalali } from '@/utils';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import {
|
import {
|
||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
@@ -60,8 +60,6 @@ export class UikitFlatpickrJalaliComponent implements AfterViewInit, OnDestroy {
|
|||||||
altFormat: 'Y/m/d',
|
altFormat: 'Y/m/d',
|
||||||
|
|
||||||
onChange: (selectedDates: Date[], dateStr: string) => {
|
onChange: (selectedDates: Date[], dateStr: string) => {
|
||||||
console.log('dateStr', jalaliToGregorian(dateStr));
|
|
||||||
|
|
||||||
this.valueChange.emit(dateStr);
|
this.valueChange.emit(dateStr);
|
||||||
if (this.control) this.control.setValue(dayjs(dateStr).toISOString());
|
if (this.control) this.control.setValue(dayjs(dateStr).toISOString());
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,19 +1,29 @@
|
|||||||
|
@if (totalPages > 1) {
|
||||||
<div class="flex items-center justify-center gap-3 p-4">
|
<div class="flex items-center justify-center gap-3 p-4">
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
icon="pi pi-angle-right"
|
icon="pi pi-angle-right"
|
||||||
size="small"
|
size="small"
|
||||||
severity="secondary"
|
severity="secondary"
|
||||||
|
outlined
|
||||||
[disabled]="loading || currentPage === 1"
|
[disabled]="loading || currentPage === 1"
|
||||||
(click)="prevPage()"
|
(click)="prevPage()"></button>
|
||||||
></button>
|
@for (page of pagesToShow(); track page) {
|
||||||
<span class="text-pretty text-sm text-muted-color">صفحه {{ currentPage }} از {{ totalPages() }}</span>
|
<p-button
|
||||||
|
[label]="page.toString()"
|
||||||
|
size="small"
|
||||||
|
[severity]="page === currentPage ? 'primary' : 'secondary'"
|
||||||
|
[outlined]="page !== currentPage"
|
||||||
|
[disabled]="loading || page === currentPage"
|
||||||
|
(click)="onPageChange(page)"></p-button>
|
||||||
|
}
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
icon="pi pi-angle-left"
|
icon="pi pi-angle-left"
|
||||||
size="small"
|
size="small"
|
||||||
severity="secondary"
|
severity="secondary"
|
||||||
[disabled]="loading || currentPage >= totalPages()"
|
outlined
|
||||||
(click)="nextPage()"
|
[disabled]="loading || currentPage >= totalPages"
|
||||||
></button>
|
(click)="nextPage()"></button>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, EventEmitter, Input, Output, signal } from '@angular/core';
|
import { Component, computed, EventEmitter, Input, Output } from '@angular/core';
|
||||||
import { ButtonModule } from 'primeng/button';
|
import { ButtonModule } from 'primeng/button';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -7,18 +7,31 @@ import { ButtonModule } from 'primeng/button';
|
|||||||
imports: [ButtonModule],
|
imports: [ButtonModule],
|
||||||
})
|
})
|
||||||
export class PaginatorComponent {
|
export class PaginatorComponent {
|
||||||
@Input() totalRecords!: number;
|
@Input() totalPages: number = 1;
|
||||||
@Input() currentPage: number = 1;
|
@Input() currentPage: number = 1;
|
||||||
@Input() perPage: number = 10;
|
@Input() perPage: number = 10;
|
||||||
@Input() loading: boolean = false;
|
@Input() loading: boolean = false;
|
||||||
@Output() onChange = new EventEmitter<number>();
|
@Output() onChange = new EventEmitter<number>();
|
||||||
|
|
||||||
totalPages = signal<number>(0);
|
pagesToShow = computed(() => {
|
||||||
|
const maxVisible = 5;
|
||||||
|
|
||||||
ngOnChanges() {
|
if (this.totalPages <= maxVisible) {
|
||||||
this.totalPages.set(Math.ceil(this.totalRecords / this.perPage));
|
return Array.from({ length: this.totalPages }, (_, i) => i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let start = Math.max(1, this.currentPage - Math.floor(maxVisible / 2));
|
||||||
|
|
||||||
|
let end = start + maxVisible - 1;
|
||||||
|
|
||||||
|
if (end > this.totalPages) {
|
||||||
|
end = this.totalPages;
|
||||||
|
start = end - maxVisible + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Array.from({ length: end - start + 1 }, (_, i) => start + i);
|
||||||
|
});
|
||||||
|
|
||||||
onPageChange(newPage: number) {
|
onPageChange(newPage: number) {
|
||||||
this.onChange.emit(newPage);
|
this.onChange.emit(newPage);
|
||||||
}
|
}
|
||||||
@@ -29,7 +42,7 @@ export class PaginatorComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextPage() {
|
nextPage() {
|
||||||
if (this.currentPage < this.totalPages()) {
|
if (this.currentPage < this.totalPages) {
|
||||||
this.onPageChange(this.currentPage + 1);
|
this.onPageChange(this.currentPage + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export function normalizeToNumber(raw: number | string | null | undefined): numb
|
|||||||
|
|
||||||
export function formatNumber(
|
export function formatNumber(
|
||||||
value: number,
|
value: number,
|
||||||
opts?: { locale?: string; useComma?: boolean; fraction?: number },
|
opts?: { locale?: string; useComma?: boolean; fraction?: number }
|
||||||
): string {
|
): string {
|
||||||
try {
|
try {
|
||||||
const fmtLocale = opts?.useComma ? 'en-US' : (opts?.locale ?? 'fa-IR');
|
const fmtLocale = opts?.useComma ? 'en-US' : (opts?.locale ?? 'fa-IR');
|
||||||
@@ -59,9 +59,9 @@ export function formatWithCurrency(
|
|||||||
num: number | string | null,
|
num: number | string | null,
|
||||||
isInputHost: boolean = false,
|
isInputHost: boolean = false,
|
||||||
currency: string | null | undefined = 'ریال',
|
currency: string | null | undefined = 'ریال',
|
||||||
opts?: { locale?: string; useComma?: boolean; fraction?: number },
|
opts?: { locale?: string; useComma?: boolean; fraction?: number }
|
||||||
): string {
|
): string {
|
||||||
if (num === null) return '';
|
if (num === null) return '0 ریال';
|
||||||
const formatted = formatNumber(parseFloat(num + ''), opts);
|
const formatted = formatNumber(parseFloat(num + ''), opts);
|
||||||
if (isInputHost) return formatted;
|
if (isInputHost) return formatted;
|
||||||
if (currency && currency.trim()) return `${formatted} ${currency.trim()}`;
|
if (currency && currency.trim()) return `${formatted} ${currency.trim()}`;
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: true,
|
production: true,
|
||||||
// apiBaseUrl: 'https://psp-api.shift-am.ir',
|
// apiBaseUrl: 'https://psp-api.shift-am.ir',
|
||||||
apiBaseUrl: 'http://192.168.128.73:5002',
|
// apiBaseUrl: 'http://192.168.128.73:5002',
|
||||||
|
apiBaseUrl: 'http://localhost:5002',
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 5000,
|
port: 5000,
|
||||||
enableLogging: false,
|
enableLogging: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user