feat: update ngsw-config.json for app version and build details; refactor invoice components for improved structure and functionality
This commit is contained in:
@@ -1,106 +0,0 @@
|
||||
@if (loading) {
|
||||
<shared-page-loading />
|
||||
} @else if (!invoice) {
|
||||
<uikit-empty-state> </uikit-empty-state>
|
||||
} @else {
|
||||
<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>
|
||||
</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_date" type="dateTime" />
|
||||
<app-key-value label="تاریخ ایجاد فاکتور" [value]="invoice.created_at" type="dateTime" />
|
||||
<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" />
|
||||
</div>
|
||||
</div>
|
||||
<p-divider align="center"> اطلاعات پرداخت </p-divider>
|
||||
<div class="grid md:grid-cols-3 sm:grid-cols-2 sm:gap-4 gap-3 items-center">
|
||||
<app-key-value label="مجموع قابل پرداخت" [value]="invoice.total_amount" type="price" />
|
||||
@for (payment of invoice.payments; track $index) {
|
||||
<app-key-value
|
||||
[label]="`${payment.payment_method === 'SET_OF' ? 'تهاتر' : payment.payment_method === 'TERMINAL' ? 'پایانه' : 'نقدی'}`"
|
||||
[value]="payment.amount"
|
||||
type="price"
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
|
||||
<p-divider align="center"> اطلاعات صادر کننده </p-divider>
|
||||
<div class="listKeyValue">
|
||||
<app-key-value label="کسب و کار" [value]="invoice.pos!.complex.business_activity.name" />
|
||||
<app-key-value label="مجموعه" [value]="invoice.pos!.complex.name" />
|
||||
<app-key-value label="پایانه فروش" [value]="invoice.pos!.name" />
|
||||
<app-key-value label="ایجاد کننده" [value]="invoice.consumer_account.account.username" />
|
||||
</div>
|
||||
|
||||
@if (variant !== "customer") {
|
||||
<p-divider align="center"> اطلاعات مشتری </p-divider>
|
||||
@if (invoice.customer) {
|
||||
<div class="listKeyValue">
|
||||
@if (invoice.customer.type === "INDIVIDUAL") {
|
||||
<app-key-value label="نوع مشتری" value="حقیقی" />
|
||||
<app-key-value label="نام" [value]="invoice.customer.individual?.first_name" />
|
||||
<app-key-value label="نام خانوادگی" [value]="invoice.customer.individual?.last_name" />
|
||||
<app-key-value label="کد اقتصادی" [value]="invoice.customer.individual?.economic_code" />
|
||||
<app-key-value label="کد ملی" [value]="invoice.customer.individual?.national_id" />
|
||||
<app-key-value label="کد پستی" [value]="invoice.customer.individual?.postal_code" />
|
||||
} @else {
|
||||
<app-key-value label="نوع مشتری" value="حقوقی" />
|
||||
<app-key-value label="نام شرکت" [value]="invoice.customer.legal?.company_name" />
|
||||
<app-key-value label="کد اقتصادی" [value]="invoice.customer.legal?.economic_code" />
|
||||
<app-key-value label="کد ثبتی" [value]="invoice.customer.legal?.registration_number" />
|
||||
<app-key-value label="کد پستی" [value]="invoice.customer.legal?.postal_code" />
|
||||
}
|
||||
</div>
|
||||
} @else if (invoice.unknown_customer) {
|
||||
<div class="listKeyValue">
|
||||
<app-key-value label="نوع مشتری" value="نوع دوم" />
|
||||
<app-key-value label="عنوان" [value]="invoice.unknown_customer.name" />
|
||||
<app-key-value label="کد ثبتی" [value]="invoice.unknown_customer.national_code" />
|
||||
</div>
|
||||
} @else {
|
||||
<p class="text-center text-text-color pt-3 pb-5">اطلاعات مشتری ثبت نشده است.</p>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</app-card-data>
|
||||
<app-card-data cardTitle="کالاهای خریداری شده" [editable]="false">
|
||||
<app-page-data-list
|
||||
[columns]="columns"
|
||||
[expandColumns]="expandableColumns"
|
||||
[expandable]="true"
|
||||
expandableItemKey="payload"
|
||||
[items]="invoice.items"
|
||||
[loading]="loading"
|
||||
pageTitle=""
|
||||
[showRefresh]="false"
|
||||
>
|
||||
<ng-template #totalAmount let-item>
|
||||
@if (!item.discount_amount) {
|
||||
<span [appPriceMask]="item.total_amount"></span>
|
||||
} @else {
|
||||
<!-- <div class="flex flex-col items-end">
|
||||
<span class="line-through text-muted-color text-xs" [appPriceMask]="item.total_amount"></span>
|
||||
<span [appPriceMask]="item.total_amount - item.discount_amount"></span>
|
||||
</div> -->
|
||||
}
|
||||
</ng-template>
|
||||
</app-page-data-list>
|
||||
</app-card-data>
|
||||
</div>
|
||||
}
|
||||
@@ -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<ISaleInvoiceFullResponse>;
|
||||
@Input() variant: TConsumerSaleInvoice = 'full';
|
||||
@Input() backRoute?: UrlTree | string | any[];
|
||||
|
||||
@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.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();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -13,6 +13,6 @@
|
||||
</ng-template>
|
||||
|
||||
<ng-template #status let-item>
|
||||
<p-badge value="ارسال نشده" severity="danger" />
|
||||
<catalog-tax-provider-status-tag [status]="item.status.value" [translate]="item.status.translate" />
|
||||
</ng-template>
|
||||
</app-page-data-list>
|
||||
|
||||
+12
-2
@@ -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<IStatisticsSaleInvoicesResponse> {
|
||||
@ViewChild('status', { static: true }) status!: TemplateRef<any>;
|
||||
@@ -38,6 +43,11 @@ export class ConsumerStatisticsLatestInvoicesComponent extends AbstractList<ISta
|
||||
type: 'nested',
|
||||
nestedOption: { path: 'consumer_account.account.username' },
|
||||
},
|
||||
{
|
||||
field: 'invoice_date',
|
||||
header: 'تاریخ فاکتور',
|
||||
type: 'dateTime',
|
||||
},
|
||||
{ field: 'status', header: 'وضعیت صدور', customDataModel: this.status },
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
import ISummary from '@/core/models/summary';
|
||||
import { TspProviderResponseStatus } from '@/shared/catalog';
|
||||
|
||||
export interface IStatisticsSaleInvoicesRawResponse {
|
||||
id: string;
|
||||
code: string;
|
||||
created_at: string;
|
||||
created_date?: string;
|
||||
invoice_date: string;
|
||||
invoice_number: number;
|
||||
main_id?: string;
|
||||
total_amount: string;
|
||||
pos: Pos;
|
||||
tax_id?: string;
|
||||
type: string;
|
||||
notes?: string;
|
||||
created_at: string;
|
||||
reference_invoice?: string;
|
||||
consumer_account: ConsumerAccount;
|
||||
pos: Pos;
|
||||
status: Status;
|
||||
customer: Customer;
|
||||
status: IEnumTranslate<TspProviderResponseStatus>;
|
||||
}
|
||||
export interface IStatisticsSaleInvoicesResponse extends IStatisticsSaleInvoicesRawResponse {}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
<div class="flex gap-10">
|
||||
<div class="h-75 flex w-full">
|
||||
<consumer-statistics-latest-Invoices class="w-full" />
|
||||
</div>
|
||||
<consumer-statistics-latest-Invoices class="w-full" />
|
||||
</div>
|
||||
|
||||
@@ -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<void>();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<app-key-value label="مجموع قابل پرداخت" [value]="invoice.total_amount" type="price" />
|
||||
@for (payment of invoice.payments; track $index) {
|
||||
<app-key-value
|
||||
[label]="`${payment.payment_method === 'SET_OF' ? 'تهاتر' : payment.payment_method === 'TERMINAL' ? 'پایانه' : 'نقدی'}`"
|
||||
[label]="`${payment.payment_method === 'SET_OFF' ? 'تهاتر' : payment.payment_method === 'TERMINAL' ? 'پایانه' : 'نقدی'}`"
|
||||
[value]="payment.amount"
|
||||
type="price"
|
||||
/>
|
||||
|
||||
@@ -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') {
|
||||
<div class="w-20 h-20 rounded-2xl overflow-hidden bg-surface-100 cursor-pointer" (click)="thumbnailClick.emit(item)">
|
||||
<div
|
||||
class="w-20 h-20 rounded-2xl overflow-hidden bg-surface-100 cursor-pointer"
|
||||
(click)="thumbnailClick.emit(item)"
|
||||
>
|
||||
@if (readFieldValue(item, column.field)) {
|
||||
<img [src]="readFieldValue(item, column.field)" class="w-full h-full object-cover" />
|
||||
}
|
||||
</div>
|
||||
} @else if (column.variant === 'tag') {
|
||||
<p-tag [value]="getCell(item, column)" [severity]="column.tagOptions?.severity || 'contrast'"></p-tag>
|
||||
<p-tag
|
||||
[value]="getCell(item, column)"
|
||||
[severity]="column.tagOptions?.severity || 'contrast'"
|
||||
></p-tag>
|
||||
} @else if (getTemplate(column)) {
|
||||
<ng-container [ngTemplateOutlet]="getTemplate(column)" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
|
||||
<ng-container
|
||||
[ngTemplateOutlet]="getTemplate(column)"
|
||||
[ngTemplateOutletContext]="{ $implicit: item }"
|
||||
></ng-container>
|
||||
} @else if (column.canCopy) {
|
||||
<uikit-copy [text]="getCell(item, column)"></uikit-copy>
|
||||
} @else {
|
||||
@@ -39,7 +48,11 @@ export class PageDataValueComponent {
|
||||
getPreviewClasses(item: Record<string, any>, 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':
|
||||
|
||||
Reference in New Issue
Block a user