This commit is contained in:
2026-05-12 20:35:04 +03:30
parent cee708209e
commit ebd2aa46dc
2 changed files with 85 additions and 77 deletions
@@ -9,7 +9,7 @@
<button <button
pButton pButton
type="button" type="button"
label="چاپ" label="چاپ کن"
icon="pi pi-print" icon="pi pi-print"
outlined outlined
size="small" size="small"
@@ -1,5 +1,6 @@
import { Maybe } from '@/core'; import { Maybe } from '@/core';
import { NativeBridgeService } from '@/core/services'; import { NativeBridgeService } from '@/core/services';
import { ToastService } from '@/core/services/toast.service';
import { PosInfoStore } from '@/domains/pos/store'; import { PosInfoStore } from '@/domains/pos/store';
import { CatalogTaxProviderStatusTagComponent } from '@/shared/catalog'; import { CatalogTaxProviderStatusTagComponent } from '@/shared/catalog';
import { AppCardComponent, KeyValueComponent } from '@/shared/components'; import { AppCardComponent, KeyValueComponent } from '@/shared/components';
@@ -47,6 +48,7 @@ export type TSaleInvoiceSingleViewVariant = 'full' | 'customer' | 'pos';
export class SharedSaleInvoiceSingleViewComponent { export class SharedSaleInvoiceSingleViewComponent {
private readonly nativeBridge = inject(NativeBridgeService); private readonly nativeBridge = inject(NativeBridgeService);
private readonly posInfoStore = inject(PosInfoStore); private readonly posInfoStore = inject(PosInfoStore);
private readonly toastService = inject(ToastService);
@Input({ required: true }) loading!: boolean; @Input({ required: true }) loading!: boolean;
@Input() invoice!: Maybe<ISaleInvoiceFullResponse>; @Input() invoice!: Maybe<ISaleInvoiceFullResponse>;
@@ -66,82 +68,88 @@ export class SharedSaleInvoiceSingleViewComponent {
}); });
printInvoice = () => { printInvoice = () => {
if (this.invoice) { try {
this.nativeBridge.print([ if (this.invoice) {
{ this.nativeBridge.print([
title: 'اطلاعات صورت‌حساب', {
items: [ title: 'اطلاعات صورت‌حساب',
{ items: [
label: 'شماره منحصر به فرد مالیاتی', {
value: 'this.invoice', label: 'شماره منحصر به فرد مالیاتی',
}, value: 'this.invoice',
{ },
label: 'شماره صورت‌حساب', {
value: this.invoice.code, label: 'شماره صورت‌حساب',
}, value: this.invoice.code,
{ },
label: 'موضوع صورت‌حساب', {
value: 'this.invoice', label: 'موضوع صورت‌حساب',
}, value: 'this.invoice',
{ },
label: 'نوع صورت‌حساب', {
value: 'this.invoice', label: 'نوع صورت‌حساب',
}, value: 'this.invoice',
{ },
label: 'تاریخ و ساعت', {
value: this.invoice.invoice_date, label: 'تاریخ و ساعت',
}, value: this.invoice.invoice_date,
{ },
label: 'وضعیت صورت‌حساب مالیاتی', {
value: this.invoice.status.translate, label: 'وضعیت صورت‌حساب مالیاتی',
}, value: this.invoice.status.translate,
], },
}, ],
{ },
title: `اطلاعات فروشنده`, {
items: [ title: `اطلاعات فروشنده`,
{ items: [
label: 'عنوان فروشگاه', {
value: this.invoice.pos.complex.business_activity.name, label: 'عنوان فروشگاه',
}, value: this.invoice.pos.complex.business_activity.name,
{ },
label: 'عنوان شعبه', {
value: this.invoice.pos.complex.name, label: 'عنوان شعبه',
}, value: this.invoice.pos.complex.name,
{ },
label: 'عنوان پایانه‌ فروش', {
value: this.invoice.pos.name, label: 'عنوان پایانه‌ فروش',
}, value: this.invoice.pos.name,
{ },
label: 'شماره اقتصادی', {
value: 'this.invoice.pos.complex.business_activity.economic_code', label: 'شماره اقتصادی',
}, value: 'this.invoice.pos.complex.business_activity.economic_code',
], },
}, ],
{ },
title: `اطلاعات خریدار`, {
items: [ title: `اطلاعات خریدار`,
{ items: [
label: 'نام خریدار', {
value: label: 'نام خریدار',
(this.invoice.customer value:
? this.invoice.customer.type === 'LEGAL' (this.invoice.customer
? this.invoice.customer.legal?.company_name ? this.invoice.customer.type === 'LEGAL'
: `${this.invoice.customer.individual?.first_name} ${this.invoice.customer.individual?.last_name}` ? this.invoice.customer.legal?.company_name
: this.invoice.unknown_customer?.name) || '-', : `${this.invoice.customer.individual?.first_name} ${this.invoice.customer.individual?.last_name}`
}, : this.invoice.unknown_customer?.name) || '-',
{ },
label: 'شماره اقتصادی', {
value: label: 'شماره اقتصادی',
(this.invoice.customer value:
? this.invoice.customer.type === 'LEGAL' (this.invoice.customer
? this.invoice.customer.legal?.economic_code ? this.invoice.customer.type === 'LEGAL'
: this.invoice.customer.individual?.economic_code || '-' ? this.invoice.customer.legal?.economic_code
: '-') || '-', : this.invoice.customer.individual?.economic_code || '-'
}, : '-') || '-',
], },
}, ],
]); },
]);
}
} catch (error) {
return this.toastService.error({
text: 'چاپ صورت‌حساب با خطا مواجه شد. لطفا دوباره تلاش کنید.',
});
} }
}; };