2026-04-25 15:19:19 +03:30
|
|
|
import { Maybe } from '@/core';
|
2026-04-27 21:53:11 +03:30
|
|
|
import { NativeBridgeService } from '@/core/services';
|
2026-05-03 16:08:26 +03:30
|
|
|
import { CatalogTaxProviderStatusTagComponent } from '@/shared/catalog';
|
2026-04-23 01:22:44 +03:30
|
|
|
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
2026-04-25 15:19:19 +03:30
|
|
|
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
2026-04-23 01:22:44 +03:30
|
|
|
import {
|
|
|
|
|
IColumn,
|
|
|
|
|
PageDataListComponent,
|
|
|
|
|
} from '@/shared/components/pageDataList/page-data-list.component';
|
2026-04-25 15:19:19 +03:30
|
|
|
import { PriceMaskDirective } from '@/shared/directives';
|
|
|
|
|
import { UikitEmptyStateComponent } from '@/uikit';
|
2026-04-23 01:22:44 +03:30
|
|
|
import { getGoodUnitTypeProperties } from '@/utils';
|
2026-05-03 16:08:26 +03:30
|
|
|
import {
|
|
|
|
|
Component,
|
|
|
|
|
EventEmitter,
|
|
|
|
|
inject,
|
|
|
|
|
Input,
|
|
|
|
|
Output,
|
|
|
|
|
TemplateRef,
|
|
|
|
|
ViewChild,
|
|
|
|
|
} from '@angular/core';
|
2026-05-04 20:02:10 +03:30
|
|
|
import { UrlTree } from '@angular/router';
|
2026-04-23 01:22:44 +03:30
|
|
|
import { ButtonDirective } from 'primeng/button';
|
|
|
|
|
import { Divider } from 'primeng/divider';
|
|
|
|
|
import { TableModule } from 'primeng/table';
|
2026-04-25 15:19:19 +03:30
|
|
|
import { ISaleInvoiceFullResponse } from '../../models';
|
2026-04-23 01:22:44 +03:30
|
|
|
|
|
|
|
|
export type TConsumerSaleInvoice = 'full' | 'customer' | 'pos';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'consumer-saleInvoice-shared',
|
|
|
|
|
templateUrl: './shared-saleInvoice.component.html',
|
|
|
|
|
imports: [
|
|
|
|
|
AppCardComponent,
|
|
|
|
|
KeyValueComponent,
|
|
|
|
|
Divider,
|
|
|
|
|
ButtonDirective,
|
|
|
|
|
PageDataListComponent,
|
|
|
|
|
TableModule,
|
2026-04-25 15:19:19 +03:30
|
|
|
PageLoadingComponent,
|
|
|
|
|
UikitEmptyStateComponent,
|
|
|
|
|
PriceMaskDirective,
|
2026-05-03 16:08:26 +03:30
|
|
|
CatalogTaxProviderStatusTagComponent,
|
2026-04-23 01:22:44 +03:30
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
export class ConsumerSaleInvoiceSharedComponent {
|
2026-04-27 21:53:11 +03:30
|
|
|
private readonly nativeBridge = inject(NativeBridgeService);
|
|
|
|
|
|
2026-04-23 01:22:44 +03:30
|
|
|
@Input({ required: true }) loading!: boolean;
|
2026-04-25 15:19:19 +03:30
|
|
|
@Input() invoice?: Maybe<ISaleInvoiceFullResponse>;
|
2026-04-23 01:22:44 +03:30
|
|
|
@Input() variant: TConsumerSaleInvoice = 'full';
|
2026-05-04 20:02:10 +03:30
|
|
|
@Input() backRoute?: UrlTree | string | any[];
|
2026-04-23 01:22:44 +03:30
|
|
|
|
2026-04-24 23:01:44 +03:30
|
|
|
@Output() onRefresh = new EventEmitter<void>();
|
|
|
|
|
|
2026-04-25 15:19:19 +03:30
|
|
|
@ViewChild('totalAmount', { static: false }) totalAmount!: TemplateRef<any>;
|
|
|
|
|
|
2026-04-23 01:22:44 +03:30
|
|
|
printInvoice = () => {
|
2026-04-27 21:53:11 +03:30
|
|
|
if (this.nativeBridge.isEnabled()) {
|
|
|
|
|
const result = this.nativeBridge.print({
|
|
|
|
|
invoiceId: this.invoice?.id,
|
|
|
|
|
code: this.invoice?.code,
|
|
|
|
|
});
|
|
|
|
|
if (result.success) return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-23 01:22:44 +03:30
|
|
|
window.print();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
columns: IColumn[] = [
|
|
|
|
|
{
|
|
|
|
|
field: '',
|
|
|
|
|
header: '',
|
|
|
|
|
type: 'index',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'name',
|
|
|
|
|
header: 'عنوان',
|
|
|
|
|
type: 'nested',
|
2026-04-24 02:23:47 +03:30
|
|
|
nestedOption: {
|
|
|
|
|
path: 'good.name',
|
|
|
|
|
},
|
2026-04-23 01:22:44 +03:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'unit_price',
|
|
|
|
|
header: 'قیمت واحد',
|
|
|
|
|
type: 'price',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'quantity',
|
|
|
|
|
header: 'مقدار',
|
|
|
|
|
customDataModel(item) {
|
|
|
|
|
return `${item.quantity} ${getGoodUnitTypeProperties(item.good.unit_type).quantitySymbolText}`;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'total_amount',
|
|
|
|
|
header: 'قیمت نهایی',
|
|
|
|
|
type: 'price',
|
2026-04-25 15:19:19 +03:30
|
|
|
// customDataModel: this.totalAmount,
|
2026-04-23 01:22:44 +03:30
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
expandableColumns: IColumn[] = [
|
|
|
|
|
{
|
|
|
|
|
field: 'commission',
|
|
|
|
|
header: 'کارمزد',
|
|
|
|
|
type: 'price',
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-04-25 15:19:19 +03:30
|
|
|
field: 'wages',
|
|
|
|
|
header: 'اجرت',
|
2026-04-23 01:22:44 +03:30
|
|
|
type: 'price',
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-04-25 15:19:19 +03:30
|
|
|
field: 'profit',
|
|
|
|
|
header: 'سود',
|
2026-04-23 01:22:44 +03:30
|
|
|
type: 'price',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
expandedRows: { [key: string]: boolean } = {};
|
2026-04-24 23:01:44 +03:30
|
|
|
|
|
|
|
|
refresh() {
|
|
|
|
|
this.onRefresh.emit();
|
|
|
|
|
}
|
2026-04-23 01:22:44 +03:30
|
|
|
}
|