Compare commits

..

4 Commits

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