Files
psp_panel/src/app/shared/components/invoices/sale-invoice-single-info-card.component.ts
T

105 lines
2.6 KiB
TypeScript
Raw Normal View History

import { Maybe } from '@/core';
import {
CatalogInvoiceTypeTagComponent,
CatalogTaxProviderStatusTagComponent,
} from '@/shared/catalog';
import { CatalogInvoiceSettlementTypeTagComponent } from '@/shared/catalog/invoiceSettlementType';
import { PriceMaskDirective } from '@/shared/directives';
import { Component, Input } from '@angular/core';
import { Card } from 'primeng/card';
import { Divider } from 'primeng/divider';
import { KeyValueComponent } from '../key-value.component/key-value.component';
import { IColumn, PageDataListComponent } from '../pageDataList/page-data-list.component';
import { ISaleInvoiceFullResponse } from './sale-invoice-full-response.model';
export type TSaleInvoiceSingleViewVariant = 'full' | 'customer' | 'pos';
@Component({
selector: 'shared-sale-invoice-single-info-card',
templateUrl: './sale-invoice-single-info-card.component.html',
imports: [
Card,
KeyValueComponent,
CatalogInvoiceTypeTagComponent,
CatalogTaxProviderStatusTagComponent,
Divider,
CatalogInvoiceSettlementTypeTagComponent,
PageDataListComponent,
PriceMaskDirective,
],
})
export class SaleInvoiceSingleInfoCardComponent {
@Input({ required: true }) loading!: boolean;
@Input() invoice!: Maybe<ISaleInvoiceFullResponse>;
@Input() variant: TSaleInvoiceSingleViewVariant = 'full';
columns: IColumn[] = [
{
field: 'name',
header: 'عنوان',
type: 'nested',
nestedOption: {
path: 'good_snapshot.name',
},
},
{
field: 'sku_code',
header: 'شناسه کالا',
},
{
field: 'unit_price',
header: 'قیمت واحد',
type: 'price',
},
{
field: 'quantity',
header: 'مقدار',
customDataModel(item) {
return `${item.quantity} ${item.measure_unit_text}`;
},
},
{
field: 'commission',
header: 'کارمزد',
type: 'nested',
nestedOption: {
path: 'payload.commission',
type: 'price',
},
},
{
field: 'wages',
header: 'اجرت',
type: 'nested',
nestedOption: {
path: 'payload.wages',
type: 'price',
},
},
{
field: 'profit',
header: 'سود',
type: 'nested',
nestedOption: {
path: 'payload.profit',
type: 'price',
},
},
{
field: 'discount_amount',
header: 'تخفیف',
type: 'price',
},
{
field: 'tax_amount',
header: 'مالیات',
type: 'price',
},
{
field: 'total_amount',
header: 'قابل پرداخت',
type: 'price',
},
];
}