create bankAccount, posAccount and update inventories

This commit is contained in:
2025-12-26 01:20:44 +03:30
parent f671e37b14
commit abfb2f3479
42 changed files with 920 additions and 95 deletions
@@ -0,0 +1,10 @@
<p-dialog
header="فرم حساب بانکی"
[(visible)]="visible"
[modal]="true"
[style]="{ width: '600px', zIndex: '100000' }"
appendTo="body"
[closable]="true"
>
<bank-account-form-template [initialValues]="initialValues" (onSubmitForm)="submit($event)" (onCancel)="close()" />
</p-dialog>
@@ -0,0 +1,57 @@
import { ToastService } from '@/core/services/toast.service';
import { BankAccountFormTemplateComponent } from '@/modules/bankAccounts/components/form-template.component';
import { IBankAccountsResponse } from '@/modules/bankAccounts/models';
import { Component, EventEmitter, Input, Output, signal } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { Dialog } from 'primeng/dialog';
import { IInventoryBankAccountRequest } from '../../models/bankAccounts.io';
import { InventoryBankAccountsService } from '../../services';
@Component({
selector: 'inventory-create-bank-account-form',
templateUrl: './create-bank-account-form.component.html',
imports: [ReactiveFormsModule, Dialog, BankAccountFormTemplateComponent],
})
export class InventoryCreateBankAccountFormComponent {
@Input() inventoryId!: number;
@Input() initialValues?: IBankAccountsResponse;
@Input()
set visible(v: boolean) {
this.visibleSignal.set(!!v);
}
get visible() {
return this.visibleSignal();
}
private visibleSignal = signal(false);
@Output() visibleChange = new EventEmitter<boolean>();
@Output() onSubmit = new EventEmitter<IBankAccountsResponse>();
constructor(
private service: InventoryBankAccountsService,
private toastService: ToastService,
) {}
submitLoading = signal(false);
submit(payload: IInventoryBankAccountRequest) {
this.submitLoading.set(true);
this.service.create(this.inventoryId, payload).subscribe({
next: (res) => {
this.toastService.success({
text: `حساب بانکی ${payload.name} با موفقیت ایجاد شد`,
});
this.close();
this.onSubmit.emit();
},
error: () => {
this.submitLoading.set(false);
},
});
}
close() {
this.visibleChange.emit(false);
}
}
@@ -0,0 +1,6 @@
<p-dialog header="الصاق حساب بانکی" [(visible)]="visible" [modal]="true" [style]="{ width: '500px' }" [closable]="true">
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
<bank-accounts-select-field [control]="form.controls.bankAccountId" [showClear]="false" />
<app-form-footer-actions [submitLabel]="'الصاق'" [loading]="form.disabled" (onCancel)="close()" />
</form>
</p-dialog>
@@ -0,0 +1,37 @@
import { BankAccountsSelectComponent } from '@/modules/bankAccounts/components/select/select.component';
import { AbstractFormDialog } from '@/shared/components/abstract-form-dialog.component';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { Component, inject } from '@angular/core';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { Dialog } from 'primeng/dialog';
import {
IInventoryAssignBankAccountRequest,
IInventoryBankAccountResponse,
} from '../../models/bankAccounts.io';
import { InventoryBankAccountsService } from '../../services';
@Component({
selector: 'app-inventory-bank-account-form',
templateUrl: './form.component.html',
imports: [ReactiveFormsModule, Dialog, BankAccountsSelectComponent, FormFooterActionsComponent],
})
export class InventoryBankAccountFormComponent extends AbstractFormDialog<
IInventoryBankAccountResponse,
IInventoryAssignBankAccountRequest
> {
private readonly route = inject(ActivatedRoute);
private readonly service = inject(InventoryBankAccountsService);
form = this.fb.group({
bankAccountId: this.fb.control<number>(0, {
nonNullable: true,
validators: [Validators.required],
}),
});
submitForm(payload: IInventoryAssignBankAccountRequest) {
const inventoryId = this.route.snapshot.paramMap.get('inventoryId')!;
return this.service.assign(Number(inventoryId), payload);
}
}
@@ -0,0 +1,33 @@
<p-card class="">
<ng-template #header>
<div class="p-4 flex items-center justify-between">
<span class="text-xl font-bold">حساب‌های بانکی متصل به انبار</span>
<div class="flex gap-2">
<button pButton outlined (click)="openAddForm()">الصاق حساب بانکی جدید</button>
<button pButton outlined (click)="openCreateForm()">ایجاد و الصاق حساب بانکی</button>
<button pButton outlined icon="pi pi-refresh" [loading]="loading()" (click)="getItems()"></button>
</div>
</div>
</ng-template>
<app-page-data-list
[columns]="columns"
emptyPlaceholderTitle="حساب بانکی‌ای به این انبار متصل نشده است"
emptyPlaceholderDescription="برای الصاق حساب بانکی، روی دکمهٔ بالا کلیک کنید."
[items]="items()"
[loading]="loading()"
(onAdd)="openAddForm()"
>
<ng-template #actions let-item>
<button pButton icon="pi pi-trash" severity="danger" (click)="unassignBankAccount($event, item)"></button>
</ng-template>
</app-page-data-list>
<app-inventory-bank-account-form [(visible)]="visibleForm" (onSubmit)="refresh()" />
<inventory-create-bank-account-form
[(visible)]="visibleBankAccountForm"
[inventoryId]="inventoryId"
(onSubmit)="refresh()"
/>
<p-confirmdialog />
</p-card>
<!-- <inventory-form [(visible)]="visibleForm" (onSubmit)="refresh()" /> -->
@@ -0,0 +1,152 @@
import {
IColumn,
PageDataListComponent,
} from '@/shared/components/pageDataList/page-data-list.component';
import { Component, inject, signal, TemplateRef, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ConfirmationService, MessageService } from 'primeng/api';
import { ButtonDirective } from 'primeng/button';
import { Card } from 'primeng/card';
import { ConfirmDialog } from 'primeng/confirmdialog';
import { InventoryPosAccountFormComponent } from '../../components/posAccounts/form.component';
import { IInventoryBankAccountResponse } from '../../models/bankAccounts.io';
import { InventoryBankAccountsService } from '../../services';
import { InventoryCreateBankAccountFormComponent } from './create-bank-account-form.component';
import { InventoryBankAccountFormComponent } from './form.component';
@Component({
selector: 'app-inventory-bank-accounts-list',
templateUrl: './list.component.html',
imports: [
PageDataListComponent,
Card,
ButtonDirective,
ConfirmDialog,
InventoryPosAccountFormComponent,
InventoryBankAccountFormComponent,
InventoryCreateBankAccountFormComponent,
],
providers: [ConfirmationService],
})
export class InventoryBankAccountsListComponent {
private confirmationService = inject(ConfirmationService);
private messageService = inject(MessageService);
private readonly route = inject(ActivatedRoute);
private readonly service = inject(InventoryBankAccountsService);
@ViewChild('actions', { static: true }) actionsTpl!: TemplateRef<any>;
items = signal<IInventoryBankAccountResponse[]>([]);
loading = signal<boolean>(false);
visibleForm = signal<boolean>(false);
visibleBankAccountForm = signal<boolean>(false);
inventoryId = this.route.snapshot.params['inventoryId'];
columns = [] as IColumn<IInventoryBankAccountResponse>[];
ngOnInit() {
this.getItems();
this.columns = [
{
field: 'name',
header: 'عنوان حساب',
customDataModel(item) {
return item.name;
},
},
{
field: 'bankName',
header: 'نام بانک',
customDataModel(item) {
return `${item.branch.bank.name} - شعبه‌ی ${item.name}`;
},
},
{
field: 'accountNumber',
header: 'شماره حساب',
customDataModel(item) {
return item.accountNumber;
},
},
{
field: 'relatedPOSes',
header: 'نقاط فروش متصل',
customDataModel(item) {
return item.posAccounts.length || '0';
},
},
{
field: 'actions',
header: '',
customDataModel: this.actionsTpl,
width: '100px',
},
];
}
getItems() {
this.loading.set(true);
this.service.getBankAccounts(this.inventoryId).subscribe({
next: (res) => {
this.items.set(res.data);
this.loading.set(false);
},
error: () => {
this.loading.set(false);
},
});
}
refresh() {
this.getItems();
}
openAddForm() {
this.visibleForm.set(true);
}
openCreateForm() {
this.visibleBankAccountForm.set(true);
}
showConfirmation(event: MouseEvent, item: IInventoryBankAccountResponse) {
this.confirmationService.confirm({
target: event.target as EventTarget,
message: 'از حذف این حساب بانکی اطمینان دارید؟',
header: 'تأییدیه',
closable: true,
closeOnEscape: true,
icon: 'pi pi-exclamation-triangle',
rejectButtonProps: {
label: 'لغو',
severity: 'secondary',
outlined: true,
},
acceptButtonProps: {
label: 'تایید',
},
accept: () => {
this.doUnassignBankAccount(item);
},
});
}
unassignBankAccount(event: MouseEvent, item: IInventoryBankAccountResponse) {
this.showConfirmation(event, item);
}
doUnassignBankAccount(item: IInventoryBankAccountResponse) {
this.loading.set(true);
this.service.unassign(this.inventoryId, { bankAccountId: item.id }).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: 'موفق',
detail: 'حساب بانکی با موفقیت حذف شد',
});
this.loading.set(false);
this.getItems();
},
error: () => {
this.loading.set(false);
},
});
}
}
@@ -0,0 +1,30 @@
<uikit-field label="حساب بانکی" [control]="control" [showLabel]="showLabel" [showErrors]="showErrors">
<p-select
[loading]="loading()"
[options]="items()"
optionLabel="name"
[optionValue]="selectOptionValue"
placeholder="انتخاب حساب بانک"
[formControl]="control"
[showClear]="showClear"
[filter]="true"
appendTo="body"
>
@if (canInsert) {
<ng-template #footer>
<div class="p-3">
<p-button
label="افزودن حساب جدید"
fluid
severity="secondary"
text
size="small"
icon="pi pi-plus"
(onClick)="onOpenForm()"
/>
</div>
</ng-template>
}
</p-select>
<app-inventory-bank-account-form [(visible)]="isOpenFormDialog" (onSubmit)="refresh()" />
</uikit-field>
@@ -0,0 +1,45 @@
import { AbstractSelectComponent } from '@/shared/components';
import { UikitFieldComponent } from '@/uikit';
import { Component, Input } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { Button } from 'primeng/button';
import { Select } from 'primeng/select';
import { IInventoryBankAccountResponse } from '../../models';
import { InventoryBankAccountsService } from '../../services';
import { InventoryBankAccountFormComponent } from './form.component';
@Component({
selector: 'app-inventory-bank-account-select',
templateUrl: './select.component.html',
imports: [
UikitFieldComponent,
Select,
Button,
InventoryBankAccountFormComponent,
ReactiveFormsModule,
],
})
export class InventoryBankAccountSelectComponent extends AbstractSelectComponent<IInventoryBankAccountResponse> {
@Input() inventoryId!: string;
@Input() override showClear: boolean = false;
constructor(private service: InventoryBankAccountsService) {
super();
}
ngOnInit() {
this.getData();
}
getData(): void {
this.loading.set(true);
this.service.getBankAccounts(Number(this.inventoryId)).subscribe({
next: (res) => {
this.loading.set(false);
this.items.set(res.data);
},
error: () => {
this.loading.set(false);
},
});
}
}
@@ -33,7 +33,11 @@
</td>
<td>{{ movement.receiptId }}</td>
<td>
<catalog-movement-reference-tag [type]="movement.info.referenceType" [movementType]="movement.info.type" />
<catalog-movement-reference-tag
[type]="movement.info.referenceType"
[movementType]="movement.info.type"
[counterName]="movement.info.counterInventory?.name"
/>
</td>
<td>{{ movement.count }}</td>
<td>{{ movement.info.quantity }}</td>
@@ -92,9 +96,6 @@
<td>{{ movement.quantity }}</td>
<td><span [appPriceMask]="movement.fee"></span></td>
<td><span [appPriceMask]="movement.totalCost"></span></td>
<td>
<!-- <p-tag [value]="order.status" [severity]="getStatusSeverity(order.status)" /> -->
</td>
<td>
<p-button type="button" icon="pi pi-search" [routerLink]="'/products/' + movement.product.id" />
</td>
@@ -0,0 +1,15 @@
<p-dialog
header="فرم نقطه فروش"
[(visible)]="visible"
[modal]="true"
[style]="{ width: '600px', zIndex: '100000' }"
appendTo="body"
[closable]="true"
>
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
<app-input label="عنوان" [control]="form.controls.name" name="name" />
<app-input label="کد" [control]="form.controls.code" name="code" />
<app-inventory-bank-account-select [control]="form.controls.bankAccountId" [inventoryId]="inventoryId" />
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="form.disabled" (onCancel)="close()" />
</form>
</p-dialog>
@@ -0,0 +1,51 @@
import { InputComponent } from '@/shared/components';
import { AbstractFormDialog } from '@/shared/components/abstract-form-dialog.component';
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 { IInventoryPosAccountRequest, IInventoryPosAccountResponse } from '../../models';
import { InventoryPosAccountsService } from '../../services/posAccounts.service';
import { InventoryBankAccountSelectComponent } from '../bankAccounts/select.component';
@Component({
selector: 'app-inventory-pos-account-form',
templateUrl: './form.component.html',
imports: [
Dialog,
ReactiveFormsModule,
InputComponent,
FormFooterActionsComponent,
InventoryBankAccountSelectComponent,
],
})
export class InventoryPosAccountFormComponent extends AbstractFormDialog<
IInventoryPosAccountResponse,
IInventoryPosAccountRequest
> {
@Input() inventoryId!: string;
private readonly service = inject(InventoryPosAccountsService);
form = this.fb.group({
name: this.fb.control<string>(this.initialValues?.name || '', {
nonNullable: true,
validators: [Validators.required],
}),
code: this.fb.control<string>(this.initialValues?.code || '', {
nonNullable: true,
validators: [Validators.required],
}),
description: this.fb.control<string>(this.initialValues?.description || '', {
nonNullable: true,
}),
bankAccountId: this.fb.control<number>(this.initialValues?.bankAccount?.id || 0, {
nonNullable: true,
validators: [Validators.required],
}),
});
submitForm(payload: IInventoryPosAccountRequest) {
return this.service.create(Number(this.inventoryId), payload);
}
}
@@ -5,7 +5,6 @@ import { Component, inject, signal } from '@angular/core';
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
import { ButtonDirective } from 'primeng/button';
import { Card } from 'primeng/card';
import { InputText } from 'primeng/inputtext';
import { Select } from 'primeng/select';
import { TableModule, TableRowSelectEvent, TableRowUnSelectEvent } from 'primeng/table';
import { Textarea } from 'primeng/textarea';
@@ -16,7 +15,6 @@ import {
IInventoryTransferRequest,
} from '../../models';
import { InventoriesService } from '../../services/main.service';
import { InventoriesSelectComponent } from '../select/select.component';
@Component({
selector: 'inventories-transfer-form',
@@ -24,13 +22,11 @@ import { InventoriesSelectComponent } from '../select/select.component';
imports: [
ReactiveFormsModule,
Card,
InventoriesSelectComponent,
InputComponent,
Textarea,
UikitFieldComponent,
Select,
TableModule,
InputText,
ButtonDirective,
UikitCounterComponent,
],
@@ -1,3 +1,5 @@
import { INVENTORY_POS_API_ROUTES } from './pos';
const baseUrl = '/api/v1/inventories';
export const INVENTORIES_API_ROUTES = {
@@ -8,4 +10,8 @@ export const INVENTORIES_API_ROUTES = {
stock: (inventoryId: string) => `${baseUrl}/${inventoryId}/stock`,
productCardex: (inventoryId: string, productId: string) =>
`${baseUrl}/${inventoryId}/products/${productId}/cardex`,
bankAccounts: (inventoryId: number) => `${baseUrl}/${inventoryId}/bank-accounts`,
assignBankAccounts: (inventoryId: number) => `${baseUrl}/${inventoryId}/bank-accounts/assign`,
unassignBankAccounts: (inventoryId: number) => `${baseUrl}/${inventoryId}/bank-accounts/unassign`,
pos: INVENTORY_POS_API_ROUTES(baseUrl),
};
@@ -0,0 +1,8 @@
export const INVENTORY_POS_API_ROUTES = (_baseUrl: string) => {
const baseUrl = (inventoryId: string) => `${_baseUrl}/${inventoryId}/pos-accounts`;
return {
list: (inventoryId: string) => `${baseUrl(inventoryId)}`,
single: (inventoryId: string, posAccountId: string) =>
`${baseUrl(inventoryId)}/${posAccountId}`,
};
};
@@ -6,7 +6,8 @@ export type TInventoriesRouteNames =
| 'inventory'
| 'transfer'
| 'products'
| 'productCardex';
| 'productCardex'
| 'posAccounts';
export const inventoriesNamedRoutes: NamedRoutes<TInventoriesRouteNames> = {
inventories: {
@@ -53,6 +54,17 @@ export const inventoriesNamedRoutes: NamedRoutes<TInventoriesRouteNames> = {
pagePath: () => '/inventories/:inventoryId/products/:productId/cardex',
},
},
posAccounts: {
path: 'inventories/:inventoryId/pos-accounts',
loadComponent: () =>
import('../../views/posAccounts/list.component').then(
(m) => m.InventoryPosAccountListComponent,
),
meta: {
title: 'نقاط فروش متصل به انبار',
pagePath: () => '/inventories/:inventoryId/pos-accounts',
},
},
};
export const INVENTORIES_ROUTES: Routes = Object.values(inventoriesNamedRoutes);
@@ -0,0 +1,23 @@
import { IBankAccountsRequest } from '@/modules/bankAccounts/models';
import { IBankAccountBranch, IInventoryPosAccountItemSummary } from './types';
export interface IInventoryBankAccountRawResponse {
id: number;
accountNumber: string;
cardNumber: null;
name: string;
iban: string;
branchId: number;
createdAt: string;
updatedAt: string;
deletedAt: null;
branch: IBankAccountBranch;
posAccounts: IInventoryPosAccountItemSummary[];
}
export interface IInventoryBankAccountResponse extends IInventoryBankAccountRawResponse {}
export interface IInventoryBankAccountRequest extends IBankAccountsRequest {}
export interface IInventoryAssignBankAccountRequest {
bankAccountId: number;
}
@@ -1,2 +1,4 @@
export * from './bankAccounts.io';
export * from './io';
export * from './posAccounts.io';
export * from './types';
@@ -0,0 +1,23 @@
import { IInventoryBankAccountSummary } from './types';
export interface IInventoryPosAccountRawResponse {
id: number;
name: string;
code: string;
description: string;
bankAccountId: number;
inventoryId: number;
createdAt: string;
updatedAt: string;
deletedAt: null;
bankAccount: IInventoryBankAccountSummary;
}
export interface IInventoryPosAccountResponse extends IInventoryPosAccountRawResponse {}
export interface IInventoryPosAccountRequest {
name: string;
code: string;
description: string;
bankAccountId: number;
}
@@ -40,3 +40,45 @@ export interface IInventoryTransferRequestItem {
}
export interface IInventoryStockProduct extends IProductRawResponse {}
export interface IBankAccountBranch {
id: number;
name: string;
code: string;
address: null;
createdAt: string;
updatedAt: string;
deletedAt: null;
bankId: number;
bank: IBankAccountBranchBank;
}
interface IBankAccountBranchBank {
id: number;
name: string;
shortName: string;
}
export interface IInventoryPosAccountItemSummary {
id: string;
name: string;
code: string;
}
export interface IInventoryBankAccountSummary {
id: number;
name: string;
accountNumber: string;
branch: IInventoryBankAccountBranch;
}
interface IInventoryBankAccountBranch {
id: number;
name: string;
bank: IInventoryBankAccountBranchBank;
}
interface IInventoryBankAccountBranchBank {
id: number;
name: string;
}
@@ -0,0 +1,55 @@
import { IPaginatedResponse } from '@/core/models/service.model';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { INVENTORIES_API_ROUTES } from '../constants';
import {
IInventoryAssignBankAccountRequest,
IInventoryBankAccountRawResponse,
IInventoryBankAccountRequest,
IInventoryBankAccountResponse,
} from '../models/bankAccounts.io';
@Injectable({ providedIn: 'root' })
export class InventoryBankAccountsService {
constructor(private http: HttpClient) {}
private apiRoutes = INVENTORIES_API_ROUTES;
getBankAccounts(
inventoryId: number,
): Observable<IPaginatedResponse<IInventoryBankAccountResponse>> {
return this.http.get<IPaginatedResponse<IInventoryBankAccountRawResponse>>(
`${this.apiRoutes.bankAccounts(inventoryId)}`,
);
}
create(
inventoryId: number,
payload: IInventoryBankAccountRequest,
): Observable<IInventoryBankAccountResponse> {
return this.http.post<IInventoryBankAccountResponse>(
`${this.apiRoutes.bankAccounts(inventoryId)}`,
payload,
);
}
assign(
inventoryId: number,
payload: IInventoryAssignBankAccountRequest,
): Observable<IInventoryBankAccountResponse> {
return this.http.post<IInventoryBankAccountResponse>(
`${this.apiRoutes.assignBankAccounts(inventoryId)}`,
payload,
);
}
unassign(
inventoryId: number,
payload: IInventoryAssignBankAccountRequest,
): Observable<IInventoryBankAccountResponse> {
return this.http.post<IInventoryBankAccountResponse>(
`${this.apiRoutes.unassignBankAccounts(inventoryId)}`,
payload,
);
}
}
@@ -0,0 +1,2 @@
export * from './bankAccounts.service';
export * from './main.service';
@@ -0,0 +1,33 @@
import { IPaginatedResponse } from '@/core/models/service.model';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { INVENTORIES_API_ROUTES } from '../constants';
import {
IInventoryPosAccountRawResponse,
IInventoryPosAccountRequest,
IInventoryPosAccountResponse,
} from '../models';
@Injectable({ providedIn: 'root' })
export class InventoryPosAccountsService {
constructor(private http: HttpClient) {}
private apiRoutes = INVENTORIES_API_ROUTES;
getList(inventoryId: number): Observable<IPaginatedResponse<IInventoryPosAccountResponse>> {
return this.http.get<IPaginatedResponse<IInventoryPosAccountRawResponse>>(
`${this.apiRoutes.pos.list(String(inventoryId))}`,
);
}
create(
inventoryId: number,
payload: IInventoryPosAccountRequest,
): Observable<IInventoryPosAccountResponse> {
return this.http.post<IInventoryPosAccountResponse>(
`${this.apiRoutes.pos.list(String(inventoryId))}`,
payload,
);
}
}
@@ -1,2 +1,3 @@
export * from './list.component';
export * from './posAccounts';
export * from './single.component';
@@ -0,0 +1 @@
export * from './list.component';
@@ -0,0 +1,23 @@
<p-card class="">
<ng-template #header>
<div class="p-4 flex items-center justify-between">
<span class="text-xl font-bold">نقاط فروش متصل به انبار</span>
<div class="flex gap-2">
<button pButton outlined (click)="openAddForm()">ایجاد نقطه فروش جدید</button>
<button pButton outlined icon="pi pi-refresh" [loading]="loading()" (click)="getItems()"></button>
</div>
</div>
</ng-template>
<app-page-data-list
[columns]="columns"
emptyPlaceholderTitle="نقطه فروش برای این انبار تعریف نشده است"
emptyPlaceholderDescription="برای تعریف نقطه‌ی فروش، روی دکمهٔ بالا کلیک کنید."
[items]="items()"
[loading]="loading()"
(onAdd)="openAddForm()"
/>
@if (inventoryId) {
<app-inventory-pos-account-form [(visible)]="visibleForm" [inventoryId]="inventoryId" />
}
</p-card>
@@ -0,0 +1,76 @@
import {
IColumn,
PageDataListComponent,
} from '@/shared/components/pageDataList/page-data-list.component';
import { Component, inject, signal } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ButtonDirective } from 'primeng/button';
import { Card } from 'primeng/card';
import { InventoryPosAccountFormComponent } from '../../components/posAccounts/form.component';
import { IInventoryPosAccountResponse } from '../../models';
import { InventoryPosAccountsService } from '../../services/posAccounts.service';
@Component({
selector: 'app-inventory-pos-account-list',
templateUrl: './list.component.html',
imports: [PageDataListComponent, Card, ButtonDirective, InventoryPosAccountFormComponent],
})
export class InventoryPosAccountListComponent {
private readonly route = inject(ActivatedRoute);
private readonly service = inject(InventoryPosAccountsService);
items = signal<IInventoryPosAccountResponse[]>([]);
loading = signal<boolean>(false);
visibleForm = signal<boolean>(false);
inventoryId = this.route.snapshot.params['inventoryId'];
columns = [] as IColumn<IInventoryPosAccountResponse>[];
ngOnInit() {
this.getItems();
this.columns = [
{
field: 'name',
header: 'عنوان نقطه فروش',
customDataModel(item) {
return item.name;
},
},
{
field: 'bankName',
header: 'حساب بانکی',
customDataModel(item) {
return `${item.bankAccount.name} - بانک ${item.bankAccount.branch.bank.name} - شعبه‌ی ${item.bankAccount.branch.name}`;
},
},
// {
// field: 'actions',
// header: '',
// customDataModel: this.actionsTpl,
// width: '100px',
// },
];
}
getItems() {
this.loading.set(true);
this.service.getList(this.inventoryId).subscribe({
next: (res) => {
this.items.set(res.data);
this.loading.set(false);
},
error: () => {
this.loading.set(false);
},
});
}
refresh() {
this.getItems();
}
openAddForm() {
this.visibleForm.set(true);
}
}
@@ -7,6 +7,13 @@
</div>
</div>
<div class="flex items-center gap-2">
<button
pButton
type="button"
label="نقاط فروش"
icon="pi pi-plus"
[routerLink]="['/inventories', inventoryId, 'pos-accounts']"
></button>
<button pButton type="button" label="افزایش موجودی" icon="pi pi-plus"></button>
<!-- [routerLink]="['/inventories', inventoryId, 'purchase']" -->
<button
@@ -38,6 +45,8 @@
</div>
</div>
<app-inventory-bank-accounts-list class="block mt-5" />
<p-card class="">
<ng-template pTemplate="header">
<div class="p-4 flex items-center justify-between">
@@ -9,6 +9,7 @@ import { Button, ButtonDirective } from 'primeng/button';
import { Card } from 'primeng/card';
import { GalleriaModule } from 'primeng/galleria';
import { TableModule } from 'primeng/table';
import { InventoryBankAccountsListComponent } from '../components/bankAccounts/list.component';
import { InventoryMovementListComponent } from '../components/movementList/movement-list.component';
import { IInventoryDetailResponse, IInventoryStockResponse } from '../models';
import { InventoriesService } from '../services/main.service';
@@ -27,6 +28,7 @@ import { InventoriesService } from '../services/main.service';
Card,
TableModule,
PriceMaskDirective,
InventoryBankAccountsListComponent,
],
})
export class InventoryComponent {