Files
psp_panel/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts
T

107 lines
2.6 KiB
TypeScript
Raw Normal View History

import { Maybe } from '@/core';
2026-04-23 01:22:44 +03:30
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
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';
import { PriceMaskDirective } from '@/shared/directives';
import { UikitEmptyStateComponent } from '@/uikit';
2026-04-23 01:22:44 +03:30
import { getGoodUnitTypeProperties } from '@/utils';
import { Component, EventEmitter, Input, Output, TemplateRef, ViewChild } from '@angular/core';
2026-04-23 01:22:44 +03:30
import { Badge } from 'primeng/badge';
import { ButtonDirective } from 'primeng/button';
import { Divider } from 'primeng/divider';
import { TableModule } from 'primeng/table';
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,
Badge,
Divider,
ButtonDirective,
PageDataListComponent,
TableModule,
PageLoadingComponent,
UikitEmptyStateComponent,
PriceMaskDirective,
2026-04-23 01:22:44 +03:30
],
})
export class ConsumerSaleInvoiceSharedComponent {
@Input({ required: true }) loading!: boolean;
@Input() invoice?: Maybe<ISaleInvoiceFullResponse>;
2026-04-23 01:22:44 +03:30
@Input() variant: TConsumerSaleInvoice = 'full';
@Output() onRefresh = new EventEmitter<void>();
@ViewChild('totalAmount', { static: false }) totalAmount!: TemplateRef<any>;
2026-04-23 01:22:44 +03:30
printInvoice = () => {
window.print();
};
columns: IColumn[] = [
{
field: '',
header: '',
type: 'index',
},
{
field: 'name',
header: 'عنوان',
type: 'nested',
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',
// customDataModel: this.totalAmount,
2026-04-23 01:22:44 +03:30
},
];
expandableColumns: IColumn[] = [
{
field: 'commission',
header: 'کارمزد',
type: 'price',
},
{
field: 'wages',
header: 'اجرت',
2026-04-23 01:22:44 +03:30
type: 'price',
},
{
field: 'profit',
header: 'سود',
2026-04-23 01:22:44 +03:30
type: 'price',
},
];
expandedRows: { [key: string]: boolean } = {};
refresh() {
this.onRefresh.emit();
}
2026-04-23 01:22:44 +03:30
}