From fda318add53f0bab8f5e0d12e4ea336699cfd0aa Mon Sep 17 00:00:00 2001 From: ahasani194 Date: Sat, 16 May 2026 18:00:53 +0330 Subject: [PATCH] feat: update ngsw-config.json for app version and build details; refactor invoice components for improved structure and functionality --- ngsw-config.json | 6 +- .../shared-saleInvoice.component.html | 106 ------------- .../invoices/shared-saleInvoice.component.ts | 143 ------------------ .../latest-Invoices.component.html | 2 +- .../latest-Invoices.component.ts | 14 +- .../dashboard/models/saleInvoices.io.d.ts | 16 +- .../dashboard/views/index.component.html | 4 +- .../pos/components/splash.component.ts | 2 - .../domains/pos/layouts/layout.component.ts | 4 +- .../sale-invoice-single-view.component.html | 2 +- .../pageDataList/page-data-value.component.ts | 31 +++- 11 files changed, 57 insertions(+), 273 deletions(-) delete mode 100644 src/app/domains/consumer/components/invoices/shared-saleInvoice.component.html delete mode 100644 src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts diff --git a/ngsw-config.json b/ngsw-config.json index 0f134c2..28333b9 100644 --- a/ngsw-config.json +++ b/ngsw-config.json @@ -1,9 +1,9 @@ { "$schema": "./node_modules/@angular/service-worker/config/schema.json", "appData": { - "appVersion": "0.0.13", - "buildDate": "2026-05-16T11:46:52.423Z", - "buildNumber": 13 + "appVersion": "0.0.14", + "buildDate": "2026-05-16T13:47:08.720Z", + "buildNumber": 14 }, "assetGroups": [ { diff --git a/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.html b/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.html deleted file mode 100644 index f93acdf..0000000 --- a/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.html +++ /dev/null @@ -1,106 +0,0 @@ -@if (loading) { - -} @else if (!invoice) { - -} @else { -
- - - - -
-
- - - - - - -
- -
-
- اطلاعات پرداخت -
- - @for (payment of invoice.payments; track $index) { - - } -
- - اطلاعات صادر کننده -
- - - - -
- - @if (variant !== "customer") { - اطلاعات مشتری - @if (invoice.customer) { -
- @if (invoice.customer.type === "INDIVIDUAL") { - - - - - - - } @else { - - - - - - } -
- } @else if (invoice.unknown_customer) { -
- - - -
- } @else { -

اطلاعات مشتری ثبت نشده است.

- } - } -
-
- - - - @if (!item.discount_amount) { - - } @else { - - } - - - -
-} diff --git a/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts b/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts deleted file mode 100644 index ce8cc4d..0000000 --- a/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts +++ /dev/null @@ -1,143 +0,0 @@ -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'; -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { PriceMaskDirective } from '@/shared/directives'; -import { UikitEmptyStateComponent } from '@/uikit'; -import { formatJalali } from '@/utils'; -import { - Component, - computed, - EventEmitter, - inject, - Input, - Output, - TemplateRef, - ViewChild, -} from '@angular/core'; -import { UrlTree } from '@angular/router'; -import { ButtonDirective } from 'primeng/button'; -import { Divider } from 'primeng/divider'; -import { TableModule } from 'primeng/table'; -import { ISaleInvoiceFullResponse } from '../../models'; - -export type TConsumerSaleInvoice = 'full' | 'customer' | 'pos'; - -@Component({ - selector: 'consumer-saleInvoice-shared', - templateUrl: './shared-saleInvoice.component.html', - imports: [ - AppCardComponent, - KeyValueComponent, - Divider, - ButtonDirective, - PageDataListComponent, - TableModule, - PageLoadingComponent, - UikitEmptyStateComponent, - PriceMaskDirective, - CatalogTaxProviderStatusTagComponent, - ], -}) -export class ConsumerSaleInvoiceSharedComponent { - private readonly nativeBridge = inject(NativeBridgeService); - - @Input({ required: true }) loading!: boolean; - @Input() invoice!: Maybe; - @Input() variant: TConsumerSaleInvoice = 'full'; - @Input() backRoute?: UrlTree | string | any[]; - - @Output() onRefresh = new EventEmitter(); - - @ViewChild('totalAmount', { static: false }) totalAmount!: TemplateRef; - 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.invoice) { - const printResult = this.nativeBridge.print([ - { - title: `فروشگاه ${this.posName()}`, - items: [ - { - label: 'شماره فاکتور', - value: this.invoice?.code, - }, - { label: 'تاریخ', value: formatJalali(this.invoice.invoice_date, 'YYYY/MM/DD') }, - { label: 'مبلغ کل', value: this.invoice.total_amount }, - ], - }, - ]); - } - }; - - columns: IColumn[] = [ - { - field: 'name', - header: 'عنوان', - type: 'nested', - nestedOption: { - path: 'good.name', - }, - }, - { - field: 'sku_code', - header: 'شناسه کالا', - }, - { - field: 'unit_price', - header: 'قیمت واحد', - type: 'price', - }, - { - field: 'quantity', - header: 'مقدار', - customDataModel(item) { - return `${item.quantity} ${item.measure_unit_text}`; - }, - }, - { - field: 'total_amount', - header: 'قیمت نهایی', - type: 'price', - // customDataModel: this.totalAmount, - }, - ]; - - expandableColumns: IColumn[] = [ - { - field: 'commission', - header: 'کارمزد', - type: 'price', - }, - { - field: 'wages', - header: 'اجرت', - type: 'price', - }, - { - field: 'profit', - header: 'سود', - type: 'price', - }, - ]; - - expandedRows: { [key: string]: boolean } = {}; - - refresh() { - this.onRefresh.emit(); - } -} diff --git a/src/app/domains/consumer/modules/dashboard/components/statistics/latestInvoices/latest-Invoices.component.html b/src/app/domains/consumer/modules/dashboard/components/statistics/latestInvoices/latest-Invoices.component.html index 4350a44..4649c94 100644 --- a/src/app/domains/consumer/modules/dashboard/components/statistics/latestInvoices/latest-Invoices.component.html +++ b/src/app/domains/consumer/modules/dashboard/components/statistics/latestInvoices/latest-Invoices.component.html @@ -13,6 +13,6 @@ - + diff --git a/src/app/domains/consumer/modules/dashboard/components/statistics/latestInvoices/latest-Invoices.component.ts b/src/app/domains/consumer/modules/dashboard/components/statistics/latestInvoices/latest-Invoices.component.ts index 2db6912..9c2dc07 100644 --- a/src/app/domains/consumer/modules/dashboard/components/statistics/latestInvoices/latest-Invoices.component.ts +++ b/src/app/domains/consumer/modules/dashboard/components/statistics/latestInvoices/latest-Invoices.component.ts @@ -1,9 +1,9 @@ import { consumerSaleInvoicesNamedRoutes } from '@/domains/consumer/modules/saleInvoices/constants'; import { AbstractList } from '@/shared/abstractClasses'; +import { CatalogTaxProviderStatusTagComponent } from '@/shared/catalog'; import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component'; import { Component, inject, TemplateRef, ViewChild } from '@angular/core'; import { Router, RouterLink } from '@angular/router'; -import { Badge } from 'primeng/badge'; import { ButtonDirective } from 'primeng/button'; import { IStatisticsSaleInvoicesResponse } from '../../../models'; import { CustomerStatisticsService } from '../../../services/main.service'; @@ -11,7 +11,12 @@ import { CustomerStatisticsService } from '../../../services/main.service'; @Component({ selector: 'consumer-statistics-latest-Invoices', templateUrl: './latest-Invoices.component.html', - imports: [PageDataListComponent, ButtonDirective, RouterLink, Badge], + imports: [ + PageDataListComponent, + ButtonDirective, + RouterLink, + CatalogTaxProviderStatusTagComponent, + ], }) export class ConsumerStatisticsLatestInvoicesComponent extends AbstractList { @ViewChild('status', { static: true }) status!: TemplateRef; @@ -38,6 +43,11 @@ export class ConsumerStatisticsLatestInvoicesComponent extends AbstractList; } export interface IStatisticsSaleInvoicesResponse extends IStatisticsSaleInvoicesRawResponse {} diff --git a/src/app/domains/consumer/modules/dashboard/views/index.component.html b/src/app/domains/consumer/modules/dashboard/views/index.component.html index 333412c..9c9bdf7 100644 --- a/src/app/domains/consumer/modules/dashboard/views/index.component.html +++ b/src/app/domains/consumer/modules/dashboard/views/index.component.html @@ -1,5 +1,3 @@
-
- -
+
diff --git a/src/app/domains/pos/components/splash.component.ts b/src/app/domains/pos/components/splash.component.ts index 6afa8ea..0709be6 100644 --- a/src/app/domains/pos/components/splash.component.ts +++ b/src/app/domains/pos/components/splash.component.ts @@ -1,7 +1,6 @@ import { brandingConfig } from '@/branding/branding.config'; import { PwaInstallService } from '@/core/services'; import { Component, EventEmitter, inject, Output } from '@angular/core'; -import { ButtonDirective } from 'primeng/button'; import { finalize, forkJoin } from 'rxjs'; import images from 'src/assets/images'; import { PosInfoStore, PosProfileStore } from '../store'; @@ -10,7 +9,6 @@ import { DeviceInfoStore } from '../store/device.store'; @Component({ selector: 'pos-splash', templateUrl: 'splash.component.html', - imports: [ButtonDirective], }) export class PosSplashComponent { @Output() onComplete = new EventEmitter(); diff --git a/src/app/domains/pos/layouts/layout.component.ts b/src/app/domains/pos/layouts/layout.component.ts index 55508ae..bab3185 100644 --- a/src/app/domains/pos/layouts/layout.component.ts +++ b/src/app/domains/pos/layouts/layout.component.ts @@ -1,6 +1,6 @@ import { CommonModule } from '@angular/common'; import { Component, computed, inject, signal } from '@angular/core'; -import { NavigationEnd, Router, RouterOutlet } from '@angular/router'; +import { NavigationEnd, Router } from '@angular/router'; import { filter } from 'rxjs'; import { PosSplashComponent } from '../components/splash.component'; import { PosPagesLayoutComponent } from './pagesLayout/layout.component'; @@ -8,7 +8,7 @@ import { PosPagesLayoutComponent } from './pagesLayout/layout.component'; @Component({ selector: 'pos-layout', templateUrl: 'layout.component.html', - imports: [PosSplashComponent, PosPagesLayoutComponent, RouterOutlet, CommonModule], + imports: [PosSplashComponent, PosPagesLayoutComponent, CommonModule], }) export class PosLayoutComponent { private readonly router = inject(Router); diff --git a/src/app/shared/components/invoices/sale-invoice-single-view.component.html b/src/app/shared/components/invoices/sale-invoice-single-view.component.html index 5970517..e833fe9 100644 --- a/src/app/shared/components/invoices/sale-invoice-single-view.component.html +++ b/src/app/shared/components/invoices/sale-invoice-single-view.component.html @@ -33,7 +33,7 @@ @for (payment of invoice.payments; track $index) { diff --git a/src/app/shared/components/pageDataList/page-data-value.component.ts b/src/app/shared/components/pageDataList/page-data-value.component.ts index e36c862..784e355 100644 --- a/src/app/shared/components/pageDataList/page-data-value.component.ts +++ b/src/app/shared/components/pageDataList/page-data-value.component.ts @@ -1,8 +1,8 @@ -import { formatJalali, formatWithCurrency, jalaliDiff } from '@/utils'; +import { UikitCopyComponent } from '@/uikit'; +import { formatJalali, formatWithCurrency, JALALI_DATE_FORMATS, jalaliDiff } from '@/utils'; import { CommonModule } from '@angular/common'; import { Component, EventEmitter, Input, Output, TemplateRef } from '@angular/core'; import { Tag } from 'primeng/tag'; -import { UikitCopyComponent } from '@/uikit'; import { IColumn } from './page-data-list.component'; @Component({ @@ -11,15 +11,24 @@ import { IColumn } from './page-data-list.component'; imports: [CommonModule, Tag, UikitCopyComponent], template: ` @if (column.type === 'thumbnail') { -
+
@if (readFieldValue(item, column.field)) { }
} @else if (column.variant === 'tag') { - + } @else if (getTemplate(column)) { - + } @else if (column.canCopy) { } @else { @@ -39,7 +48,11 @@ export class PageDataValueComponent { getPreviewClasses(item: Record, column: IColumn): string { if (!item || !column || column.customDataModel) return ''; const data = item[String(column.field)]; - if (column.type === 'date' && column.dateOption?.expiredMode && jalaliDiff(new Date(), data) > 0) { + if ( + column.type === 'date' && + column.dateOption?.expiredMode && + jalaliDiff(new Date(), data) > 0 + ) { return 'text-error'; } return ''; @@ -57,7 +70,9 @@ export class PageDataValueComponent { if (column.type === 'nested') { const path = column.nestedOption?.path; if (!path) return '-'; - data = path.split('.').reduce((obj: any, key: string) => (obj && obj[key] !== undefined ? obj[key] : null), item); + data = path + .split('.') + .reduce((obj: any, key: string) => (obj && obj[key] !== undefined ? obj[key] : null), item); type = column.nestedOption?.type || 'simple'; } @@ -66,6 +81,8 @@ export class PageDataValueComponent { return data ? `${data.slice(0, 5)}...${data.slice(data.length - 5)}` : '-'; case 'date': return data ? formatJalali(data) : '-'; + case 'dateTime': + return data ? formatJalali(data, JALALI_DATE_FORMATS.NUMERIC_WITH_TIME) : '-'; case 'boolean': return data ? 'بله' : 'خیر'; case 'price':