feat: Refactor sale invoice store to use new response model and improve state management
fix: Update single component to correctly bind invoice data feat: Enhance partner info model with detailed license status refactor: Simplify account list component by removing unnecessary details fix: Correctly reference username in consumer account form feat: Add POS related fields to consumer account list chore: Update models to include charge account details for partners feat: Implement charge account dialog for partner consumers feat: Create API routes for accounts charge functionality feat: Add charge account service for handling requests feat: Introduce license info template component for dashboard refactor: Update dashboard view to display license information fix: Improve layout component to handle POS information more effectively chore: Clean up unused imports and components in various files feat: Add loading state handling in landing views feat: Implement charge account form dialog for partner consumers
This commit is contained in:
@@ -1,64 +1,99 @@
|
||||
<div class="flex flex-col gap-6">
|
||||
<app-card-data cardTitle="اطلاعات فاکتور" [editable]="false">
|
||||
<ng-template #moreActions>
|
||||
<button pButton type="button" label="چاپ" icon="pi pi-print" outlined (click)="printInvoice()"></button>
|
||||
</ng-template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="کد رهگیری" [value]="invoice()?.code" />
|
||||
<app-key-value label="تاریخ فاکتور" [value]="invoice()?.invoice_date" type="dateTime" />
|
||||
<app-key-value label="تاریخ ایجاد فاکتور" [value]="invoice()?.created_at" type="dateTime" />
|
||||
<app-key-value label="وضعیت صدور به سامانهی مودیان">
|
||||
<p-badge value="ارسال نشده" severity="danger" />
|
||||
</app-key-value>
|
||||
<div class="col-span-3">
|
||||
<app-key-value label="توضیحات" [value]="invoice()?.notes" />
|
||||
@if (loading) {
|
||||
<shared-page-loading />
|
||||
} @else if (!invoice) {
|
||||
<uikit-empty-state> </uikit-empty-state>
|
||||
} @else {
|
||||
<div class="flex flex-col gap-6">
|
||||
<app-card-data cardTitle="اطلاعات فاکتور" [editable]="false">
|
||||
<ng-template #moreActions>
|
||||
<button pButton type="button" label="چاپ" icon="pi pi-print" outlined (click)="printInvoice()"></button>
|
||||
</ng-template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="کد رهگیری" [value]="invoice.code" />
|
||||
<app-key-value label="تاریخ فاکتور" [value]="invoice.invoice_date" type="dateTime" />
|
||||
<app-key-value label="تاریخ ایجاد فاکتور" [value]="invoice.created_at" type="dateTime" />
|
||||
<app-key-value label="وضعیت صدور به سامانهی مودیان">
|
||||
<p-badge value="ارسال نشده" severity="danger" />
|
||||
</app-key-value>
|
||||
<div class="col-span-3">
|
||||
<app-key-value label="توضیحات" [value]="invoice.notes" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p-divider align="center"> اطلاعات پرداخت </p-divider>
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="مجموع قابل پرداخت" [value]="invoice()?.total_amount" type="price" />
|
||||
@for (payment of invoice()?.payments; track $index) {
|
||||
<app-key-value
|
||||
[label]="
|
||||
`${payment.payment_method === 'SET_OF' ? 'تهاتر' : payment.payment_method === 'TERMINAL' ? 'پایانه' : 'نقدی'}`
|
||||
"
|
||||
[value]="payment.amount"
|
||||
type="price"
|
||||
/>
|
||||
<p-divider align="center"> اطلاعات پرداخت </p-divider>
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="مجموع قابل پرداخت" [value]="invoice.total_amount" type="price" />
|
||||
@for (payment of invoice.payments; track $index) {
|
||||
<app-key-value
|
||||
[label]="`${payment.payment_method === 'SET_OF' ? 'تهاتر' : payment.payment_method === 'TERMINAL' ? 'پایانه' : 'نقدی'}`"
|
||||
[value]="payment.amount"
|
||||
type="price"
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
|
||||
<p-divider align="center"> اطلاعات صادر کننده </p-divider>
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="کسب و کار" [value]="invoice.pos!.complex.business_activity.name" />
|
||||
<app-key-value label="مجموعه" [value]="invoice.pos!.complex.name" />
|
||||
<app-key-value label="پایانهی فروش" [value]="invoice.pos!.name" />
|
||||
<app-key-value label="ایجاد کننده" [value]="invoice.consumer_account.account.username" />
|
||||
</div>
|
||||
|
||||
@if (variant !== "customer") {
|
||||
<p-divider align="center"> اطلاعات مشتری </p-divider>
|
||||
@if (invoice.customer) {
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
@if (invoice.customer.type === "INDIVIDUAL") {
|
||||
<app-key-value label="نوع مشتری" value="حقیقی" />
|
||||
<app-key-value label="نام" [value]="invoice.customer.customer_individual?.first_name" />
|
||||
<app-key-value label="نام خانوادگی" [value]="invoice.customer.customer_individual?.last_name" />
|
||||
<app-key-value label="کد اقتصادی" [value]="invoice.customer.customer_individual?.economic_code" />
|
||||
<app-key-value label="کد ملی" [value]="invoice.customer.customer_individual?.national_id" />
|
||||
<app-key-value label="کد پستی" [value]="invoice.customer.customer_individual?.postal_code" />
|
||||
} @else {
|
||||
<app-key-value label="نوع مشتری" value="حقوقی" />
|
||||
<app-key-value label="نام شرکت" [value]="invoice.customer.customer_legal?.company_name" />
|
||||
<app-key-value label="کد اقتصادی" [value]="invoice.customer.customer_legal?.economic_code" />
|
||||
<app-key-value label="کد ثبتی" [value]="invoice.customer.customer_legal?.registration_number" />
|
||||
<app-key-value label="کد پستی" [value]="invoice.customer.customer_legal?.postal_code" />
|
||||
}
|
||||
</div>
|
||||
} @else if (invoice.unknown_customer) {
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="نوع مشتری" value="نوع دوم" />
|
||||
<app-key-value label="عنوان" [value]="invoice.unknown_customer.name" />
|
||||
<app-key-value label="کد ثبتی" [value]="invoice.unknown_customer.national_code" />
|
||||
</div>
|
||||
} @else {
|
||||
<p class="text-center text-text-color pt-3 pb-5">اطلاعات مشتری ثبت نشده است.</p>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<p-divider align="center"> اطلاعات صادر کننده </p-divider>
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="کسب و کار" [value]="invoice()?.pos!.complex.business_activity.name" />
|
||||
<app-key-value label="مجموعه" [value]="invoice()?.pos!.complex.name" />
|
||||
<app-key-value label="پایانهی فروش" [value]="invoice()?.pos!.name" />
|
||||
<app-key-value label="ایجاد کننده" [value]="invoice()?.consumer_account?.account?.username" />
|
||||
</div>
|
||||
|
||||
@if (variant !== "customer") {
|
||||
<p-divider align="center"> اطلاعات مشتری </p-divider>
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
@if (invoice()?.customer) {}
|
||||
<!-- <app-key-value label="کسب و کار" [value]="invoice()?.pos!.complex.business_activity.name" />
|
||||
<app-key-value label="مجموعه" [value]="invoice()?.pos!.complex.name" />
|
||||
<app-key-value label="پایانهی فروش" [value]="invoice()?.pos!.name" />
|
||||
<app-key-value label="ایجاد کننده" [value]="invoice()?.account?.account?.username" /> -->
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</app-card-data>
|
||||
<app-card-data cardTitle="کالاهای خریداری شده" [editable]="false">
|
||||
<app-page-data-list
|
||||
[columns]="columns"
|
||||
[expandColumns]="expandableColumns"
|
||||
[expandable]="true"
|
||||
expandableItemKey="payload"
|
||||
[items]="invoice()?.items"
|
||||
[loading]="loading"
|
||||
pageTitle=""
|
||||
(onRefresh)="refresh()"
|
||||
/>
|
||||
</app-card-data>
|
||||
</div>
|
||||
</app-card-data>
|
||||
<app-card-data cardTitle="کالاهای خریداری شده" [editable]="false">
|
||||
<app-page-data-list
|
||||
[columns]="columns"
|
||||
[expandColumns]="expandableColumns"
|
||||
[expandable]="true"
|
||||
expandableItemKey="payload"
|
||||
[items]="invoice.items"
|
||||
[loading]="loading"
|
||||
pageTitle=""
|
||||
[showRefresh]="false"
|
||||
>
|
||||
<ng-template #totalAmount let-item>
|
||||
aaa
|
||||
@if (!item.discount_amount) {
|
||||
<span [appPriceMask]="item.total_amount"></span>
|
||||
} @else {
|
||||
<!-- <div class="flex flex-col items-end">
|
||||
<span class="line-through text-muted-color text-xs" [appPriceMask]="item.total_amount"></span>
|
||||
<span [appPriceMask]="item.total_amount - item.discount_amount"></span>
|
||||
</div> -->
|
||||
}
|
||||
</ng-template>
|
||||
</app-page-data-list>
|
||||
</app-card-data>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import { Maybe } from '@/core';
|
||||
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
||||
import {
|
||||
IColumn,
|
||||
PageDataListComponent,
|
||||
} from '@/shared/components/pageDataList/page-data-list.component';
|
||||
import { PriceMaskDirective } from '@/shared/directives';
|
||||
import { UikitEmptyStateComponent } from '@/uikit';
|
||||
import { getGoodUnitTypeProperties } from '@/utils';
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, Output, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { Badge } from 'primeng/badge';
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import { Divider } from 'primeng/divider';
|
||||
import { TableModule } from 'primeng/table';
|
||||
import { ISaleInvoiceFullResponse } from '../../models';
|
||||
|
||||
export type TConsumerSaleInvoice = 'full' | 'customer' | 'pos';
|
||||
|
||||
@@ -23,15 +28,20 @@ export type TConsumerSaleInvoice = 'full' | 'customer' | 'pos';
|
||||
ButtonDirective,
|
||||
PageDataListComponent,
|
||||
TableModule,
|
||||
PageLoadingComponent,
|
||||
UikitEmptyStateComponent,
|
||||
PriceMaskDirective,
|
||||
],
|
||||
})
|
||||
export class ConsumerSaleInvoiceSharedComponent {
|
||||
@Input({ required: true }) loading!: boolean;
|
||||
@Input({ required: true }) invoice!: any;
|
||||
@Input() invoice?: Maybe<ISaleInvoiceFullResponse>;
|
||||
@Input() variant: TConsumerSaleInvoice = 'full';
|
||||
|
||||
@Output() onRefresh = new EventEmitter<void>();
|
||||
|
||||
@ViewChild('totalAmount', { static: false }) totalAmount!: TemplateRef<any>;
|
||||
|
||||
printInvoice = () => {
|
||||
window.print();
|
||||
};
|
||||
@@ -66,6 +76,7 @@ export class ConsumerSaleInvoiceSharedComponent {
|
||||
field: 'total_amount',
|
||||
header: 'قیمت نهایی',
|
||||
type: 'price',
|
||||
// customDataModel: this.totalAmount,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -76,13 +87,13 @@ export class ConsumerSaleInvoiceSharedComponent {
|
||||
type: 'price',
|
||||
},
|
||||
{
|
||||
field: 'profit',
|
||||
header: 'سود',
|
||||
field: 'wages',
|
||||
header: 'اجرت',
|
||||
type: 'price',
|
||||
},
|
||||
{
|
||||
field: 'wages',
|
||||
header: 'اجرت',
|
||||
field: 'profit',
|
||||
header: 'سود',
|
||||
type: 'price',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -8,9 +8,9 @@ export const CONSUMER_MENU_ITEMS = [
|
||||
routerLink: ['/consumer'],
|
||||
},
|
||||
{
|
||||
label: 'حسابهای کاربری',
|
||||
label: 'فعالیتهای اقتصادی',
|
||||
icon: 'pi pi-fw pi-home',
|
||||
routerLink: ['/consumer/accounts'],
|
||||
routerLink: ['/consumer/business_activities'],
|
||||
},
|
||||
{
|
||||
label: 'پایانههای فروش',
|
||||
@@ -18,15 +18,21 @@ export const CONSUMER_MENU_ITEMS = [
|
||||
routerLink: ['/consumer/poses'],
|
||||
},
|
||||
{
|
||||
label: 'فعالیتهای اقتصادی',
|
||||
label: 'لیست فاکتورها',
|
||||
icon: 'pi pi-fw pi-home',
|
||||
routerLink: ['/consumer/business_activities'],
|
||||
routerLink: ['/consumer/sale_invoices'],
|
||||
},
|
||||
{
|
||||
label: 'مشتریان',
|
||||
icon: 'pi pi-fw pi-home',
|
||||
routerLink: ['/consumer/customers'],
|
||||
},
|
||||
|
||||
{
|
||||
label: 'حسابهای کاربری',
|
||||
icon: 'pi pi-fw pi-home',
|
||||
routerLink: ['/consumer/accounts'],
|
||||
},
|
||||
],
|
||||
},
|
||||
] as MenuItem[];
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { LayoutService } from '@/layout/service/layout.service';
|
||||
import { Component, inject, signal, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { RouterOutlet } from '@angular/router';
|
||||
import { Button, ButtonIcon } from 'primeng/button';
|
||||
import { ConsumerLicenseInfoDialogComponent } from '../components/license-info-dialog.component';
|
||||
import { CONSUMER_MENU_ITEMS } from '../constants';
|
||||
import { ConsumerStore } from '../store/main.store';
|
||||
@@ -9,7 +8,7 @@ import { ConsumerStore } from '../store/main.store';
|
||||
@Component({
|
||||
selector: 'consumer-layout',
|
||||
templateUrl: './layout.component.html',
|
||||
imports: [RouterOutlet, Button, ButtonIcon, ConsumerLicenseInfoDialogComponent],
|
||||
imports: [RouterOutlet, ConsumerLicenseInfoDialogComponent],
|
||||
})
|
||||
export class LayoutComponent {
|
||||
@ViewChild('topBarMoreAction') topBarMoreAction!: TemplateRef<any>;
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export * from './io';
|
||||
export * from './saleInvoice.io';
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import ISummary from '@/core/models/summary';
|
||||
|
||||
export interface ISaleInvoiceFullRawResponse {
|
||||
id: string;
|
||||
code: string;
|
||||
total_amount: string;
|
||||
invoice_date: string;
|
||||
consumer_account: ConsumerAccount;
|
||||
pos: Pos;
|
||||
payments: Payment[];
|
||||
items: Item[];
|
||||
created_at: string;
|
||||
notes?: string;
|
||||
customer?: Customer;
|
||||
unknown_customer?: UnknownCustomer;
|
||||
}
|
||||
|
||||
export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {}
|
||||
|
||||
interface Item {
|
||||
id: string;
|
||||
good: ISummary;
|
||||
}
|
||||
|
||||
interface Payment {
|
||||
amount: string;
|
||||
payment_method: string;
|
||||
}
|
||||
|
||||
interface Customer {
|
||||
id: string;
|
||||
type: string;
|
||||
customer_legal?: CustomerLegal;
|
||||
customer_individual?: CustomerIndividual;
|
||||
}
|
||||
|
||||
interface CustomerIndividual {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
national_id: string;
|
||||
postal_code: string;
|
||||
economic_code: string;
|
||||
}
|
||||
|
||||
interface CustomerLegal {
|
||||
company_name: string;
|
||||
registration_number: string;
|
||||
postal_code: string;
|
||||
economic_code: string;
|
||||
}
|
||||
|
||||
interface Pos extends ISummary {
|
||||
complex: Complex;
|
||||
}
|
||||
|
||||
interface Complex extends ISummary {
|
||||
business_activity: ISummary;
|
||||
}
|
||||
|
||||
interface ConsumerAccount {
|
||||
role: string;
|
||||
account: {
|
||||
username: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface UnknownCustomer {
|
||||
name?: string;
|
||||
national_code?: string;
|
||||
}
|
||||
@@ -19,9 +19,9 @@ import { ConsumerBusinessActivityFormComponent } from './form.component';
|
||||
export class ConsumerBusinessActivityListComponent extends AbstractList<IBusinessActivityResponse> {
|
||||
@Input() fullHeight?: boolean;
|
||||
@Input() header: IColumn[] = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'name', header: 'عنوان' },
|
||||
{ field: 'guild', header: 'صنف', type: 'nested', nestedOption: { path: 'guild.name' } },
|
||||
{ field: 'economic_code', header: 'کد اقتصادی' },
|
||||
{
|
||||
field: 'license_info',
|
||||
header: 'محدودیت کاربر',
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ export class ConsumerCustomerSaleInvoiceListComponent extends AbstractList<ICust
|
||||
},
|
||||
{
|
||||
field: 'pos',
|
||||
header: 'شعبه',
|
||||
header: 'پایانه',
|
||||
customDataModel(item: ICustomerSaleInvoicesResponse) {
|
||||
return `${item.pos.complex.business_activity.name}، شعبه ${item.pos.complex.name}، پایانهی فروش ${item.pos.name}`;
|
||||
},
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
import ISummary from '@/core/models/summary';
|
||||
import { ISaleInvoiceFullRawResponse } from '@/domains/consumer/models';
|
||||
import { CustomerType } from '@/shared/localEnum/constants/customerTypes';
|
||||
import { CustomerIndividual, CustomerLegal } from './io';
|
||||
|
||||
export interface ICustomerSaleInvoicesRawResponse {
|
||||
id: string;
|
||||
code: string;
|
||||
total_amount: string;
|
||||
invoice_date: string;
|
||||
consumer_account: ConsumerAccount;
|
||||
pos: Pos;
|
||||
items: SaleInvoiceItem[];
|
||||
payments: Payment[];
|
||||
unknown_customer?: UnknownCustomer;
|
||||
customer?: Customer;
|
||||
notes?: string;
|
||||
created_at: string;
|
||||
}
|
||||
export interface ICustomerSaleInvoicesRawResponse extends ISaleInvoiceFullRawResponse {}
|
||||
export interface ICustomerSaleInvoicesResponse extends ICustomerSaleInvoicesRawResponse {}
|
||||
|
||||
interface ConsumerAccount {
|
||||
|
||||
@@ -1 +1 @@
|
||||
<consumer-saleInvoice-shared [loading]="loading()" [invoice]="invoice" variant="customer" />
|
||||
<consumer-saleInvoice-shared [loading]="loading()" [invoice]="invoice()" variant="customer" />
|
||||
|
||||
+14
-1
@@ -24,7 +24,20 @@ export class ConsumerStatisticsLatestInvoicesComponent extends AbstractList<ISta
|
||||
override setColumns(): void {
|
||||
this.columns = [
|
||||
{ field: 'code', header: 'کد پیگیری' },
|
||||
{ field: 'total_amount', header: 'مجموع قیمت', type: 'price' },
|
||||
{ field: 'total_amount', header: 'قیمت نهایی', type: 'price' },
|
||||
{
|
||||
field: 'pos',
|
||||
header: 'پایانه',
|
||||
customDataModel(item) {
|
||||
return `${item.pos.name} - ${item.pos.complex.name} - ${item.pos.complex.business_activity.name}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'consumer_account',
|
||||
header: 'ایجاد شده توسط',
|
||||
type: 'nested',
|
||||
nestedOption: { path: 'consumer_account.account.username' },
|
||||
},
|
||||
{ field: 'status', header: 'وضعیت صدور', customDataModel: this.status },
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="grid grid-cols-2 gap-10">
|
||||
<div class="h-[300px] flex">
|
||||
<div class="flex gap-10">
|
||||
<div class="h-75 flex w-full">
|
||||
<consumer-statistics-latest-Invoices class="w-full" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -26,16 +26,16 @@ export class ConsumerSaleInvoiceListComponent extends AbstractList<IConsumerSale
|
||||
},
|
||||
{
|
||||
field: 'pos',
|
||||
header: 'شعبه',
|
||||
header: 'پایانه',
|
||||
customDataModel(item: IConsumerSaleInvoicesResponse) {
|
||||
return `${item.pos.complex.business_activity.name}، شعبه ${item.pos.complex.name}، پایانهی فروش ${item.pos.name}`;
|
||||
return `${item.pos.name} (${item.pos.complex.name} - ${item.pos.complex.business_activity.name})`;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'account',
|
||||
field: 'consumer_account',
|
||||
header: 'ایجاد شده توسط',
|
||||
type: 'nested',
|
||||
nestedOption: { path: 'account.account.username' },
|
||||
nestedOption: { path: 'consumer_account.account.username' },
|
||||
},
|
||||
{
|
||||
field: 'invoice_date',
|
||||
|
||||
@@ -5,21 +5,21 @@ export type TConsumerSaleInvoicesRouteNames = 'saleInvoices' | 'saleInvoice';
|
||||
|
||||
export const consumerSaleInvoicesNamedRoutes: NamedRoutes<TConsumerSaleInvoicesRouteNames> = {
|
||||
saleInvoices: {
|
||||
path: 'saleInvoices',
|
||||
path: 'sale_invoices',
|
||||
loadComponent: () =>
|
||||
import('../../views/list.component').then((m) => m.ConsumerSaleInvoicesComponent),
|
||||
meta: {
|
||||
title: 'فاکتورهای صادر شده',
|
||||
pagePath: () => `/consumer/saleInvoices`,
|
||||
pagePath: () => `/consumer/sale_invoices`,
|
||||
},
|
||||
},
|
||||
saleInvoice: {
|
||||
path: 'saleInvoices/:invoiceId',
|
||||
path: 'sale_invoices/:invoiceId',
|
||||
loadComponent: () =>
|
||||
import('../../views/single.component').then((m) => m.ConsumerSaleInvoiceComponent),
|
||||
meta: {
|
||||
title: 'فاکتور صادر شده',
|
||||
pagePath: (saleInvoiceId: string) => `/consumer/saleInvoices/${saleInvoiceId}`,
|
||||
pagePath: (saleInvoiceId: string) => `/consumer/sale_invoices/${saleInvoiceId}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ export interface IConsumerSaleInvoicesRawResponse {
|
||||
notes?: string;
|
||||
total_amount: string;
|
||||
pos: Pos;
|
||||
account: ConsumerAccount;
|
||||
consumer_account: ConsumerAccount;
|
||||
created_at: string;
|
||||
items_count: number;
|
||||
payments: Payments[];
|
||||
@@ -16,7 +16,6 @@ export interface IConsumerSaleInvoicesResponse extends IConsumerSaleInvoicesRawR
|
||||
|
||||
interface ConsumerAccount {
|
||||
role: string;
|
||||
user: User;
|
||||
account: Account;
|
||||
}
|
||||
|
||||
@@ -24,11 +23,6 @@ interface Account {
|
||||
username: string;
|
||||
}
|
||||
|
||||
interface User {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
}
|
||||
|
||||
interface Pos extends ISummary {
|
||||
complex: Complex;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { IPaginatedResponse } from '@/core/models/service.model';
|
||||
import { ISaleInvoiceFullRawResponse, ISaleInvoiceFullResponse } from '@/domains/consumer/models';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -16,7 +17,7 @@ export class ConsumerSaleInvoicesService {
|
||||
this.apiRoutes.list(),
|
||||
);
|
||||
}
|
||||
getSingle(invoiceId: string): Observable<IConsumerSaleInvoicesResponse> {
|
||||
return this.http.get<IConsumerSaleInvoicesRawResponse>(this.apiRoutes.single(invoiceId));
|
||||
getSingle(invoiceId: string): Observable<ISaleInvoiceFullResponse> {
|
||||
return this.http.get<ISaleInvoiceFullRawResponse>(this.apiRoutes.single(invoiceId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { EntityState, EntityStore } from '@/core/state';
|
||||
import { defaultBaseStateData, EntityState, EntityStore } from '@/core/state';
|
||||
import { ISaleInvoiceFullResponse } from '@/domains/consumer/models';
|
||||
import { computed, inject, Injectable } from '@angular/core';
|
||||
import { MenuItem } from 'primeng/api';
|
||||
import { catchError, finalize } from 'rxjs';
|
||||
import { consumerSaleInvoicesNamedRoutes } from '../constants';
|
||||
import { IConsumerSaleInvoicesResponse } from '../models';
|
||||
import { ConsumerSaleInvoicesService } from '../services/main.service';
|
||||
|
||||
interface ConsumerSaleInvoiceState extends EntityState<IConsumerSaleInvoicesResponse> {
|
||||
interface ConsumerSaleInvoiceState extends EntityState<ISaleInvoiceFullResponse> {
|
||||
breadcrumbItems: MenuItem[];
|
||||
}
|
||||
|
||||
@@ -14,17 +14,13 @@ interface ConsumerSaleInvoiceState extends EntityState<IConsumerSaleInvoicesResp
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ConsumerSaleInvoiceStore extends EntityStore<
|
||||
IConsumerSaleInvoicesResponse,
|
||||
ISaleInvoiceFullResponse,
|
||||
ConsumerSaleInvoiceState
|
||||
> {
|
||||
private readonly service = inject(ConsumerSaleInvoicesService);
|
||||
constructor() {
|
||||
super({
|
||||
loading: false,
|
||||
error: null,
|
||||
entity: null,
|
||||
initialized: false,
|
||||
isRefreshing: false,
|
||||
...defaultBaseStateData,
|
||||
breadcrumbItems: [],
|
||||
});
|
||||
}
|
||||
@@ -67,11 +63,7 @@ export class ConsumerSaleInvoiceStore extends EntityStore<
|
||||
|
||||
override reset(): void {
|
||||
this.setState({
|
||||
loading: false,
|
||||
error: null,
|
||||
entity: null,
|
||||
initialized: false,
|
||||
isRefreshing: false,
|
||||
...defaultBaseStateData,
|
||||
breadcrumbItems: [],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
<consumer-saleInvoice-shared [loading]="loading()" [invoice]="invoice" />
|
||||
<consumer-saleInvoice-shared [loading]="loading()" [invoice]="invoice()" />
|
||||
|
||||
Reference in New Issue
Block a user