From 4e4cc08224efc6404ed8ea927fdcf20a04d37748 Mon Sep 17 00:00:00 2001 From: ahasani194 Date: Wed, 17 Jun 2026 10:03:06 +0330 Subject: [PATCH] feat: enhance invoice handling with success messages and payment data integration --- .../modules/saleInvoices/models/fiscal.io.ts | 2 ++ .../saleInvoices/views/single.component.ts | 21 ++++++++++++++++--- .../sale-invoice-single-view.component.ts | 15 ++++++++++--- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/app/domains/pos/modules/saleInvoices/models/fiscal.io.ts b/src/app/domains/pos/modules/saleInvoices/models/fiscal.io.ts index 73e6392..3f608f3 100644 --- a/src/app/domains/pos/modules/saleInvoices/models/fiscal.io.ts +++ b/src/app/domains/pos/modules/saleInvoices/models/fiscal.io.ts @@ -1,6 +1,8 @@ import { TspProviderResponseStatus } from '@/shared/catalog'; +import { IPosSaleInvoicesSummaryResponse } from './io'; export interface IPosSaleInvoiceFiscalActionResponse { + invoice: IPosSaleInvoicesSummaryResponse; message?: string; status: TspProviderResponseStatus; } diff --git a/src/app/domains/pos/modules/saleInvoices/views/single.component.ts b/src/app/domains/pos/modules/saleInvoices/views/single.component.ts index 2d11ba1..d8c231d 100644 --- a/src/app/domains/pos/modules/saleInvoices/views/single.component.ts +++ b/src/app/domains/pos/modules/saleInvoices/views/single.component.ts @@ -94,7 +94,12 @@ export class PosSaleInvoiceComponent { this.correctionLoading.set(false); }) ) - .subscribe(); + .subscribe((res) => { + this.toastService.success({ + text: `اصلاحیه‌ی صورت‌حساب با شماره‌ی ${res.invoice?.invoice_number} با موفقیت ایجاد شد.`, + }); + this.store.updateStatus(res.status); + }); } returnFromSale(data: IPosReturnFromSaleRequest) { this.backFromSaleLoading.set(true); @@ -105,7 +110,12 @@ export class PosSaleInvoiceComponent { this.backFromSaleLoading.set(false); }) ) - .subscribe(); + .subscribe((res) => { + this.toastService.success({ + text: `برگشت از فروش با شماره‌ی ${res.invoice?.invoice_number} با موفقیت ایجاد شد.`, + }); + this.store.updateStatus(res.status); + }); } revoke() { this.revokeLoading.set(true); @@ -116,7 +126,12 @@ export class PosSaleInvoiceComponent { this.revokeLoading.set(false); }) ) - .subscribe(); + .subscribe((res) => { + this.toastService.success({ + text: `صورت‌حساب شماره‌ی ${res.invoice?.invoice_number} با موفقیت ابطال شد.`, + }); + this.store.updateStatus(res.status); + }); } ngOnInit() { diff --git a/src/app/shared/components/invoices/sale-invoice-single-view.component.ts b/src/app/shared/components/invoices/sale-invoice-single-view.component.ts index ed6ba97..8fbbe52 100644 --- a/src/app/shared/components/invoices/sale-invoice-single-view.component.ts +++ b/src/app/shared/components/invoices/sale-invoice-single-view.component.ts @@ -110,8 +110,10 @@ export class SharedSaleInvoiceSingleViewComponent { showQrCodeDialog = signal(false); showCorrectionPaymentDialog = signal(false); correctionRequiredPayment = signal(0); + paymentData = signal>(null); readonly isApplication = config.isPosApplication; - private pendingCorrectionSubmitResolver: Maybe<(allowed: boolean) => void> = null; + private pendingCorrectionSubmitResolver: Maybe<(allowed: boolean, payment?: IPayment) => void> = + null; publicInvoiceRoute = computed(() => { if (this.invoice) { @@ -282,6 +284,7 @@ export class SharedSaleInvoiceSingleViewComponent { total_amount, discount_amount, tax_amount, + payments: this.paymentData() || undefined, }; } @@ -310,7 +313,12 @@ export class SharedSaleInvoiceSingleViewComponent { return false; } - return (await this.beforeCorrectionSubmit?.(mapped)) ?? true; + return ( + (await this.beforeCorrectionSubmit?.({ + ...mapped, + payments: this.paymentData() || undefined, + })) ?? true + ); } confirmCorrectionPayment(_event: { @@ -318,7 +326,8 @@ export class SharedSaleInvoiceSingleViewComponent { settlementType: 'CASH' | 'CREDIT' | 'MIXED'; }) { this.showCorrectionPaymentDialog.set(false); - this.pendingCorrectionSubmitResolver?.(true); + this.paymentData.set(_event.payment); + this.pendingCorrectionSubmitResolver?.(true, _event.payment); this.pendingCorrectionSubmitResolver = null; }