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()" />
|
||||
|
||||
+15
-1
@@ -10,5 +10,19 @@ export interface IPartnerRawResponse {
|
||||
}
|
||||
export interface IPartnerResponse extends IPartnerRawResponse {}
|
||||
|
||||
export interface IPartnerInfoRawResponse extends ISummary {}
|
||||
export interface IPartnerInfoRawResponse {
|
||||
licenses_status: LicensesStatus;
|
||||
license_renews_status: LicensesStatus;
|
||||
account_quotas_status: LicensesStatus;
|
||||
id: string;
|
||||
name: string;
|
||||
code: string;
|
||||
created_at: string;
|
||||
}
|
||||
export interface IPartnerInfoResponse extends IPartnerInfoRawResponse {}
|
||||
|
||||
interface LicensesStatus {
|
||||
total_purchased: number;
|
||||
total_activated: number;
|
||||
total_expired: number;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
[columns]="columns"
|
||||
emptyPlaceholderTitle="حساب کاربریای یافت نشد"
|
||||
[items]="items()"
|
||||
[showDetails]="true"
|
||||
[loading]="loading()"
|
||||
(onDetails)="toSinglePage($event)"
|
||||
(onRefresh)="refresh()"
|
||||
/>
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export class ConsumerAccountFormComponent extends AbstractFormDialog<
|
||||
if (this.editMode) {
|
||||
return this.fb.group(
|
||||
{
|
||||
username: [this.initialValues?.username || '', [Validators.required]],
|
||||
username: [this.initialValues?.account.username || '', [Validators.required]],
|
||||
password: ['', [password()]],
|
||||
confirmPassword: [''],
|
||||
},
|
||||
@@ -49,7 +49,7 @@ export class ConsumerAccountFormComponent extends AbstractFormDialog<
|
||||
}
|
||||
return this.fb.group(
|
||||
{
|
||||
username: [this.initialValues?.username || '', [Validators.required]],
|
||||
username: [this.initialValues?.account.username || '', [Validators.required]],
|
||||
role: ['', [Validators.required]],
|
||||
password: ['', [Validators.required, password()]],
|
||||
confirmPassword: ['', [Validators.required]],
|
||||
|
||||
@@ -26,17 +26,27 @@ export class ConsumerAccountListComponent extends AbstractList<IConsumerAccountR
|
||||
nestedOption: { path: 'account.username' },
|
||||
},
|
||||
{ field: 'role', header: 'نوع حساب' },
|
||||
{
|
||||
field: 'pos',
|
||||
header: 'پایانهی مرتبط',
|
||||
customDataModel(item: IConsumerAccountResponse) {
|
||||
if (item.pos) {
|
||||
return `${item.pos.name} (${item.pos.complex.name} - ${item.pos.complex.business_activity.name})`;
|
||||
}
|
||||
return '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
header: 'وضعیت',
|
||||
type: 'nested',
|
||||
nestedOption: { path: 'account.status' },
|
||||
},
|
||||
{
|
||||
field: 'created_at',
|
||||
header: 'تاریخ ایجاد',
|
||||
type: 'date',
|
||||
},
|
||||
// {
|
||||
// field: 'created_at',
|
||||
// header: 'تاریخ ایجاد',
|
||||
// type: 'date',
|
||||
// },
|
||||
];
|
||||
private readonly service = inject(PartnerConsumerAccountsService);
|
||||
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<p-dialog
|
||||
header="شارژ کاربر"
|
||||
[(visible)]="visible"
|
||||
[modal]="true"
|
||||
[style]="{ width: '300px' }"
|
||||
[closable]="true"
|
||||
(onHide)="close()"
|
||||
>
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<app-input label="تعداد شارژ کاربران" [control]="form.controls.quantity" type="number" [min]="1" />
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||
import { InputComponent } from '@/shared/components';
|
||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
import { IPartnerChargeAccountRequest } from '../../models';
|
||||
import { PartnerChargeAccountService } from '../../services/chargeAccount.service';
|
||||
|
||||
@Component({
|
||||
selector: 'partner-charge-account-form-dialog',
|
||||
templateUrl: './charge-account-form-dialog.component.html',
|
||||
imports: [Dialog, ReactiveFormsModule, InputComponent, FormFooterActionsComponent],
|
||||
})
|
||||
export class PartnerChargeAccountFormDialogComponent extends AbstractFormDialog<
|
||||
IPartnerChargeAccountRequest,
|
||||
any
|
||||
> {
|
||||
@Input({ required: true }) consumerId!: string;
|
||||
@Input({ required: true }) businessId!: string;
|
||||
|
||||
private readonly service = inject(PartnerChargeAccountService);
|
||||
|
||||
form = this.fb.group({
|
||||
quantity: [0, [Validators.required, Validators.min(1)]],
|
||||
});
|
||||
|
||||
submitForm(payload: IPartnerChargeAccountRequest) {
|
||||
return this.service.charge(this.consumerId, this.businessId, payload);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
const baseUrl = (consumerId: string, businessId: string) =>
|
||||
`/api/v1/partner/consumers/${consumerId}/business-activities/${businessId}/accounts-charge`;
|
||||
|
||||
export const PARTNER_BA_ACCOUNTS_CHARGE_API_ROUTES = {
|
||||
single: (consumerId: string, businessId: string) => `${baseUrl(consumerId, businessId)}`,
|
||||
};
|
||||
@@ -1,8 +1,12 @@
|
||||
import { TAccountType } from '@/core/constants/accountTypes.const';
|
||||
import ISummary from '@/core/models/summary';
|
||||
|
||||
export interface IConsumerAccountRawResponse {
|
||||
username: string;
|
||||
id: string;
|
||||
role: string;
|
||||
created_at: string;
|
||||
pos: Pos;
|
||||
account: Account;
|
||||
}
|
||||
export interface IConsumerAccountResponse extends IConsumerAccountRawResponse {}
|
||||
|
||||
@@ -11,3 +15,17 @@ export interface IConsumerAccountRequest {
|
||||
password?: string;
|
||||
type: TAccountType;
|
||||
}
|
||||
|
||||
interface Account {
|
||||
username: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
interface Pos extends ISummary {
|
||||
complex: Complex;
|
||||
}
|
||||
|
||||
interface Complex extends ISummary {
|
||||
branch_code: string;
|
||||
business_activity: ISummary;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface IPartnerChargeAccountRawResponse {
|
||||
id: string;
|
||||
created_at: string;
|
||||
// tracking_code: string;
|
||||
// activation_expires_at: string;
|
||||
// charged_license_count: number;
|
||||
// activated_license_count: number;
|
||||
// remained_license_count: number;
|
||||
}
|
||||
|
||||
export interface IPartnerChargeAccountResponse extends IPartnerChargeAccountRawResponse {}
|
||||
|
||||
export interface IPartnerChargeAccountRequest {
|
||||
quantity: number;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from './accounts_io';
|
||||
export * from './businessActivities_io';
|
||||
export * from './chargeAccount_io';
|
||||
export * from './complexes_io';
|
||||
export * from './io';
|
||||
export * from './licenses_io';
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PARTNER_BA_ACCOUNTS_CHARGE_API_ROUTES } from '../constants/apiRoutes/accountsCharge';
|
||||
import { IPartnerChargeAccountRequest } from '../models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PartnerChargeAccountService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
private apiRoutes = PARTNER_BA_ACCOUNTS_CHARGE_API_ROUTES;
|
||||
|
||||
// getAll(consumerId: string, businessId: string): Observable<IPaginatedResponse<IPartnerChargeAccountRequest>> {
|
||||
// return this.http.get<IPaginatedResponse<IPartnerChargeAccountRequest>>(
|
||||
// this.apiRoutes.single(partnerId),
|
||||
// );
|
||||
// }
|
||||
|
||||
charge(
|
||||
consumerId: string,
|
||||
businessId: string,
|
||||
data: IPartnerChargeAccountRequest,
|
||||
): Observable<IPartnerChargeAccountRequest> {
|
||||
return this.http.post<IPartnerChargeAccountRequest>(
|
||||
this.apiRoutes.single(consumerId, businessId),
|
||||
data,
|
||||
);
|
||||
}
|
||||
}
|
||||
+10
@@ -1,5 +1,8 @@
|
||||
<div class="flex flex-col gap-6">
|
||||
<app-card-data cardTitle="اطلاعات فعالیت اقتصادی" [editable]="true" [(editMode)]="editMode">
|
||||
<ng-template #moreActions>
|
||||
<button pButton outlined (click)="showAccountsChargeDialog()">افزایش محدودیت کاربر</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]="businessActivity()?.name" />
|
||||
@@ -21,4 +24,11 @@
|
||||
[initialValues]="businessActivity() || undefined"
|
||||
(onSubmit)="getData()"
|
||||
/>
|
||||
<partner-charge-account-form-dialog
|
||||
[(visible)]="visibleAccountsChargeForm"
|
||||
[consumerId]="consumerId()"
|
||||
[businessId]="businessId()"
|
||||
(onSubmit)="getData()"
|
||||
>
|
||||
</partner-charge-account-form-dialog>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,9 @@ import pageParamsUtils from '@/utils/page-params.utils';
|
||||
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import { ConsumerBusinessActivitiesFormComponent } from '../../components/businessActivities/form.component';
|
||||
import { PartnerChargeAccountFormDialogComponent } from '../../components/chargeAccount/charge-account-form-dialog.component';
|
||||
import { ConsumerComplexesComponent } from '../../components/complexes/list.component';
|
||||
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||
import { ConsumerStore } from '../../store/consumer.store';
|
||||
@@ -17,6 +19,8 @@ import { ConsumerStore } from '../../store/consumer.store';
|
||||
KeyValueComponent,
|
||||
ConsumerBusinessActivitiesFormComponent,
|
||||
ConsumerComplexesComponent,
|
||||
ButtonDirective,
|
||||
PartnerChargeAccountFormDialogComponent,
|
||||
],
|
||||
})
|
||||
export class PartnerUserBusinessActivityComponent {
|
||||
@@ -30,6 +34,7 @@ export class PartnerUserBusinessActivityComponent {
|
||||
readonly consumerId = signal<string>(this.pageParams()['consumerId']!);
|
||||
readonly businessId = signal<string>(this.pageParams()['businessActivityId']!);
|
||||
editMode = signal<boolean>(false);
|
||||
visibleAccountsChargeForm = signal<boolean>(false);
|
||||
|
||||
readonly loading = computed(() => this.store.loading());
|
||||
readonly businessActivity = computed(() => this.store.entity());
|
||||
@@ -52,4 +57,8 @@ export class PartnerUserBusinessActivityComponent {
|
||||
...this.store.breadcrumbItems(),
|
||||
]);
|
||||
}
|
||||
|
||||
showAccountsChargeDialog() {
|
||||
this.visibleAccountsChargeForm.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { BreadcrumbService } from '@/core/services';
|
||||
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||
import { JalaliDateDirective } from '@/shared/directives';
|
||||
import { getLicenseStatus } from '@/utils';
|
||||
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Button } from 'primeng/button';
|
||||
import { ConsumerAccountListComponent } from '../components/accounts/list.component';
|
||||
import { ConsumerBusinessActivitiesComponent } from '../components/businessActivities/list.component';
|
||||
import { ConsumerUserFormComponent } from '../components/form.component';
|
||||
import { ConsumerLicenseFormComponent } from '../components/licenses/form.component';
|
||||
import { ConsumerStore } from '../store/consumer.store';
|
||||
|
||||
@Component({
|
||||
@@ -20,9 +17,6 @@ import { ConsumerStore } from '../store/consumer.store';
|
||||
ConsumerUserFormComponent,
|
||||
ConsumerAccountListComponent,
|
||||
ConsumerBusinessActivitiesComponent,
|
||||
Button,
|
||||
JalaliDateDirective,
|
||||
ConsumerLicenseFormComponent,
|
||||
],
|
||||
})
|
||||
export class ConsumerComponent {
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<p-card class="border border-surface-border bg-surface-card rounded-2xl p-4 text-text-color">
|
||||
<div class="text-center w-full flex items-center justify-center gap-1">
|
||||
<span class="text-xl font-semibold">وضعیت {{ title }}</span>
|
||||
</div>
|
||||
<hr class="mb-6!" />
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<div class="flex flex-col gap-1 items-center justify-center">
|
||||
<span class="text-sm text-muted-color">فروخته شده</span>
|
||||
<span class="text-lg font-semibold">{{ activated }}</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 items-center justify-center">
|
||||
<span class="text-sm text-muted-color">منقضی شده</span>
|
||||
<span class="text-lg font-semibold">{{ expired }}</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 items-center justify-center">
|
||||
<span class="text-sm text-muted-color">قابل فروش</span>
|
||||
<span class="text-lg font-semibold">
|
||||
{{ remained }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</p-card>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Card } from 'primeng/card';
|
||||
|
||||
@Component({
|
||||
selector: 'partner-license-info-template',
|
||||
templateUrl: './license-info-template.component.html',
|
||||
imports: [Card],
|
||||
})
|
||||
export class PartnerLicenseInfoTemplateComponent {
|
||||
@Input({ required: true }) title!: string;
|
||||
@Input({ required: true }) total!: number;
|
||||
@Input({ required: true }) activated!: number;
|
||||
@Input({ required: true }) expired!: number;
|
||||
@Input({ required: true }) remained!: number;
|
||||
constructor() {}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import { defaultBaseStateData, EntityState, EntityStore } from '@/core/state';
|
||||
import { IPartnerInfoResponse } from '@/domains/partner/models';
|
||||
import { PartnerService } from '@/domains/partner/services/main.service';
|
||||
import { LayoutService } from '@/layout/service/layout.service';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { catchError, finalize } from 'rxjs';
|
||||
|
||||
@@ -12,7 +11,6 @@ interface PartnerInfoState extends EntityState<IPartnerInfoResponse> {}
|
||||
})
|
||||
export class PartnerInfoStore extends EntityStore<IPartnerInfoResponse, PartnerInfoState> {
|
||||
private readonly service = inject(PartnerService);
|
||||
private readonly layoutService = inject(LayoutService);
|
||||
|
||||
constructor() {
|
||||
super(defaultBaseStateData);
|
||||
|
||||
@@ -1 +1,37 @@
|
||||
<div class="grid grid-cols-2 gap-10">به پنل مدیریتی شریک تجاری خوش آمدید.</div>
|
||||
<div class="grid grid-cols-3 w-full gap-4">
|
||||
<partner-license-info-template
|
||||
title="لایسنسها"
|
||||
[total]="entity()?.licenses_status?.total_purchased || 0"
|
||||
[expired]="entity()?.licenses_status?.total_expired || 0"
|
||||
[activated]="entity()?.licenses_status?.total_activated || 0"
|
||||
[remained]="
|
||||
(entity()?.licenses_status?.total_purchased || 0) -
|
||||
(entity()?.licenses_status?.total_activated || 0) -
|
||||
(entity()?.licenses_status?.total_expired || 0)
|
||||
"
|
||||
/>
|
||||
|
||||
<partner-license-info-template
|
||||
title="شارژ کاربران"
|
||||
[total]="entity()?.account_quotas_status?.total_purchased || 0"
|
||||
[expired]="entity()?.account_quotas_status?.total_expired || 0"
|
||||
[activated]="entity()?.account_quotas_status?.total_activated || 0"
|
||||
[remained]="
|
||||
(entity()?.account_quotas_status?.total_purchased || 0) -
|
||||
(entity()?.account_quotas_status?.total_activated || 0) -
|
||||
(entity()?.account_quotas_status?.total_expired || 0)
|
||||
"
|
||||
/>
|
||||
|
||||
<partner-license-info-template
|
||||
title="تمدید لایسنسها"
|
||||
[total]="entity()?.license_renews_status?.total_purchased || 0"
|
||||
[expired]="entity()?.license_renews_status?.total_expired || 0"
|
||||
[activated]="entity()?.license_renews_status?.total_activated || 0"
|
||||
[remained]="
|
||||
(entity()?.license_renews_status?.total_purchased || 0) -
|
||||
(entity()?.license_renews_status?.total_activated || 0) -
|
||||
(entity()?.license_renews_status?.total_expired || 0)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
import { PartnerLicenseInfoTemplateComponent } from '../components/licenseInfo/license-info-template.component';
|
||||
import { PartnerInfoStore } from '../store/main.store';
|
||||
|
||||
@Component({
|
||||
selector: 'partner-dashboard',
|
||||
templateUrl: './index.component.html',
|
||||
imports: [PartnerLicenseInfoTemplateComponent],
|
||||
})
|
||||
export class DashboardComponent {
|
||||
private readonly store = inject(PartnerInfoStore);
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
<div class="w-svw h-svh bg-surface-ground flex flex-col gap-4 p-4">
|
||||
<div class="w-full flex items-center gap-4 shrink-0 justify-between">
|
||||
<div class="flex gap-2 items-center">
|
||||
<div class="w-10 h-10">
|
||||
<img [src]="placeholderLogo" alt="Logo" class="w-full h-full object-cover rounded-md bg-surface-card" />
|
||||
</div>
|
||||
@if (posInfo()) {
|
||||
<span class="text-lg font-bold">{{ posInfo()?.name }} - شعبه {{ posInfo()?.complex?.name }}</span>
|
||||
<div class="w-10 h-10">
|
||||
<img [src]="placeholderLogo" alt="Logo" class="w-full h-full object-cover rounded-md bg-surface-card" />
|
||||
</div>
|
||||
<span class="text-lg font-bold">
|
||||
{{ posInfo()?.name }} ({{ posInfo()?.complex!.name }} - {{ posInfo()?.businessActivity!.name }})
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
|
||||
@@ -8,8 +8,7 @@ import { ButtonDirective } from 'primeng/button';
|
||||
import { Card } from 'primeng/card';
|
||||
import { Menu } from 'primeng/menu';
|
||||
import images from 'src/assets/images';
|
||||
import { PosProfileStore } from '../store';
|
||||
import { PosStore } from '../store/pos.store';
|
||||
import { PosInfoStore, PosProfileStore } from '../store';
|
||||
import { PosChooseCardsComponent } from './choose-pos.component';
|
||||
|
||||
@Component({
|
||||
@@ -28,19 +27,20 @@ import { PosChooseCardsComponent } from './choose-pos.component';
|
||||
export class PosLayoutComponent {
|
||||
constructor() {}
|
||||
|
||||
private readonly posInfoStore = inject(PosStore);
|
||||
private readonly posProfileStore = inject(PosProfileStore);
|
||||
private readonly posInfoStore = inject(PosInfoStore);
|
||||
private readonly authService = inject(AuthService);
|
||||
|
||||
readonly posInfoLoading = computed(() => this.posInfoStore.loading());
|
||||
readonly posInfo = computed(() => this.posInfoStore.entity());
|
||||
readonly posInfoError = computed(() => this.posInfoStore.error());
|
||||
readonly posProfileLoading = computed(() => this.posProfileStore.loading());
|
||||
readonly posProfile = computed(() => this.posProfileStore.entity());
|
||||
readonly posProfileError = computed(() => this.posProfileStore.error());
|
||||
|
||||
readonly loading = computed(() => this.posInfoLoading() || this.posProfileLoading());
|
||||
readonly error = computed(() => this.posInfoError() || this.posProfileError());
|
||||
readonly posInfoLoading = computed(() => this.posInfoStore.loading());
|
||||
readonly posInfo = computed(() => this.posInfoStore.entity());
|
||||
readonly posInfoError = computed(() => this.posInfoStore.error());
|
||||
|
||||
readonly loading = computed(() => this.posProfileLoading());
|
||||
readonly error = computed(() => this.posProfileError());
|
||||
|
||||
logout = () => {
|
||||
this.authService.logout();
|
||||
@@ -64,8 +64,11 @@ export class PosLayoutComponent {
|
||||
now = new Date();
|
||||
|
||||
getData() {
|
||||
this.posProfileStore.getData().subscribe();
|
||||
this.posInfoStore.getData().subscribe();
|
||||
this.posProfileStore.getData().subscribe({
|
||||
next: () => {
|
||||
this.posInfoStore.getData().subscribe();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onChoosePos() {
|
||||
|
||||
@@ -120,6 +120,7 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
||||
const baseTotalAmount = totalAmountBeforeProfit + profitAmount;
|
||||
const baseAmountForDiscountCalculation =
|
||||
this.discountType() === 1 ? profitAmount : baseTotalAmount;
|
||||
|
||||
const taxAmount = (profitAmount + commissionAmount + wageAmount - discountAmount) * 0.1;
|
||||
const totalAmount = baseTotalAmount - discountAmount + taxAmount;
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<div class="flex gap-4 grow overflow-hidden h-full">
|
||||
@if (posInfo()) {
|
||||
@if (loading()) {
|
||||
<shared-page-loading />
|
||||
|
||||
} @else if (pos()) {
|
||||
<div class="flex gap-4 grow overflow-hidden h-full">
|
||||
<div class="grow h-full overflow-auto">
|
||||
<pos-goods />
|
||||
</div>
|
||||
<div class="shrink-0 h-full">
|
||||
<pos-order-section />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||
import { PosStore } from '@/domains/pos/store/pos.store';
|
||||
import { PosInfoStore } from '@/domains/pos/store/pos.store';
|
||||
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
import { PosGoodsComponent } from '../components/goods.component';
|
||||
import { PosOrderSectionComponent } from '../components/order/order-section.component';
|
||||
@@ -9,10 +10,16 @@ import { PosOrderSectionComponent } from '../components/order/order-section.comp
|
||||
templateUrl: './root.component.html',
|
||||
host: { class: 'grow overflow-hidden' },
|
||||
|
||||
imports: [PosGoodsComponent, PosOrderSectionComponent],
|
||||
imports: [PosGoodsComponent, PosOrderSectionComponent, PageLoadingComponent],
|
||||
})
|
||||
export class PosLandingComponent {
|
||||
private readonly posStore = inject(PosStore);
|
||||
private readonly store = inject(PosInfoStore);
|
||||
|
||||
readonly posInfo = computed(() => this.posStore.entity());
|
||||
readonly loading = computed(() => this.store.loading());
|
||||
readonly pos = computed(() => this.store.entity());
|
||||
readonly error = computed(() => this.store.error());
|
||||
|
||||
getData() {
|
||||
this.store.getData().subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ interface PosState extends EntityState<IPosInfoResponse> {
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PosStore extends EntityStore<IPosInfoResponse, PosState> {
|
||||
export class PosInfoStore extends EntityStore<IPosInfoResponse, PosState> {
|
||||
private readonly service = inject(PosService);
|
||||
|
||||
constructor(private readonly cookieService: CookieService) {
|
||||
|
||||
+5
-5
@@ -6,11 +6,11 @@ import { nowJalali } from '@/utils';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
import { IPartnerChargeAccountRequest } from '../../models/chargeAccount_io';
|
||||
import { IAdminPartnerChargeAccountRequest } from '../../models/chargeAccount_io';
|
||||
import { AdminPartnerChargeAccountService } from '../../services/chargeAccount.service';
|
||||
|
||||
@Component({
|
||||
selector: 'partner-charge-account-form-dialog',
|
||||
selector: 'admin-partner-charge-account-form-dialog',
|
||||
templateUrl: './charge-account-form-dialog.component.html',
|
||||
imports: [
|
||||
Dialog,
|
||||
@@ -20,8 +20,8 @@ import { AdminPartnerChargeAccountService } from '../../services/chargeAccount.s
|
||||
UikitFlatpickrJalaliComponent,
|
||||
],
|
||||
})
|
||||
export class PartnerChargeAccountFormDialogComponent extends AbstractFormDialog<
|
||||
IPartnerChargeAccountRequest,
|
||||
export class AdminPartnerChargeAccountFormDialogComponent extends AbstractFormDialog<
|
||||
IAdminPartnerChargeAccountRequest,
|
||||
any
|
||||
> {
|
||||
@Input({ required: true }) partnerId!: string;
|
||||
@@ -35,7 +35,7 @@ export class PartnerChargeAccountFormDialogComponent extends AbstractFormDialog<
|
||||
|
||||
minDate = nowJalali();
|
||||
|
||||
submitForm(payload: IPartnerChargeAccountRequest) {
|
||||
submitForm(payload: IAdminPartnerChargeAccountRequest) {
|
||||
return this.service.charge(this.partnerId, payload);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { IPartnerChargeAccountRawResponse } from '../../models';
|
||||
import { IAdminPartnerChargeAccountRawResponse } from '../../models';
|
||||
import { AdminPartnerChargeAccountService } from '../../services/chargeAccount.service';
|
||||
|
||||
@Component({
|
||||
@@ -9,7 +9,7 @@ import { AdminPartnerChargeAccountService } from '../../services/chargeAccount.s
|
||||
templateUrl: './list.component.html',
|
||||
imports: [PageDataListComponent],
|
||||
})
|
||||
export class AdminPartnerChargeAccountListComponent extends AbstractList<IPartnerChargeAccountRawResponse> {
|
||||
export class AdminPartnerChargeAccountListComponent extends AbstractList<IAdminPartnerChargeAccountRawResponse> {
|
||||
@Input({ required: true }) partnerId!: string;
|
||||
|
||||
private readonly service = inject(AdminPartnerChargeAccountService);
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import { IPartnerActivatedLicenseResponse } from '../../models';
|
||||
import { AdminPartnerActivatedLicensesService } from '../../services/licenses.service';
|
||||
|
||||
@Component({
|
||||
selector: 'admin-partner-licenses',
|
||||
templateUrl: './list.component.html',
|
||||
imports: [PageDataListComponent, ButtonDirective],
|
||||
imports: [PageDataListComponent],
|
||||
})
|
||||
export class AdminPartnerLicensesComponent extends AbstractList<IPartnerActivatedLicenseResponse> {
|
||||
@Input({ required: true }) partnerId!: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface IPartnerChargeAccountRawResponse {
|
||||
export interface IAdminPartnerChargeAccountRawResponse {
|
||||
id: string;
|
||||
created_at: string;
|
||||
tracking_code: string;
|
||||
@@ -8,9 +8,9 @@ export interface IPartnerChargeAccountRawResponse {
|
||||
remained_license_count: number;
|
||||
}
|
||||
|
||||
export interface IPartnerChargeAccountResponse extends IPartnerChargeAccountRawResponse {}
|
||||
export interface IAdminPartnerChargeAccountResponse extends IAdminPartnerChargeAccountRawResponse {}
|
||||
|
||||
export interface IPartnerChargeAccountRequest {
|
||||
export interface IAdminPartnerChargeAccountRequest {
|
||||
quantity: number;
|
||||
activated_expires_at: string;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PARTNER_CHARGE_ACCOUNT_API_ROUTES } from '../constants';
|
||||
import {
|
||||
IPartnerChargeAccountRawResponse,
|
||||
IPartnerChargeAccountRequest,
|
||||
IPartnerChargeAccountResponse,
|
||||
IAdminPartnerChargeAccountRawResponse,
|
||||
IAdminPartnerChargeAccountRequest,
|
||||
IAdminPartnerChargeAccountResponse,
|
||||
} from '../models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
@@ -15,16 +15,19 @@ export class AdminPartnerChargeAccountService {
|
||||
|
||||
private apiRoutes = PARTNER_CHARGE_ACCOUNT_API_ROUTES;
|
||||
|
||||
getAll(partnerId: string): Observable<IPaginatedResponse<IPartnerChargeAccountRawResponse>> {
|
||||
return this.http.get<IPaginatedResponse<IPartnerChargeAccountResponse>>(
|
||||
getAll(partnerId: string): Observable<IPaginatedResponse<IAdminPartnerChargeAccountResponse>> {
|
||||
return this.http.get<IPaginatedResponse<IAdminPartnerChargeAccountRawResponse>>(
|
||||
this.apiRoutes.single(partnerId),
|
||||
);
|
||||
}
|
||||
|
||||
charge(
|
||||
partnerId: string,
|
||||
data: IPartnerChargeAccountRequest,
|
||||
): Observable<IPartnerChargeAccountRawResponse> {
|
||||
return this.http.post<IPartnerChargeAccountResponse>(this.apiRoutes.single(partnerId), data);
|
||||
data: IAdminPartnerChargeAccountRequest,
|
||||
): Observable<IAdminPartnerChargeAccountResponse> {
|
||||
return this.http.post<IAdminPartnerChargeAccountRawResponse>(
|
||||
this.apiRoutes.single(partnerId),
|
||||
data,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@
|
||||
(onSubmit)="getData()"
|
||||
/>
|
||||
|
||||
<partner-charge-account-form-dialog
|
||||
<admin-partner-charge-account-form-dialog
|
||||
[(visible)]="visibleChargeAccountFormDialog"
|
||||
[partnerId]="partnerId()"
|
||||
(onSubmit)="getData()"
|
||||
></partner-charge-account-form-dialog>
|
||||
></admin-partner-charge-account-form-dialog>
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Button } from 'primeng/button';
|
||||
import { Divider } from 'primeng/divider';
|
||||
import { ConsumerAccountListComponent } from '../components/accounts/list.component';
|
||||
import { PartnerChargeLicenseFormDialogComponent } from '../components/charge-license-form-dialog.component';
|
||||
import { PartnerChargeAccountFormDialogComponent } from '../components/chargeAccount/charge-account-form-dialog.component';
|
||||
import { AdminPartnerChargeAccountFormDialogComponent } from '../components/chargeAccount/charge-account-form-dialog.component';
|
||||
import { AdminPartnerChargeAccountListComponent } from '../components/chargeAccount/list.component';
|
||||
import { AdminPartnerChargeLicenseTransactionListComponent } from '../components/chargeLicenseTransactions/list.component';
|
||||
import { GuildFormComponent } from '../components/form.component';
|
||||
@@ -24,7 +24,7 @@ import { PartnerStore } from '../store/partner.store';
|
||||
ConsumerAccountListComponent,
|
||||
Button,
|
||||
AdminPartnerChargeAccountListComponent,
|
||||
PartnerChargeAccountFormDialogComponent,
|
||||
AdminPartnerChargeAccountFormDialogComponent,
|
||||
PartnerChargeLicenseFormDialogComponent,
|
||||
AdminPartnerLicensesComponent,
|
||||
AdminPartnerChargeLicenseTransactionListComponent,
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
<ng-template #title>
|
||||
<ng-container [ngTemplateOutlet]="header">
|
||||
<div class="flex items-center gap-10 justify-between">
|
||||
<h5 class="font-bold">{{ cardTitle }}</h5>
|
||||
<h5 class="font-bold py-1.5">{{ cardTitle }}</h5>
|
||||
<div class="flex items-center gap-2 shrink-0">
|
||||
<ng-container [ngTemplateOutlet]="moreActions"></ng-container>
|
||||
@if (showRefresh) {
|
||||
<p-button icon="pi pi-refresh" outlined (click)="refresh()"></p-button>
|
||||
}
|
||||
@if (editable) {
|
||||
<button
|
||||
pButton
|
||||
|
||||
@@ -9,18 +9,19 @@ import {
|
||||
signal,
|
||||
TemplateRef,
|
||||
} from '@angular/core';
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import { Button, ButtonDirective } from 'primeng/button';
|
||||
import { Card } from 'primeng/card';
|
||||
|
||||
@Component({
|
||||
selector: 'app-card-data',
|
||||
standalone: true,
|
||||
templateUrl: './card-data.component.html',
|
||||
imports: [Card, CommonModule, ButtonDirective],
|
||||
imports: [Card, CommonModule, ButtonDirective, Button],
|
||||
})
|
||||
export class AppCardComponent {
|
||||
@Input() cardTitle!: string;
|
||||
@Input() editable: boolean = false;
|
||||
@Input() showRefresh: boolean = false;
|
||||
|
||||
@Input()
|
||||
set editMode(v: boolean) {
|
||||
@@ -32,6 +33,7 @@ export class AppCardComponent {
|
||||
}
|
||||
private editModeSignal = signal(false);
|
||||
@Output() editModeChange = new EventEmitter<boolean>();
|
||||
@Output() onRefresh = new EventEmitter<void>();
|
||||
|
||||
@ContentChild('header', { static: true }) header?: Maybe<TemplateRef<any>>;
|
||||
@ContentChild('moreActions', { static: true }) moreActions?: Maybe<TemplateRef<any>>;
|
||||
@@ -47,4 +49,8 @@ export class AppCardComponent {
|
||||
onEditClick() {
|
||||
this.editModeChange.emit(!this.editMode);
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.onRefresh.emit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,6 @@ export class PageDataListComponent<I> {
|
||||
|
||||
getTemplate(col: IColumn): TemplateRef<any> | null {
|
||||
const v = col.customDataModel;
|
||||
|
||||
return v instanceof TemplateRef ? (v as TemplateRef<any>) : null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user