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:
@@ -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