remove unused codes and update

This commit is contained in:
2026-05-10 09:44:30 +03:30
parent a138034c06
commit 048e292bdd
107 changed files with 317 additions and 17930 deletions
@@ -91,7 +91,6 @@
[showRefresh]="false"
>
<ng-template #totalAmount let-item>
aaa
@if (!item.discount_amount) {
<span [appPriceMask]="item.total_amount"></span>
} @else {
@@ -1,5 +1,6 @@
import { Maybe } from '@/core';
import { NativeBridgeService } from '@/core/services';
import { PosInfoStore } from '@/domains/pos/store';
import { CatalogTaxProviderStatusTagComponent } from '@/shared/catalog';
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
@@ -9,9 +10,10 @@ import {
} from '@/shared/components/pageDataList/page-data-list.component';
import { PriceMaskDirective } from '@/shared/directives';
import { UikitEmptyStateComponent } from '@/uikit';
import { getGoodUnitTypeProperties } from '@/utils';
import { formatJalali, getGoodUnitTypeProperties } from '@/utils';
import {
Component,
computed,
EventEmitter,
inject,
Input,
@@ -54,22 +56,30 @@ export class ConsumerSaleInvoiceSharedComponent {
@Output() onRefresh = new EventEmitter<void>();
@ViewChild('totalAmount', { static: false }) totalAmount!: TemplateRef<any>;
private readonly posInfoStore = inject(PosInfoStore);
readonly posName = computed(() => {
if (this.posInfoStore.entity()) {
const { name, businessActivity, complex } = this.posInfoStore.entity()!;
return `${name} (${businessActivity.name} - ${complex.name})`;
}
return '';
});
printInvoice = () => {
if (this.nativeBridge.isEnabled() && this.invoice) {
const result = this.nativeBridge.print({
title: 'salam',
if (this.invoice) {
const printResult = this.nativeBridge.print({
title: `فروشگاه ${this.posName()}`,
items: [
{
label: 'مجموع قیمت',
value: this.invoice?.total_amount,
label: 'شماره فاکتور',
value: this.invoice?.code,
},
{ label: 'تاریخ', value: formatJalali(this.invoice.invoice_date, 'YYYY/MM/DD') },
{ label: 'مبلغ کل', value: this.invoice.total_amount },
],
});
if (result.success) return;
}
window.print();
};
columns: IColumn[] = [
@@ -4,7 +4,7 @@
<ng-template #topbarCenter>
@if (posInfo()) {
<div class="flex flex-col items-center justify-center gap-2">
<a [routerLink]="homeRouteLink" class="flex flex-col items-center justify-center gap-2">
<div class="w-8 h-8">
<img
[src]="posInfo()?.partner?.logo_url ?? placeholderLogo"
@@ -13,14 +13,14 @@
/>
</div>
<span class="text-base font-semibold">{{ posInfo()?.partner?.name }}</span>
</div>
</a>
}
</ng-template>
<ng-template #topbarEnd>
<div class="">
<p-menu #menu [model]="profileMenuItems" [popup]="true" />
<p-button (click)="menu.toggle($event)" icon="pi pi-user" text outlined size="large" />
<p-button (click)="menu.toggle($event)" icon="pi pi-user" outlined size="large" />
</div>
</ng-template>
@@ -32,7 +32,7 @@
>
@if (pullDistance() >= 0) {
<div
class="w-full flex justify-center items-center py-2 min-h-10 text-xs text-surface-500 overflow-hidden fixed top-0 inset-x-0 z-1000 translate-y--20px"
class="w-full flex justify-center items-center py-2 min-h-10 text-xs text-surface-500 overflow-hidden fixed top-0 inset-x-0 z-1000 translate-y-[-20px]"
[ngStyle]="{ height: pullDistance() + 'px' }"
>
<div
@@ -1,6 +1,4 @@
import { AuthService } from '@/core';
import { NativeBridgeService } from '@/core/services';
import { ToastService } from '@/core/services/toast.service';
import { LayoutService } from '@/layout/service/layout.service';
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
import { CommonModule } from '@angular/common';
@@ -13,13 +11,15 @@ import {
inject,
signal,
} from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { RouterLinkWithHref, RouterOutlet } from '@angular/router';
import { MenuItem } from 'primeng/api';
import { Button, ButtonDirective } from 'primeng/button';
import { Card } from 'primeng/card';
import { Menu } from 'primeng/menu';
import { finalize } from 'rxjs';
import images from 'src/assets/images';
import { PosInfoStore, PosProfileStore } from '../store';
import { DeviceInfoStore } from '../store/device.store';
import { PosChooseCardsComponent } from './choose-pos.component';
import { PosMainMenuSidebarComponent } from './mainMenuSidebar/main-menu-sidebar.component';
@@ -36,13 +36,14 @@ import { PosMainMenuSidebarComponent } from './mainMenuSidebar/main-menu-sidebar
PosMainMenuSidebarComponent,
Menu,
CommonModule,
RouterLinkWithHref,
],
})
export class PosLayoutComponent implements AfterViewInit {
constructor() {}
private readonly nativeBridgeService = inject(NativeBridgeService);
private readonly toastService = inject(ToastService);
// private readonly nativeBridgeService = inject(NativeBridgeService);
// private readonly toastService = inject(ToastService);
@ViewChild('topbarStart', { static: true }) topbarStart!: TemplateRef<any>;
@ViewChild('topbarCenter', { static: true }) topbarCenter!: TemplateRef<any>;
@@ -50,6 +51,7 @@ export class PosLayoutComponent implements AfterViewInit {
private readonly posProfileStore = inject(PosProfileStore);
private readonly posInfoStore = inject(PosInfoStore);
private readonly deviceInfoStore = inject(DeviceInfoStore);
private readonly authService = inject(AuthService);
private readonly layoutService = inject(LayoutService);
@@ -66,6 +68,8 @@ export class PosLayoutComponent implements AfterViewInit {
readonly loading = computed(() => this.posProfileLoading());
readonly error = computed(() => this.posProfileError());
readonly deviceInfo = computed(() => this.deviceInfoStore.entity());
logout = () => {
this.authService.logout();
};
@@ -91,10 +95,21 @@ export class PosLayoutComponent implements AfterViewInit {
pullDistance = signal(0);
readonly pullThreshold = 80;
getData() {
this.posProfileStore.getData().subscribe({
homeRouteLink = '/pos';
async getData() {
await this.layoutService.changeFullPageLoading(true);
await this.deviceInfoStore.getData();
await this.posProfileStore.getData().subscribe({
next: () => {
this.posInfoStore.getData().subscribe();
this.posInfoStore
.getData()
.pipe(
finalize(() => {
this.layoutService.changeFullPageLoading(false);
}),
)
.subscribe();
},
});
}
@@ -37,8 +37,11 @@ export class PosMainMenuSidebarComponent extends AbstractDialog {
.then((res) => res.json())
.then((data: { appData?: { appVersion?: string } }) => {
this.appVersion = data?.appData?.appVersion || this.appVersion;
console.log('appVersion:', data?.appData);
})
.catch(() => {});
.catch((err) => {
console.log('err', err);
});
this.swUpdate.versionUpdates
.pipe(filter((event): event is VersionReadyEvent => event.type === 'VERSION_READY'))
+6
View File
@@ -0,0 +1,6 @@
export interface IDeviceProfileRawResponse {
androidId: string;
deviceName: string;
}
export interface IDeviceProfileResponse extends IDeviceProfileRawResponse {}
+1
View File
@@ -1,3 +1,4 @@
export * from './device.io';
export * from './good.io';
export * from './pos.io';
export * from './profile.io';
@@ -28,7 +28,7 @@ export class PosOrderCustomerDialogComponent extends AbstractDialog {
customerTypes = [
{
label: 'بدون اطلاعات (نوع دوم)',
label: 'نوع دوم',
value: 'UNKNOWN',
},
{
@@ -12,7 +12,7 @@
</div>
<div class="flex gap-2 justify-center">
<button pButton type="button" outlined (click)="printInvoice()">چاپ</button>
<button pButton type="button" outlined (click)="sendToTsp()">ارسال به سامانه مودیان</button>
<button pButton type="button" outlined (click)="sendInvoice()">ارسال به سامانه مودیان</button>
<button pButton type="button" outlined (click)="openOrderDetails()">جزئیات</button>
</div>
</shared-dialog>
@@ -1,10 +1,14 @@
import { NativeBridgeService } from '@/core/services';
import { ToastService } from '@/core/services/toast.service';
import { PosInfoStore } from '@/domains/pos/store';
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
import { SharedDialogComponent } from '@/shared/components';
import { Component, inject, Input, signal } from '@angular/core';
import { formatJalali } from '@/utils';
import { Component, computed, inject, Input, signal } from '@angular/core';
import { Router } from '@angular/router';
import { ButtonDirective } from 'primeng/button';
import { finalize } from 'rxjs';
import { posSaleInvoicesNamedRoutes } from '../../../saleInvoices/constants';
import { PosSaleInvoicesService } from '../../../saleInvoices/services/main.service';
import { IPosOrderResponse } from '../../models';
@@ -18,12 +22,24 @@ export class PosOrderSubmittedDialogComponent extends AbstractDialog {
private readonly nativeBridgeService = inject(NativeBridgeService);
private readonly service = inject(PosSaleInvoicesService);
private readonly toastService = inject(ToastService);
private readonly posInfoStore = inject(PosInfoStore);
private readonly router = inject(Router);
readonly posName = computed(() => {
if (this.posInfoStore.entity()) {
const { name, businessActivity, complex } = this.posInfoStore.entity()!;
return `${name} (${businessActivity.name} - ${complex.name})`;
}
return '';
});
sendingLoading = signal(false);
sended = signal(false);
openOrderDetails() {
this.close();
this.router.navigateByUrl(
posSaleInvoicesNamedRoutes.saleInvoice.meta.pagePath!(this.invoice.id),
);
}
sendInvoice() {
@@ -39,15 +55,14 @@ export class PosOrderSubmittedDialogComponent extends AbstractDialog {
printInvoice() {
const printResult = this.nativeBridgeService.print({
title: 'رسید پرداخت',
title: `فروشگاه ${this.posName()}`,
items: [
{ label: 'مبلغ کل', value: String(this.invoice.code) },
// { label: 'نقدی', value: String(this.invoice.payment.cash || 0) },
// { label: 'تهاتر', value: String(this.invoice.payment.set_off || 0) },
// {
// label: 'پایانه',
// value: String((this.invoice.payment.terminals || []).reduce((acc, item) => acc + item, 0)),
// },
{
label: 'شماره فاکتور',
value: this.invoice.code,
},
{ label: 'تاریخ', value: formatJalali(this.invoice.invoice_date, 'YYYY/MM/DD') },
{ label: 'مبلغ کل', value: this.invoice.total_amount },
],
});
}
@@ -247,7 +247,7 @@ export class PosPaymentFormDialogComponent extends AbstractFormDialog<IPayment,
(terminal) => terminal.value!,
);
this.selectedPayByTerminalStep.set(terminalPayments.length);
this.selectedPayByTerminalStep.set(terminalPayments.length || 1);
if (terminalPayments.length) {
if (this.nativeBridgeService.isEnabled()) {
+15 -1
View File
@@ -1,5 +1,7 @@
import { IPosInfoRawResponse } from '@/domains/pos/models';
import { CustomerType } from '@/shared/localEnum/constants/customerTypes';
import { ICustomer } from './customer';
import { IEnumTranslate } from '@/shared/models/enum_translate.type';
import { ICustomer, IUnknownCustomer } from './customer';
import { IPayment } from './payment';
import { IPosOrderItem } from './types';
@@ -17,5 +19,17 @@ export interface IPosOrderRequest {
export interface IPosOrderRawResponse {
id: string;
code: string;
invoice_number: number;
invoice_date: string;
created_at: string;
total_amount: string;
customer: ICustomer;
unknown_customer: IUnknownCustomer;
status: IEnumTranslate;
}
export interface IPosOrderResponse extends IPosOrderRawResponse {}
export interface IPosInfoResponse extends IPosInfoRawResponse {}
export interface IPosHeldOrderRawResponse extends IPosOrderResponse {}
export interface IPosHeldOrderResponse extends IPosHeldOrderRawResponse {}
@@ -6,9 +6,11 @@
<div class="grow min-h-[calc(100dvh-5.5rem)]">
<pos-goods class="block h-full" />
</div>
<div class="md:shrink-0 h-full md:block hidden p-4 overflow-auto">
<pos-order-section />
</div>
@if (!isMobile()) {
<div class="md:shrink-0 h-full md:block hidden p-4 overflow-auto">
<pos-order-section />
</div>
}
</div>
</div>
@@ -39,7 +41,9 @@
[closable]="true"
header="فاکتور"
>
<pos-order-section (onAddMoreGoods)="closeInvoiceBottomSheet()" (onSuccess)="onSuccessSubmit($event)" />
@if (showInvoiceBottomSheet()) {
<pos-order-section (onAddMoreGoods)="closeInvoiceBottomSheet()" (onSuccess)="onSuccessSubmit($event)" />
}
</shared-dialog>
@if (responseInvoice()) {
@@ -1,6 +1,7 @@
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
import { Maybe } from '@/core';
import { PosInfoStore } from '@/domains/pos/store/pos.store';
import { AbstractIsMobileComponent } from '@/shared/abstractClasses/abstract-is-mobile';
import { SharedDialogComponent } from '@/shared/components';
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
import { PriceMaskDirective } from '@/shared/directives';
@@ -27,7 +28,7 @@ import { PosLandingStore } from '../store/main.store';
PosOrderSubmittedDialogComponent,
],
})
export class PosLandingComponent {
export class PosLandingComponent extends AbstractIsMobileComponent {
private readonly infoStore = inject(PosInfoStore);
private readonly landingStore = inject(PosLandingStore);
@@ -0,0 +1,3 @@
export * from './filter-drawer.component';
export * from './list.component';
export * from './sale-invoice-card.component';
@@ -68,7 +68,14 @@ export class SaleInvoiceCardComponent {
this.service
.sendToTsp(this.saleInvoice.id)
.pipe(finalize(() => this.sendingLoading.set(false)))
.subscribe(() => {
.subscribe((res) => {
if (res.status === 'FAILURE') {
this.toastService.error({
text: res.message || 'خطا در ارسال فاکتور رخ داده است.',
});
} else {
this.toastService.success({ text: 'ارسال فاکتور با موفقیت انجام شد.' });
}
this.toastService.success({ text: 'ارسال فاکتور با موفقیت انجام شد.' });
this.refreshRequested.emit();
});
@@ -89,8 +96,12 @@ export class SaleInvoiceCardComponent {
this.service
.retrySendToTsp(this.saleInvoice.id)
.pipe(finalize(() => this.resendingLoading.set(false)))
.subscribe(() => {
this.toastService.success({ text: 'ارسال مجدد فاکتور با موفقیت انجام شد.' });
.subscribe((res) => {
if (res.status === 'FAILURE') {
this.toastService.error({ text: res.message || 'خطا در ارسال مجدد فاکتور رخ داده است.' });
} else {
this.toastService.success({ text: 'ارسال مجدد فاکتور با موفقیت انجام شد.' });
}
this.refreshRequested.emit();
});
}
@@ -7,7 +7,7 @@ export const POS_SALE_INVOICES_API_ROUTES = {
send: (invoiceId: string) => `${baseUrl()}/${invoiceId}/send`,
getInquiry: (invoiceId: string) => `${baseUrl()}/${invoiceId}/inquiry`,
revoke: (invoiceId: string) => `${baseUrl()}/${invoiceId}/revoke`,
retry: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/retry`,
retry: (invoiceId: string) => `${baseUrl()}/${invoiceId}/retry`,
status: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/status`,
attempts: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/attempts`,
},
+45
View File
@@ -0,0 +1,45 @@
import { NativeBridgeService } from '@/core/services';
import { defaultBaseStateData, EntityState, EntityStore } from '@/core/state';
import { HttpErrorResponse } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { IDeviceProfileResponse } from '../models';
interface DeviceInfoState extends EntityState<IDeviceProfileResponse> {}
@Injectable({
providedIn: 'root',
})
export class DeviceInfoStore extends EntityStore<IDeviceProfileResponse, DeviceInfoState> {
private readonly nativeBridgeService = inject(NativeBridgeService);
constructor() {
super({
...defaultBaseStateData,
});
}
async getData() {
this.patchState({ loading: true });
if (this.nativeBridgeService.isEnabled()) {
const deviceInfoRes = await this.nativeBridgeService.getDeviceInfo();
if (deviceInfoRes.success && deviceInfoRes.data) {
const deviceInfo = deviceInfoRes.data;
this.setEntity({
deviceName: deviceInfo.deviceName,
androidId: deviceInfo.androidId,
});
} else {
this.setError(
new HttpErrorResponse({ error: deviceInfoRes.error || 'Failed to get device info' }),
);
}
}
this.patchState({ loading: true });
}
override reset(): void {
this.setState({
...defaultBaseStateData,
});
}
}