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