diff --git a/src/app/modules/bankAccounts/components/form-template.component.html b/src/app/modules/bankAccounts/components/form-template.component.html deleted file mode 100644 index cd9f5ad..0000000 --- a/src/app/modules/bankAccounts/components/form-template.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
- - - - - - - - diff --git a/src/app/modules/bankAccounts/components/form-template.component.ts b/src/app/modules/bankAccounts/components/form-template.component.ts deleted file mode 100644 index d18da67..0000000 --- a/src/app/modules/bankAccounts/components/form-template.component.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { BankBranchesSelectComponent } from '@/modules/bankBranches/components/select/select.component'; -import { InputComponent } from '@/shared/components'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, EventEmitter, inject, Input, Output } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { IBankAccountsRequest, IBankAccountsResponse } from '../models'; - -@Component({ - selector: 'bank-account-form-template', - templateUrl: './form-template.component.html', - imports: [ - ReactiveFormsModule, - InputComponent, - FormFooterActionsComponent, - BankBranchesSelectComponent, - ], -}) -export class BankAccountFormTemplateComponent { - @Input() initialValues?: IBankAccountsResponse; - - @Output() onSubmitForm = new EventEmitter(); - @Output() onCancel = new EventEmitter(); - - fb = inject(FormBuilder); - - form = this.fb.group({ - name: this.fb.control(this.initialValues?.name || '', { - nonNullable: true, - validators: Validators.required, - }), - branchId: this.fb.control(this.initialValues?.branch?.id || 0, { - nonNullable: true, - validators: Validators.required, - }), - cardNumber: this.fb.control(this.initialValues?.cardNumber || '', { - nonNullable: true, - validators: Validators.required, - }), - accountNumber: this.fb.control(this.initialValues?.accountNumber || '', { - nonNullable: true, - validators: Validators.required, - }), - iban: this.fb.control(this.initialValues?.iban || '', { - nonNullable: true, - validators: Validators.required, - }), - }); - - submit() { - this.form.markAllAsTouched(); - if (this.form.valid) { - this.onSubmitForm.emit(this.form.value as IBankAccountsRequest); - } - } - - close() { - this.onCancel.emit(); - } -} diff --git a/src/app/modules/bankAccounts/components/form.component.html b/src/app/modules/bankAccounts/components/form.component.html deleted file mode 100644 index 5b4880e..0000000 --- a/src/app/modules/bankAccounts/components/form.component.html +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/src/app/modules/bankAccounts/components/form.component.ts b/src/app/modules/bankAccounts/components/form.component.ts deleted file mode 100644 index dee71b8..0000000 --- a/src/app/modules/bankAccounts/components/form.component.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { Component, EventEmitter, Input, Output, signal } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { Dialog } from 'primeng/dialog'; -import { IBankAccountsRequest, IBankAccountsResponse } from '../models'; -import { BankAccountsService } from '../services/main.service'; -import { BankAccountFormTemplateComponent } from './form-template.component'; - -@Component({ - selector: 'bank-account-form', - templateUrl: './form.component.html', - imports: [ReactiveFormsModule, Dialog, BankAccountFormTemplateComponent], -}) -export class BankAccountFormComponent { - @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(); - @Output() onSubmit = new EventEmitter(); - - constructor( - private service: BankAccountsService, - private toastService: ToastService, - ) {} - - submitLoading = signal(false); - - submit(payload: IBankAccountsRequest) { - this.submitLoading.set(true); - this.service.create(payload).subscribe({ - next: (res) => { - this.toastService.success({ - text: `حساب بانکی ${payload.name} با موفقیت ایجاد شد`, - }); - this.onSubmit.emit(res); - }, - error: () => { - this.submitLoading.set(false); - }, - }); - } - - close() { - this.visibleChange.emit(false); - } -} diff --git a/src/app/modules/bankAccounts/components/select/select.component.html b/src/app/modules/bankAccounts/components/select/select.component.html deleted file mode 100644 index d8c3dc2..0000000 --- a/src/app/modules/bankAccounts/components/select/select.component.html +++ /dev/null @@ -1,30 +0,0 @@ - - - @if (canInsert) { - -
- -
-
- } -
- -
diff --git a/src/app/modules/bankAccounts/components/select/select.component.ts b/src/app/modules/bankAccounts/components/select/select.component.ts deleted file mode 100644 index 1aab0dd..0000000 --- a/src/app/modules/bankAccounts/components/select/select.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { AbstractSelectComponent } from '@/shared/components'; -import { UikitFieldComponent } from '@/uikit'; -import { Component } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { Button } from 'primeng/button'; -import { Select } from 'primeng/select'; -import { IBankAccountsResponse } from '../../models'; -import { BankAccountsService } from '../../services/main.service'; -import { BankAccountFormComponent } from '../form.component'; - -@Component({ - selector: 'bank-accounts-select-field', - templateUrl: './select.component.html', - imports: [ReactiveFormsModule, Select, UikitFieldComponent, Button, BankAccountFormComponent], -}) -export class BankAccountsSelectComponent extends AbstractSelectComponent< - IBankAccountsResponse, - IPaginatedResponse -> { - constructor(private service: BankAccountsService) { - super(); - this.getData(); - } - - getDataService() { - return this.service.getAll(); - } -} diff --git a/src/app/modules/bankAccounts/constants/apiRoutes/index.ts b/src/app/modules/bankAccounts/constants/apiRoutes/index.ts deleted file mode 100644 index 39fa1cd..0000000 --- a/src/app/modules/bankAccounts/constants/apiRoutes/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -const baseUrl = '/api/v1/bank-accounts'; - -export const BANK_ACCOUNTS_API_ROUTES = { - list: () => `${baseUrl}`, - single: (bankAccountId: string) => `${baseUrl}/${bankAccountId}`, - transactions: (bankAccountId: string) => `${baseUrl}/${bankAccountId}/transactions`, -}; diff --git a/src/app/modules/bankAccounts/constants/index.ts b/src/app/modules/bankAccounts/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/bankAccounts/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/bankAccounts/constants/routes/index.ts b/src/app/modules/bankAccounts/constants/routes/index.ts deleted file mode 100644 index a8ec966..0000000 --- a/src/app/modules/bankAccounts/constants/routes/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { NamedRoutes } from '@/core'; -import { Routes } from '@angular/router'; - -export type TBankAccountsRouteNames = 'bankAccounts' | 'bankAccount'; - -export const bankAccountsNamedRoutes: NamedRoutes = { - bankAccounts: { - path: 'bankAccounts', - loadComponent: () => import('../../views/list.component').then((m) => m.BankAccountsComponent), - meta: { - title: 'حساب‌های بانکی', - pagePath: () => '/bankAccounts', - }, - }, - bankAccount: { - path: 'bankAccounts/:bankAccountId', - loadComponent: () => import('../../views/single.component').then((m) => m.BankAccountComponent), - meta: { - title: 'حساب‌ بانکی', - pagePath: () => '/bankAccounts/:bankAccountId', - }, - }, -}; - -export const BANK_ACCOUNTS_ROUTES: Routes = Object.values(bankAccountsNamedRoutes); diff --git a/src/app/modules/bankAccounts/models/index.ts b/src/app/modules/bankAccounts/models/index.ts deleted file mode 100644 index 61a518a..0000000 --- a/src/app/modules/bankAccounts/models/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './io'; diff --git a/src/app/modules/bankAccounts/models/io.d.ts b/src/app/modules/bankAccounts/models/io.d.ts deleted file mode 100644 index e1d4a14..0000000 --- a/src/app/modules/bankAccounts/models/io.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Maybe } from '@/core'; -import { - IBankAccountBranchSummary, - IReferencePos, - IReferencePosRaw, - IReferencePurchase, - IReferencePurchaseRaw, -} from './types'; - -export interface IBankAccountsRawResponse { - id: number; - name: string; - branch: IBankAccountBranchSummary; - currentBalance: number; - accountNumber?: string; - iban?: string; - cardNumber?: string; - createdAt?: string; - updatedAt?: string; - deletedAt?: string; -} - -export interface IBankAccountsResponse extends IBankAccountsRawResponse {} - -export interface IBankAccountsRequest { - name: string; - branchId: number; - accountNumber?: string; - iban?: string; - cardNumber?: string; -} - -export interface IBankAccountTransactionRawResponse { - id: number; - bankAccountId: number; - type: string; - amount: string; - balanceAfter: string; - referenceId: number; - referenceType: string; - description: null; - createdAt: string; - reference: Maybe; -} - -export interface IBankAccountTransactionResponse extends IBankAccountTransactionRawResponse { - reference: Maybe; -} diff --git a/src/app/modules/bankAccounts/models/types.ts b/src/app/modules/bankAccounts/models/types.ts deleted file mode 100644 index a6d0ab3..0000000 --- a/src/app/modules/bankAccounts/models/types.ts +++ /dev/null @@ -1,46 +0,0 @@ -export interface IBankAccountBranchSummary { - id: number; - name: string; - code: string; - bank: Bank; -} - -interface Bank { - id: number; - name: string; - shortName: string; -} - -interface IReferenceCommon { - id: number; - code: string; - totalAmount: string; -} - -export interface IReferencePurchaseRaw extends IReferenceCommon { - supplier: IPersonSummary; -} - -export interface IReferencePosRaw extends IReferenceCommon { - customer: IPersonSummary; -} - -export interface IReferencePurchase extends IReferenceCommon { - supplier: { - id: number; - name: string; - }; -} - -export interface IReferencePos extends IReferenceCommon { - customer: { - id: number; - name: string; - }; -} - -interface IPersonSummary { - id: number; - firstName: string; - lastName: string; -} diff --git a/src/app/modules/bankAccounts/services/main.service.ts b/src/app/modules/bankAccounts/services/main.service.ts deleted file mode 100644 index cfc6590..0000000 --- a/src/app/modules/bankAccounts/services/main.service.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { Maybe } from '@/core'; -import { IPaginatedResponse } from '@/core/models/service.model'; -import { BankTransactionReferenceType } from '@/shared/catalog/transactionReferenceTypes'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { map, Observable } from 'rxjs'; -import { BANK_ACCOUNTS_API_ROUTES } from '../constants'; -import { - IBankAccountsRawResponse, - IBankAccountsRequest, - IBankAccountsResponse, - IBankAccountTransactionRawResponse, - IBankAccountTransactionResponse, -} from '../models'; -import { - IReferencePos, - IReferencePosRaw, - IReferencePurchase, - IReferencePurchaseRaw, -} from '../models/types'; - -@Injectable({ providedIn: 'root' }) -export class BankAccountsService { - constructor(private http: HttpClient) {} - - private apiRoutes = BANK_ACCOUNTS_API_ROUTES; - - getAll(): Observable> { - return this.http.get>(this.apiRoutes.list()); - } - - getSingle(bankAccountId: string): Observable { - return this.http.get(this.apiRoutes.single(bankAccountId)); - } - - create(data: IBankAccountsRequest): Observable { - return this.http.post(this.apiRoutes.list(), data); - } - - getTransactions( - bankAccountId: string, - ): Observable> { - return this.http - .get< - IPaginatedResponse - >(this.apiRoutes.transactions(bankAccountId)) - .pipe( - map((res) => ({ - meta: res.meta, - data: res.data.map((transaction) => this.transformTransaction(transaction)), - })), - ); - } - - private transformTransaction( - transaction: IBankAccountTransactionRawResponse, - ): IBankAccountTransactionResponse { - const { reference, referenceType, ...rest } = transaction; - let transformedReference: Maybe = null; - - if (reference) { - if ( - referenceType === BankTransactionReferenceType.PURCHASE_PAYMENT || - referenceType === BankTransactionReferenceType.PURCHASE_REFUND - ) { - const purchaseRef = reference as IReferencePurchaseRaw; - transformedReference = { - id: purchaseRef.id, - code: purchaseRef.code, - totalAmount: purchaseRef.totalAmount, - supplier: { - id: purchaseRef.supplier.id, - name: `${purchaseRef.supplier.firstName} ${purchaseRef.supplier.lastName}`, - }, - }; - } else if ( - referenceType === BankTransactionReferenceType.POS_SALE || - referenceType === BankTransactionReferenceType.POS_REFUND - ) { - const posRef = reference as IReferencePosRaw; - transformedReference = { - id: posRef.id, - code: posRef.code, - totalAmount: posRef.totalAmount, - customer: { - id: posRef.customer.id, - name: `${posRef.customer.firstName} ${posRef.customer.lastName}`, - }, - }; - } - } - - return { - ...rest, - referenceType, - reference: transformedReference, - }; - } -} diff --git a/src/app/modules/bankAccounts/store/bankAccount.store.ts b/src/app/modules/bankAccounts/store/bankAccount.store.ts deleted file mode 100644 index f1507f6..0000000 --- a/src/app/modules/bankAccounts/store/bankAccount.store.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { EntityState, EntityStore } from '@/core/state'; -import { Injectable } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { IBankAccountsResponse } from '../models'; -import { BankAccountsService } from '../services/main.service'; - -export interface BankAccountState extends EntityState {} - -@Injectable({ - providedIn: 'root', -}) -export class BankAccountStore extends EntityStore { - constructor( - private activeRoute: ActivatedRoute, - private service: BankAccountsService, - private toastService: ToastService, - ) { - super({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - entities: {}, - selectedId: null, - ids: [], - }); - this.initial(); - } - - supplierId!: string; - - initial() {} - - getSingle(bankAccountId: string) { - if (this.entities()[bankAccountId]) { - return; - } - this.patchState({ loading: true }); - this.service.getSingle(bankAccountId).subscribe({ - next: (res) => { - this.patchState({ - entities: { [res.id]: res }, - loading: false, - }); - }, - error: (err) => { - this.patchState({ loading: false, error: err }); - this.toastService.error({ - text: 'خطا در دریافت اطلاعات حساب بانکی', - }); - }, - }); - } - - refresh(bankAccountId: string) { - const { bankAccountId: _, ...entities } = this.entities(); - this.patchState({ - entities, - }); - this.getSingle(bankAccountId); - } - - reset(): void { - const queryParams = this.activeRoute.snapshot.queryParams; - this.setState({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - entities: {}, - selectedId: null, - ids: [], - }); - } -} diff --git a/src/app/modules/bankAccounts/views/index.ts b/src/app/modules/bankAccounts/views/index.ts deleted file mode 100644 index bc9dfc9..0000000 --- a/src/app/modules/bankAccounts/views/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './list.component'; -export * from './single.component'; diff --git a/src/app/modules/bankAccounts/views/list.component.html b/src/app/modules/bankAccounts/views/list.component.html deleted file mode 100644 index 75693da..0000000 --- a/src/app/modules/bankAccounts/views/list.component.html +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/src/app/modules/bankAccounts/views/list.component.ts b/src/app/modules/bankAccounts/views/list.component.ts deleted file mode 100644 index 6f015fa..0000000 --- a/src/app/modules/bankAccounts/views/list.component.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, signal } from '@angular/core'; -import { Router } from '@angular/router'; -import { BankAccountFormComponent } from '../components/form.component'; -import { IBankAccountsResponse } from '../models'; -import { BankAccountsService } from '../services/main.service'; - -@Component({ - selector: 'app-bank-accounts', - templateUrl: './list.component.html', - imports: [PageDataListComponent, BankAccountFormComponent], -}) -export class BankAccountsComponent { - constructor( - private service: BankAccountsService, - private router: Router, - ) { - this.getData(); - } - - columns = [ - { field: 'id', header: 'شناسه', width: '60px' }, - { - field: 'name', - header: 'نام', - minWidth: '160px', - }, - { - field: 'bank', - header: 'شعبه', - customDataModel(item) { - return `شعبه‌ی ${item.branch?.name} بانک ${item.branch?.bank?.name}`; - }, - minWidth: '200px', - }, - { - field: 'currentBalance', - header: 'مانده حساب', - type: 'price', - minWidth: '180px', - }, - { - field: 'accountNumber', - header: 'شماره حساب بانکی', - canCopy: true, - minWidth: '160px', - }, - { - field: 'iban', - header: 'شماره شبا', - canCopy: true, - minWidth: '200px', - }, - { - field: 'cardNumber', - header: 'شماره کارت بانکی', - canCopy: true, - minWidth: '160px', - }, - { field: 'createdAt', header: 'تاریخ ایجاد', type: 'date', minWidth: '120px' }, - ] as IColumn[]; - - loading = signal(false); - items = signal([]); - visibleForm = signal(false); - - refresh() { - this.getData(); - } - - getData() { - this.loading.set(true); - this.service.getAll().subscribe((res) => { - this.loading.set(false); - this.items.set(res.data); - }); - } - - openAddForm() { - this.visibleForm.set(true); - } - - toDetails(item: IBankAccountsResponse) { - this.router.navigate(['/bankAccounts', item.id]); - } -} diff --git a/src/app/modules/bankAccounts/views/single.component.html b/src/app/modules/bankAccounts/views/single.component.html deleted file mode 100644 index e2f77cd..0000000 --- a/src/app/modules/bankAccounts/views/single.component.html +++ /dev/null @@ -1,48 +0,0 @@ -
- - - @if (!loading()) { -
-
- -
-
- -
-
- - - -
-
- } - - - - - - - - - - @if (item.referenceType === "PURCHASE_PAYMENT" || item.referenceType === "PURCHASE_REFUND") { - {{ item.reference.supplier?.name || "-" }} - } @else if (item.referenceType === "CUSTOMER_PAYMENT" || item.referenceType === "CUSTOMER_REFUND") { - {{ item.reference.customer?.name || "-" }} - } @else { - {{ item.referenceType }} - } - - - -
diff --git a/src/app/modules/bankAccounts/views/single.component.ts b/src/app/modules/bankAccounts/views/single.component.ts deleted file mode 100644 index e26c8ca..0000000 --- a/src/app/modules/bankAccounts/views/single.component.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { Maybe } from '@/core'; -import { IResponseMetadata } from '@/core/models/service.model'; -import { CatalogBankAccountTransactionReferenceTypeTagComponent } from '@/shared/catalog/transactionReferenceTypes'; -import { CatalogBankAccountTransactionTypeTagComponent } from '@/shared/catalog/transactionTypes'; -import { KeyValueComponent } from '@/shared/components'; -import { InnerPagesHeaderComponent } from '@/shared/components/innerPagesHeader/inner-pages-header.component'; -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { PriceMaskDirective } from '@/shared/directives'; -import { Component, computed, inject, signal, TemplateRef, ViewChild } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { IBankAccountTransactionResponse } from '../models'; -import { BankAccountsService } from '../services/main.service'; -import { BankAccountStore } from '../store/bankAccount.store'; - -@Component({ - selector: 'app-bank-account', - templateUrl: './single.component.html', - imports: [ - InnerPagesHeaderComponent, - KeyValueComponent, - PriceMaskDirective, - PageDataListComponent, - CatalogBankAccountTransactionTypeTagComponent, - CatalogBankAccountTransactionReferenceTypeTagComponent, - ], -}) -export class BankAccountComponent { - private route = inject(ActivatedRoute); - private store = inject(BankAccountStore); - - @ViewChild('typeTpl', { static: true }) typeTpl!: TemplateRef; - @ViewChild('referenceTypeTpl', { static: true }) referenceTypeTpl!: TemplateRef; - @ViewChild('counterpartyTpl', { static: true }) counterpartyTpl!: TemplateRef; - - bankAccountId = this.route.snapshot.paramMap.get('bankAccountId')!; - - transactionsColumn = [] as IColumn[]; - - bankAccount = computed(() => this.store.entities()[this.bankAccountId]); - loading = this.store.loading; - - transactions = signal([]); - transactionsLoading = signal(false); - transactionsPagination = signal>(null); - - constructor(private readonly service: BankAccountsService) { - this.store.getSingle(this.bankAccountId); - this.getTransactions(); - } - - pageTitle = computed(() => { - const account = this.bankAccount(); - return account ? `حساب بانک: ${account.name}` : 'حساب بانک'; - }); - - ngOnInit() { - this.transactionsColumn = [ - { field: 'id', header: 'شناسه', width: '60px' }, - { field: 'type', header: 'نوع تراکنش', customDataModel: this.typeTpl }, - { field: 'amount', header: 'مبلغ', type: 'price' }, - { field: 'balanceAfter', header: 'مانده حساب', type: 'price' }, - { field: 'type', header: 'نوع رسید', customDataModel: this.referenceTypeTpl }, - { field: 'counterparty', header: 'طرف حساب', customDataModel: this.counterpartyTpl }, - { field: 'description', header: 'توضیحات' }, - { field: 'createdAt', header: 'تاریخ ایجاد', type: 'date' }, - ]; - } - - getTransactions() { - this.transactionsLoading.set(true); - this.service.getTransactions(this.bankAccountId).subscribe({ - next: (res) => { - this.transactions.set(res.data); - this.transactionsPagination.set(res.meta); - this.transactionsLoading.set(false); - }, - error: () => { - this.transactionsLoading.set(false); - }, - }); - } -} diff --git a/src/app/modules/bankBranches/components/form.component.html b/src/app/modules/bankBranches/components/form.component.html deleted file mode 100644 index d691b3a..0000000 --- a/src/app/modules/bankBranches/components/form.component.html +++ /dev/null @@ -1,15 +0,0 @@ - -
- - - - - -
diff --git a/src/app/modules/bankBranches/components/form.component.ts b/src/app/modules/bankBranches/components/form.component.ts deleted file mode 100644 index 7c3e2f3..0000000 --- a/src/app/modules/bankBranches/components/form.component.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { BanksSelectComponent } from '@/shared/catalog/banks'; -import { InputComponent } from '@/shared/components'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, effect, EventEmitter, inject, Input, Output, signal } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { Dialog } from 'primeng/dialog'; -import { IBankBranchRequest, IBankBranchResponse } from '../models'; -import { BankBranchesService } from '../services/main.service'; - -@Component({ - selector: 'bank-branch-form', - templateUrl: './form.component.html', - imports: [ - ReactiveFormsModule, - Dialog, - InputComponent, - FormFooterActionsComponent, - BanksSelectComponent, - ], -}) -export class BankBranchFormComponent { - @Input() initialValues?: IBankBranchResponse; - - @Input() - set visible(v: boolean) { - this.visibleSignal.set(!!v); - } - get visible() { - return this.visibleSignal(); - } - private visibleSignal = signal(false); - - @Output() visibleChange = new EventEmitter(); - @Output() onSubmit = new EventEmitter(); - - private fb = inject(FormBuilder); - constructor( - private service: BankBranchesService, - private toastService: ToastService, - ) { - effect(() => { - const v = this.visibleSignal(); - if (!v) this.form.reset(); - }); - } - - form = this.fb.group({ - name: this.fb.control(this.initialValues?.name || '', { - nonNullable: true, - validators: Validators.required, - }), - code: this.fb.control(this.initialValues?.code || '', { - nonNullable: true, - validators: Validators.required, - }), - bankId: this.fb.control(this.initialValues?.bank?.id || 0, { - nonNullable: true, - validators: Validators.required, - }), - }); - - submitLoading = signal(false); - - submit() { - this.form.markAllAsTouched(); - if (this.form.valid) { - this.form.disable(); - this.submitLoading.set(true); - this.service.create(this.form.value as IBankBranchRequest).subscribe({ - next: (res) => { - this.toastService.success({ - text: `شعبه بانک ${this.form.value.name} با موفقیت ایجاد شد`, - }); - this.close(); - this.submitLoading.set(false); - this.form.enable(); - this.form.reset(); - this.onSubmit.emit(res); - }, - error: () => { - this.submitLoading.set(false); - this.form.enable(); - }, - }); - } - } - - close() { - this.visibleChange.emit(false); - } -} diff --git a/src/app/modules/bankBranches/components/select/select.component.html b/src/app/modules/bankBranches/components/select/select.component.html deleted file mode 100644 index 0c2193e..0000000 --- a/src/app/modules/bankBranches/components/select/select.component.html +++ /dev/null @@ -1,30 +0,0 @@ - - - @if (canInsert) { - -
- -
-
- } -
- -
diff --git a/src/app/modules/bankBranches/components/select/select.component.ts b/src/app/modules/bankBranches/components/select/select.component.ts deleted file mode 100644 index 0f9fca9..0000000 --- a/src/app/modules/bankBranches/components/select/select.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { AbstractSelectComponent } from '@/shared/components'; -import { UikitFieldComponent } from '@/uikit'; -import { Component } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { Button } from 'primeng/button'; -import { Select } from 'primeng/select'; -import { IBankBranchResponse } from '../../models'; -import { BankBranchesService } from '../../services/main.service'; -import { BankBranchFormComponent } from '../form.component'; - -@Component({ - selector: 'bank-branches-select-field', - templateUrl: './select.component.html', - imports: [ReactiveFormsModule, Select, UikitFieldComponent, Button, BankBranchFormComponent], -}) -export class BankBranchesSelectComponent extends AbstractSelectComponent< - IBankBranchResponse, - IPaginatedResponse -> { - constructor(private service: BankBranchesService) { - super(); - this.getData(); - } - - getDataService() { - return this.service.getAll(); - } -} diff --git a/src/app/modules/bankBranches/constants/apiRoutes/index.ts b/src/app/modules/bankBranches/constants/apiRoutes/index.ts deleted file mode 100644 index 15c7647..0000000 --- a/src/app/modules/bankBranches/constants/apiRoutes/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -const baseUrl = '/api/v1/bank-branches'; - -export const BANK_BRANCHES_API_ROUTES = { - list: () => `${baseUrl}`, -}; diff --git a/src/app/modules/bankBranches/constants/index.ts b/src/app/modules/bankBranches/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/bankBranches/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/bankBranches/constants/routes/index.ts b/src/app/modules/bankBranches/constants/routes/index.ts deleted file mode 100644 index 84efeac..0000000 --- a/src/app/modules/bankBranches/constants/routes/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { NamedRoutes } from '@/core'; -import { Routes } from '@angular/router'; - -export type TBankBranchesRouteNames = 'bankBranches'; - -export const bankBranchesNamedRoutes: NamedRoutes = { - bankBranches: { - path: 'bankBranches', - loadComponent: () => import('../../views/list.component').then((m) => m.BankBranchesComponent), - meta: { - title: 'شعب بانک', - pagePath: () => '/bankBranches', - }, - }, -}; - -export const BANK_BRANCHES_ROUTES: Routes = Object.values(bankBranchesNamedRoutes); diff --git a/src/app/modules/bankBranches/models/index.ts b/src/app/modules/bankBranches/models/index.ts deleted file mode 100644 index 61a518a..0000000 --- a/src/app/modules/bankBranches/models/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './io'; diff --git a/src/app/modules/bankBranches/models/io.d.ts b/src/app/modules/bankBranches/models/io.d.ts deleted file mode 100644 index d9917d9..0000000 --- a/src/app/modules/bankBranches/models/io.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { IBankResponse } from '@/shared/catalog/banks/models'; - -export interface IBankBranchRawResponse { - id: number; - name: string; - code: string; - bank: IBankResponse; - createdAt: Date; - updatedAt: Date; - deletedAt: Date; -} - -export interface IBankBranchResponse extends IBankBranchRawResponse {} - -export interface IBankBranchRequest { - name: string; - code: string; - bankId: number; -} diff --git a/src/app/modules/bankBranches/models/types.ts b/src/app/modules/bankBranches/models/types.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/modules/bankBranches/services/main.service.ts b/src/app/modules/bankBranches/services/main.service.ts deleted file mode 100644 index 42fe134..0000000 --- a/src/app/modules/bankBranches/services/main.service.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { BANK_BRANCHES_API_ROUTES } from '../constants'; -import { IBankBranchRawResponse, IBankBranchRequest, IBankBranchResponse } from '../models'; - -@Injectable({ providedIn: 'root' }) -export class BankBranchesService { - constructor(private http: HttpClient) {} - - private apiRoutes = BANK_BRANCHES_API_ROUTES; - - getAll(): Observable> { - return this.http.get>(this.apiRoutes.list()); - } - - create(data: IBankBranchRequest): Observable { - return this.http.post(this.apiRoutes.list(), data); - } -} diff --git a/src/app/modules/bankBranches/views/index.ts b/src/app/modules/bankBranches/views/index.ts deleted file mode 100644 index bc9dfc9..0000000 --- a/src/app/modules/bankBranches/views/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './list.component'; -export * from './single.component'; diff --git a/src/app/modules/bankBranches/views/list.component.html b/src/app/modules/bankBranches/views/list.component.html deleted file mode 100644 index 92c1fcb..0000000 --- a/src/app/modules/bankBranches/views/list.component.html +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/src/app/modules/bankBranches/views/list.component.ts b/src/app/modules/bankBranches/views/list.component.ts deleted file mode 100644 index 4047ed4..0000000 --- a/src/app/modules/bankBranches/views/list.component.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, signal } from '@angular/core'; -import { BankBranchFormComponent } from '../components/form.component'; -import { IBankBranchResponse } from '../models'; -import { BankBranchesService } from '../services/main.service'; - -@Component({ - selector: 'app-bank-branches', - templateUrl: './list.component.html', - imports: [PageDataListComponent, BankBranchFormComponent], -}) -export class BankBranchesComponent { - constructor(private service: BankBranchesService) { - this.getData(); - } - - columns = [ - { field: 'id', header: 'شناسه' }, - { field: 'name', header: 'نام' }, - { field: 'code', header: 'کد شعبه' }, - { field: 'bank', header: 'بانک', type: 'nested', nestedPath: 'name' }, - { field: 'createdAt', header: 'تاریخ ایجاد', type: 'date' }, - { field: 'updatedAt', header: 'تاریخ به‌روزرسانی', type: 'date' }, - ] as IColumn[]; - - loading = signal(false); - items = signal([]); - visibleForm = signal(false); - - refresh() { - this.getData(); - } - - getData() { - this.loading.set(true); - this.service.getAll().subscribe((res) => { - this.loading.set(false); - this.items.set(res.data); - }); - } - - openAddForm() { - this.visibleForm.set(true); - } -} diff --git a/src/app/modules/bankBranches/views/single.component.html b/src/app/modules/bankBranches/views/single.component.html deleted file mode 100644 index 7144e26..0000000 --- a/src/app/modules/bankBranches/views/single.component.html +++ /dev/null @@ -1 +0,0 @@ -
diff --git a/src/app/modules/bankBranches/views/single.component.ts b/src/app/modules/bankBranches/views/single.component.ts deleted file mode 100644 index 77d906c..0000000 --- a/src/app/modules/bankBranches/views/single.component.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-customer', - templateUrl: './single.component.html', -}) -export class CustomerComponent { - constructor() {} -} diff --git a/src/app/modules/cardex/components/filters/filters.component.html b/src/app/modules/cardex/components/filters/filters.component.html deleted file mode 100644 index 3fa3ea3..0000000 --- a/src/app/modules/cardex/components/filters/filters.component.html +++ /dev/null @@ -1,19 +0,0 @@ -
-
- - - - -
-
- -
-
diff --git a/src/app/modules/cardex/components/filters/filters.component.ts b/src/app/modules/cardex/components/filters/filters.component.ts deleted file mode 100644 index de2bb48..0000000 --- a/src/app/modules/cardex/components/filters/filters.component.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Maybe } from '@/core'; -import { InventoriesSelectComponent } from '@/modules/inventories/components'; -import { IInventorySummaryResponse } from '@/modules/inventories/models'; -import { ProductsSelectComponent } from '@/modules/products/components/select/select.component'; -import { IProductResponse } from '@/modules/products/models'; -import { UikitFlatpickrJalaliComponent } from '@/uikit'; -import { Component, EventEmitter, inject, Output } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; -import { ActivatedRoute, Router } from '@angular/router'; -import { ButtonDirective } from 'primeng/button'; -import { - ICardexInventorySummary, - ICardexProductSummary, - ICardexRequestPayload, -} from '../../models'; -import { CardexStore } from '../../store/main.store'; - -@Component({ - selector: 'cardex-filters', - templateUrl: './filters.component.html', - imports: [ - ReactiveFormsModule, - InventoriesSelectComponent, - ProductsSelectComponent, - UikitFlatpickrJalaliComponent, - ButtonDirective, - ], -}) -export class CardexFiltersComponent { - private route = inject(ActivatedRoute); - private fb = inject(FormBuilder); - private store = inject(CardexStore); - @Output() onSearch = new EventEmitter(); - - filters = {} as Partial; - - constructor(private router: Router) { - this.filters = this.store.filters(); - this.form.patchValue(this.filters); - } - - form = this.fb.group({ - inventoryId: [this.filters.inventoryId || 0], - productId: [this.filters.productId || 0], - startDate: [this.filters.startDate || ''], - endDate: [this.filters.endDate || ''], - }); - - onChangeInventory(inventory: Maybe) { - this.store.setInventory(inventory); - } - onChangeProduct(product: Maybe) { - this.store.setProduct(product); - } - - search() { - this.store.updateFilter(this.form.value as ICardexRequestPayload); - - this.store.getCardex(); - } - - setDefaultInventory(inventory: IInventorySummaryResponse) { - this.store.setDefaultInventory(inventory); - } - setDefaultProduct(product: IProductResponse) { - this.store.setDefaultProduct(product); - } -} diff --git a/src/app/modules/cardex/components/index.ts b/src/app/modules/cardex/components/index.ts deleted file mode 100644 index bcac1e7..0000000 --- a/src/app/modules/cardex/components/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './filters/filters.component'; diff --git a/src/app/modules/cardex/components/templates/inventory.component.html b/src/app/modules/cardex/components/templates/inventory.component.html deleted file mode 100644 index 20c1173..0000000 --- a/src/app/modules/cardex/components/templates/inventory.component.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - ردیف - تاریخ - شرح - شماره - طرف حساب - @if (variant === "inventory") { - کالا - } @else if (variant === "product") { - انبار - } - ورودی - خروجی - مانده - - - تعداد - فی - تعداد - فی - تعداد - - - - - - - {{ i + 1 }} - - - - - {{ item.referenceId || "-" }} - - {{ (item.referenceType === "SALES" ? item.customer?.name : item.supplier?.name) || "-" }} - - @if (variant === "inventory") { - {{ item.product.name || "-" }} - } @else if (variant === "product") { - {{ item.inventory.name || "-" }} - } - - {{ item.type === "IN" ? item.quantity : 0 }} - - - @if (item.type === "IN") { - - } @else { - 0 - } - - - {{ item.type === "OUT" ? item.quantity : 0 }} - - - @if (item.type === "OUT") { - - } @else { - 0 - } - - {{ item.remainedInStock }} - - - - diff --git a/src/app/modules/cardex/components/templates/inventory.component.ts b/src/app/modules/cardex/components/templates/inventory.component.ts deleted file mode 100644 index 08f4ef5..0000000 --- a/src/app/modules/cardex/components/templates/inventory.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { CatalogMovementReferenceTagComponent } from '@/shared/catalog/movementReferenceTypes'; -import { JalaliDateDirective, PriceMaskDirective } from '@/shared/directives'; -import { Component, Input } from '@angular/core'; -import { TableModule } from 'primeng/table'; -import { IInventoryCardex } from './types'; - -@Component({ - selector: 'cardex-templates-inventory', - templateUrl: './inventory.component.html', - imports: [ - TableModule, - JalaliDateDirective, - CatalogMovementReferenceTagComponent, - PriceMaskDirective, - ], - hostDirectives: [PriceMaskDirective], -}) -export class CardexComponent { - @Input() items: IInventoryCardex[] = []; - @Input() loading: boolean = false; - @Input() variant: 'inventory' | 'product' | 'general' = 'inventory'; - constructor() {} -} diff --git a/src/app/modules/cardex/components/templates/types.ts b/src/app/modules/cardex/components/templates/types.ts deleted file mode 100644 index 9a0837d..0000000 --- a/src/app/modules/cardex/components/templates/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { ICardexResponse } from '../../models'; - -export interface IInventoryCardex extends ICardexResponse {} diff --git a/src/app/modules/cardex/constants/apiRoutes/index.ts b/src/app/modules/cardex/constants/apiRoutes/index.ts deleted file mode 100644 index 2b85bca..0000000 --- a/src/app/modules/cardex/constants/apiRoutes/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -const baseUrl = '/api/v1/cardex'; - -export const CARDEX_API_ROUTES = { - cardex: () => `${baseUrl}`, -}; diff --git a/src/app/modules/cardex/constants/index.ts b/src/app/modules/cardex/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/cardex/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/cardex/constants/routes/index.ts b/src/app/modules/cardex/constants/routes/index.ts deleted file mode 100644 index 7a87856..0000000 --- a/src/app/modules/cardex/constants/routes/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { NamedRoutes } from '@/core'; -import { Routes } from '@angular/router'; - -export type TCARDEXRouteNames = 'CARDEX'; - -export const cardexNamedRoutes: NamedRoutes = { - CARDEX: { - path: 'cardex', - loadComponent: () => import('../../views/cardex.component').then((m) => m.CardexPageComponent), - meta: { - title: 'کاردکس', - pagePath: () => '/cardex', - }, - }, -}; - -export const CARDEX_ROUTES: Routes = Object.values(cardexNamedRoutes); diff --git a/src/app/modules/cardex/models/index.ts b/src/app/modules/cardex/models/index.ts deleted file mode 100644 index d390b4d..0000000 --- a/src/app/modules/cardex/models/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './io'; -export * from './types'; diff --git a/src/app/modules/cardex/models/io.d.ts b/src/app/modules/cardex/models/io.d.ts deleted file mode 100644 index 86293c2..0000000 --- a/src/app/modules/cardex/models/io.d.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { ICardexInventorySummary, ICardexProductSummary } from './types'; - -export interface ICardexRawResponse { - id: number; - type: string; - quantity: number; - unitPrice: number; - totalCost: number; - referenceType: string; - referenceId: string; - createdAt: string; - avgCost: number; - product: ICardexProductSummary; - inventory: ICardexInventorySummary; - supplier?: { - id: number; - firstName: string; - lastName: string; - }; - customer?: { - id: number; - firstName: string; - lastName: string; - }; - counterInventory?: ICardexInventorySummary; -} - -export interface ICardexResponse extends ICardexRawResponse { - supplier?: { - id: number; - name: string; - }; - customer?: { - id: number; - name: string; - }; -} - -export interface ICardexRequestPayload { - startDate?: string; - endDate?: string; - inventoryId?: number; - productId?: number; -} diff --git a/src/app/modules/cardex/models/types.ts b/src/app/modules/cardex/models/types.ts deleted file mode 100644 index 9eb1ca3..0000000 --- a/src/app/modules/cardex/models/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -export interface ICardexInventorySummary { - name: string; - id: number; -} - -export interface ICardexProductSummary { - name: string; - sku: string; - id: number; -} diff --git a/src/app/modules/cardex/services/main.service.ts b/src/app/modules/cardex/services/main.service.ts deleted file mode 100644 index f6407bd..0000000 --- a/src/app/modules/cardex/services/main.service.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { getFullName } from '@/utils'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { map, Observable } from 'rxjs'; -import { CARDEX_API_ROUTES } from '../constants'; -import { ICardexRawResponse, ICardexRequestPayload, ICardexResponse } from '../models'; - -@Injectable({ providedIn: 'root' }) -export class CardexService { - constructor(private http: HttpClient) {} - - private apiRoutes = CARDEX_API_ROUTES; - - getCardex(params: ICardexRequestPayload): Observable> { - return this.http - .get>(this.apiRoutes.cardex(), { - params: { ...params }, - }) - .pipe( - map((res) => { - return { - meta: res.meta, - data: res.data.map((item) => ({ - ...item, - supplier: item.supplier - ? { - ...item.supplier, - name: getFullName(item.supplier), - } - : undefined, - customer: item.customer - ? { - ...item.customer, - name: getFullName(item.customer), - } - : undefined, - })), - }; - }), - ); - } -} diff --git a/src/app/modules/cardex/store/main.store.ts b/src/app/modules/cardex/store/main.store.ts deleted file mode 100644 index 55765ad..0000000 --- a/src/app/modules/cardex/store/main.store.ts +++ /dev/null @@ -1,220 +0,0 @@ -import { Maybe } from '@/core'; -import { ToastService } from '@/core/services/toast.service'; -import { PaginatedState, PaginatedStore } from '@/core/state'; -import { computed, Injectable } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { - ICardexInventorySummary, - ICardexProductSummary, - ICardexRequestPayload, - ICardexResponse, -} from '../models'; -import { CardexService } from '../services/main.service'; - -export interface CardexState extends PaginatedState { - filters: ICardexRequestPayload; - selectedInventory: Maybe; - selectedProduct: Maybe; - variant: 'inventory' | 'product' | 'general'; - canChangeVariant: boolean; - cardexTitle: string; -} - -@Injectable({ - providedIn: 'root', -}) -export class CardexStore extends PaginatedStore { - private readonly _cardexState = { - isRefreshing: false, - filters: {}, - selectedInventory: null, - selectedProduct: null, - variant: 'general', - canChangeVariant: true, - }; - - constructor( - private router: Router, - private route: ActivatedRoute, - private service: CardexService, - private toastService: ToastService, - ) { - const queryParams = route.snapshot.queryParams; - - super({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - items: [], - totalCount: 0, - currentPage: Number(queryParams['page']) || 1, - pageSize: Number(queryParams['pageSize']) || 30, - totalPages: 0, - hasMore: false, - filters: { - inventoryId: queryParams['inventoryId'] - ? parseInt(queryParams['inventoryId'], 10) - : undefined, - productId: queryParams['productId'] ? parseInt(queryParams['productId'], 10) : undefined, - startDate: queryParams['startDate'], - endDate: queryParams['endDate'], - }, - selectedInventory: null, - selectedProduct: null, - variant: 'general', - canChangeVariant: true, - cardexTitle: 'کاردکس', - }); - this.initial(); - } - - readonly filters = computed(() => this._state().filters); - readonly variant = computed(() => this._state().variant); - readonly canChangeVariant = computed(() => this._state().canChangeVariant); - readonly cardexTitle = computed(() => this._state().cardexTitle); - - /** - * Reset state to initial values - */ - reset(): void { - const queryParams = this.route.snapshot.queryParams; - this.setState({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - items: [], - totalCount: 0, - currentPage: Number(queryParams['page']) || 1, - pageSize: Number(queryParams['pageSize']) || 30, - totalPages: 0, - hasMore: false, - filters: { - inventoryId: queryParams['inventoryId'], - productId: queryParams['productId'], - startDate: queryParams['startDate'], - endDate: queryParams['endDate'], - }, - selectedInventory: null, - selectedProduct: null, - variant: 'general', - canChangeVariant: this.state().canChangeVariant, - cardexTitle: 'کاردکس', - }); - } - - initial() { - this.getCardex(); - } - - getCardex() { - const filters = this.validateFilters(); - if (filters) { - this.patchState({ initialized: true }); - this.setLoading(true); - this.service.getCardex(filters).subscribe({ - next: (res) => { - this.setItems(res.data, res.meta); - }, - error: (err) => { - this.setError(err); - }, - }); - } - } - - private validateFilters() { - const { productId, inventoryId, startDate, endDate } = this.filters(); - const filters = {} as Partial; - Object.entries(this.filters()).forEach(([key, value]) => { - if (value && value !== '0') { - filters[key as keyof ICardexRequestPayload] = value; - } - }); - if (!productId && !inventoryId) { - this.toastService.warn({ text: 'برای مشاهده‌ی کاردکس حداقل انبار و یا کالا را مشخص کنید' }); - return false; - } - return filters; - } - - onPageChange(page: number) { - this.setCurrentPage(page); - this.getCardex(); - } - - updateFilter(filters: ICardexRequestPayload) { - this.updateVariant(); - - const cleanedFilters = this.validateFilters() || {}; - - this.router - .navigate([], { - relativeTo: this.route, - queryParams: cleanedFilters, - }) - .then((res) => console.log(res)) - .catch((err) => { - console.log(err); - }); - this.patchState({ filters }); - this.updateCardexTitle(); - } - - setProduct(product: Maybe) { - this.patchState({ selectedProduct: product }); - } - setInventory(inventory: Maybe) { - this.patchState({ selectedInventory: inventory }); - } - - setCanChangeVariant(status: boolean) { - this.patchState({ canChangeVariant: status }); - } - - setDefaultInventory(inventory: ICardexInventorySummary) { - this.patchState({ selectedInventory: inventory }); - this.updateCardexTitle(); - } - - setDefaultProduct(product: ICardexProductSummary) { - this.patchState({ selectedProduct: product }); - this.updateCardexTitle(); - } - - private updateVariant() { - const inventoryIsSelected = Boolean(this._state().selectedInventory); - const productIsSelected = Boolean(this._state().selectedProduct); - let variant = 'general' as 'product' | 'inventory' | 'general'; - if (inventoryIsSelected) { - if (!productIsSelected) { - variant = 'inventory'; - } - } else if (productIsSelected) { - variant = 'product'; - } - this.updateCardexTitle(); - - this.patchState({ variant }); - } - - updateCardexTitle() { - let title = ''; - switch (this._state().variant) { - case 'product': - title = `کاردکس کالای ${this._state().selectedProduct?.name}`; - break; - case 'inventory': - title = `کاردکس انبار ${this._state().selectedInventory?.name}`; - break; - default: - title = `کاردکس ${this._state().selectedProduct ? 'کالای ' + this._state().selectedProduct?.name : ''} ${ - this._state().selectedInventory ? 'در انبار ' + this._state().selectedInventory?.name : '' - }`; - break; - } - - this.patchState({ cardexTitle: title }); - } -} diff --git a/src/app/modules/cardex/views/cardex.component.html b/src/app/modules/cardex/views/cardex.component.html deleted file mode 100644 index 7553dda..0000000 --- a/src/app/modules/cardex/views/cardex.component.html +++ /dev/null @@ -1,14 +0,0 @@ -
- - - - - @if (!initialized) { - - } @else { -

{{ cardexTitle }}

- - - } -
-
diff --git a/src/app/modules/cardex/views/cardex.component.ts b/src/app/modules/cardex/views/cardex.component.ts deleted file mode 100644 index dec75eb..0000000 --- a/src/app/modules/cardex/views/cardex.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { UikitEmptyStateComponent } from '@/uikit'; -import { Component } from '@angular/core'; -import { Card } from 'primeng/card'; -import { CardexFiltersComponent } from '../components'; -import { CardexComponent } from '../components/templates/inventory.component'; -import { CardexStore } from '../store/main.store'; - -@Component({ - selector: 'app-cardex', - templateUrl: './cardex.component.html', - imports: [Card, CardexFiltersComponent, UikitEmptyStateComponent, CardexComponent], -}) -export class CardexPageComponent { - constructor(private store: CardexStore) {} - - get cardexTitle() { - return this.store.cardexTitle(); - } - get initialized() { - return this.store.initialized(); - } - get loading() { - return this.store.loading(); - } - get variant() { - return this.store.variant(); - } - get items() { - return this.store.items(); - } -} diff --git a/src/app/modules/customers/components/form.component.html b/src/app/modules/customers/components/form.component.html deleted file mode 100644 index d1a237c..0000000 --- a/src/app/modules/customers/components/form.component.html +++ /dev/null @@ -1,21 +0,0 @@ - -
- - - - - - - - - - - -
diff --git a/src/app/modules/customers/components/form.component.ts b/src/app/modules/customers/components/form.component.ts deleted file mode 100644 index 22d2c82..0000000 --- a/src/app/modules/customers/components/form.component.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { InputComponent } from '@/shared/components'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, effect, EventEmitter, inject, Input, Output, signal } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { Dialog } from 'primeng/dialog'; -import { ICustomerRequest, ICustomerResponse } from '../models'; -import { CustomersService } from '../services/main.service'; - -@Component({ - selector: 'customer-form', - templateUrl: './form.component.html', - imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent], -}) -export class CustomerFormComponent { - @Input() initialValues?: ICustomerResponse; - - @Input() - set visible(v: boolean) { - this.visibleSignal.set(!!v); - } - get visible() { - return this.visibleSignal(); - } - private visibleSignal = signal(false); - - @Output() visibleChange = new EventEmitter(); - @Output() onSubmit = new EventEmitter(); - - private fb = inject(FormBuilder); - constructor( - private service: CustomersService, - private toastService: ToastService, - ) { - effect(() => { - const v = this.visibleSignal(); - if (!v) this.form.reset(); - }); - } - - form = this.fb.group({ - firstName: [this.initialValues?.firstName || null, [Validators.required]], - lastName: [this.initialValues?.lastName || null, [Validators.required]], - email: [this.initialValues?.email || null, [Validators.required, Validators.email]], - mobileNumber: [this.initialValues?.mobileNumber || null, [Validators.required]], - address: [this.initialValues?.address || null, [Validators.required]], - city: [this.initialValues?.city || null, [Validators.required]], - state: [this.initialValues?.state || null, [Validators.required]], - country: [this.initialValues?.country || null, [Validators.required]], - isActive: [this.initialValues?.isActive || false, [Validators.required]], - }); - - submitLoading = signal(false); - - submit() { - this.form.markAllAsTouched(); - if (this.form.valid) { - this.form.disable(); - this.submitLoading.set(true); - this.service.create(this.form.value as ICustomerRequest).subscribe({ - next: (res) => { - this.toastService.success({ - text: `مشتری ${this.form.value.firstName} با موفقیت ایجاد شد`, - }); - this.close(); - this.submitLoading.set(false); - this.form.enable(); - this.form.reset(); - this.onSubmit.emit(res); - }, - error: () => { - this.submitLoading.set(false); - this.form.enable(); - }, - }); - } - } - - close() { - this.visibleChange.emit(false); - } -} diff --git a/src/app/modules/customers/components/select/select.component.html b/src/app/modules/customers/components/select/select.component.html deleted file mode 100644 index f5aa411..0000000 --- a/src/app/modules/customers/components/select/select.component.html +++ /dev/null @@ -1,30 +0,0 @@ - - - @if (canInsert) { - -
- -
-
- } -
- -
diff --git a/src/app/modules/customers/components/select/select.component.ts b/src/app/modules/customers/components/select/select.component.ts deleted file mode 100644 index 698a3ff..0000000 --- a/src/app/modules/customers/components/select/select.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { AbstractSelectComponent } from '@/shared/components'; -import { UikitFieldComponent } from '@/uikit'; -import { Component } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { Button } from 'primeng/button'; -import { Select } from 'primeng/select'; -import { ICustomerResponse } from '../../models'; -import { CustomersService } from '../../services/main.service'; -import { CustomerFormComponent } from '../form.component'; - -@Component({ - selector: 'customers-select-field', - templateUrl: './select.component.html', - imports: [ReactiveFormsModule, Select, UikitFieldComponent, Button, CustomerFormComponent], -}) -export class CustomersSelectComponent extends AbstractSelectComponent< - ICustomerResponse, - IPaginatedResponse -> { - constructor(private service: CustomersService) { - super(); - this.getData(); - } - - getDataService() { - return this.service.getAll(); - } -} diff --git a/src/app/modules/customers/constants/apiRoutes/index.ts b/src/app/modules/customers/constants/apiRoutes/index.ts deleted file mode 100644 index bb3175d..0000000 --- a/src/app/modules/customers/constants/apiRoutes/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -const baseUrl = '/api/v1/customers'; - -export const CUSTOMERS_API_ROUTES = { - list: () => `${baseUrl}`, - single: (customerId: string) => `${baseUrl}/${customerId}`, -}; diff --git a/src/app/modules/customers/constants/index.ts b/src/app/modules/customers/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/customers/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/customers/constants/routes/index.ts b/src/app/modules/customers/constants/routes/index.ts deleted file mode 100644 index 9213c5d..0000000 --- a/src/app/modules/customers/constants/routes/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { NamedRoutes } from '@/core'; -import { Routes } from '@angular/router'; - -export type TCustomersRouteNames = 'customers' | 'customer'; - -export const customersNamedRoutes: NamedRoutes = { - customers: { - path: 'customers', - loadComponent: () => import('../../views/list.component').then((m) => m.CustomersComponent), - meta: { - title: 'مشتریان', - pagePath: () => '/customers', - }, - }, - customer: { - path: 'customers/:customerId', - loadComponent: () => import('../../views/single.component').then((m) => m.CustomerComponent), - meta: { - title: 'مشتری', - pagePath: () => '/customers/:customerId', - }, - }, -}; - -export const CUSTOMERS_ROUTES: Routes = Object.values(customersNamedRoutes); diff --git a/src/app/modules/customers/models/index.ts b/src/app/modules/customers/models/index.ts deleted file mode 100644 index 61a518a..0000000 --- a/src/app/modules/customers/models/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './io'; diff --git a/src/app/modules/customers/models/io.d.ts b/src/app/modules/customers/models/io.d.ts deleted file mode 100644 index 7deef4d..0000000 --- a/src/app/modules/customers/models/io.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -export interface ICustomerRawResponse { - id: number; - firstName: string; - lastName: string; - email: string; - mobileNumber: string; - address: string; - city: string; - state: string; - country: string; - isActive: boolean; - createdAt: Date; - updatedAt: Date; - deletedAt: Date; -} - -export interface ICustomerResponse extends ICustomerRawResponse {} - -export interface ICustomerRequest { - firstName: string; - lastName: string; - email: string; - mobileNumber: string; - address: string; - city: string; - state: string; - country: string; - isActive: boolean; -} diff --git a/src/app/modules/customers/services/main.service.ts b/src/app/modules/customers/services/main.service.ts deleted file mode 100644 index 4313768..0000000 --- a/src/app/modules/customers/services/main.service.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { getFullName } from '@/utils'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { map, Observable } from 'rxjs'; -import { CUSTOMERS_API_ROUTES } from '../constants'; -import { ICustomerRawResponse, ICustomerRequest, ICustomerResponse } from '../models'; - -@Injectable({ providedIn: 'root' }) -export class CustomersService { - constructor(private http: HttpClient) {} - - private apiRoutes = CUSTOMERS_API_ROUTES; - - getAll(): Observable> { - return this.http.get>(this.apiRoutes.list()).pipe( - map((res) => { - return { - meta: res.meta, - data: res.data.map((item) => ({ ...item, fullName: getFullName(item) })), - }; - }), - ); - } - - getSingle(customerId: string): Observable { - return this.http.get(this.apiRoutes.single(customerId)).pipe( - map((res) => { - return { ...res, fullName: getFullName(res) }; - }), - ); - } - - create(data: ICustomerRequest): Observable { - return this.http.post(this.apiRoutes.list(), data); - } -} diff --git a/src/app/modules/customers/views/index.ts b/src/app/modules/customers/views/index.ts deleted file mode 100644 index bc9dfc9..0000000 --- a/src/app/modules/customers/views/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './list.component'; -export * from './single.component'; diff --git a/src/app/modules/customers/views/list.component.html b/src/app/modules/customers/views/list.component.html deleted file mode 100644 index 1e87d46..0000000 --- a/src/app/modules/customers/views/list.component.html +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/src/app/modules/customers/views/list.component.ts b/src/app/modules/customers/views/list.component.ts deleted file mode 100644 index 4e5ac2e..0000000 --- a/src/app/modules/customers/views/list.component.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, signal } from '@angular/core'; -import { CustomerFormComponent } from '../components/form.component'; -import { ICustomerResponse } from '../models'; -import { CustomersService } from '../services/main.service'; - -@Component({ - selector: 'app-customers', - templateUrl: './list.component.html', - imports: [PageDataListComponent, CustomerFormComponent], -}) -export class CustomersComponent { - constructor(private customerService: CustomersService) { - this.getData(); - } - - columns = [ - { field: 'id', header: 'شناسه' }, - { field: 'firstName', header: 'نام' }, - { field: 'lastName', header: 'نام خانوادگی' }, - { field: 'email', header: 'ایمیل' }, - { field: 'mobileNumber', header: 'شماره موبایل' }, - { field: 'address', header: 'آدرس' }, - { field: 'city', header: 'شهر' }, - { field: 'state', header: 'استان' }, - { field: 'country', header: 'کشور' }, - { field: 'isActive', header: 'فعال' }, - { field: 'createdAt', header: 'تاریخ ایجاد', type: 'date' }, - { field: 'updatedAt', header: 'تاریخ به‌روزرسانی', type: 'date' }, - , - ] as IColumn[]; - - loading = signal(false); - items = signal([]); - visibleForm = signal(false); - - refresh() { - this.getData(); - } - - getData() { - this.loading.set(true); - this.customerService.getAll().subscribe((res) => { - this.loading.set(false); - this.items.set(res.data); - }); - } - - openAddForm() { - this.visibleForm.set(true); - } -} diff --git a/src/app/modules/customers/views/single.component.html b/src/app/modules/customers/views/single.component.html deleted file mode 100644 index 7144e26..0000000 --- a/src/app/modules/customers/views/single.component.html +++ /dev/null @@ -1 +0,0 @@ -
diff --git a/src/app/modules/customers/views/single.component.ts b/src/app/modules/customers/views/single.component.ts deleted file mode 100644 index 77d906c..0000000 --- a/src/app/modules/customers/views/single.component.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-customer', - templateUrl: './single.component.html', -}) -export class CustomerComponent { - constructor() {} -} diff --git a/src/app/modules/inventories/components/bankAccounts/create-bank-account-form.component.html b/src/app/modules/inventories/components/bankAccounts/create-bank-account-form.component.html deleted file mode 100644 index 5b4880e..0000000 --- a/src/app/modules/inventories/components/bankAccounts/create-bank-account-form.component.html +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/src/app/modules/inventories/components/bankAccounts/create-bank-account-form.component.ts b/src/app/modules/inventories/components/bankAccounts/create-bank-account-form.component.ts deleted file mode 100644 index 83c26ee..0000000 --- a/src/app/modules/inventories/components/bankAccounts/create-bank-account-form.component.ts +++ /dev/null @@ -1,57 +0,0 @@ -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(); - @Output() onSubmit = new EventEmitter(); - - 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); - } -} diff --git a/src/app/modules/inventories/components/bankAccounts/form.component.html b/src/app/modules/inventories/components/bankAccounts/form.component.html deleted file mode 100644 index dc5c37a..0000000 --- a/src/app/modules/inventories/components/bankAccounts/form.component.html +++ /dev/null @@ -1,6 +0,0 @@ - -
- - - -
diff --git a/src/app/modules/inventories/components/bankAccounts/form.component.ts b/src/app/modules/inventories/components/bankAccounts/form.component.ts deleted file mode 100644 index e6cfb37..0000000 --- a/src/app/modules/inventories/components/bankAccounts/form.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -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(0, { - nonNullable: true, - validators: [Validators.required], - }), - }); - - submitForm(payload: IInventoryAssignBankAccountRequest) { - const inventoryId = this.route.snapshot.paramMap.get('inventoryId')!; - return this.service.assign(Number(inventoryId), payload); - } -} diff --git a/src/app/modules/inventories/components/bankAccounts/list.component.html b/src/app/modules/inventories/components/bankAccounts/list.component.html deleted file mode 100644 index f014a67..0000000 --- a/src/app/modules/inventories/components/bankAccounts/list.component.html +++ /dev/null @@ -1,33 +0,0 @@ - - -
- حساب‌های بانکی متصل به انبار -
- - - -
-
-
- - - - - - - - - -
- diff --git a/src/app/modules/inventories/components/bankAccounts/list.component.ts b/src/app/modules/inventories/components/bankAccounts/list.component.ts deleted file mode 100644 index 204152d..0000000 --- a/src/app/modules/inventories/components/bankAccounts/list.component.ts +++ /dev/null @@ -1,150 +0,0 @@ -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 { 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, - 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; - - items = signal([]); - loading = signal(false); - visibleForm = signal(false); - visibleBankAccountForm = signal(false); - inventoryId = this.route.snapshot.params['inventoryId']; - - columns = [] as IColumn[]; - - 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); - }, - }); - } -} diff --git a/src/app/modules/inventories/components/bankAccounts/select.component.html b/src/app/modules/inventories/components/bankAccounts/select.component.html deleted file mode 100644 index 14b7e1b..0000000 --- a/src/app/modules/inventories/components/bankAccounts/select.component.html +++ /dev/null @@ -1,30 +0,0 @@ - - - @if (canInsert) { - -
- -
-
- } -
- -
diff --git a/src/app/modules/inventories/components/bankAccounts/select.component.ts b/src/app/modules/inventories/components/bankAccounts/select.component.ts deleted file mode 100644 index 7481c22..0000000 --- a/src/app/modules/inventories/components/bankAccounts/select.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -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, - IPaginatedResponse -> { - @Input() inventoryId!: string; - @Input() override showClear: boolean = false; - - constructor(private service: InventoryBankAccountsService) { - super(); - } - - ngOnInit() { - console.log(this.inventoryId); - this.getData(); - } - - getDataService() { - return this.service.getBankAccounts(Number(this.inventoryId)); - } -} diff --git a/src/app/modules/inventories/components/form.component.html b/src/app/modules/inventories/components/form.component.html deleted file mode 100644 index 8ea75ab..0000000 --- a/src/app/modules/inventories/components/form.component.html +++ /dev/null @@ -1,8 +0,0 @@ - -
- - - - - -
diff --git a/src/app/modules/inventories/components/form.component.ts b/src/app/modules/inventories/components/form.component.ts deleted file mode 100644 index 9183d7a..0000000 --- a/src/app/modules/inventories/components/form.component.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { InputComponent } from '@/shared/components'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, effect, EventEmitter, inject, Input, Output, signal } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { Dialog } from 'primeng/dialog'; -import { IInventoryRequest, IInventorySummaryResponse } from '../models'; -import { InventoriesService } from '../services/main.service'; - -@Component({ - selector: 'inventory-form', - templateUrl: './form.component.html', - imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent], -}) -export class InventoryFormComponent { - @Input() initialValues?: IInventorySummaryResponse; - - @Input() - set visible(v: boolean) { - this.visibleSignal.set(!!v); - } - get visible() { - return this.visibleSignal(); - } - private visibleSignal = signal(false); - - @Output() visibleChange = new EventEmitter(); - @Output() onSubmit = new EventEmitter(); - - private fb = inject(FormBuilder); - constructor( - private service: InventoriesService, - private toastService: ToastService, - ) { - effect(() => { - const v = this.visibleSignal(); - if (!v) this.form.reset(); - }); - } - - form = this.fb.group({ - name: [this.initialValues?.name || null, [Validators.required]], - location: [this.initialValues?.location || null, [Validators.required]], - isActive: [this.initialValues?.isActive || false, [Validators.required]], - }); - - submitLoading = signal(false); - - submit() { - this.form.markAllAsTouched(); - if (this.form.valid) { - this.form.disable(); - this.submitLoading.set(true); - this.service.create(this.form.value as IInventoryRequest).subscribe({ - next: (res) => { - this.toastService.success({ - text: `انبار ${this.form.value.name} با موفقیت ایجاد شد`, - }); - this.close(); - this.submitLoading.set(false); - this.form.enable(); - this.form.reset(); - this.onSubmit.emit(res); - }, - error: () => { - this.submitLoading.set(false); - this.form.enable(); - }, - }); - } - } - - close() { - this.visibleChange.emit(false); - } -} diff --git a/src/app/modules/inventories/components/index.ts b/src/app/modules/inventories/components/index.ts deleted file mode 100644 index 915bb30..0000000 --- a/src/app/modules/inventories/components/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './form.component'; -export * from './movementList/movement-list.component'; -export * from './select/select.component'; -export * from './transfer/transfer-form.component'; diff --git a/src/app/modules/inventories/components/movementList/movement-list.component.html b/src/app/modules/inventories/components/movementList/movement-list.component.html deleted file mode 100644 index 894a32a..0000000 --- a/src/app/modules/inventories/components/movementList/movement-list.component.html +++ /dev/null @@ -1,117 +0,0 @@ - - -
- {{ title }} - -
-
- - - - - - شناسه رسید - نوع گردش - انواع کالاها - تعداد کالاها - مجموع قیمت - تاریخ - - - - - - - - {{ movement.receiptId }} - - - - {{ movement.count }} - {{ movement.info.quantity }} - - - - - - - - - - - -
کالاهای جابجا شده در این گردش
-
- - - -
- شناسه کالا - -
- - -
- عنوان کالا - -
- - -
- تعداد - -
- - -
- قیمت واحد - -
- - -
- قیمت نهایی - -
- - - -
- - - {{ movement.product.id }} - {{ movement.product.name }} - {{ movement.quantity }} - - - - - - - -
-
- - -
- - - - هیچ گردش موجودی یافت نشد. - - -
-
-
diff --git a/src/app/modules/inventories/components/movementList/movement-list.component.ts b/src/app/modules/inventories/components/movementList/movement-list.component.ts deleted file mode 100644 index 66dbcce..0000000 --- a/src/app/modules/inventories/components/movementList/movement-list.component.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { MovementType } from '@/shared/catalog'; -import { CatalogMovementReferenceTagComponent } from '@/shared/catalog/movementReferenceTypes'; -import { JalaliDateDirective, PriceMaskDirective } from '@/shared/directives'; -import { Component, Input, signal } from '@angular/core'; -import { RouterLink } from '@angular/router'; -import { Button, ButtonDirective } from 'primeng/button'; -import { Card } from 'primeng/card'; -import { Ripple } from 'primeng/ripple'; -import { TableModule } from 'primeng/table'; -import { IInventoryStockMovementResponse } from '../../models'; -import { InventoriesService } from '../../services/main.service'; - -@Component({ - selector: 'inventory-movement-list', - templateUrl: './movement-list.component.html', - imports: [ - Card, - TableModule, - ButtonDirective, - Ripple, - Button, - RouterLink, - CatalogMovementReferenceTagComponent, - PriceMaskDirective, - JalaliDateDirective, - ], -}) -export class InventoryMovementListComponent { - @Input() inventoryId!: string; - @Input() movementType?: MovementType; - - loading = signal(false); - movements = signal([]); - expandedRows = {}; - - constructor(private service: InventoriesService) {} - - get title() { - switch (this.movementType) { - case 'IN': - return 'گردش ورودی کالاها'; - case 'OUT': - return 'گردش خروجی کالاها'; - case 'ADJUST': - return 'گردش تعدیل کالاها'; - default: - return 'تمام گردش کالاها'; - } - } - - ngOnInit() { - this.getAll(); - } - - getAll() { - this.loading.set(true); - - return this.service.getMovements(this.inventoryId, this.movementType).subscribe({ - next: (res) => { - this.movements.set(res.data); - this.loading.set(false); - }, - error: () => { - this.loading.set(false); - }, - }); - } -} diff --git a/src/app/modules/inventories/components/posAccounts/form.component.html b/src/app/modules/inventories/components/posAccounts/form.component.html deleted file mode 100644 index 82c9966..0000000 --- a/src/app/modules/inventories/components/posAccounts/form.component.html +++ /dev/null @@ -1,15 +0,0 @@ - -
- - - - - -
diff --git a/src/app/modules/inventories/components/posAccounts/form.component.ts b/src/app/modules/inventories/components/posAccounts/form.component.ts deleted file mode 100644 index bb0a850..0000000 --- a/src/app/modules/inventories/components/posAccounts/form.component.ts +++ /dev/null @@ -1,51 +0,0 @@ -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(this.initialValues?.name || '', { - nonNullable: true, - validators: [Validators.required], - }), - code: this.fb.control(this.initialValues?.code || '', { - nonNullable: true, - validators: [Validators.required], - }), - description: this.fb.control(this.initialValues?.description || '', { - nonNullable: true, - }), - bankAccountId: this.fb.control(this.initialValues?.bankAccount?.id || 0, { - nonNullable: true, - validators: [Validators.required], - }), - }); - - submitForm(payload: IInventoryPosAccountRequest) { - return this.service.create(Number(this.inventoryId), payload); - } -} diff --git a/src/app/modules/inventories/components/select/select.component.html b/src/app/modules/inventories/components/select/select.component.html deleted file mode 100644 index bf256d5..0000000 --- a/src/app/modules/inventories/components/select/select.component.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/src/app/modules/inventories/components/select/select.component.ts b/src/app/modules/inventories/components/select/select.component.ts deleted file mode 100644 index 91e2bcd..0000000 --- a/src/app/modules/inventories/components/select/select.component.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { AbstractSelectComponent } from '@/shared/components'; -import { UikitFieldComponent } from '@/uikit'; -import { Component } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { Select } from 'primeng/select'; -import { IInventorySummaryResponse } from '../../models'; -import { InventoriesService } from '../../services/main.service'; - -@Component({ - selector: 'inventories-select-field', - templateUrl: './select.component.html', - imports: [ReactiveFormsModule, Select, UikitFieldComponent], -}) -export class InventoriesSelectComponent extends AbstractSelectComponent< - IInventorySummaryResponse, - IPaginatedResponse -> { - constructor(private service: InventoriesService) { - super(); - this.getData(); - } - - getDataService() { - return this.service.getAll(); - } -} diff --git a/src/app/modules/inventories/components/transfer/transfer-form.component.html b/src/app/modules/inventories/components/transfer/transfer-form.component.html deleted file mode 100644 index 1b8b46d..0000000 --- a/src/app/modules/inventories/components/transfer/transfer-form.component.html +++ /dev/null @@ -1,142 +0,0 @@ - - انتقال موجودی بین انبارها - -
-
-
- -
- - - - - -
- - انبار مبدا -
- - - کالاهای موجود در انبار مبدا - -
- @if (!form.controls.fromInventory.value) { -
لطفا انبار مبدا را انتخاب کنید
- } @else { - - - - - نام کالا - موجودی - میانگین قیمت - - - - - - - - {{ item.product.name }} - {{ item.quantity }} - {{ item.avgCost }} - - - - } -
-
-
-
- -
-
- -
-
- - - انبار مقصد -
- - - - کالاهای انتخاب شده -
- @if (!form.controls.fromInventory.value) { -
لطفا انبار مبدا را انتخاب کنید
- } @else { - - - - نام کالا - مقدار برای انتقال - - - - - {{ item.controls.product.value?.name }} - - - - - - - } -
-
-
-
-
- -
- - -
-
-
-
diff --git a/src/app/modules/inventories/components/transfer/transfer-form.component.ts b/src/app/modules/inventories/components/transfer/transfer-form.component.ts deleted file mode 100644 index 960e692..0000000 --- a/src/app/modules/inventories/components/transfer/transfer-form.component.ts +++ /dev/null @@ -1,151 +0,0 @@ -import { Maybe } from '@/core'; -import { InputComponent } from '@/shared/components'; -import { UikitCounterComponent, UikitFieldComponent } from '@/uikit'; -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 { Select } from 'primeng/select'; -import { TableModule, TableRowSelectEvent, TableRowUnSelectEvent } from 'primeng/table'; -import { Textarea } from 'primeng/textarea'; -import { - IInventoryProduct, - IInventoryStockResponse, - IInventorySummaryResponse, - IInventoryTransferRequest, -} from '../../models'; -import { InventoriesService } from '../../services/main.service'; - -@Component({ - selector: 'inventories-transfer-form', - templateUrl: './transfer-form.component.html', - imports: [ - ReactiveFormsModule, - Card, - InputComponent, - Textarea, - UikitFieldComponent, - Select, - TableModule, - ButtonDirective, - UikitCounterComponent, - ], -}) -export class InventoriesTransferFormComponent { - fb = inject(FormBuilder); - - form = this.fb.group({ - fromInventory: [null as Maybe, [Validators.required]], - toInventory: [null as Maybe, [Validators.required]], - code: ['', [Validators.required]], - description: [''], - items: this.fb.array( - [ - this.fb.group({ - product: [null as Maybe, [Validators.required]], - count: [1, [Validators.required, Validators.min(1)]], - }), - ], - Validators.required, - ), - }); - - inventoriesLoading = signal(false); - inventories = signal[]>([]); - get toInventories() { - const fromInventoryId = this.form.controls.fromInventory.value; - return this.inventories().filter((inv) => inv?.id !== fromInventoryId?.id); - } - - originInventoryStock = signal([]); - originInventoryStockLoading = signal(false); - - selectedProducts = signal[]>([]); - - constructor(private service: InventoriesService) { - this.form.controls.toInventory.disable(); - this.form.controls.fromInventory.valueChanges.subscribe((val) => { - if (val && val.id) { - this.form.controls.toInventory.enable(); - this.getSelectedInventoryStock(); - } - }); - this.getInventories(); - } - - setSelectedProductsInForm($e: TableRowSelectEvent) { - const stock = $e.data as Maybe; - if (stock && stock.product) { - if ( - this.form.controls.items.length === 1 && - !this.form.controls.items.value?.at(0)?.product - ) { - this.form.controls.items.removeAt(0); - } - this.form.controls.items.push( - // @ts-ignore - this.fb.group({ - product: [stock.product, [Validators.required]], - count: [1, [Validators.required, Validators.min(1)]], - }), - ); - } - } - - clearSelectedProductsInForm($e: TableRowUnSelectEvent) { - if ($e.index != null) { - this.form.controls.items.removeAt($e.index); - } - } - - getInventories() { - this.inventoriesLoading.set(true); - this.service.getAll().subscribe({ - next: (res) => { - this.inventories.set(res.data); - this.inventoriesLoading.set(false); - }, - error: () => { - this.inventoriesLoading.set(false); - }, - }); - } - - getSelectedInventoryStock() { - this.originInventoryStockLoading.set(true); - this.service.getStock(String(this.form.controls.fromInventory.value?.id)).subscribe({ - next: (res) => { - this.originInventoryStock.set(res.data); - this.originInventoryStockLoading.set(false); - }, - error: () => { - this.originInventoryStockLoading.set(false); - }, - }); - } - - submitLoading = signal(false); - submit() { - this.submitLoading.set(true); - const payload = { - fromInventoryId: this.form.controls.fromInventory.value?.id, - toInventoryId: this.form.controls.toInventory.value?.id, - code: this.form.controls.code.value || '', - description: this.form.controls.description.value || '', - items: this.form.controls.items.value.map((item) => ({ - productId: item.product?.id, - count: item.count, - })), - } as IInventoryTransferRequest; - - this.service.transfer(payload).subscribe({ - next: () => { - this.submitLoading.set(false); - // this.form.reset(); - }, - error: () => { - this.submitLoading.set(false); - }, - }); - } -} diff --git a/src/app/modules/inventories/constants/apiRoutes/index.ts b/src/app/modules/inventories/constants/apiRoutes/index.ts deleted file mode 100644 index f036b30..0000000 --- a/src/app/modules/inventories/constants/apiRoutes/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { INVENTORY_POS_API_ROUTES } from './pos'; - -const baseUrl = '/api/v1/inventories'; - -export const INVENTORIES_API_ROUTES = { - list: () => `${baseUrl}`, - single: (inventoryId: string) => `${baseUrl}/${inventoryId}`, - inventoryMovements: (inventoryId: string) => `${baseUrl}/${inventoryId}/movements`, - transfer: () => `${baseUrl}/transfers`, - stock: (inventoryId: string) => `${baseUrl}/${inventoryId}/stock`, - cardex: (inventoryId: string) => `${baseUrl}/${inventoryId}/cardex`, - 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), -}; diff --git a/src/app/modules/inventories/constants/apiRoutes/pos.ts b/src/app/modules/inventories/constants/apiRoutes/pos.ts deleted file mode 100644 index 9143017..0000000 --- a/src/app/modules/inventories/constants/apiRoutes/pos.ts +++ /dev/null @@ -1,8 +0,0 @@ -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}`, - }; -}; diff --git a/src/app/modules/inventories/constants/index.ts b/src/app/modules/inventories/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/inventories/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/inventories/constants/routes/index.ts b/src/app/modules/inventories/constants/routes/index.ts deleted file mode 100644 index 1ed3493..0000000 --- a/src/app/modules/inventories/constants/routes/index.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { NamedRoutes } from '@/core'; -import { Routes } from '@angular/router'; - -export const inventoriesNamedRoutes: NamedRoutes = { - inventories: { - path: 'inventories', - loadComponent: () => import('../../views/list.component').then((m) => m.InventoriesComponent), - meta: { - title: 'انبارها', - pagePath: () => '/inventories', - }, - }, - - transfer: { - path: 'inventories/transfer', - loadComponent: () => - import('../../views/transfer.component').then((m) => m.InventoriesTransferComponent), - meta: { - title: 'انتقال بین انبارها', - pagePath: () => '/inventories/transfer', - }, - }, - inventory: { - path: 'inventories/:inventoryId', - loadComponent: () => import('../../views/single.component').then((m) => m.InventoryComponent), - meta: { - title: 'انبار', - pagePath: () => '/inventories/:inventoryId', - }, - }, - products: { - path: 'inventories/:inventoryId/products', - loadComponent: () => - import('../../views/products.component').then((m) => m.InventoryProductsComponent), - meta: { - title: 'محصولات انبار', - pagePath: () => '/inventories/:inventoryId/products', - }, - }, - cardex: { - path: 'inventories/:inventoryId/cardex', - loadComponent: () => - import('../../views/cardex.component').then((m) => m.InventoryCardexComponent), - meta: { - title: 'کاردکس انبار', - pagePath: () => '/inventories/:inventoryId/cardex', - }, - }, - productCardex: { - path: 'inventories/:inventoryId/products/:productId/cardex', - loadComponent: () => - import('../../views/product-cardex.component').then((m) => m.InventoryProductCardexComponent), - meta: { - title: 'کاردکس انبار محصول', - 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', - }, - }, - purchase: { - path: 'inventories/:inventoryId/purchase', - loadComponent: () => - import('../../views/purchase.component').then((m) => m.InventoryPurchaseComponent), - meta: { - title: 'ثبت خرید در انبار', - pagePath: () => '/inventories/:inventoryId/purchase', - }, - }, -} as const; - -export type TInventoriesRouteNames = keyof typeof inventoriesNamedRoutes; - -export const INVENTORIES_ROUTES: Routes = Object.values(inventoriesNamedRoutes); diff --git a/src/app/modules/inventories/models/bankAccounts.io.ts b/src/app/modules/inventories/models/bankAccounts.io.ts deleted file mode 100644 index f1590c5..0000000 --- a/src/app/modules/inventories/models/bankAccounts.io.ts +++ /dev/null @@ -1,44 +0,0 @@ -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; -} - -export interface IBankAccountSummary { - branch: Branch; - accountNumber: string; - cardNumber: string; - name: string; - id: number; - iban: string; -} - -interface Branch { - id: number; - name: string; - bank: Bank; -} - -interface Bank { - id: number; - name: string; - shortName: string; -} diff --git a/src/app/modules/inventories/models/index.ts b/src/app/modules/inventories/models/index.ts deleted file mode 100644 index fca944e..0000000 --- a/src/app/modules/inventories/models/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './bankAccounts.io'; -export * from './io'; -export * from './posAccounts.io'; -export * from './types'; diff --git a/src/app/modules/inventories/models/io.d.ts b/src/app/modules/inventories/models/io.d.ts deleted file mode 100644 index 476a79a..0000000 --- a/src/app/modules/inventories/models/io.d.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { ICardexResponse } from '@/modules/cardex/models'; -import { - IInventoryInfo, - IInventoryMovement, - IInventoryStockProduct, - IInventoryTransferRequestItem, -} from './types'; - -export interface IInventorySummaryRawResponse { - id: number; - name: string; - location: string; - isActive: boolean; - isPointOfSale: boolean; - createdAt: string; - updatedAt: string; - deletedAt: Maybe; -} - -export interface IInventorySummaryResponse extends IInventorySummaryRawResponse {} - -export interface IInventoryDetailRawResponse extends IInventorySummaryRawResponse { - availableProductTypes: number; - availableProductCount: number; - availableProductsCost: number; -} - -export interface IInventoryDetailResponse extends IInventoryDetailRawResponse {} - -export interface IInventoryRequest { - name: string; - location: string; - isActive: boolean; -} - -export interface IInventoryStockMovementRawResponse { - receiptId: string; - count: number; - info: IInventoryInfo; - movements: IInventoryMovement[]; -} - -export interface IInventoryStockMovementResponse extends IInventoryStockMovementRawResponse {} - -export interface IInventoryTransferRequest { - code: string; - description: string; - fromInventoryId: number; - toInventoryId: number; - items: IInventoryTransferRequestItem[]; -} - -export interface IInventoryStockRawResponse { - quantity: number; - avgCost: number; - product: IInventoryStockProduct; -} - -export interface IInventoryStockResponse extends IInventoryStockRawResponse {} - -export interface IInventoryStockQuery { - isAvailable?: boolean; -} - -export interface IInventoryProductCardexRawResponse extends ICardexResponse {} - -export interface IInventoryProductCardexResponse extends IInventoryProductCardexRawResponse {} diff --git a/src/app/modules/inventories/models/posAccounts.io.ts b/src/app/modules/inventories/models/posAccounts.io.ts deleted file mode 100644 index 19b9e79..0000000 --- a/src/app/modules/inventories/models/posAccounts.io.ts +++ /dev/null @@ -1,24 +0,0 @@ -import ISummary from '@/core/models/summary'; -import { IInventoryBankAccountSummary } from './types'; - -export interface IInventoryPosAccountRawResponse { - id: number; - name: string; - code: string; - description: string; - bankAccountId: number; - inventory: ISummary; - createdAt: string; - updatedAt: string; - deletedAt: null; - bankAccount: IInventoryBankAccountSummary; -} - -export interface IInventoryPosAccountResponse extends IInventoryPosAccountRawResponse {} - -export interface IInventoryPosAccountRequest { - name: string; - code: string; - description: string; - bankAccountId: number; -} diff --git a/src/app/modules/inventories/models/types.ts b/src/app/modules/inventories/models/types.ts deleted file mode 100644 index 1288a73..0000000 --- a/src/app/modules/inventories/models/types.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { IProductRawResponse } from '@/modules/products/models'; - -export interface IInventoryMovement { - id: number; - quantity: number; - unitPrice: number; - totalCost: number; - avgCost: number; - product: IInventoryProduct; - remainedInStock: number; -} - -export interface IInventoryProduct { - id: number; - name: string; - description: null; - sku: string; - barcode: string; - createdAt: string; - updatedAt: string; - deletedAt: null; - brandId: number; - categoryId: number; -} - -export interface IInventoryInfo { - date: string; - type: string; - quantity: number; - unitPrice: number; - totalCost: number; - referenceType: string; - referenceId: string; - createdAt: string; -} - -export interface IInventoryTransferRequestItem { - productId: number; - count: number; -} - -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; -} diff --git a/src/app/modules/inventories/services/bankAccounts.service.ts b/src/app/modules/inventories/services/bankAccounts.service.ts deleted file mode 100644 index e680718..0000000 --- a/src/app/modules/inventories/services/bankAccounts.service.ts +++ /dev/null @@ -1,55 +0,0 @@ -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> { - return this.http.get>( - `${this.apiRoutes.bankAccounts(inventoryId)}`, - ); - } - - create( - inventoryId: number, - payload: IInventoryBankAccountRequest, - ): Observable { - return this.http.post( - `${this.apiRoutes.bankAccounts(inventoryId)}`, - payload, - ); - } - - assign( - inventoryId: number, - payload: IInventoryAssignBankAccountRequest, - ): Observable { - return this.http.post( - `${this.apiRoutes.assignBankAccounts(inventoryId)}`, - payload, - ); - } - unassign( - inventoryId: number, - payload: IInventoryAssignBankAccountRequest, - ): Observable { - return this.http.post( - `${this.apiRoutes.unassignBankAccounts(inventoryId)}`, - payload, - ); - } -} diff --git a/src/app/modules/inventories/services/index.ts b/src/app/modules/inventories/services/index.ts deleted file mode 100644 index 796f816..0000000 --- a/src/app/modules/inventories/services/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './bankAccounts.service'; -export * from './main.service'; diff --git a/src/app/modules/inventories/services/main.service.ts b/src/app/modules/inventories/services/main.service.ts deleted file mode 100644 index ea3b885..0000000 --- a/src/app/modules/inventories/services/main.service.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { MovementType } from '@/shared/catalog'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { INVENTORIES_API_ROUTES } from '../constants'; -import { - IInventoryDetailRawResponse, - IInventoryDetailResponse, - IInventoryProductCardexRawResponse, - IInventoryProductCardexResponse, - IInventoryRequest, - IInventoryStockMovementRawResponse, - IInventoryStockMovementResponse, - IInventoryStockQuery, - IInventoryStockRawResponse, - IInventoryStockResponse, - IInventorySummaryRawResponse, - IInventorySummaryResponse, - IInventoryTransferRequest, -} from '../models'; - -@Injectable({ providedIn: 'root' }) -export class InventoriesService { - constructor(private http: HttpClient) {} - - private apiRoutes = INVENTORIES_API_ROUTES; - - getAll(): Observable> { - return this.http.get>(this.apiRoutes.list()); - } - - getSingle(inventoryId: string): Observable { - return this.http.get(this.apiRoutes.single(inventoryId)); - } - - create(data: IInventoryRequest): Observable { - return this.http.post(this.apiRoutes.list(), data); - } - - getMovements( - inventoryId: string, - movementType?: MovementType, - ): Observable> { - return this.http.get>( - this.apiRoutes.inventoryMovements(inventoryId), - { - params: movementType ? { type: movementType } : {}, - }, - ); - } - - transfer(payload: IInventoryTransferRequest): Observable { - return this.http.post(this.apiRoutes.transfer(), payload); - } - - getStock( - inventoryId: string, - params?: IInventoryStockQuery, - ): Observable> { - return this.http.get>( - this.apiRoutes.stock(inventoryId), - { params: params ? { ...params } : {} }, - ); - } - - getProductCardex( - inventoryId: string, - productId: string, - ): Observable> { - return this.http.get>( - `${this.apiRoutes.productCardex(inventoryId, productId)}`, - ); - } - getCardex(inventoryId: string): Observable> { - return this.http.get>( - `${this.apiRoutes.cardex(inventoryId)}`, - ); - } -} diff --git a/src/app/modules/inventories/services/posAccounts.service.ts b/src/app/modules/inventories/services/posAccounts.service.ts deleted file mode 100644 index 12a35aa..0000000 --- a/src/app/modules/inventories/services/posAccounts.service.ts +++ /dev/null @@ -1,33 +0,0 @@ -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> { - return this.http.get>( - `${this.apiRoutes.pos.list(String(inventoryId))}`, - ); - } - - create( - inventoryId: number, - payload: IInventoryPosAccountRequest, - ): Observable { - return this.http.post( - `${this.apiRoutes.pos.list(String(inventoryId))}`, - payload, - ); - } -} diff --git a/src/app/modules/inventories/store/inventory.store.ts b/src/app/modules/inventories/store/inventory.store.ts deleted file mode 100644 index 566a89a..0000000 --- a/src/app/modules/inventories/store/inventory.store.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { EntityState, EntityStore } from '@/core/state'; -import { Injectable } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { IInventoryDetailResponse } from '../models'; -import { InventoriesService } from '../services'; - -export interface InventoryState extends EntityState {} - -@Injectable({ - providedIn: 'root', -}) -export class InventoryStore extends EntityStore { - private readonly _inventoryState = { - isRefreshing: false, - }; - - constructor( - private activeRoute: ActivatedRoute, - private service: InventoriesService, - private toastService: ToastService, - ) { - super({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - entities: {}, - selectedId: null, - ids: [], - }); - this.initial(); - } - - supplierId!: string; - - initial() {} - - getSingle(inventoryId: string) { - if (this.entities()[inventoryId]) { - return; - } - this.patchState({ loading: true }); - this.service.getSingle(inventoryId).subscribe({ - next: (res) => { - console.log('first'); - - this.patchState({ - entities: { [res.id]: res }, - loading: false, - }); - console.log(this.entities()); - }, - error: (err) => { - this.patchState({ loading: false, error: err }); - this.toastService.error({ - text: 'خطا در دریافت اطلاعات انبار', - }); - }, - }); - } - - refresh(inventoryId: string) { - const { inventoryId: _, ...entities } = this.entities(); - this.patchState({ - entities, - }); - this.getSingle(inventoryId); - } - - reset(): void { - const queryParams = this.activeRoute.snapshot.queryParams; - this.setState({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - entities: {}, - selectedId: null, - ids: [], - }); - } -} diff --git a/src/app/modules/inventories/views/cardex.component.html b/src/app/modules/inventories/views/cardex.component.html deleted file mode 100644 index bc39b4c..0000000 --- a/src/app/modules/inventories/views/cardex.component.html +++ /dev/null @@ -1,15 +0,0 @@ -@if (pageLoading) { -
- -
-} @else { - - -
- کاردکس انبار {{ inventory()?.name }} -
-
- - -
-} diff --git a/src/app/modules/inventories/views/cardex.component.ts b/src/app/modules/inventories/views/cardex.component.ts deleted file mode 100644 index fb2c605..0000000 --- a/src/app/modules/inventories/views/cardex.component.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Maybe } from '@/core'; -import { CardexComponent } from '@/modules/cardex/components/templates/inventory.component'; -import { IProductResponse } from '@/modules/products/models'; -import { Component, computed, inject, signal } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { Card } from 'primeng/card'; -import { ProgressSpinner } from 'primeng/progressspinner'; -import { IInventoryProductCardexResponse } from '../models'; -import { InventoriesService } from '../services/main.service'; -import { InventoryStore } from '../store/inventory.store'; - -@Component({ - selector: 'inventory-cardex', - templateUrl: './cardex.component.html', - imports: [ProgressSpinner, Card, CardexComponent], -}) -export class InventoryCardexComponent { - private route = inject(ActivatedRoute); - private readonly store = inject(InventoryStore); - - inventoryId = this.route.snapshot.paramMap.get('inventoryId')!; - - inventory = computed(() => this.store.entities()[this.inventoryId]); - loading = this.store.loading; - - getInventoryLoading = signal(false); - getProductLoading = signal(false); - product = signal>(null); - - getCardexLoading = signal(false); - cardex = signal>(null); - - get pageLoading() { - return this.getInventoryLoading() || this.getProductLoading(); - } - - constructor(private service: InventoriesService) { - this.store.getSingle(this.inventoryId); - this.getCardex(); - } - - getCardex() { - this.service.getCardex(this.inventoryId).subscribe({ - next: (res) => { - this.getCardexLoading.set(false); - this.cardex.set(res.data); - }, - error: () => { - this.getCardexLoading.set(false); - }, - }); - } -} diff --git a/src/app/modules/inventories/views/index.ts b/src/app/modules/inventories/views/index.ts deleted file mode 100644 index c2246ae..0000000 --- a/src/app/modules/inventories/views/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './list.component'; -export * from './posAccounts'; -export * from './single.component'; diff --git a/src/app/modules/inventories/views/list.component.html b/src/app/modules/inventories/views/list.component.html deleted file mode 100644 index 903dd89..0000000 --- a/src/app/modules/inventories/views/list.component.html +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/src/app/modules/inventories/views/list.component.ts b/src/app/modules/inventories/views/list.component.ts deleted file mode 100644 index babd0e7..0000000 --- a/src/app/modules/inventories/views/list.component.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, inject, signal } from '@angular/core'; -import { Router } from '@angular/router'; -import { InventoryFormComponent } from '../components/form.component'; -import { IInventorySummaryResponse } from '../models'; -import { InventoriesService } from '../services/main.service'; - -@Component({ - selector: 'app-inventories', - templateUrl: './list.component.html', - imports: [PageDataListComponent, InventoryFormComponent], -}) -export class InventoriesComponent { - private router = inject(Router); - constructor(private inventoryService: InventoriesService) { - this.getData(); - } - - columns = [ - { field: 'id', header: 'شناسه' }, - { field: 'name', header: 'نام' }, - { field: 'location', header: 'موقعیت' }, - { field: 'isPointOfSale', header: 'نقطه فروش', type: 'boolean' }, - { field: 'isActive', header: 'فعال', type: 'boolean' }, - ] as IColumn[]; - - loading = signal(false); - items = signal([]); - visibleForm = signal(false); - - refresh() { - this.getData(); - } - - getData() { - this.loading.set(true); - this.inventoryService.getAll().subscribe((res) => { - this.loading.set(false); - this.items.set(res.data); - }); - } - - openAddForm() { - this.visibleForm.set(true); - } - - toDetails(item: IInventorySummaryResponse) { - this.router.navigate(['/inventories', item.id]); - } -} diff --git a/src/app/modules/inventories/views/posAccounts/index.ts b/src/app/modules/inventories/views/posAccounts/index.ts deleted file mode 100644 index 576a89e..0000000 --- a/src/app/modules/inventories/views/posAccounts/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './list.component'; diff --git a/src/app/modules/inventories/views/posAccounts/list.component.html b/src/app/modules/inventories/views/posAccounts/list.component.html deleted file mode 100644 index 64441e5..0000000 --- a/src/app/modules/inventories/views/posAccounts/list.component.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - -
- @if (item.todaySalesInfo.salesCount) { - - {{ item.todaySalesInfo.salesCount }} فاکتور - } @else { - فروشی ثبت نشده است - } -
-
- - -
- - -
-
-
- @if (inventoryId) { - - } -
diff --git a/src/app/modules/inventories/views/posAccounts/list.component.ts b/src/app/modules/inventories/views/posAccounts/list.component.ts deleted file mode 100644 index 00963c7..0000000 --- a/src/app/modules/inventories/views/posAccounts/list.component.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { InnerPagesHeaderComponent } from '@/shared/components/innerPagesHeader/inner-pages-header.component'; -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { PriceMaskDirective } from '@/shared/directives'; -import { Component, computed, inject, signal, TemplateRef, ViewChild } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { Button, 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'; -import { InventoryStore } from '../../store/inventory.store'; - -@Component({ - selector: 'app-inventory-pos-account-list', - templateUrl: './list.component.html', - imports: [ - PageDataListComponent, - Card, - ButtonDirective, - InventoryPosAccountFormComponent, - InnerPagesHeaderComponent, - PriceMaskDirective, - Button, - ], -}) -export class InventoryPosAccountListComponent { - private readonly route = inject(ActivatedRoute); - private readonly service = inject(InventoryPosAccountsService); - private readonly inventoryStore = inject(InventoryStore); - - inventoryId = this.route.snapshot.params['inventoryId']; - items = signal([]); - loading = signal(false); - visibleForm = signal(false); - inventory = computed(() => this.inventoryStore.entities()[this.inventoryId]); - - @ViewChild('salesInfoTpl', { static: true }) salesInfoTpl!: TemplateRef; - @ViewChild('actionsTpl', { static: true }) actionsTpl!: TemplateRef; - - columns = [] as IColumn[]; - - pageTitle = computed(() => `نقاط فروش متصل به انبار ${this.inventory()?.name || ''}`); - - ngOnInit() { - this.inventoryStore.getSingle(this.inventoryId); - 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: 'salesInfo', - header: 'جزییات فروش امروز', - customDataModel: this.salesInfoTpl, - }, - - { - 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); - } - - toPos(item: IInventoryPosAccountResponse) { - window.open(`/pos/${item.id}`, '_blank'); - } - - toPosInfo(item: IInventoryPosAccountResponse) {} -} diff --git a/src/app/modules/inventories/views/product-cardex.component.html b/src/app/modules/inventories/views/product-cardex.component.html deleted file mode 100644 index f3210b1..0000000 --- a/src/app/modules/inventories/views/product-cardex.component.html +++ /dev/null @@ -1,16 +0,0 @@ -@if (pageLoading) { -
- -
-} @else { - - -
- کاردکس کالای {{ product()?.name }} در انبار {{ inventory()?.name }} - -
-
- - -
-} diff --git a/src/app/modules/inventories/views/product-cardex.component.ts b/src/app/modules/inventories/views/product-cardex.component.ts deleted file mode 100644 index 00d9aa2..0000000 --- a/src/app/modules/inventories/views/product-cardex.component.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { Maybe } from '@/core'; -import { CardexComponent } from '@/modules/cardex/components/templates/inventory.component'; -import { IProductResponse } from '@/modules/products/models'; -import { ProductsService } from '@/modules/products/services/main.service'; -import { Component, computed, inject, signal } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { Card } from 'primeng/card'; -import { ProgressSpinner } from 'primeng/progressspinner'; -import { IInventoryProductCardexResponse } from '../models'; -import { InventoriesService } from '../services/main.service'; -import { InventoryStore } from '../store/inventory.store'; - -@Component({ - selector: 'inventory-product-cardex', - templateUrl: './product-cardex.component.html', - imports: [ProgressSpinner, Card, CardexComponent], -}) -export class InventoryProductCardexComponent { - private route = inject(ActivatedRoute); - private readonly store = inject(InventoryStore); - - inventoryId = this.route.snapshot.paramMap.get('inventoryId')!; - productId = this.route.snapshot.params['productId']; - - inventory = computed(() => this.store.entities()[this.inventoryId]); - loading = this.store.loading; - - getInventoryLoading = signal(false); - getProductLoading = signal(false); - product = signal>(null); - - getCardexLoading = signal(false); - cardex = signal>(null); - - get pageLoading() { - return this.getInventoryLoading() || this.getProductLoading(); - } - - constructor( - private service: InventoriesService, - private productService: ProductsService, - ) { - this.store.getSingle(this.inventoryId); - this.getProduct(); - this.getCardex(); - } - - getProduct() { - this.getProductLoading.set(true); - this.productService.getSingle(this.productId).subscribe({ - next: (res) => { - this.getProductLoading.set(false); - this.product.set(res); - }, - error: () => { - this.getProductLoading.set(false); - }, - }); - } - - getCardex() { - this.service.getProductCardex(this.inventoryId, this.productId).subscribe({ - next: (res) => { - this.getCardexLoading.set(false); - this.cardex.set(res.data); - }, - error: () => { - this.getCardexLoading.set(false); - }, - }); - } -} diff --git a/src/app/modules/inventories/views/products.component.html b/src/app/modules/inventories/views/products.component.html deleted file mode 100644 index dc3da19..0000000 --- a/src/app/modules/inventories/views/products.component.html +++ /dev/null @@ -1,51 +0,0 @@ - - -
- کالاهای موجود در انبار - -
-
- - - - -
- شناسه کالا - -
- - -
- عنوان کالا - -
- - -
- تعداد - -
- - -
- قیمت متوسط - -
- - - -
- - - {{ stock.product.sku }} - {{ stock.product.name }} - {{ stock.quantity }} - - - - - - - -
-
diff --git a/src/app/modules/inventories/views/products.component.ts b/src/app/modules/inventories/views/products.component.ts deleted file mode 100644 index bf22f7a..0000000 --- a/src/app/modules/inventories/views/products.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { PriceMaskDirective } from '@/shared/directives'; -import { Component, inject, signal } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { ButtonDirective } from 'primeng/button'; -import { Card } from 'primeng/card'; -import { TableModule } from 'primeng/table'; -import { IInventoryStockResponse } from '../models'; -import { InventoriesService } from '../services/main.service'; - -@Component({ - selector: 'inventory-products', - templateUrl: './products.component.html', - imports: [Card, TableModule, ButtonDirective, PriceMaskDirective], -}) -export class InventoryProductsComponent { - private route = inject(ActivatedRoute); - constructor(private service: InventoriesService) { - this.getData(); - } - - inventoryId = this.route.snapshot.params['inventoryId']; - loading = signal(false); - data = signal([]); - - getData() { - this.loading.set(true); - this.service.getStock(this.inventoryId).subscribe({ - next: (res) => { - this.data.set(res.data); - this.loading.set(false); - }, - error: () => { - this.loading.set(false); - }, - }); - } -} diff --git a/src/app/modules/inventories/views/purchase.component.html b/src/app/modules/inventories/views/purchase.component.html deleted file mode 100644 index d7bdecc..0000000 --- a/src/app/modules/inventories/views/purchase.component.html +++ /dev/null @@ -1,4 +0,0 @@ -@if (loading()) { -} @else { - -} diff --git a/src/app/modules/inventories/views/purchase.component.ts b/src/app/modules/inventories/views/purchase.component.ts deleted file mode 100644 index 8022e69..0000000 --- a/src/app/modules/inventories/views/purchase.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { PurchaseReceiptTemplateComponent } from '@/modules/purchases/components'; -import { Component, computed, inject } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { InventoryStore } from '../store/inventory.store'; - -@Component({ - selector: 'app-inventory-purchase', - templateUrl: './purchase.component.html', - imports: [PurchaseReceiptTemplateComponent], -}) -export class InventoryPurchaseComponent { - private readonly route = inject(ActivatedRoute); - private readonly store = inject(InventoryStore); - - inventoryId = this.route.snapshot.paramMap.get('inventoryId')!; - - inventory = computed(() => this.store.entities()[this.inventoryId]); - loading = this.store.loading; - constructor() { - this.store.getSingle(this.inventoryId); - } -} diff --git a/src/app/modules/inventories/views/single.component.html b/src/app/modules/inventories/views/single.component.html deleted file mode 100644 index fa3ab8b..0000000 --- a/src/app/modules/inventories/views/single.component.html +++ /dev/null @@ -1,110 +0,0 @@ -
-
-
-
- -

{{ data()?.name }}

-
-
-
- - - - - - -
-
-
-
- -
-
- -
-
- -
-
- @for (item of topBarCardDetails; track $index) { - - } -
-
- - - - - -
- کالاهای موجود در انبار - -
-
- - - - -
- شناسه کالا - -
- - -
- عنوان کالا - -
- - -
- تعداد - -
- - -
- قیمت متوسط - -
- - - -
- - - {{ stock.product.sku }} - {{ stock.product.name }} - {{ stock.quantity }} - - - - - - - -
-
- - - - -
diff --git a/src/app/modules/inventories/views/single.component.ts b/src/app/modules/inventories/views/single.component.ts deleted file mode 100644 index 0ee26d5..0000000 --- a/src/app/modules/inventories/views/single.component.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { Maybe } from '@/core'; -import { KeyValueComponent } from '@/shared/components'; -import { DetailsInfoCardComponent } from '@/shared/components/detailsInfoCard/details-info-card.component'; -import { PriceMaskDirective } from '@/shared/directives'; -import { formatWithCurrency } from '@/utils'; -import { Component, inject, signal } from '@angular/core'; -import { ActivatedRoute, RouterLink } from '@angular/router'; -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'; - -@Component({ - selector: 'app-product', - templateUrl: './single.component.html', - imports: [ - ButtonDirective, - RouterLink, - GalleriaModule, - KeyValueComponent, - Button, - InventoryMovementListComponent, - DetailsInfoCardComponent, - Card, - TableModule, - PriceMaskDirective, - InventoryBankAccountsListComponent, - ], -}) -export class InventoryComponent { - private route = inject(ActivatedRoute); - constructor(private service: InventoriesService) { - this.getData(); - this.getStock(); - } - - inventoryId = this.route.snapshot.params['inventoryId']; - loading = signal(false); - data = signal>(null); - - getData() { - this.loading.set(true); - this.service.getSingle(this.inventoryId).subscribe({ - next: (res) => { - this.data.set(res); - this.loading.set(false); - }, - error: () => { - this.loading.set(false); - }, - }); - } - - getStockLoading = signal(false); - stock = signal([]); - - getStock() { - this.getStockLoading.set(true); - this.service.getStock(this.inventoryId, { isAvailable: true }).subscribe({ - next: (res) => { - this.getStockLoading.set(false); - this.stock.set(res.data); - }, - error: () => { - this.getStockLoading.set(false); - }, - }); - } - - get topBarCardDetails() { - return [ - { - icon: 'pi pi-box', - label: 'تعداد کالاهای موجود', - value: this.data()?.availableProductCount, - }, - { - icon: 'pi pi-dollar', - label: 'تنوع کالاها', - value: this.data()?.availableProductTypes, - }, - { - icon: 'pi pi-dollar', - label: 'ارزش کلی کالاهای موجود', - value: formatWithCurrency(this.data()?.availableProductsCost || 0), - }, - ]; - } - - openDeleteConfirm() {} -} diff --git a/src/app/modules/inventories/views/transfer.component.html b/src/app/modules/inventories/views/transfer.component.html deleted file mode 100644 index 16e3ab5..0000000 --- a/src/app/modules/inventories/views/transfer.component.html +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/src/app/modules/inventories/views/transfer.component.ts b/src/app/modules/inventories/views/transfer.component.ts deleted file mode 100644 index 30517e0..0000000 --- a/src/app/modules/inventories/views/transfer.component.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Component } from '@angular/core'; -import { InventoriesTransferFormComponent } from '../components/transfer/transfer-form.component'; - -@Component({ - selector: 'inventories-transfer', - templateUrl: './transfer.component.html', - imports: [InventoriesTransferFormComponent], -}) -export class InventoriesTransferComponent { - constructor() {} -} diff --git a/src/app/modules/productBrands/components/form.component.html b/src/app/modules/productBrands/components/form.component.html deleted file mode 100644 index 3b16286..0000000 --- a/src/app/modules/productBrands/components/form.component.html +++ /dev/null @@ -1,15 +0,0 @@ - -
- - - - - -
diff --git a/src/app/modules/productBrands/components/form.component.ts b/src/app/modules/productBrands/components/form.component.ts deleted file mode 100644 index f364f3f..0000000 --- a/src/app/modules/productBrands/components/form.component.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { InputComponent } from '@/shared/components'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, effect, EventEmitter, inject, Input, Output, signal } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { Dialog } from 'primeng/dialog'; -import { IProductBrandRequest, IProductBrandResponse } from '../models'; -import { ProductBrandsService } from '../services/main.service'; - -@Component({ - selector: 'product-brand-form', - templateUrl: './form.component.html', - imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent], -}) -export class ProductBrandFormComponent { - @Input() initialValues?: IProductBrandResponse; - - @Input() - set visible(v: boolean) { - this.visibleSignal.set(!!v); - } - get visible() { - return this.visibleSignal(); - } - private visibleSignal = signal(false); - - @Output() visibleChange = new EventEmitter(); - @Output() onSubmit = new EventEmitter(); - - private fb = inject(FormBuilder); - constructor( - private service: ProductBrandsService, - private toastService: ToastService, - ) { - effect(() => { - const v = this.visibleSignal(); - if (!v) this.form.reset(); - }); - } - - form = this.fb.group({ - name: [this.initialValues?.name || null, [Validators.required]], - description: [this.initialValues?.description || null], - imageUrl: [this.initialValues?.imageUrl || null], - }); - - submitLoading = signal(false); - - submit() { - this.form.markAllAsTouched(); - if (this.form.valid) { - this.form.disable(); - this.submitLoading.set(true); - this.service.create(this.form.value as IProductBrandRequest).subscribe({ - next: (res) => { - this.toastService.success({ - text: `برند ${this.form.value.name} با موفقیت ایجاد شد`, - }); - this.close(); - this.submitLoading.set(false); - this.form.enable(); - this.form.reset(); - this.onSubmit.emit(res); - }, - error: () => { - this.submitLoading.set(false); - this.form.enable(); - }, - }); - } - } - - close() { - this.visibleChange.emit(false); - } -} diff --git a/src/app/modules/productBrands/components/index.ts b/src/app/modules/productBrands/components/index.ts deleted file mode 100644 index 4078bb8..0000000 --- a/src/app/modules/productBrands/components/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './form.component'; -export * from './select/select.component'; diff --git a/src/app/modules/productBrands/components/select/select.component.html b/src/app/modules/productBrands/components/select/select.component.html deleted file mode 100644 index 28ef6e4..0000000 --- a/src/app/modules/productBrands/components/select/select.component.html +++ /dev/null @@ -1,31 +0,0 @@ -
- - - @if (canInsert) { - -
- -
-
- } -
-
- -
diff --git a/src/app/modules/productBrands/components/select/select.component.ts b/src/app/modules/productBrands/components/select/select.component.ts deleted file mode 100644 index 00fbf49..0000000 --- a/src/app/modules/productBrands/components/select/select.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { AbstractSelectComponent } from '@/shared/components'; -import { UikitFieldComponent } from '@/uikit'; -import { Component } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { Button } from 'primeng/button'; -import { Select } from 'primeng/select'; -import { IProductBrandResponse } from '../../models'; -import { ProductBrandsService } from '../../services/main.service'; -import { ProductBrandFormComponent } from '../form.component'; - -@Component({ - selector: 'product-brands-select-field', - templateUrl: './select.component.html', - imports: [ReactiveFormsModule, Select, UikitFieldComponent, Button, ProductBrandFormComponent], -}) -export class ProductBrandsSelectComponent extends AbstractSelectComponent< - IProductBrandResponse, - IPaginatedResponse -> { - constructor(private service: ProductBrandsService) { - super(); - this.getData(); - } - - getDataService() { - return this.service.getAll(); - } -} diff --git a/src/app/modules/productBrands/constants/apiRoutes/index.ts b/src/app/modules/productBrands/constants/apiRoutes/index.ts deleted file mode 100644 index 381bee9..0000000 --- a/src/app/modules/productBrands/constants/apiRoutes/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -const baseUrl = '/api/v1/product-brands'; - -export const PRODUCT_BRANDS_API_ROUTES = { - list: () => `${baseUrl}`, - single: (brandId: string) => `${baseUrl}/${brandId}`, -}; diff --git a/src/app/modules/productBrands/constants/index.ts b/src/app/modules/productBrands/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/productBrands/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/productBrands/constants/routes/index.ts b/src/app/modules/productBrands/constants/routes/index.ts deleted file mode 100644 index ed8e79b..0000000 --- a/src/app/modules/productBrands/constants/routes/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { NamedRoutes } from '@/core'; -import { Routes } from '@angular/router'; - -export type TProductBrandsRouteNames = 'productBrands' | 'productBrand'; - -export const productBrandsNamedRoutes: NamedRoutes = { - productBrands: { - path: 'product-brands', - loadComponent: () => import('../../views/list.component').then((m) => m.ProductBrandsComponent), - meta: { - title: 'برندهای کالا', - pagePath: () => '/product-brands', - }, - }, - productBrand: { - path: 'product-brands/:brandId', - loadComponent: () => - import('../../views/single.component').then((m) => m.ProductBrandComponent), - meta: { - title: 'برند کالا', - pagePath: () => '/product-brands/:brandId', - }, - }, -}; - -export const PRODUCT_BRANDS_ROUTES: Routes = Object.values(productBrandsNamedRoutes); diff --git a/src/app/modules/productBrands/index.ts b/src/app/modules/productBrands/index.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/modules/productBrands/models/index.ts b/src/app/modules/productBrands/models/index.ts deleted file mode 100644 index 61a518a..0000000 --- a/src/app/modules/productBrands/models/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './io'; diff --git a/src/app/modules/productBrands/models/io.d.ts b/src/app/modules/productBrands/models/io.d.ts deleted file mode 100644 index ed1e14e..0000000 --- a/src/app/modules/productBrands/models/io.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -export interface IProductBrandRawResponse { - id: number; - name: string; - description: string; - imageUrl: string; - createdAt: Date; - updatedAt: Date; - deletedAt: Date; -} - -export interface IProductBrandResponse extends IProductBrandRawResponse {} - -export interface IProductBrandRequest { - name: string; - description: string; - imageUrl: string; -} diff --git a/src/app/modules/productBrands/services/main.service.ts b/src/app/modules/productBrands/services/main.service.ts deleted file mode 100644 index 27a1905..0000000 --- a/src/app/modules/productBrands/services/main.service.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { PRODUCT_BRANDS_API_ROUTES } from '../constants'; -import { IProductBrandRawResponse, IProductBrandRequest, IProductBrandResponse } from '../models'; - -@Injectable({ providedIn: 'root' }) -export class ProductBrandsService { - constructor(private http: HttpClient) {} - - private apiRoutes = PRODUCT_BRANDS_API_ROUTES; - - getAll(): Observable> { - return this.http.get>(this.apiRoutes.list()); - } - - getSingle(brandId: string): Observable { - return this.http.get(this.apiRoutes.single(brandId)); - } - - create(data: IProductBrandRequest): Observable { - return this.http.post(this.apiRoutes.list(), data); - } -} diff --git a/src/app/modules/productBrands/views/index.ts b/src/app/modules/productBrands/views/index.ts deleted file mode 100644 index bc9dfc9..0000000 --- a/src/app/modules/productBrands/views/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './list.component'; -export * from './single.component'; diff --git a/src/app/modules/productBrands/views/list.component.html b/src/app/modules/productBrands/views/list.component.html deleted file mode 100644 index 74db881..0000000 --- a/src/app/modules/productBrands/views/list.component.html +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/src/app/modules/productBrands/views/list.component.ts b/src/app/modules/productBrands/views/list.component.ts deleted file mode 100644 index c60375e..0000000 --- a/src/app/modules/productBrands/views/list.component.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, signal } from '@angular/core'; -import { ProductBrandFormComponent } from '../components/form.component'; -import { IProductBrandResponse } from '../models'; -import { ProductBrandsService } from '../services/main.service'; - -@Component({ - selector: 'app-product-brands', - templateUrl: './list.component.html', - imports: [PageDataListComponent, ProductBrandFormComponent], -}) -export class ProductBrandsComponent { - constructor(private productBrandService: ProductBrandsService) { - this.getData(); - } - - columns = [ - { field: 'id', header: 'شناسه' }, - { field: 'name', header: 'نام' }, - { field: 'description', header: 'توضیحات' }, - { field: 'imageUrl', header: 'تصویر' }, - { field: 'createdAt', header: 'تاریخ ایجاد', type: 'date' }, - { field: 'updatedAt', header: 'تاریخ به‌روزرسانی', type: 'date' }, - ] as IColumn[]; - - loading = signal(false); - items = signal([]); - visibleForm = signal(false); - - refresh() { - this.getData(); - } - - getData() { - this.loading.set(true); - this.productBrandService.getAll().subscribe((res) => { - this.loading.set(false); - this.items.set(res.data); - }); - } - - openAddForm() { - this.visibleForm.set(true); - } -} diff --git a/src/app/modules/productBrands/views/single.component.html b/src/app/modules/productBrands/views/single.component.html deleted file mode 100644 index 7144e26..0000000 --- a/src/app/modules/productBrands/views/single.component.html +++ /dev/null @@ -1 +0,0 @@ -
diff --git a/src/app/modules/productBrands/views/single.component.ts b/src/app/modules/productBrands/views/single.component.ts deleted file mode 100644 index 9375bfe..0000000 --- a/src/app/modules/productBrands/views/single.component.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-product-brand', - templateUrl: './single.component.html', -}) -export class ProductBrandComponent { - constructor() {} -} diff --git a/src/app/modules/productCategories/components/form.component.html b/src/app/modules/productCategories/components/form.component.html deleted file mode 100644 index eaf66a4..0000000 --- a/src/app/modules/productCategories/components/form.component.html +++ /dev/null @@ -1,14 +0,0 @@ - -
- - - - - -
diff --git a/src/app/modules/productCategories/components/form.component.ts b/src/app/modules/productCategories/components/form.component.ts deleted file mode 100644 index 520b098..0000000 --- a/src/app/modules/productCategories/components/form.component.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { InputComponent } from '@/shared/components'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, effect, EventEmitter, inject, Input, Output, signal } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { Dialog } from 'primeng/dialog'; -import { IProductCategoryRequest, IProductCategoryResponse } from '../models'; -import { ProductCategoriesService } from '../services/main.service'; - -@Component({ - selector: 'product-category-form', - templateUrl: './form.component.html', - imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent], -}) -export class ProductCategoryFormComponent { - @Input() initialValues?: IProductCategoryResponse; - - @Input() - set visible(v: boolean) { - this.visibleSignal.set(!!v); - } - get visible() { - return this.visibleSignal(); - } - private visibleSignal = signal(false); - - @Output() visibleChange = new EventEmitter(); - @Output() onSubmit = new EventEmitter(); - - private fb = inject(FormBuilder); - constructor( - private service: ProductCategoriesService, - private toastService: ToastService, - ) { - effect(() => { - const v = this.visibleSignal(); - if (!v) this.form.reset(); - }); - } - - form = this.fb.group({ - name: [this.initialValues?.name || null, [Validators.required]], - description: [this.initialValues?.description || null], - imageUrl: [this.initialValues?.imageUrl || null], - }); - - submitLoading = signal(false); - - submit() { - this.form.markAllAsTouched(); - if (this.form.valid) { - this.form.disable(); - this.submitLoading.set(true); - this.service.create(this.form.value as IProductCategoryRequest).subscribe({ - next: (res) => { - this.toastService.success({ - text: `دسته‌بندی ${this.form.value.name} با موفقیت ایجاد شد`, - }); - this.close(); - this.submitLoading.set(false); - this.form.enable(); - this.form.reset(); - this.onSubmit.emit(res); - }, - error: () => { - this.submitLoading.set(false); - this.form.enable(); - }, - }); - } - } - - close() { - this.visibleChange.emit(false); - } -} diff --git a/src/app/modules/productCategories/components/index.ts b/src/app/modules/productCategories/components/index.ts deleted file mode 100644 index 4078bb8..0000000 --- a/src/app/modules/productCategories/components/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './form.component'; -export * from './select/select.component'; diff --git a/src/app/modules/productCategories/components/select/select.component.html b/src/app/modules/productCategories/components/select/select.component.html deleted file mode 100644 index 60f699f..0000000 --- a/src/app/modules/productCategories/components/select/select.component.html +++ /dev/null @@ -1,31 +0,0 @@ -
- - - @if (canInsert) { - -
- -
-
- } -
-
- -
diff --git a/src/app/modules/productCategories/components/select/select.component.ts b/src/app/modules/productCategories/components/select/select.component.ts deleted file mode 100644 index 0b06447..0000000 --- a/src/app/modules/productCategories/components/select/select.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { AbstractSelectComponent } from '@/shared/components'; -import { UikitFieldComponent } from '@/uikit'; -import { Component } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { Button } from 'primeng/button'; -import { Select } from 'primeng/select'; -import { IProductCategoryResponse } from '../../models'; -import { ProductCategoriesService } from '../../services/main.service'; -import { ProductCategoryFormComponent } from '../form.component'; - -@Component({ - selector: 'product-categories-select-field', - templateUrl: './select.component.html', - imports: [ReactiveFormsModule, Select, UikitFieldComponent, Button, ProductCategoryFormComponent], -}) -export class ProductCategoriesSelectComponent extends AbstractSelectComponent< - IProductCategoryResponse, - IPaginatedResponse -> { - constructor(private service: ProductCategoriesService) { - super(); - this.getData(); - } - - getDataService() { - return this.service.getAll(); - } -} diff --git a/src/app/modules/productCategories/constants/apiRoutes/index.ts b/src/app/modules/productCategories/constants/apiRoutes/index.ts deleted file mode 100644 index c24a2d2..0000000 --- a/src/app/modules/productCategories/constants/apiRoutes/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -const baseUrl = '/api/v1/product-categories'; - -export const PRODUCT_CATEGORIES_API_ROUTES = { - list: () => `${baseUrl}`, - single: (categoryId: string) => `${baseUrl}/${categoryId}`, -}; diff --git a/src/app/modules/productCategories/constants/index.ts b/src/app/modules/productCategories/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/productCategories/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/productCategories/constants/routes/index.ts b/src/app/modules/productCategories/constants/routes/index.ts deleted file mode 100644 index 5b3c3c4..0000000 --- a/src/app/modules/productCategories/constants/routes/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { NamedRoutes } from '@/core'; -import { Routes } from '@angular/router'; - -export type TProductCategoriesRouteNames = 'productCategories' | 'productCategory'; - -export const productCategoriesNamedRoutes: NamedRoutes = { - productCategories: { - path: 'product-categories', - loadComponent: () => - import('../../views/list.component').then((m) => m.ProductCategoriesComponent), - meta: { - title: 'دسته‌بندی کالاها', - pagePath: () => '/product-categories', - }, - }, - productCategory: { - path: 'product-categories/:categoryId', - loadComponent: () => - import('../../views/single.component').then((m) => m.ProductCategoryComponent), - meta: { - title: 'دسته‌بندی کالا', - pagePath: () => '/product-categories/:categoryId', - }, - }, -}; - -export const PRODUCT_CATEGORIES_ROUTES: Routes = Object.values(productCategoriesNamedRoutes); diff --git a/src/app/modules/productCategories/models/index.ts b/src/app/modules/productCategories/models/index.ts deleted file mode 100644 index 61a518a..0000000 --- a/src/app/modules/productCategories/models/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './io'; diff --git a/src/app/modules/productCategories/models/io.d.ts b/src/app/modules/productCategories/models/io.d.ts deleted file mode 100644 index 42ff440..0000000 --- a/src/app/modules/productCategories/models/io.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface IProductCategoryRawResponse { - id: number; - name: string; - description: string; - imageUrl: string; - createdAt: Date; -} - -export interface IProductCategoryResponse extends IProductCategoryRawResponse {} - -export interface IProductCategoryRequest { - name: string; - description: string; - imageUrl: string; -} diff --git a/src/app/modules/productCategories/services/main.service.ts b/src/app/modules/productCategories/services/main.service.ts deleted file mode 100644 index e9ede0a..0000000 --- a/src/app/modules/productCategories/services/main.service.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { PRODUCT_CATEGORIES_API_ROUTES } from '../constants'; -import { - IProductCategoryRawResponse, - IProductCategoryRequest, - IProductCategoryResponse, -} from '../models'; - -@Injectable({ providedIn: 'root' }) -export class ProductCategoriesService { - constructor(private http: HttpClient) {} - - private apiRoutes = PRODUCT_CATEGORIES_API_ROUTES; - - getAll(): Observable> { - return this.http.get>(this.apiRoutes.list()); - } - - getSingle(categoryId: string): Observable { - return this.http.get(this.apiRoutes.single(categoryId)); - } - - create(data: IProductCategoryRequest): Observable { - return this.http.post(this.apiRoutes.list(), data); - } -} diff --git a/src/app/modules/productCategories/views/index.ts b/src/app/modules/productCategories/views/index.ts deleted file mode 100644 index bc9dfc9..0000000 --- a/src/app/modules/productCategories/views/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './list.component'; -export * from './single.component'; diff --git a/src/app/modules/productCategories/views/list.component.html b/src/app/modules/productCategories/views/list.component.html deleted file mode 100644 index 6a6c877..0000000 --- a/src/app/modules/productCategories/views/list.component.html +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/src/app/modules/productCategories/views/list.component.ts b/src/app/modules/productCategories/views/list.component.ts deleted file mode 100644 index eab7b96..0000000 --- a/src/app/modules/productCategories/views/list.component.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, signal } from '@angular/core'; -import { ProductCategoryFormComponent } from '../components/form.component'; -import { IProductCategoryResponse } from '../models'; -import { ProductCategoriesService } from '../services/main.service'; - -@Component({ - selector: 'app-product-categories', - templateUrl: './list.component.html', - imports: [PageDataListComponent, ProductCategoryFormComponent], -}) -export class ProductCategoriesComponent { - constructor(private productCategoryService: ProductCategoriesService) { - this.getData(); - } - - columns = [ - { field: 'id', header: 'شناسه' }, - { field: 'name', header: 'نام' }, - { field: 'description', header: 'توضیحات' }, - { field: 'imageUrl', header: 'تصویر' }, - { field: 'createdAt', header: 'تاریخ ایجاد', type: 'date' }, - ] as IColumn[]; - - loading = signal(false); - items = signal([]); - visibleForm = signal(false); - - refresh() { - this.getData(); - } - - getData() { - this.loading.set(true); - this.productCategoryService.getAll().subscribe((res) => { - this.loading.set(false); - this.items.set(res.data); - }); - } - - openAddForm() { - this.visibleForm.set(true); - } -} diff --git a/src/app/modules/productCategories/views/single.component.html b/src/app/modules/productCategories/views/single.component.html deleted file mode 100644 index 7144e26..0000000 --- a/src/app/modules/productCategories/views/single.component.html +++ /dev/null @@ -1 +0,0 @@ -
diff --git a/src/app/modules/productCategories/views/single.component.ts b/src/app/modules/productCategories/views/single.component.ts deleted file mode 100644 index 41d37f8..0000000 --- a/src/app/modules/productCategories/views/single.component.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-product-category', - templateUrl: './single.component.html', -}) -export class ProductCategoryComponent { - constructor() {} -} diff --git a/src/app/modules/productCharges/components/form.component.html b/src/app/modules/productCharges/components/form.component.html deleted file mode 100644 index 0a77ab2..0000000 --- a/src/app/modules/productCharges/components/form.component.html +++ /dev/null @@ -1,26 +0,0 @@ - -
-
- - - - - - - - - - - - - -
- -
- - -
- - - -
diff --git a/src/app/modules/productCharges/components/form.component.ts b/src/app/modules/productCharges/components/form.component.ts deleted file mode 100644 index 81bca94..0000000 --- a/src/app/modules/productCharges/components/form.component.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { InventoriesSelectComponent } from '@/modules/inventories/components/select/select.component'; -import { ProductsSelectComponent } from '@/modules/products/components/select/select.component'; -import { SuppliersSelectComponent } from '@/modules/suppliers/components/select/select.component'; -import { InputComponent } from '@/shared/components'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, effect, inject, model, output } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { DialogModule } from 'primeng/dialog'; -import { Textarea } from 'primeng/textarea'; -import { IProductChargeRequest } from '../models'; -import { ProductChargesService } from '../services/main.service'; - -@Component({ - selector: 'product-charge-form', - standalone: true, - imports: [ - DialogModule, - ReactiveFormsModule, - InputComponent, - FormFooterActionsComponent, - Textarea, - ProductsSelectComponent, - InventoriesSelectComponent, - SuppliersSelectComponent, - ], - templateUrl: './form.component.html', -}) -export class ProductChargeFormComponent { - private fb = inject(FormBuilder); - private productChargeService = inject(ProductChargesService); - - visible = model(false); - onSubmit = output(); - - form = this.fb.group({ - count: [0, [Validators.required, Validators.min(1)]], - unitPrice: [0, [Validators.required, Validators.min(0)]], - totalAmount: [0, [Validators.required, Validators.min(0)]], - isSettled: [false], - buyAt: ['', Validators.required], - description: [''], - productId: [0, [Validators.required, Validators.min(1)]], - inventoryId: [0, [Validators.required, Validators.min(1)]], - supplierId: [0, [Validators.required, Validators.min(1)]], - }); - - constructor() { - effect(() => { - if (!this.visible()) { - this.form.reset(); - } - }); - } - - submit() { - this.form.markAllAsTouched(); - if (this.form.valid) { - this.form.disable(); - const data = this.form.value as IProductChargeRequest; - - this.productChargeService.create(data).subscribe({ - next: () => { - this.form.enable(); - this.visible.set(false); - this.onSubmit.emit(); - }, - error: () => { - this.form.enable(); - }, - }); - } - } - - cancel() { - this.visible.set(false); - } -} diff --git a/src/app/modules/productCharges/constants/apiRoutes/index.ts b/src/app/modules/productCharges/constants/apiRoutes/index.ts deleted file mode 100644 index 04f5c03..0000000 --- a/src/app/modules/productCharges/constants/apiRoutes/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -const BASE_URL = '/api/v1/product-charges'; - -export const PRODUCT_CHARGES_API_ROUTES = { - getAll: BASE_URL, - getSingle: (id: number) => `${BASE_URL}/${id}`, - create: BASE_URL, -}; diff --git a/src/app/modules/productCharges/constants/index.ts b/src/app/modules/productCharges/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/productCharges/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/productCharges/constants/routes/index.ts b/src/app/modules/productCharges/constants/routes/index.ts deleted file mode 100644 index 0d9fa1f..0000000 --- a/src/app/modules/productCharges/constants/routes/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Routes } from '@angular/router'; - -export type TProductChargesRouteNames = 'product-charges' | 'product-charge'; - -export const PRODUCT_CHARGES_ROUTES: Routes = [ - { - path: '', - loadComponent: () => - import('../../views/list.component').then((m) => m.ProductChargesComponent), - }, - { - path: ':productChargeId', - loadComponent: () => - import('../../views/single.component').then((m) => m.ProductChargeComponent), - }, -]; diff --git a/src/app/modules/productCharges/models/index.ts b/src/app/modules/productCharges/models/index.ts deleted file mode 100644 index 61a518a..0000000 --- a/src/app/modules/productCharges/models/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './io'; diff --git a/src/app/modules/productCharges/models/io.d.ts b/src/app/modules/productCharges/models/io.d.ts deleted file mode 100644 index 73b21c3..0000000 --- a/src/app/modules/productCharges/models/io.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -export interface IProductChargeRaw { - id: number; - name: string; - count: number; - unitPrice: number; - totalAmount: number; - isSettled?: boolean; - buyAt: string; - description?: string; - productId: number; - inventoryId: number; - supplierId: number; - createdAt: string; - updatedAt: string; - deletedAt?: string; -} - -export interface IProductChargeResponse extends IProductChargeRaw {} - -export interface IProductChargeRequest { - name: string; - count: number; - unitPrice: number; - totalAmount: number; - isSettled?: boolean; - buyAt: string; - description?: string; - productId: number; - inventoryId: number; - supplierId: number; -} diff --git a/src/app/modules/productCharges/services/main.service.ts b/src/app/modules/productCharges/services/main.service.ts deleted file mode 100644 index a02247a..0000000 --- a/src/app/modules/productCharges/services/main.service.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { HttpClient } from '@angular/common/http'; -import { inject, Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { PRODUCT_CHARGES_API_ROUTES } from '../constants'; -import { IProductChargeRequest, IProductChargeResponse } from '../models'; - -@Injectable({ - providedIn: 'root', -}) -export class ProductChargesService { - private http = inject(HttpClient); - - getAll(): Observable<{ data: IProductChargeResponse[] }> { - return this.http.get<{ data: IProductChargeResponse[] }>(PRODUCT_CHARGES_API_ROUTES.getAll); - } - - getSingle(id: number): Observable<{ data: IProductChargeResponse }> { - return this.http.get<{ data: IProductChargeResponse }>( - PRODUCT_CHARGES_API_ROUTES.getSingle(id), - ); - } - - create(data: IProductChargeRequest): Observable<{ data: IProductChargeResponse }> { - return this.http.post<{ data: IProductChargeResponse }>( - PRODUCT_CHARGES_API_ROUTES.create, - data, - ); - } -} diff --git a/src/app/modules/productCharges/views/list.component.html b/src/app/modules/productCharges/views/list.component.html deleted file mode 100644 index 8378a9e..0000000 --- a/src/app/modules/productCharges/views/list.component.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/app/modules/productCharges/views/list.component.ts b/src/app/modules/productCharges/views/list.component.ts deleted file mode 100644 index a5485b7..0000000 --- a/src/app/modules/productCharges/views/list.component.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, effect, inject, signal } from '@angular/core'; -import { ProductChargeFormComponent } from '../components/form.component'; -import { IProductChargeResponse } from '../models'; -import { ProductChargesService } from '../services/main.service'; - -@Component({ - selector: 'app-product-charges', - standalone: true, - imports: [PageDataListComponent, ProductChargeFormComponent], - templateUrl: './list.component.html', -}) -export class ProductChargesComponent { - private productChargeService = inject(ProductChargesService); - - loading = signal(false); - items = signal([]); - visibleForm = signal(false); - - columns: IColumn[] = [ - { field: 'id', header: 'شناسه' }, - { field: 'name', header: 'نام' }, - { field: 'count', header: 'تعداد' }, - { field: 'unitPrice', header: 'هزینه' }, - { field: 'totalAmount', header: 'مبلغ کل' }, - { field: 'isSettled', header: 'تسویه شده' }, - { field: 'buyAt', header: 'تاریخ خرید' }, - { field: 'productId', header: 'شناسه کالا' }, - { field: 'inventoryId', header: 'شناسه انبار' }, - { field: 'supplierId', header: 'شناسه تامین‌کننده' }, - { field: 'createdAt', header: 'تاریخ ایجاد' }, - { field: 'updatedAt', header: 'تاریخ بروزرسانی' }, - ]; - - constructor() { - effect(() => { - this.getData(); - }); - } - - refresh() { - this.getData(); - } - - openAddForm() { - this.visibleForm.set(true); - } - - getData() { - this.loading.set(true); - this.productChargeService.getAll().subscribe((res) => { - this.loading.set(false); - this.items.set(res.data); - }); - } -} diff --git a/src/app/modules/productCharges/views/single.component.html b/src/app/modules/productCharges/views/single.component.html deleted file mode 100644 index 5b75608..0000000 --- a/src/app/modules/productCharges/views/single.component.html +++ /dev/null @@ -1 +0,0 @@ -

product-charge works!

diff --git a/src/app/modules/productCharges/views/single.component.ts b/src/app/modules/productCharges/views/single.component.ts deleted file mode 100644 index 4bd5afe..0000000 --- a/src/app/modules/productCharges/views/single.component.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-product-charge', - standalone: true, - imports: [], - templateUrl: './single.component.html', -}) -export class ProductChargeComponent {} diff --git a/src/app/modules/products/components/form.component.html b/src/app/modules/products/components/form.component.html deleted file mode 100644 index cb2cae9..0000000 --- a/src/app/modules/products/components/form.component.html +++ /dev/null @@ -1,13 +0,0 @@ - -
- - - - - - - - -
diff --git a/src/app/modules/products/components/form.component.ts b/src/app/modules/products/components/form.component.ts deleted file mode 100644 index 38ffb8a..0000000 --- a/src/app/modules/products/components/form.component.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { ProductBrandsSelectComponent } from '@/modules/productBrands/components'; -import { ProductCategoriesSelectComponent } from '@/modules/productCategories/components'; -import { InputComponent } from '@/shared/components'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, effect, EventEmitter, inject, Input, Output, signal } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { Dialog } from 'primeng/dialog'; -import { IProductRequest, IProductResponse } from '../models'; -import { ProductsService } from '../services/main.service'; - -@Component({ - selector: 'product-form', - templateUrl: './form.component.html', - imports: [ - ReactiveFormsModule, - Dialog, - InputComponent, - FormFooterActionsComponent, - ProductBrandsSelectComponent, - ProductCategoriesSelectComponent, - ], -}) -export class ProductFormComponent { - @Input() initialValues?: IProductResponse; - - @Input() - set visible(v: boolean) { - this.visibleSignal.set(!!v); - } - get visible() { - return this.visibleSignal(); - } - private visibleSignal = signal(false); - - @Output() visibleChange = new EventEmitter(); - @Output() onSubmit = new EventEmitter(); - - private fb = inject(FormBuilder); - constructor(private service: ProductsService) { - effect(() => { - const v = this.visibleSignal(); - if (!v) this.form.reset(); - }); - } - - form = this.fb.group({ - name: [this.initialValues?.name || null, [Validators.required]], - description: [this.initialValues?.description || null], - // productType: [this.initialValues?.productType || null, [Validators.required]], - brandId: [this.initialValues?.brand?.id || null, [Validators.required]], - categoryId: [this.initialValues?.category?.id || null], - }); - - submitLoading = signal(false); - - submit() { - this.form.markAllAsTouched(); - if (this.form.valid) { - this.form.disable(); - this.submitLoading.set(true); - this.service.create(this.form.value as IProductRequest).subscribe({ - next: (res) => { - this.submitLoading.set(false); - this.form.enable(); - this.form.reset(); - this.onSubmit.emit(res); - }, - error: () => { - this.submitLoading.set(false); - this.form.enable(); - }, - }); - } - } - - close() { - this.visibleChange.emit(false); - } -} diff --git a/src/app/modules/products/components/fullForm/full-form.component.html b/src/app/modules/products/components/fullForm/full-form.component.html deleted file mode 100644 index 3f6cdf7..0000000 --- a/src/app/modules/products/components/fullForm/full-form.component.html +++ /dev/null @@ -1,60 +0,0 @@ -
-
-
- -

{{ initialData ? "ویرایش کالا" : "ایجاد کالا جدید" }}

-
-
- - -
-
-
-
- -
- - - - - - - - -
-
-
-
- -
- - -
- -
- - - -
-
-
-
-
diff --git a/src/app/modules/products/components/fullForm/full-form.component.ts b/src/app/modules/products/components/fullForm/full-form.component.ts deleted file mode 100644 index 9317092..0000000 --- a/src/app/modules/products/components/fullForm/full-form.component.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { ProductBrandsSelectComponent } from '@/modules/productBrands/components'; -import { ProductCategoriesSelectComponent } from '@/modules/productCategories/components'; -import { InputComponent } from '@/shared/components'; -import { BarcodeInputComponent } from '@/shared/components/barcodeInput/barcode-input.component'; -import { UikitFieldComponent } from '@/uikit'; -import { Component, effect, EventEmitter, inject, Input, Output } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { RouterLink } from '@angular/router'; -import { Button, ButtonDirective } from 'primeng/button'; -import { Card } from 'primeng/card'; -import { TextareaModule } from 'primeng/textarea'; -import { IProductRequest, IProductResponse } from '../../models'; - -@Component({ - selector: 'product-full-form', - templateUrl: './full-form.component.html', - imports: [ - Button, - RouterLink, - ButtonDirective, - Card, - ReactiveFormsModule, - InputComponent, - UikitFieldComponent, - TextareaModule, - BarcodeInputComponent, - ProductBrandsSelectComponent, - ProductCategoriesSelectComponent, - ], -}) -export class ProductFullFormComponent { - @Input() initialData?: IProductResponse; - @Input() loading: boolean = false; - @Output() onSubmit = new EventEmitter(); - - private fb = inject(FormBuilder); - constructor() { - effect(() => { - if (this.initialData) { - this.form.patchValue({ - ...this.initialData, - brandId: this.initialData.brand?.id || null, - categoryId: this.initialData.category?.id || null, - }); - } else { - this.form.reset(); - } - }); - } - - form = this.fb.group({ - name: [this.initialData?.name || '', [Validators.required]], - brandId: [this.initialData?.brand?.id || null, [Validators.required]], - sku: [this.initialData?.sku || null], - barcode: [this.initialData?.barcode || null], - description: [this.initialData?.description || null], - categoryId: [this.initialData?.category?.id || null], - minimumStockAlertLevel: [ - this.initialData?.minimumStockAlertLevel || 1, - [Validators.required, Validators.min(0)], - ], - imageUrl: [null], - salePrice: [this.initialData?.salePrice || 0, [Validators.required, Validators.min(0)]], - }); - - get backRoute() { - return this.initialData ? ['/products', this.initialData.id] : ['/products']; - } - - submit() { - this.form.markAsTouched(); - if (this.form.valid) { - this.onSubmit.emit(this.form.value as IProductRequest); - } - } -} diff --git a/src/app/modules/products/components/select/select.component.html b/src/app/modules/products/components/select/select.component.html deleted file mode 100644 index a08301c..0000000 --- a/src/app/modules/products/components/select/select.component.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/src/app/modules/products/components/select/select.component.ts b/src/app/modules/products/components/select/select.component.ts deleted file mode 100644 index ac40f04..0000000 --- a/src/app/modules/products/components/select/select.component.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { AbstractSelectComponent } from '@/shared/components'; -import { UikitFieldComponent } from '@/uikit'; -import { CommonModule } from '@angular/common'; -import { Component } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { Select } from 'primeng/select'; -import { IProductResponse } from '../../models'; -import { ProductsService } from '../../services/main.service'; - -@Component({ - selector: 'products-select-field', - templateUrl: './select.component.html', - imports: [ReactiveFormsModule, Select, UikitFieldComponent, CommonModule], -}) -export class ProductsSelectComponent extends AbstractSelectComponent< - IProductResponse, - IPaginatedResponse -> { - constructor(private service: ProductsService) { - super(); - this.getData(); - } - - getDataService() { - return this.service.getAll(); - } -} diff --git a/src/app/modules/products/constants/apiRoutes/index.ts b/src/app/modules/products/constants/apiRoutes/index.ts deleted file mode 100644 index a68ef6a..0000000 --- a/src/app/modules/products/constants/apiRoutes/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -const baseUrl = '/api/v1/products'; - -export const PRODUCTS_API_ROUTES = { - list: () => `${baseUrl}`, - single: (productId: string) => `${baseUrl}/${productId}`, -}; diff --git a/src/app/modules/products/constants/index.ts b/src/app/modules/products/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/products/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/products/constants/routes/index.ts b/src/app/modules/products/constants/routes/index.ts deleted file mode 100644 index f47d99d..0000000 --- a/src/app/modules/products/constants/routes/index.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { NamedRoutes } from '@/core'; -import { Routes } from '@angular/router'; - -export type TProductsRouteNames = 'products' | 'product' | 'create' | 'update' | 'purchase'; - -export const productsNamedRoutes: NamedRoutes = { - products: { - path: 'products', - loadComponent: () => import('../../views/list.component').then((m) => m.ProductsComponent), - meta: { - title: 'کالاها', - pagePath: () => '/products', - }, - }, - create: { - path: 'products/create', - loadComponent: () => - import('../../views/create.component').then((m) => m.CreateProductComponent), - meta: { - title: 'ایجاد کالا جدید', - pagePath: () => '/products/create', - }, - }, - product: { - path: 'products/:productId', - loadComponent: () => import('../../views/single.component').then((m) => m.ProductComponent), - meta: { - title: 'کالا', - pagePath: () => '/products/:productId', - }, - }, - update: { - path: 'products/:productId/update', - loadComponent: () => - import('../../views/update.component').then((m) => m.UpdateProductComponent), - meta: { - title: 'کالا', - pagePath: () => '/products/:productId/update', - }, - }, - purchase: { - path: 'products/:productId/purchase', - loadComponent: () => - import('../../views/purchase.component').then((m) => m.ProductPurchaseComponent), - meta: { - title: 'کالا', - pagePath: () => '/products/:productId/purchase', - }, - }, -}; - -export const PRODUCTS_ROUTES: Routes = Object.values(productsNamedRoutes); diff --git a/src/app/modules/products/models/index.ts b/src/app/modules/products/models/index.ts deleted file mode 100644 index 61a518a..0000000 --- a/src/app/modules/products/models/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './io'; diff --git a/src/app/modules/products/models/io.d.ts b/src/app/modules/products/models/io.d.ts deleted file mode 100644 index 9b6ef5c..0000000 --- a/src/app/modules/products/models/io.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Maybe } from '@/core'; -import { IPaginatedQuery } from '@/core/models/service.model'; -import ISummary from '@/core/models/summary'; -import { IProductStockBalanceSummary } from './types'; - -export interface IGetProductsQueryParams extends IPaginatedQuery {} - -export interface IProductRawResponse { - id: number; - name: string; - description?: string; - barcode?: Maybe; - sku: string; - brand?: ISummary; - category?: ISummary; - salePrice?: string; - createdAt: Date; - updatedAt: Date; - deletedAt?: Maybe; - stock: number; - avgCost?: number; - stockBalances: IProductStockBalanceSummary[]; - salesCount: number; - minimumStockAlertLevel: number; -} - -export interface IProductResponse extends IProductRawResponse {} - -export interface IProductRequest { - name: string; - // productType: string; - brandId: number; - description: Maybe; - barcode: Maybe; - sku: Maybe; - categoryId: Maybe; - // supplierId: number; -} diff --git a/src/app/modules/products/models/types.ts b/src/app/modules/products/models/types.ts deleted file mode 100644 index a3d1745..0000000 --- a/src/app/modules/products/models/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -import ISummary from '@/core/models/summary'; - -export interface IProductCategory { - id: number; - name: string; -} -export interface IProductBrand { - id: number; - name: string; -} - -export interface IProductStockBalanceSummary { - avgCost?: number; - quantity: number; - inventory: ISummary; -} diff --git a/src/app/modules/products/services/main.service.ts b/src/app/modules/products/services/main.service.ts deleted file mode 100644 index 0458d73..0000000 --- a/src/app/modules/products/services/main.service.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { PRODUCTS_API_ROUTES } from '../constants'; -import { - IGetProductsQueryParams, - IProductRawResponse, - IProductRequest, - IProductResponse, -} from '../models'; - -@Injectable({ providedIn: 'root' }) -export class ProductsService { - constructor(private http: HttpClient) {} - - private apiRoutes = PRODUCTS_API_ROUTES; - - getAll(params?: IGetProductsQueryParams): Observable> { - return this.http.get>(this.apiRoutes.list(), { - params: { ...params }, - }); - } - - getSingle(productId: string): Observable { - return this.http.get(this.apiRoutes.single(productId)); - } - - create(data: IProductRequest): Observable { - return this.http.post(this.apiRoutes.list(), data); - } - update(productId: string, data: Partial): Observable { - return this.http.patch(this.apiRoutes.single(productId), data); - } -} diff --git a/src/app/modules/products/store/main.ts b/src/app/modules/products/store/main.ts deleted file mode 100644 index 57a27b3..0000000 --- a/src/app/modules/products/store/main.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { PaginatedState, PaginatedStore } from '@/core/state'; -import { Injectable } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { IProductResponse } from '../models'; -import { ProductsService } from '../services/main.service'; - -export interface ProductsState extends PaginatedState {} - -@Injectable({ - providedIn: 'root', -}) -export class ProductsStore extends PaginatedStore { - // Login-specific state - private readonly _productsState = { - isRefreshing: false, - }; - - constructor( - private activeRoute: ActivatedRoute, - private service: ProductsService, - ) { - const queryParams = activeRoute.snapshot.queryParams; - - super({ - initialized: false, - loading: false, - error: null, - isRefreshing: false, - items: [], - totalCount: 0, - currentPage: Number(queryParams['page']) || 1, - pageSize: Number(queryParams['pageSize']) || 30, - totalPages: 0, - hasMore: false, - }); - this.initial(); - } - - /** - * Reset state to initial values - */ - reset(): void { - this.setState({ - initialized: false, - loading: false, - error: null, - isRefreshing: false, - items: [], - totalCount: 0, - currentPage: Number(this.activeRoute.snapshot.queryParams['page']) || 1, - pageSize: Number(this.activeRoute.snapshot.queryParams['pageSize']) || 30, - totalPages: 0, - hasMore: false, - }); - } - - initial() { - this.getAll(); - } - - getAll() { - this.setLoading(true); - this.service.getAll({ page: this.currentPage(), pageSize: this.pageSize() }).subscribe({ - next: (res) => { - this.setItems(res.data, res.meta); - }, - error: (err) => { - this.setError(err); - }, - }); - } - - onPageChange(page: number) { - this.setCurrentPage(page); - this.getAll(); - } -} diff --git a/src/app/modules/products/views/create.component.html b/src/app/modules/products/views/create.component.html deleted file mode 100644 index 184b3bb..0000000 --- a/src/app/modules/products/views/create.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/modules/products/views/create.component.ts b/src/app/modules/products/views/create.component.ts deleted file mode 100644 index ce1249f..0000000 --- a/src/app/modules/products/views/create.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { Component, signal } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { Router } from '@angular/router'; -import { TextareaModule } from 'primeng/textarea'; -import { ProductFullFormComponent } from '../components/fullForm/full-form.component'; -import { IProductRequest } from '../models'; -import { ProductsService } from '../services/main.service'; - -@Component({ - selector: 'app-product-create', - templateUrl: './create.component.html', - imports: [TextareaModule, ReactiveFormsModule, ProductFullFormComponent], -}) -export class CreateProductComponent { - constructor( - private service: ProductsService, - private toastService: ToastService, - private router: Router, - ) {} - - submitLoading = signal(false); - - submit(payload: IProductRequest) { - this.submitLoading.set(true); - this.service.create(payload).subscribe({ - next: (res) => { - this.toastService.success({ text: `کالا ${payload.name} با موفقیت ایجاد شد` }); - this.router.navigate(['products', res.id]); - this.submitLoading.set(false); - }, - error: (err) => { - this.submitLoading.set(false); - }, - }); - } -} diff --git a/src/app/modules/products/views/index.ts b/src/app/modules/products/views/index.ts deleted file mode 100644 index fc1be4a..0000000 --- a/src/app/modules/products/views/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './create.component'; -export * from './list.component'; -export * from './purchase.component'; -export * from './single.component'; -export * from './update.component'; diff --git a/src/app/modules/products/views/list.component.html b/src/app/modules/products/views/list.component.html deleted file mode 100644 index 12933ad..0000000 --- a/src/app/modules/products/views/list.component.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - diff --git a/src/app/modules/products/views/list.component.ts b/src/app/modules/products/views/list.component.ts deleted file mode 100644 index 2bc717f..0000000 --- a/src/app/modules/products/views/list.component.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { SimpleStockTextAlertComponent } from '@/shared/components/simpleStockTextAlert/simple-stock-text-alert.component'; -import { AfterViewInit, Component, signal, TemplateRef, ViewChild } from '@angular/core'; -import { Router } from '@angular/router'; -import { ProductFormComponent } from '../components/form.component'; -import { productsNamedRoutes } from '../constants'; -import { IProductResponse } from '../models'; -import { ProductsService } from '../services/main.service'; -import { ProductsStore } from '../store/main'; - -@Component({ - selector: 'app-products', - templateUrl: './list.component.html', - imports: [PageDataListComponent, ProductFormComponent, SimpleStockTextAlertComponent], -}) -export class ProductsComponent implements AfterViewInit { - @ViewChild('stockTpl', { static: true }) stockTpl!: TemplateRef; - - columns = signal([]); - - constructor( - private productService: ProductsService, - private router: Router, - private store: ProductsStore, - ) { - store.initial(); - } - - ngAfterViewInit() { - this.columns.set([ - { field: 'sku', header: 'شناسه' }, - { field: 'name', header: 'نام' }, - { - field: 'brand', - header: 'برند', - customDataModel(item) { - return item.brand?.name || '-'; - }, - }, - { - field: 'category', - header: 'دسته‌بندی', - customDataModel(item) { - return item.category?.name || '-'; - }, - }, - { - field: 'salePrice', - header: 'قیمت پایه فروش', - type: 'price', - }, - { - field: 'stockss', - header: 'موجودی کلی', - customDataModel: this.stockTpl, - }, - { field: 'createdAt', header: 'تاریخ ایجاد', type: 'date' }, - { field: 'updatedAt', header: 'تاریخ به‌روزرسانی', type: 'date' }, - ]); - } - - get loading() { - return this.store.loading; - } - get items() { - return this.store.items; - } - get paginatedMeta() { - return this.store.paginatedMeta; - } - - visibleForm = signal(false); - - refresh() { - this.store.initial(); - } - - openAddForm() { - const pagePathFn = productsNamedRoutes.create.meta.pagePath; - if (pagePathFn) { - this.router.navigateByUrl(pagePathFn({})); - } - } - - toDetails(product: IProductResponse) { - this.router.navigate(['/products', product.id]); - } - - onPageChange(page: number) { - this.store.onPageChange(page); - } -} diff --git a/src/app/modules/products/views/purchase.component.html b/src/app/modules/products/views/purchase.component.html deleted file mode 100644 index dc7c765..0000000 --- a/src/app/modules/products/views/purchase.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/modules/products/views/purchase.component.ts b/src/app/modules/products/views/purchase.component.ts deleted file mode 100644 index 9f21deb..0000000 --- a/src/app/modules/products/views/purchase.component.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { PurchaseReceiptTemplateComponent } from '@/modules/purchases/components/receiptTemplate/purchase-receipt-template.component'; -import { Component } from '@angular/core'; - -@Component({ - selector: 'product-purchase', - templateUrl: './purchase.component.html', - imports: [PurchaseReceiptTemplateComponent], -}) -export class ProductPurchaseComponent { - constructor() {} -} diff --git a/src/app/modules/products/views/single.component.html b/src/app/modules/products/views/single.component.html deleted file mode 100644 index cf870f4..0000000 --- a/src/app/modules/products/views/single.component.html +++ /dev/null @@ -1,80 +0,0 @@ -
- @if (loading()) { - - } @else if (product()) { - - - - - - - -
-
- -
-
- -
-
-
-
-
- - - - @for (item of topBarCardDetails; track $index) { - - } -
- - -
-
- توضیحات -

{{ product()?.description || "بدون توضیحات" }}

-
-
- -
- دسته‌بندی -

{{ product()?.category?.name || "بدون دسته‌بندی" }}

-
-
-
- برند -

{{ product()?.brand?.name || "بدون برند" }}

-
-
-
-
-
-
- - - - - - - - -
- - } -
diff --git a/src/app/modules/products/views/single.component.ts b/src/app/modules/products/views/single.component.ts deleted file mode 100644 index 2cf667d..0000000 --- a/src/app/modules/products/views/single.component.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { Maybe } from '@/core'; -import { PurchaseFormComponent } from '@/modules/purchases/components/form.component'; -import { KeyValueComponent } from '@/shared/components'; -import { DetailsInfoCardComponent } from '@/shared/components/detailsInfoCard/details-info-card.component'; -import { InnerPagesHeaderComponent } from '@/shared/components/innerPagesHeader/inner-pages-header.component'; -import { SimpleStockTextAlertComponent } from '@/shared/components/simpleStockTextAlert/simple-stock-text-alert.component'; -import priceMaskUtils from '@/utils/price-mask.utils'; -import { Component, inject, signal } from '@angular/core'; -import { ActivatedRoute, RouterLink } from '@angular/router'; -import { ButtonDirective } from 'primeng/button'; -import { Card } from 'primeng/card'; -import { GalleriaModule } from 'primeng/galleria'; -import { ProgressSpinner } from 'primeng/progressspinner'; -import { IProductResponse } from '../models'; -import { ProductsService } from '../services/main.service'; - -@Component({ - selector: 'app-product', - templateUrl: './single.component.html', - imports: [ - ButtonDirective, - RouterLink, - GalleriaModule, - KeyValueComponent, - Card, - PurchaseFormComponent, - DetailsInfoCardComponent, - ProgressSpinner, - SimpleStockTextAlertComponent, - InnerPagesHeaderComponent, - ], -}) -export class ProductComponent { - private route = inject(ActivatedRoute); - constructor(private service: ProductsService) { - this.getData(); - } - - images = signal([ - { - itemImageSrc: 'https://primefaces.org/cdn/primeng/images/galleria/galleria1.jpg', - alt: 'Description for Image 1', - title: 'Title 1', - }, - { - itemImageSrc: 'https://primefaces.org/cdn/primeng/images/galleria/galleria2.jpg', - alt: 'Description for Image 2', - title: 'Title 2', - }, - { - itemImageSrc: 'https://primefaces.org/cdn/primeng/images/galleria/galleria3.jpg', - alt: 'Description for Image 3', - title: 'Title 3', - }, - { - itemImageSrc: 'https://primefaces.org/cdn/primeng/images/galleria/galleria4.jpg', - alt: 'Description for Image 4', - title: 'Title 4', - }, - { - itemImageSrc: 'https://primefaces.org/cdn/primeng/images/galleria/galleria5.jpg', - alt: 'Description for Image 5', - title: 'Title 5', - }, - ]); - - productId = this.route.snapshot.params['productId']; - isOpenChargeForm = signal(false); - loading = signal(false); - product = signal>(null); - - getData() { - this.loading.set(true); - this.service.getSingle(this.productId).subscribe({ - next: (res) => { - this.product.set(res); - this.loading.set(false); - }, - error: () => { - this.loading.set(false); - }, - }); - } - - get topBarCardDetails() { - return [ - { - icon: 'pi pi-dollar', - label: 'قیمت پایه', - value: this.product()?.salePrice - ? priceMaskUtils.formatWithCurrency(this.product()!.salePrice!) - : 'تعیین نشده', - }, - { - icon: 'pi pi-dollar', - label: 'میانگین قیمت خرید', - value: this.product()?.salePrice - ? priceMaskUtils.formatWithCurrency(this.product()!.avgCost!) - : 'تعیین نشده', - type: 'price', - }, - { - icon: 'pi pi-clock', - label: 'تعداد فروش', - value: this.product()?.salesCount || 0, - }, - ]; - } - - openDeleteConfirm() {} - openChargeForm() { - this.isOpenChargeForm.set(true); - } -} diff --git a/src/app/modules/products/views/update.component.html b/src/app/modules/products/views/update.component.html deleted file mode 100644 index 13db74e..0000000 --- a/src/app/modules/products/views/update.component.html +++ /dev/null @@ -1,9 +0,0 @@ -@if (loading()) { - -} @else { - -} diff --git a/src/app/modules/products/views/update.component.ts b/src/app/modules/products/views/update.component.ts deleted file mode 100644 index f697888..0000000 --- a/src/app/modules/products/views/update.component.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Maybe } from '@/core'; -import { ToastService } from '@/core/services/toast.service'; -import { Component, inject, signal } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { ProgressSpinner } from 'primeng/progressspinner'; -import { ProductFullFormComponent } from '../components/fullForm/full-form.component'; -import { IProductRequest, IProductResponse } from '../models'; -import { ProductsService } from '../services/main.service'; - -@Component({ - selector: 'app-product-update', - templateUrl: './update.component.html', - imports: [ProductFullFormComponent, ProgressSpinner], -}) -export class UpdateProductComponent { - private route = inject(ActivatedRoute); - constructor( - private service: ProductsService, - private toastService: ToastService, - private router: Router, - ) { - this.getData(); - } - - submitLoading = signal(false); - - productId = this.route.snapshot.params['productId']; - loading = signal(false); - product = signal>(null); - - getData() { - this.loading.set(true); - this.service.getSingle(this.productId).subscribe({ - next: (res) => { - this.product.set(res); - this.loading.set(false); - }, - error: () => { - this.loading.set(false); - }, - }); - } - - submit(payload: IProductRequest) { - this.submitLoading.set(true); - this.service.update(this.productId, payload).subscribe({ - next: (res) => { - this.toastService.success({ text: `کالا ${payload.name} با موفقیت ویرایش شد` }); - this.router.navigate(['products', this.productId]); - this.submitLoading.set(false); - }, - error: (err) => { - this.submitLoading.set(false); - }, - }); - } -} diff --git a/src/app/modules/purchaseReceipts/constants/apiRoutes/index.ts b/src/app/modules/purchaseReceipts/constants/apiRoutes/index.ts deleted file mode 100644 index 35f43f0..0000000 --- a/src/app/modules/purchaseReceipts/constants/apiRoutes/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -const baseUrl = '/api/v1/purchase-receipt-payments'; - -export const PURCHASE_RECEIPT_PAYMENTS_API_ROUTES = { - list: () => `${baseUrl}`, -}; diff --git a/src/app/modules/purchaseReceipts/constants/index.ts b/src/app/modules/purchaseReceipts/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/purchaseReceipts/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/purchaseReceipts/constants/routes/index.ts b/src/app/modules/purchaseReceipts/constants/routes/index.ts deleted file mode 100644 index 80ad55d..0000000 --- a/src/app/modules/purchaseReceipts/constants/routes/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { NamedRoutes } from '@/core'; -import { Routes } from '@angular/router'; - -export const purchaseReceiptsNamedRoutes: NamedRoutes = {} as const; - -export type TPurchaseReceiptsRouteNames = - (typeof purchaseReceiptsNamedRoutes)[keyof typeof purchaseReceiptsNamedRoutes]; - -export const PURCHASE_RECEIPTS_ROUTES: Routes = Object.values(purchaseReceiptsNamedRoutes); diff --git a/src/app/modules/purchases/components/form.component.html b/src/app/modules/purchases/components/form.component.html deleted file mode 100644 index c5bc0fe..0000000 --- a/src/app/modules/purchases/components/form.component.html +++ /dev/null @@ -1,25 +0,0 @@ - -
-
- -
-
- - - - - - - - -
- -
- - -
- - -
-
-
diff --git a/src/app/modules/purchases/components/form.component.ts b/src/app/modules/purchases/components/form.component.ts deleted file mode 100644 index a7ea84c..0000000 --- a/src/app/modules/purchases/components/form.component.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { InventoriesSelectComponent } from '@/modules/inventories/components/select/select.component'; -import { IInventorySummaryResponse } from '@/modules/inventories/models'; -import { IProductResponse } from '@/modules/products/models'; -import { SuppliersSelectComponent } from '@/modules/suppliers/components/select/select.component'; -import { ISupplierResponse } from '@/modules/suppliers/models'; -import { InputComponent } from '@/shared/components'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, effect, inject, Input, model, output } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { DialogModule } from 'primeng/dialog'; -import { Textarea } from 'primeng/textarea'; -import { IPurchaseRequest } from '../models'; -import { PurchasesService } from '../services/main.service'; -import { ProductChargeRowFormComponent } from './product-charge-row-form.component'; - -@Component({ - selector: 'purchase-form', - standalone: true, - imports: [ - DialogModule, - ReactiveFormsModule, - InputComponent, - FormFooterActionsComponent, - Textarea, - InventoriesSelectComponent, - SuppliersSelectComponent, - ProductChargeRowFormComponent, - ], - templateUrl: './form.component.html', -}) -export class PurchaseFormComponent { - @Input() product?: IProductResponse; - @Input() inventory?: IInventorySummaryResponse; - @Input() supplier?: ISupplierResponse; - - private fb = inject(FormBuilder); - private service = inject(PurchasesService); - - visible = model(false); - onSubmit = output(); - - form = this.fb.group({ - totalAmount: [0, [Validators.required, Validators.min(0)]], - isSettled: [false], - buyAt: ['', Validators.required], - description: [''], - products: this.fb.array([ - this.fb.group({ - productId: [this.product?.id || 0, [Validators.required]], - count: [0, [Validators.required, Validators.min(1)]], - unitPrice: [0, [Validators.required, Validators.min(0)]], - }), - ]), - inventoryId: [this.inventory?.id || 0, [Validators.required]], - supplierId: [this.supplier?.id || 0, [Validators.required]], - }); - - get formTitle() { - if (this.product) { - return `شارژ کالا ${this.product.name}`; - } - if (this.inventory) { - return `شارژ انبار ${this.inventory.name}`; - } - if (this.supplier) { - return `شارژ تامین‌کننده ${this.supplier.fullname}`; - } - return 'شارژ کالا'; - } - - constructor() { - effect(() => { - if (!this.visible()) { - this.form.reset(); - } - }); - } - - submit() { - this.form.markAllAsTouched(); - if (this.form.valid) { - this.form.disable(); - const data = this.form.value as IPurchaseRequest; - - this.service.create(data).subscribe({ - next: () => { - this.form.enable(); - this.visible.set(false); - this.onSubmit.emit(); - }, - error: () => { - this.form.enable(); - }, - }); - } - } - - cancel() { - this.visible.set(false); - } -} diff --git a/src/app/modules/purchases/components/index.ts b/src/app/modules/purchases/components/index.ts deleted file mode 100644 index 954eecf..0000000 --- a/src/app/modules/purchases/components/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './receiptTemplate'; diff --git a/src/app/modules/purchases/components/product-charge-row-form-fields.component.html b/src/app/modules/purchases/components/product-charge-row-form-fields.component.html deleted file mode 100644 index 79108f5..0000000 --- a/src/app/modules/purchases/components/product-charge-row-form-fields.component.html +++ /dev/null @@ -1,7 +0,0 @@ -
- -
- - -
-
diff --git a/src/app/modules/purchases/components/product-charge-row-form-fields.component.ts b/src/app/modules/purchases/components/product-charge-row-form-fields.component.ts deleted file mode 100644 index 1af916b..0000000 --- a/src/app/modules/purchases/components/product-charge-row-form-fields.component.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Maybe } from '@/core'; -import { ProductsSelectComponent } from '@/modules/products/components/select/select.component'; -import { InputComponent } from '@/shared/components'; -import { Component, Input } from '@angular/core'; -import { FormControl } from '@angular/forms'; - -@Component({ - selector: 'product-charge-row-form-fields', - templateUrl: './product-charge-row-form-fields.component.html', - imports: [ProductsSelectComponent, InputComponent], -}) -export class ProductChargeRowFormFieldsComponent { - @Input() productIdControl!: FormControl>; - @Input() countControl!: FormControl>; - @Input() feeControl!: FormControl>; - constructor() {} -} diff --git a/src/app/modules/purchases/components/product-charge-row-form.component.html b/src/app/modules/purchases/components/product-charge-row-form.component.html deleted file mode 100644 index 2a0f9d0..0000000 --- a/src/app/modules/purchases/components/product-charge-row-form.component.html +++ /dev/null @@ -1,32 +0,0 @@ -
-
- @for (product of products; let i = $index; track product.controls["productId"].value) { -
-
- -
- - @if (canAddOrRemoveProducts) { - - } -
- } -
- @if (canAddOrRemoveProducts) { - - } -
diff --git a/src/app/modules/purchases/components/product-charge-row-form.component.ts b/src/app/modules/purchases/components/product-charge-row-form.component.ts deleted file mode 100644 index f92381c..0000000 --- a/src/app/modules/purchases/components/product-charge-row-form.component.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Maybe } from '@/core'; -import { CommonModule } from '@angular/common'; -import { Component, Input, OnInit, inject } from '@angular/core'; -import { - FormArray, - FormBuilder, - FormControl, - FormGroup, - ReactiveFormsModule, - Validators, -} from '@angular/forms'; -import { ButtonModule } from 'primeng/button'; -import { ProductChargeRowFormFieldsComponent } from './product-charge-row-form-fields.component'; - -@Component({ - selector: 'product-charge-row-form', - standalone: true, - imports: [CommonModule, ReactiveFormsModule, ButtonModule, ProductChargeRowFormFieldsComponent], - templateUrl: './product-charge-row-form.component.html', -}) -export class ProductChargeRowFormComponent implements OnInit { - private fb = inject(FormBuilder); - - @Input() productsControl!: FormArray< - FormGroup<{ - productId: FormControl>; - count: FormControl>; - unitPrice: FormControl>; - }> - >; - @Input() isSingleProduct = false; - - ngOnInit() { - if (this.productsControl.length === 0) { - this.addProduct(); - } - if (this.isSingleProduct) { - this.productsControl.at(0).get('productId')?.disable(); - } - } - - addProduct() { - const productFormGroup = this.fb.group({ - productId: [0, [Validators.required]], - count: [1, [Validators.required, Validators.min(1)]], - unitPrice: [0, [Validators.required, Validators.min(0)]], - }); - this.productsControl.push(productFormGroup); - } - - removeProduct(index: number) { - this.productsControl.removeAt(index); - } - - get products() { - return this.productsControl.controls as FormGroup[]; - } - get canAddOrRemoveProducts() { - return this.isSingleProduct === false; - } -} diff --git a/src/app/modules/purchases/components/receiptTemplate/index.ts b/src/app/modules/purchases/components/receiptTemplate/index.ts deleted file mode 100644 index 568ebe2..0000000 --- a/src/app/modules/purchases/components/receiptTemplate/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './purchase-receipt-product-row.component'; -export * from './purchase-receipt-template.component'; diff --git a/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-product-row.component.html b/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-product-row.component.html deleted file mode 100644 index 4b1dd45..0000000 --- a/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-product-row.component.html +++ /dev/null @@ -1,54 +0,0 @@ - - {{ rowIndex + 1 }} - -@if (editMode()) { - - - - - - - - - - - - - -} @else { - {{ purchaseItemControl.controls.product.value?.sku || "" }} - {{ purchaseItemControl.controls.product.value?.name || "" }} - {{ purchaseItemControl.controls.description.value || "" }} - - {{ purchaseItemControl.controls.count.value }} - - -} diff --git a/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-product-row.component.ts b/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-product-row.component.ts deleted file mode 100644 index e633475..0000000 --- a/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-product-row.component.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { ProductsSelectComponent } from '@/modules/products/components/select/select.component'; -import { InputComponent } from '@/shared/components'; -import { PriceMaskDirective } from '@/shared/directives'; -import { Component, EventEmitter, Input, Output, signal } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { ButtonDirective } from 'primeng/button'; -import { InputText } from 'primeng/inputtext'; -import { Textarea } from 'primeng/textarea'; -import { IPurchaseItemFormGroup } from '../../models'; - -@Component({ - selector: 'tr[purchase-receipt-product-row]', - templateUrl: './purchase-receipt-product-row.component.html', - imports: [ - ButtonDirective, - InputText, - ReactiveFormsModule, - ProductsSelectComponent, - InputComponent, - Textarea, - PriceMaskDirective, - ], -}) -export class PurchaseReceiptProductRowComponent { - @Input() rowIndex!: number; - @Input() canRemove: boolean = true; - @Input() purchaseItemControl!: IPurchaseItemFormGroup; - - @Output() onRemove = new EventEmitter(); - - editMode = signal(true); - - constructor() {} - - ngOnInit() { - this.purchaseItemControl?.controls.product.valueChanges.subscribe((res) => { - this.purchaseItemControl?.controls.unitPrice.setValue(Number(res?.salePrice) || 0); - }); - this.purchaseItemControl?.controls.count.valueChanges.subscribe(() => { - this.updateTotal(); - }); - this.purchaseItemControl?.controls.unitPrice.valueChanges.subscribe(() => { - this.updateTotal(); - }); - } - - updateTotal() { - this.purchaseItemControl.controls.total.setValue( - (this.purchaseItemControl.controls.count.value || 0) * - (this.purchaseItemControl.controls.unitPrice.value || 0), - ); - } - - toggleEditMode() { - this.editMode.set(!this.editMode()); - } - onDeleteClick() { - this.onRemove.emit(); - } -} diff --git a/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-template.component.html b/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-template.component.html deleted file mode 100644 index 4eeb9a2..0000000 --- a/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-template.component.html +++ /dev/null @@ -1,203 +0,0 @@ -
- -
-

رسید خرید

-
-
-
-
- - انبار: - - - -
- {{ form.controls.inventory.value?.name || "وارد نشده" }} - @if (!inventory) { - - } -
-
- - - -
-
-
- - تامین کننده: - - - -
- {{ form.controls.supplier.value?.fullname || "وارد نشده" }} - -
-
- - - -
-
-
-
-
-
- - شماره رسید: - - - -
- {{ form.controls.code.value || "وارد نشده" }} - -
-
- - - -
-
-
- - تاریخ خرید: - - - -
- {{ form.controls.buyAt.value || "وارد نشده" }} - -
-
- - - -
-
-
-
-
- - - - @for (col of columns; track $index) { - - {{ col.header }} - - } - - - - - - - - - -
- -
- - - - - -
-
- جمع کل: - -
-
- مالیات (۱۰٪): - -
-
- - - - -
- مبلغ قابل پرداخت: - -
- - -
- -
- - -
-
-
- -
- - -
- - @if (purchaseReceiptResponse()) { - - } - diff --git a/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-template.component.ts b/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-template.component.ts deleted file mode 100644 index b7c2772..0000000 --- a/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-template.component.ts +++ /dev/null @@ -1,230 +0,0 @@ -import { Maybe } from '@/core'; -import { ToastService } from '@/core/services/toast.service'; -import { InventoriesSelectComponent } from '@/modules/inventories/components/select/select.component'; -import { IInventorySummaryResponse } from '@/modules/inventories/models'; -import { IProductResponse } from '@/modules/products/models'; -import { SuppliersSelectComponent } from '@/modules/suppliers/components/select/select.component'; -import { ISupplierResponse } from '@/modules/suppliers/models'; -import { InputComponent } from '@/shared/components'; -import { IColumn } from '@/shared/components/pageDataList/page-data-list.component'; -import { PurchaseReceiptPaymentWrapperComponent } from '@/shared/components/purchaseReceiptPayment/wrapper.component'; -import { PriceAlphabetDirective, PriceMaskDirective } from '@/shared/directives'; -import { UikitFlatpickrJalaliComponent } from '@/uikit'; -import { CommonModule } from '@angular/common'; -import { Component, effect, inject, Input, signal } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import dayjs from 'dayjs'; -import { ButtonDirective } from 'primeng/button'; -import { Card } from 'primeng/card'; -import { Inplace } from 'primeng/inplace'; -import { TableModule } from 'primeng/table'; -import { IPurchaseReceiptResponse, IPurchaseRequest } from '../../models'; -import { PurchasesService } from '../../services/main.service'; -import { PurchaseReceiptProductRowComponent } from './purchase-receipt-product-row.component'; - -@Component({ - selector: 'purchase-receipt-template', - templateUrl: './purchase-receipt-template.component.html', - standalone: true, - - imports: [ - Card, - InventoriesSelectComponent, - SuppliersSelectComponent, - InputComponent, - TableModule, - PurchaseReceiptProductRowComponent, - PriceAlphabetDirective, - PriceMaskDirective, - ButtonDirective, - CommonModule, - ReactiveFormsModule, - UikitFlatpickrJalaliComponent, - PurchaseReceiptPaymentWrapperComponent, - Inplace, - ], -}) -export class PurchaseReceiptTemplateComponent { - private fb = inject(FormBuilder); - - @Input() product?: IProductResponse; - @Input() inventory?: IInventorySummaryResponse; - @Input() supplier?: ISupplierResponse; - - columns = [ - { - field: 'index', - header: 'ردیف', - width: '60px', - }, - { - field: 'sku', - header: 'کد کالا', - width: '120px', - }, - { - field: 'name', - header: 'نام کالا', - minWidth: '160px', - width: '160px', - }, - { - field: 'description', - header: 'توضیحات', - width: '200px', - }, - { - field: 'unitPrice', - header: 'قیمت واحد', - width: '200px', - }, - { - field: 'count', - header: 'تعداد', - width: '80px', - }, - { - field: 'totalPrice', - header: 'مبلغ کل', - type: 'price', - width: '140px', - }, - // { - // field: 'action', - // header: '', - // width: '100px', - // }, - ] as IColumn[]; - - form = this.fb.group({ - totalAmount: [0, [Validators.required, Validators.min(0)]], - code: ['', [Validators.required]], - isSettled: this.fb.control(false, { validators: [Validators.required] }), - paidAmount: this.fb.control(0, { validators: [Validators.required, Validators.min(0)] }), - buyAt: [dayjs().calendar('jalali').format('YYYY/MM/DD'), Validators.required], - description: [''], - products: this.fb.array([ - this.fb.group({ - product: [null as Maybe, [Validators.required]], - count: [0, [Validators.required, Validators.min(1)]], - unitPrice: [0, [Validators.required, Validators.min(0)]], - description: [''], - total: [0, [Validators.required, Validators.min(0)]], - }), - ]), - inventory: [null as Maybe, [Validators.required]], - supplier: [null as Maybe, [Validators.required]], - }); - - constructor( - private service: PurchasesService, - private toastService: ToastService, - ) { - this.form.controls.products.valueChanges.subscribe((products) => { - let totalAmount = 0; - products.forEach((p: any) => { - totalAmount += p.total || 0; - }); - this.form.controls.totalAmount.setValue(totalAmount); - }); - - this.form.controls.isSettled.valueChanges.subscribe((isSettled) => { - if (isSettled) { - this.form.controls.paidAmount.setValue(this.totalAmount); - } else { - this.form.controls.paidAmount.setValue(0); - } - }); - - effect(() => { - if (this.inventory) { - this.form.controls.inventory.setValue(this.inventory); - } - if (this.supplier) { - this.form.controls.supplier.setValue(this.supplier); - } - }); - } - - formIsSubmitted = signal(false); - purchaseReceiptResponse = signal>(null); - - ngOnInit() { - this.formIsSubmitted.set(false); - this.form.controls.products.controls.pop(); - if (this.product) { - this.form.controls.products.setValue([ - { - product: this.product, - count: 0, - unitPrice: 0, - description: '', - total: 0, - }, - ]); - } - } - - get totalAmount() { - return this.form.controls.totalAmount.value || 0; - } - - onAddProductClick() { - this.form.controls.products.push( - this.fb.group({ - product: [null as Maybe, [Validators.required]], - count: [0, [Validators.required, Validators.min(1)]], - unitPrice: [0, [Validators.required, Validators.min(0)]], - description: [''], - total: [0, [Validators.required, Validators.min(0)]], - }), - ); - } - - removePurchaseItem(index: number) { - this.form.controls.products.removeAt(index); - } - - onSubmit() { - this.formIsSubmitted.set(true); - this.form.markAllAsTouched(); - if (this.form.valid) { - const { products, inventory, supplier, ...res } = this.form.value; - - const payload = { - ...res, - inventoryId: this.form.controls.inventory.value?.id, - supplierId: this.form.controls.supplier.value?.id, - items: this.form.controls.products.value.map((item) => { - const { product, description, ...res } = item; - return { ...res, productId: item.product?.id }; - }), - } as IPurchaseRequest; - this.form.disable(); - - this.service.create(payload).subscribe({ - next: (res) => { - this.toastService.success({ text: 'ثبت سند خرید با موفقیت انجام شد' }); - this.form.enable(); - // this.form.reset(); - this.form.controls.code.setValue(this.form.controls.code.value + '1'); - this.formIsSubmitted.set(false); - this.purchaseReceiptResponse.set(res); - }, - error: () => { - this.form.enable(); - }, - }); - } else { - this.form.markAllAsTouched(); - } - } - - onCancel() {} - - paymentSubmitted() { - this.purchaseReceiptResponse.set(null); - this.form.reset(); - this.formIsSubmitted.set(false); - } -} diff --git a/src/app/modules/purchases/constants/apiRoutes/index.ts b/src/app/modules/purchases/constants/apiRoutes/index.ts deleted file mode 100644 index aafb373..0000000 --- a/src/app/modules/purchases/constants/apiRoutes/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -const BASE_URL = '/api/v1/purchase-receipts'; - -export const PURCHASES_API_ROUTES = { - getAll: BASE_URL, - getSingle: (id: number) => `${BASE_URL}/${id}`, - create: BASE_URL, -}; diff --git a/src/app/modules/purchases/constants/index.ts b/src/app/modules/purchases/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/purchases/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/purchases/constants/routes/index.ts b/src/app/modules/purchases/constants/routes/index.ts deleted file mode 100644 index 0d9fa1f..0000000 --- a/src/app/modules/purchases/constants/routes/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Routes } from '@angular/router'; - -export type TProductChargesRouteNames = 'product-charges' | 'product-charge'; - -export const PRODUCT_CHARGES_ROUTES: Routes = [ - { - path: '', - loadComponent: () => - import('../../views/list.component').then((m) => m.ProductChargesComponent), - }, - { - path: ':productChargeId', - loadComponent: () => - import('../../views/single.component').then((m) => m.ProductChargeComponent), - }, -]; diff --git a/src/app/modules/purchases/models/index.ts b/src/app/modules/purchases/models/index.ts deleted file mode 100644 index 2742fa8..0000000 --- a/src/app/modules/purchases/models/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Maybe } from '@/core'; -import { IProductResponse } from '@/modules/products/models'; -import { FormArray, FormControl, FormGroup } from '@angular/forms'; - -export * from './io'; - -export interface IPurchaseItemFormGroup extends FormGroup<{ - product: FormControl; - count: FormControl; - unitPrice: FormControl; - description: FormControl; - total: FormControl; -}> {} - -export interface IPurchaseFormGroup extends FormGroup<{ - code: FormControl; - isSettled: FormControl; - buyAt: FormControl; - description: FormControl>; - products: FormArray; - inventoryId: FormControl; - supplierId: FormControl; -}> {} diff --git a/src/app/modules/purchases/models/io.d.ts b/src/app/modules/purchases/models/io.d.ts deleted file mode 100644 index f482d84..0000000 --- a/src/app/modules/purchases/models/io.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Maybe } from '@/core'; - -export interface IPurchaseReceiptRawResponse { - id: number; - totalAmount: number; - inventoryId: number; - supplierId: number; - code: string; - items: IPurchaseItemResponse[]; - createdAt: string; - updatedAt: string; - deletedAt?: string; -} - -export interface IPurchaseReceiptResponse extends IPurchaseReceiptRawResponse {} - -export interface IPurchaseItemRawResponse { - id: number; - count: number; - unitPrice: number; - total: number; - productId: number; -} - -export interface IPurchaseRequest { - totalAmount: number; - inventoryId: number; - supplierId: number; - code?: string; - description?: string; - items: IPurchaseItemRequest[]; -} - -export interface IPurchaseItemRequest { - productId: number; - count: number; - unitPrice: number; - total: number; -} - -export interface IPurchaseForm { - inventory: Maybe; - supplier: Maybe; - code: string; - isSettled: boolean; - buyAt: Date | string; - description: string; - totalAmount: number; - products: IPurchaseItemForm[]; -} -export interface IPurchaseItemForm { - product: Maybe; - count: number; - unitPrice: number; - total: number; - description?: string; -} diff --git a/src/app/modules/purchases/services/main.service.ts b/src/app/modules/purchases/services/main.service.ts deleted file mode 100644 index 8922e87..0000000 --- a/src/app/modules/purchases/services/main.service.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { HttpClient } from '@angular/common/http'; -import { inject, Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { PURCHASES_API_ROUTES } from '../constants'; -import { IPurchaseReceiptRawResponse, IPurchaseReceiptResponse, IPurchaseRequest } from '../models'; - -@Injectable({ - providedIn: 'root', -}) -export class PurchasesService { - private http = inject(HttpClient); - - getAll(): Observable<{ data: IPurchaseReceiptRawResponse[] }> { - return this.http.get<{ data: IPurchaseReceiptResponse[] }>(PURCHASES_API_ROUTES.getAll); - } - - getSingle(id: number): Observable<{ data: IPurchaseReceiptResponse }> { - return this.http.get<{ data: IPurchaseReceiptResponse }>(PURCHASES_API_ROUTES.getSingle(id)); - } - - create(data: IPurchaseRequest): Observable { - return this.http.post(PURCHASES_API_ROUTES.create, data); - } -} diff --git a/src/app/modules/purchases/views/list.component.html b/src/app/modules/purchases/views/list.component.html deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/modules/purchases/views/list.component.ts b/src/app/modules/purchases/views/list.component.ts deleted file mode 100644 index e35d58f..0000000 --- a/src/app/modules/purchases/views/list.component.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-product-charges', - templateUrl: './list.component.html', -}) -export class ProductChargesComponent {} diff --git a/src/app/modules/purchases/views/single.component.html b/src/app/modules/purchases/views/single.component.html deleted file mode 100644 index 5b75608..0000000 --- a/src/app/modules/purchases/views/single.component.html +++ /dev/null @@ -1 +0,0 @@ -

product-charge works!

diff --git a/src/app/modules/purchases/views/single.component.ts b/src/app/modules/purchases/views/single.component.ts deleted file mode 100644 index 4bd5afe..0000000 --- a/src/app/modules/purchases/views/single.component.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-product-charge', - standalone: true, - imports: [], - templateUrl: './single.component.html', -}) -export class ProductChargeComponent {} diff --git a/src/app/modules/statistics/constants/apiRoutes/index.ts b/src/app/modules/statistics/constants/apiRoutes/index.ts deleted file mode 100644 index 475439c..0000000 --- a/src/app/modules/statistics/constants/apiRoutes/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -const baseUrl = '/api/v1/pos'; - -export const POS_API_ROUTES = { - info: (posId: number) => `${baseUrl}/${posId}`, - stock: (posId: number) => `${baseUrl}/${posId}/stock`, - productCategories: (posId: number) => `${baseUrl}/${posId}/product-categories`, - submitOrder: (posId: number) => `${baseUrl}/${posId}/orders/create`, -}; diff --git a/src/app/modules/statistics/constants/index.ts b/src/app/modules/statistics/constants/index.ts deleted file mode 100644 index b853783..0000000 --- a/src/app/modules/statistics/constants/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './apiRoutes'; diff --git a/src/app/modules/statistics/shared/components/card.component.html b/src/app/modules/statistics/shared/components/card.component.html deleted file mode 100644 index a9e4fc5..0000000 --- a/src/app/modules/statistics/shared/components/card.component.html +++ /dev/null @@ -1,10 +0,0 @@ -
-
- {{ title }} - -
- -
-
diff --git a/src/app/modules/statistics/shared/components/card.component.ts b/src/app/modules/statistics/shared/components/card.component.ts deleted file mode 100644 index 888b762..0000000 --- a/src/app/modules/statistics/shared/components/card.component.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Component, EventEmitter, Input, Output } from '@angular/core'; -import { ButtonDirective } from 'primeng/button'; - -@Component({ - selector: 'app-statistics-shared-card', - templateUrl: './card.component.html', - imports: [ButtonDirective], - host: { - class: 'block h-full overflow-auto', - }, -}) -export class StatisticsSharedCardComponent { - @Input() title!: string; - @Input() loading: boolean = false; - @Output() onRefresh = new EventEmitter(); - constructor() {} -} diff --git a/src/app/modules/statistics/shared/components/index.ts b/src/app/modules/statistics/shared/components/index.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/modules/statistics/shared/components/top-alert-stocks.component.html b/src/app/modules/statistics/shared/components/top-alert-stocks.component.html deleted file mode 100644 index 43ec5f9..0000000 --- a/src/app/modules/statistics/shared/components/top-alert-stocks.component.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/src/app/modules/statistics/shared/components/top-alert-stocks.component.ts b/src/app/modules/statistics/shared/components/top-alert-stocks.component.ts deleted file mode 100644 index d071cea..0000000 --- a/src/app/modules/statistics/shared/components/top-alert-stocks.component.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, signal, TemplateRef, ViewChild } from '@angular/core'; -import { RouterLink } from '@angular/router'; -import { ButtonDirective } from 'primeng/button'; -import { IStatisticsTopAlertStockResponse } from '../models/io'; -import { SharedStatisticsService } from '../services/main.service'; -import { StatisticsSharedCardComponent } from './card.component'; - -@Component({ - selector: 'app-statistics-shared-top-alert-stocks', - templateUrl: './top-alert-stocks.component.html', - imports: [StatisticsSharedCardComponent, PageDataListComponent, ButtonDirective, RouterLink], -}) -export class StatisticsSharedTopAlertStocksComponent { - items = signal([]); - loading = signal(false); - column = [] as IColumn[]; - @ViewChild('actionTpl', { static: true }) actionTpl!: TemplateRef; - - constructor(private readonly service: SharedStatisticsService) { - this.getData(); - } - - ngOnInit() { - this.column = [ - { field: 'sku', header: 'شناسه' }, - { field: 'name', header: 'عنوان' }, - { - field: 'brand', - header: 'برند', - type: 'nested', - nestedPath: 'name', - }, - - { - field: 'stock', - header: 'موجودی ', - }, - { field: 'minimumStockAlertLevel', header: 'حد هشدار' }, - { - field: 'chargeAction', - header: '', - customDataModel: this.actionTpl, - width: '40px', - }, - ]; - } - - getData() { - this.loading.set(true); - this.service.getTopAlertStock().subscribe({ - next: (res) => { - this.items.set(res.data); - this.loading.set(false); - }, - error: () => { - this.loading.set(false); - }, - }); - } - - toPurchase(item: IStatisticsTopAlertStockResponse) {} -} diff --git a/src/app/modules/statistics/shared/components/top-sales.component.html b/src/app/modules/statistics/shared/components/top-sales.component.html deleted file mode 100644 index 0126a97..0000000 --- a/src/app/modules/statistics/shared/components/top-sales.component.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/src/app/modules/statistics/shared/components/top-sales.component.ts b/src/app/modules/statistics/shared/components/top-sales.component.ts deleted file mode 100644 index d798d7a..0000000 --- a/src/app/modules/statistics/shared/components/top-sales.component.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, signal, TemplateRef, ViewChild } from '@angular/core'; -import { RouterLink } from '@angular/router'; -import { ButtonDirective } from 'primeng/button'; -import { IStatisticsTopSalesResponse } from '../models/io'; -import { SharedStatisticsService } from '../services/main.service'; -import { StatisticsSharedCardComponent } from './card.component'; - -@Component({ - selector: 'app-statistics-shared-top-sales', - templateUrl: './top-sales.component.html', - imports: [StatisticsSharedCardComponent, PageDataListComponent, ButtonDirective, RouterLink], -}) -export class StatisticsSharedTopSalesComponent { - items = signal([]); - loading = signal(false); - column = [] as IColumn[]; - @ViewChild('actionTpl', { static: true }) actionTpl!: TemplateRef; - - constructor(private readonly service: SharedStatisticsService) { - this.getData(); - } - - ngOnInit() { - this.column = [ - { field: 'sku', header: 'شناسه' }, - { field: 'name', header: 'عنوان' }, - { - field: 'brand', - header: 'برند', - type: 'nested', - nestedPath: 'name', - }, - ]; - } - - getData() { - this.loading.set(true); - this.service.getTopSales().subscribe({ - next: (res) => { - this.items.set(res.data); - this.loading.set(false); - }, - error: () => { - this.loading.set(false); - }, - }); - } -} diff --git a/src/app/modules/statistics/shared/components/top-supplier-debts.component.html b/src/app/modules/statistics/shared/components/top-supplier-debts.component.html deleted file mode 100644 index 87c7812..0000000 --- a/src/app/modules/statistics/shared/components/top-supplier-debts.component.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/src/app/modules/statistics/shared/components/top-supplier-debts.component.ts b/src/app/modules/statistics/shared/components/top-supplier-debts.component.ts deleted file mode 100644 index 0f54afd..0000000 --- a/src/app/modules/statistics/shared/components/top-supplier-debts.component.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, signal, TemplateRef, ViewChild } from '@angular/core'; -import { IStatisticsTopSupplierDebtsResponse } from '../models/io'; -import { SharedStatisticsService } from '../services/main.service'; -import { StatisticsSharedCardComponent } from './card.component'; - -@Component({ - selector: 'app-statistics-shared-top-supplier-debts', - templateUrl: './top-supplier-debts.component.html', - imports: [StatisticsSharedCardComponent, PageDataListComponent], -}) -export class StatisticsSharedTopSupplierDebtsComponent { - items = signal([]); - loading = signal(false); - column = [] as IColumn[]; - @ViewChild('actionTpl', { static: true }) actionTpl!: TemplateRef; - - constructor(private readonly service: SharedStatisticsService) { - this.getData(); - } - - ngOnInit() { - this.column = [ - { field: 'name', header: 'عنوان' }, - { - field: 'totalDebt', - header: 'بدهی کل', - type: 'price', - }, - { - field: 'unpaidReceipts', - header: 'فاکتورهای تسویه‌نشده', - }, - ]; - } - - getData() { - this.loading.set(true); - this.service.getTopSupplierDebts().subscribe({ - next: (res) => { - this.items.set(res.data); - this.loading.set(false); - }, - error: () => { - this.loading.set(false); - }, - }); - } -} diff --git a/src/app/modules/statistics/shared/constants/apiRoutes/index.ts b/src/app/modules/statistics/shared/constants/apiRoutes/index.ts deleted file mode 100644 index c81be92..0000000 --- a/src/app/modules/statistics/shared/constants/apiRoutes/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -const baseUrl = '/api/v1/statistics'; - -export const SHARED_STATISTICS_API_ROUTES = { - topAlertStock: `${baseUrl}/top-alert-stocks`, - topSales: `${baseUrl}/top-sales`, - topSupplierDebts: `${baseUrl}/top-supplier-debts`, - topSellProducts: `${baseUrl}/top-sell-products`, -}; diff --git a/src/app/modules/statistics/shared/constants/index.ts b/src/app/modules/statistics/shared/constants/index.ts deleted file mode 100644 index b853783..0000000 --- a/src/app/modules/statistics/shared/constants/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './apiRoutes'; diff --git a/src/app/modules/statistics/shared/index.ts b/src/app/modules/statistics/shared/index.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/modules/statistics/shared/models/index.ts b/src/app/modules/statistics/shared/models/index.ts deleted file mode 100644 index 61a518a..0000000 --- a/src/app/modules/statistics/shared/models/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './io'; diff --git a/src/app/modules/statistics/shared/models/io.ts b/src/app/modules/statistics/shared/models/io.ts deleted file mode 100644 index 316e8e3..0000000 --- a/src/app/modules/statistics/shared/models/io.ts +++ /dev/null @@ -1,27 +0,0 @@ -import ISummary from '@/core/models/summary'; - -export interface IStatisticsTopAlertStockRawResponse { - id: number; - name: string; - sku: string; - minimumStockAlertLevel: string; - stockBalances: any[]; - category: ISummary; - brand: ISummary; - deficit: number; -} -export interface IStatisticsTopAlertStockResponse extends IStatisticsTopAlertStockRawResponse {} - -export interface IStatisticsTopSalesRawResponse {} -export interface IStatisticsTopSalesResponse extends IStatisticsTopSalesRawResponse {} - -export interface IStatisticsTopSupplierDebtsRawResponse { - id: number; - name: string; - totalDebt: number; - unpaidReceipts: number; -} -export interface IStatisticsTopSupplierDebtsResponse extends IStatisticsTopSupplierDebtsRawResponse {} - -export interface IStatisticsTopSellProductsRawResponse {} -export interface IStatisticsTopSellProductsResponse extends IStatisticsTopSellProductsRawResponse {} diff --git a/src/app/modules/statistics/shared/services/main.service.ts b/src/app/modules/statistics/shared/services/main.service.ts deleted file mode 100644 index acb2858..0000000 --- a/src/app/modules/statistics/shared/services/main.service.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { SHARED_STATISTICS_API_ROUTES } from '../constants'; -import { - IStatisticsTopAlertStockRawResponse, - IStatisticsTopAlertStockResponse, - IStatisticsTopSalesRawResponse, - IStatisticsTopSalesResponse, - IStatisticsTopSellProductsRawResponse, - IStatisticsTopSellProductsResponse, - IStatisticsTopSupplierDebtsRawResponse, - IStatisticsTopSupplierDebtsResponse, -} from '../models'; - -@Injectable({ providedIn: 'root' }) -export class SharedStatisticsService { - constructor(private http: HttpClient) {} - - private apiRoutes = SHARED_STATISTICS_API_ROUTES; - - getTopAlertStock(): Observable> { - return this.http.get>( - `${this.apiRoutes.topAlertStock}`, - ); - } - - getTopSales(): Observable> { - return this.http.get>( - `${this.apiRoutes.topSales}`, - ); - } - - getTopSupplierDebts(): Observable> { - return this.http.get>( - `${this.apiRoutes.topSupplierDebts}`, - ); - } - - getTopSellProducts(): Observable> { - return this.http.get>( - `${this.apiRoutes.topSellProducts}`, - ); - } -} diff --git a/src/app/modules/suppliers/components/form.component.html b/src/app/modules/suppliers/components/form.component.html deleted file mode 100644 index 80d8418..0000000 --- a/src/app/modules/suppliers/components/form.component.html +++ /dev/null @@ -1,14 +0,0 @@ - -
- - - - - - - - - - - -
diff --git a/src/app/modules/suppliers/components/form.component.ts b/src/app/modules/suppliers/components/form.component.ts deleted file mode 100644 index bd5d41a..0000000 --- a/src/app/modules/suppliers/components/form.component.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { InputComponent } from '@/shared/components'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, effect, EventEmitter, inject, Input, Output, signal } from '@angular/core'; -import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { Dialog } from 'primeng/dialog'; -import { ISupplierRequest, ISupplierResponse } from '../models'; -import { SuppliersService } from '../services/main.service'; - -@Component({ - selector: 'supplier-form', - templateUrl: './form.component.html', - imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent], -}) -export class SupplierFormComponent { - @Input() initialValues?: ISupplierResponse; - - @Input() - set visible(v: boolean) { - this.visibleSignal.set(!!v); - } - get visible() { - return this.visibleSignal(); - } - private visibleSignal = signal(false); - - @Output() visibleChange = new EventEmitter(); - @Output() onSubmit = new EventEmitter(); - - private fb = inject(FormBuilder); - constructor( - private service: SuppliersService, - private toastService: ToastService, - ) { - effect(() => { - const v = this.visibleSignal(); - if (!v) this.form.reset(); - }); - } - - form = this.fb.group({ - firstName: [this.initialValues?.firstName || null, [Validators.required]], - lastName: [this.initialValues?.lastName || null, [Validators.required]], - mobileNumber: [this.initialValues?.mobileNumber || null, [Validators.required]], - email: [this.initialValues?.email || null, [Validators.email]], - address: [this.initialValues?.address || null], - city: [this.initialValues?.city || null], - state: [this.initialValues?.state || null], - country: [this.initialValues?.country || null], - isActive: [this.initialValues?.isActive || false], - }); - - submitLoading = signal(false); - - submit() { - this.form.markAllAsTouched(); - if (this.form.valid) { - this.form.disable(); - this.submitLoading.set(true); - this.service.create(this.form.value as ISupplierRequest).subscribe({ - next: (res) => { - this.toastService.success({ - text: `تأمین‌کننده ${this.form.value.firstName} ${this.form.value.lastName} با موفقیت ایجاد شد`, - }); - this.close(); - this.submitLoading.set(false); - this.form.enable(); - this.form.reset(); - this.onSubmit.emit(res); - }, - error: () => { - this.submitLoading.set(false); - this.form.enable(); - }, - }); - } - } - - close() { - this.visibleChange.emit(false); - } -} diff --git a/src/app/modules/suppliers/components/invoices/invoices.component.html b/src/app/modules/suppliers/components/invoices/invoices.component.html deleted file mode 100644 index 97673ed..0000000 --- a/src/app/modules/suppliers/components/invoices/invoices.component.html +++ /dev/null @@ -1,128 +0,0 @@ - - -
- فاکتورهای خرید -
- @if (showViewAllCTA) { - - } - -
-
-
- - - - - - شناسه رسید - انبار - مجموع قیمت - وضعیت تسویه حساب - مانده حساب - تاریخ - - - - - - - - - {{ item.code }} - {{ item.inventory.name }} - - - - - - - - - - - - - - - - -
کالاهای تامین شده
-
- - - -
- شناسه کالا - -
- - -
- عنوان کالا - -
- - -
- تعداد - -
- - -
- قیمت واحد - -
- - -
- قیمت نهایی - -
- - - -
- - - {{ item.product.id }} - {{ item.product.name }} - {{ item.count }} - - - - - - - -
-
- - -
- - - - هیچ فاکتوری ثبت نشده است. - - -
-
-
diff --git a/src/app/modules/suppliers/components/invoices/invoices.component.ts b/src/app/modules/suppliers/components/invoices/invoices.component.ts deleted file mode 100644 index 8d2ae32..0000000 --- a/src/app/modules/suppliers/components/invoices/invoices.component.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { Maybe } from '@/core'; -import { CatalogPurchaseReceiptStatusTagComponent } from '@/shared/catalog'; -import { JalaliDateDirective, PriceMaskDirective } from '@/shared/directives'; -import { CommonModule } from '@angular/common'; -import { Component, Input, OnInit, signal } from '@angular/core'; -import { RouterLink } from '@angular/router'; -import { Button, ButtonDirective } from 'primeng/button'; -import { Card } from 'primeng/card'; -import { Ripple } from 'primeng/ripple'; -import { TableModule } from 'primeng/table'; -import { ISupplierInvoicesResponse } from '../../models/invoices.io'; -import { SupplierInvoicesService } from '../../services'; - -@Component({ - selector: 'suppliers-invoices', - standalone: true, - imports: [ - CommonModule, - Card, - ButtonDirective, - TableModule, - PriceMaskDirective, - JalaliDateDirective, - Ripple, - Button, - RouterLink, - CatalogPurchaseReceiptStatusTagComponent, - ], - templateUrl: './invoices.component.html', -}) -export class SuppliersInvoicesComponent implements OnInit { - @Input() supplierId!: string; - @Input() showViewAllCTA: boolean = true; - @Input() perPage: number = 10; - - constructor(private service: SupplierInvoicesService) {} - - ngOnInit(): void { - this.getAll(); - } - - expandedRows = {}; - - loading = signal(true); - items = signal>(null); - - getAll() { - this.loading.set(true); - this.service.getAll(this.supplierId).subscribe({ - next: (res) => { - this.loading.set(false); - this.items.set(res.data); - }, - error: () => { - this.loading.set(false); - }, - }); - } -} diff --git a/src/app/modules/suppliers/components/invoices/pay-form-template.component.html b/src/app/modules/suppliers/components/invoices/pay-form-template.component.html deleted file mode 100644 index b61133d..0000000 --- a/src/app/modules/suppliers/components/invoices/pay-form-template.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- - - - - diff --git a/src/app/modules/suppliers/components/invoices/pay-form-template.component.ts b/src/app/modules/suppliers/components/invoices/pay-form-template.component.ts deleted file mode 100644 index 7be79b3..0000000 --- a/src/app/modules/suppliers/components/invoices/pay-form-template.component.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { InventoryBankAccountSelectComponent } from '@/modules/inventories/components/bankAccounts/select.component'; -import { PaymentMethodTypeSelectComponent } from '@/shared/catalog/paymentMethodTypes/components'; -import { PaymentType } from '@/shared/catalog/paymentTypes'; -import { InputComponent } from '@/shared/components'; -import { AbstractForm } from '@/shared/components/abstract-form'; -import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { formatNumber } from '@/utils/price-mask.utils'; -import { Component, computed, inject, Input } from '@angular/core'; -import { ReactiveFormsModule, Validators } from '@angular/forms'; -import dayjs from 'dayjs'; -import { Dialog } from 'primeng/dialog'; -import { IPayRequestPayload, IPayResponse } from '../../models/invoices.io'; -import { SupplierInvoicesService } from '../../services'; - -@Component({ - selector: 'app-supplier-invoice-pay-form-template', - templateUrl: './pay-form-template.component.html', - imports: [ - Dialog, - ReactiveFormsModule, - InventoryBankAccountSelectComponent, - FormFooterActionsComponent, - InputComponent, - PaymentMethodTypeSelectComponent, - ], -}) -export class SupplierInvoicePayFormTemplateComponent extends AbstractForm< - IPayResponse, - IPayRequestPayload -> { - @Input() debtAmount!: number; - @Input() supplierId!: string; - @Input() invoiceId!: string; - @Input() inventoryId!: string; - - private readonly service = inject(SupplierInvoicesService); - - override defaultValues = { - type: PaymentType.PAYMENT, - payedAt: dayjs().format('YYYY-MM-DD'), - }; - - form = this.fb.group({ - amount: [0, [Validators.required, Validators.max(this.debtAmount), Validators.min(1)]], - bankAccountId: [null, [Validators.required]], - paymentMethod: [null, [Validators.required]], - type: [PaymentType.PAYMENT, [Validators.required]], - payedAt: [dayjs().format('YYYY-MM-DD'), [Validators.required]], - description: [''], - }); - - amountFieldHint = computed(() => `بدهی شما مبلغ ${formatNumber(this.debtAmount)} ریال می‌باشد.`); - - submitForm(payload: IPayRequestPayload) { - return this.service.pay(this.supplierId, this.invoiceId, payload); - } -} diff --git a/src/app/modules/suppliers/components/invoices/pay-form.component.html b/src/app/modules/suppliers/components/invoices/pay-form.component.html deleted file mode 100644 index f3bb767..0000000 --- a/src/app/modules/suppliers/components/invoices/pay-form.component.html +++ /dev/null @@ -1,16 +0,0 @@ - - - diff --git a/src/app/modules/suppliers/components/invoices/pay-form.component.ts b/src/app/modules/suppliers/components/invoices/pay-form.component.ts deleted file mode 100644 index 3f64ec4..0000000 --- a/src/app/modules/suppliers/components/invoices/pay-form.component.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { PaymentType } from '@/shared/catalog/paymentTypes'; -import { AbstractFormDialog } from '@/shared/components/abstract-form-dialog.component'; -import { formatNumber } from '@/utils/price-mask.utils'; -import { Component, computed, inject, Input } from '@angular/core'; -import { ReactiveFormsModule, Validators } from '@angular/forms'; -import dayjs from 'dayjs'; -import { Dialog } from 'primeng/dialog'; -import { IPayRequestPayload, IPayResponse } from '../../models/invoices.io'; -import { SupplierInvoicesService } from '../../services'; -import { SupplierInvoicePayFormTemplateComponent } from './pay-form-template.component'; - -@Component({ - selector: 'app-supplier-invoice-pay-form', - templateUrl: './pay-form.component.html', - imports: [Dialog, ReactiveFormsModule, SupplierInvoicePayFormTemplateComponent], -}) -export class SupplierInvoicePayFormComponent extends AbstractFormDialog< - IPayResponse, - IPayRequestPayload -> { - @Input() debtAmount!: number; - @Input() supplierId!: string; - @Input() invoiceId!: string; - @Input() inventoryId!: string; - - private readonly service = inject(SupplierInvoicesService); - - override defaultValues = { - type: PaymentType.PAYMENT, - payedAt: dayjs().format('YYYY-MM-DD'), - }; - - form = this.fb.group({ - amount: [0, [Validators.required, Validators.max(this.debtAmount), Validators.min(1)]], - bankAccountId: [null, [Validators.required]], - paymentMethod: [null, [Validators.required]], - type: [PaymentType.PAYMENT, [Validators.required]], - payedAt: [dayjs().format('YYYY-MM-DD'), [Validators.required]], - description: [''], - }); - - amountFieldHint = computed(() => `بدهی شما مبلغ ${formatNumber(this.debtAmount)} ریال می‌باشد.`); - - submitForm(payload: IPayRequestPayload) { - return this.service.pay(this.supplierId, this.invoiceId, payload); - } -} diff --git a/src/app/modules/suppliers/components/invoices/payments.component.html b/src/app/modules/suppliers/components/invoices/payments.component.html deleted file mode 100644 index 1a2828d..0000000 --- a/src/app/modules/suppliers/components/invoices/payments.component.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/app/modules/suppliers/components/invoices/payments.component.ts b/src/app/modules/suppliers/components/invoices/payments.component.ts deleted file mode 100644 index ad77c52..0000000 --- a/src/app/modules/suppliers/components/invoices/payments.component.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { CatalogPaymentMethodTypeTagComponent } from '@/shared/catalog/paymentMethodTypes'; -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, Input, signal, TemplateRef, ViewChild } from '@angular/core'; -import { IInvoicePaymentResponse } from '../../models/invoices.io'; -import { SupplierInvoicesService } from '../../services'; - -@Component({ - selector: 'app-invoice-payments', - templateUrl: './payments.component.html', - imports: [PageDataListComponent, CatalogPaymentMethodTypeTagComponent], -}) -export class InvoicePaymentsComponent { - @Input() supplierId!: string; - @Input() invoiceId!: string; - @ViewChild('paymentMethodTpl', { static: true }) paymentMethodTpl!: TemplateRef; - constructor(private readonly service: SupplierInvoicesService) {} - - columns = [] as IColumn[]; - - ngOnInit() { - console.log(this.invoiceId); - this.columns = [ - { - field: 'index', - header: 'ردیف', - type: 'index', - }, - { - field: 'code', - header: 'شناسه پرداخت', - }, - { - field: 'amount', - header: 'مبلغ پرداختی', - type: 'price', - }, - { - field: 'paymentMethod', - header: 'روش پرداخت', - customDataModel: this.paymentMethodTpl, - }, - { - field: 'bankAccount', - header: 'حساب بانکی', - customDataModel: (item: IInvoicePaymentResponse) => - `${item.bankAccount.name} - بانک ${item.bankAccount.branch.bank.name} - شعبه ${item.bankAccount.branch.name}`, - }, - { - field: 'payedAt', - header: 'تاریخ پرداخت', - type: 'date', - }, - ]; - this.getData(); - } - - items = signal([]); - loading = signal(false); - - getData() { - this.loading.set(true); - return this.service.getPayments(this.supplierId!, this.invoiceId!).subscribe({ - next: (res) => { - this.items.set(res.data); - this.loading.set(false); - }, - error: (err) => { - this.loading.set(false); - }, - }); - } -} diff --git a/src/app/modules/suppliers/components/ledger/ledger.component.html b/src/app/modules/suppliers/components/ledger/ledger.component.html deleted file mode 100644 index 101070d..0000000 --- a/src/app/modules/suppliers/components/ledger/ledger.component.html +++ /dev/null @@ -1,41 +0,0 @@ - - -
- دفتر کل تامین‌کننده -
- @if (showViewAllCTA) { - - } - -
-
-
- - - - - ردیف - بدهکار - بستانکار - تسویه - تاریخ - - - - - {{ i + 1 }} - - - - - - - - - - هیچ رکوردی ثبت نشده است. - - - - -
diff --git a/src/app/modules/suppliers/components/ledger/ledger.component.ts b/src/app/modules/suppliers/components/ledger/ledger.component.ts deleted file mode 100644 index 6962f3d..0000000 --- a/src/app/modules/suppliers/components/ledger/ledger.component.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Maybe } from '@/core'; -import { CatalogPurchaseReceiptStatusTagComponent } from '@/shared/catalog'; -import { JalaliDateDirective, PriceMaskDirective } from '@/shared/directives'; -import { CommonModule } from '@angular/common'; -import { Component, Input, OnInit, signal } from '@angular/core'; -import { RouterLink } from '@angular/router'; -import { ButtonDirective } from 'primeng/button'; -import { Card } from 'primeng/card'; -import { TableModule } from 'primeng/table'; -import { ISupplierLedgerResponse } from '../../models'; -import { SuppliersService } from '../../services'; - -@Component({ - selector: 'supplier-ledger', - standalone: true, - imports: [ - CommonModule, - Card, - ButtonDirective, - TableModule, - PriceMaskDirective, - JalaliDateDirective, - RouterLink, - CatalogPurchaseReceiptStatusTagComponent, - ], - templateUrl: './ledger.component.html', -}) -export class SupplierLedgerComponent implements OnInit { - @Input() supplierId!: string; - @Input() showViewAllCTA: boolean = true; - @Input() perPage: number = 10; - - constructor(private service: SuppliersService) {} - - ngOnInit(): void { - this.getAll(); - } - - expandedRows = {}; - - loading = signal(true); - items = signal>(null); - - getAll() { - this.loading.set(true); - this.service.getLedger(this.supplierId).subscribe({ - next: (res) => { - this.loading.set(false); - this.items.set(res.data); - }, - error: () => { - this.loading.set(false); - }, - }); - } -} diff --git a/src/app/modules/suppliers/components/select/select.component.html b/src/app/modules/suppliers/components/select/select.component.html deleted file mode 100644 index 002d9e6..0000000 --- a/src/app/modules/suppliers/components/select/select.component.html +++ /dev/null @@ -1,15 +0,0 @@ -
- - - - -
diff --git a/src/app/modules/suppliers/components/select/select.component.ts b/src/app/modules/suppliers/components/select/select.component.ts deleted file mode 100644 index 8467a27..0000000 --- a/src/app/modules/suppliers/components/select/select.component.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { AbstractSelectComponent } from '@/shared/components'; -import { UikitFieldComponent } from '@/uikit'; -import { Component } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { SelectModule } from 'primeng/select'; -import { ISupplierResponse } from '../../models'; -import { SuppliersService } from '../../services/main.service'; - -@Component({ - selector: 'suppliers-select-field', - templateUrl: './select.component.html', - imports: [ReactiveFormsModule, SelectModule, UikitFieldComponent], -}) -export class SuppliersSelectComponent extends AbstractSelectComponent< - ISupplierResponse, - IPaginatedResponse -> { - constructor(private service: SuppliersService) { - super(); - this.getData(); - } - - getDataService() { - return this.service.getAll(); - } -} diff --git a/src/app/modules/suppliers/constants/apiRoutes/index.ts b/src/app/modules/suppliers/constants/apiRoutes/index.ts deleted file mode 100644 index 1279885..0000000 --- a/src/app/modules/suppliers/constants/apiRoutes/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { SUPPLIER_INVOICES_API_ROUTES } from './invoices'; - -const baseUrl = '/api/v1/suppliers'; - -export const SUPPLIERS_API_ROUTES = { - list: () => `${baseUrl}`, - single: (supplierId: string) => `${baseUrl}/${supplierId}`, - ledger: (supplierId: string) => `${baseUrl}/${supplierId}/ledger`, - invoices: SUPPLIER_INVOICES_API_ROUTES(baseUrl), -}; diff --git a/src/app/modules/suppliers/constants/apiRoutes/invoices.ts b/src/app/modules/suppliers/constants/apiRoutes/invoices.ts deleted file mode 100644 index 29c52e8..0000000 --- a/src/app/modules/suppliers/constants/apiRoutes/invoices.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const SUPPLIER_INVOICES_API_ROUTES = (_baseUrl: string) => { - const baseUrl = (supplierId: string) => `${_baseUrl}/${supplierId}/invoices`; - return { - list: (supplierId: string) => `${baseUrl(supplierId)}`, - single: (supplierId: string, invoiceId: string) => `${baseUrl(supplierId)}/${invoiceId}`, - pay: (supplierId: string, invoiceId: string) => `${baseUrl(supplierId)}/${invoiceId}/pay`, - invoicePayments: (supplierId: string, invoiceId: string) => - `${baseUrl(supplierId)}/${invoiceId}/payments`, - }; -}; diff --git a/src/app/modules/suppliers/constants/index.ts b/src/app/modules/suppliers/constants/index.ts deleted file mode 100644 index ee61bd7..0000000 --- a/src/app/modules/suppliers/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './apiRoutes'; -export * from './routes'; diff --git a/src/app/modules/suppliers/constants/routes/index.ts b/src/app/modules/suppliers/constants/routes/index.ts deleted file mode 100644 index 2f71b83..0000000 --- a/src/app/modules/suppliers/constants/routes/index.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { NamedRoutes } from '@/core'; -import { Routes } from '@angular/router'; - -export const suppliersNamedRoutes: NamedRoutes = { - suppliers: { - path: 'suppliers', - loadComponent: () => import('../../views/list.component').then((m) => m.SuppliersComponent), - meta: { - title: 'تامین‌کنندگان', - pagePath: () => '/suppliers', - }, - }, - supplier: { - path: 'suppliers/:supplierId', - loadComponent: () => import('../../views/single.component').then((m) => m.SupplierComponent), - meta: { - title: 'تامین‌کننده', - pagePath: () => '/suppliers/:supplierId', - }, - }, - invoices: { - path: 'suppliers/:supplierId/invoices', - loadComponent: () => - import('../../views/invoices.component').then((m) => m.SupplierInvoicesComponent), - meta: { - title: 'فاکتورها', - pagePath: () => '/suppliers/:supplierId/invoices', - }, - }, - invoice: { - path: 'suppliers/:supplierId/invoices/:invoiceId', - loadComponent: () => - import('../../views/invoice.component').then((m) => m.SupplierInvoiceComponent), - meta: { - title: 'فاکتور', - pagePath: () => '/suppliers/:supplierId/invoices/:invoiceId', - }, - }, - purchase: { - path: 'suppliers/:supplierId/purchase', - loadComponent: () => - import('../../views/purchase.component').then((m) => m.InventoryPurchaseComponent), - meta: { - title: 'خرید', - pagePath: () => '/suppliers/:supplierId/purchase', - }, - }, -} as const; - -export type TSuppliersRouteNames = (typeof suppliersNamedRoutes)[keyof typeof suppliersNamedRoutes]; - -export const SUPPLIERS_ROUTES: Routes = Object.values(suppliersNamedRoutes); diff --git a/src/app/modules/suppliers/models/index.ts b/src/app/modules/suppliers/models/index.ts deleted file mode 100644 index 61a518a..0000000 --- a/src/app/modules/suppliers/models/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './io'; diff --git a/src/app/modules/suppliers/models/invoices.io.ts b/src/app/modules/suppliers/models/invoices.io.ts deleted file mode 100644 index 023bcaf..0000000 --- a/src/app/modules/suppliers/models/invoices.io.ts +++ /dev/null @@ -1,55 +0,0 @@ -import ISummary from '@/core/models/summary'; -import { IBankAccountSummary } from '@/modules/inventories/models'; -import { PurchaseReceiptStatus } from '@/shared/catalog'; -import { PaymentMethodType } from '@/shared/catalog/paymentMethodTypes'; -import { PaymentType } from '@/shared/catalog/paymentTypes'; -import { IReceiptInfo, ISupplierReceiptItemSummary } from './types'; - -export interface ISupplierInvoicesRawResponse { - id: number; - code: string; - totalAmount: string; - paidAmount: string; - status: PurchaseReceiptStatus; - description?: string; - createdAt: string; - updatedAt: string; - items: ISupplierReceiptItemSummary[]; - inventory: ISummary; - payments: any[]; -} - -export interface ISupplierInvoicesResponse extends ISupplierInvoicesRawResponse {} - -export interface IPayRequestPayload { - amount: number; - bankAccountId: string; - paymentMethod: PaymentMethodType; - type: PaymentType; - payedAt: string; - description?: string; -} -export interface IPayRawResponse { - amount: number; - bankAccountId: string; - paymentMethod: PaymentMethodType; - type: PaymentType; - payedAt: string; - description?: string; -} -export interface IPayResponse extends IPayRawResponse {} - -export interface IInvoicePaymentRawResponse { - id: number; - amount: string; - paymentMethod: string; - type: string; - bankAccountId: number; - payedAt: string; - description: null; - createdAt: string; - receipt: IReceiptInfo; - bankAccount: IBankAccountSummary; -} - -export interface IInvoicePaymentResponse extends IInvoicePaymentRawResponse {} diff --git a/src/app/modules/suppliers/models/io.d.ts b/src/app/modules/suppliers/models/io.d.ts deleted file mode 100644 index 5324a7a..0000000 --- a/src/app/modules/suppliers/models/io.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { IReceiptsOverview } from './types'; - -export interface ISupplierRawResponse { - id: number; - firstName: string; - lastName: string; - email: string; - mobileNumber: string; - address: string; - city: string; - state: string; - country: string; - isActive: boolean; - createdAt: string; - updatedAt: string; - deletedAt: string; -} - -export interface ISupplierResponse extends ISupplierRawResponse { - fullname: string; -} - -export interface ISupplierFullInfoRawResponse extends ISupplierRawResponse { - receiptsOverview: IReceiptsOverview; -} -export interface ISupplierFullInfoResponse extends ISupplierFullInfoRawResponse { - fullname: string; -} - -export interface ISupplierRequest { - firstName: string; - lastName: string; - email: string; - mobileNumber: string; - address: string; - city: string; - state: string; - country: string; - isActive: boolean; -} - -export interface ISupplierLedgerRawResponse {} -export interface ISupplierLedgerResponse extends ISupplierLedgerRawResponse {} diff --git a/src/app/modules/suppliers/models/types.ts b/src/app/modules/suppliers/models/types.ts deleted file mode 100644 index c6bc532..0000000 --- a/src/app/modules/suppliers/models/types.ts +++ /dev/null @@ -1,37 +0,0 @@ -import ISummary from '@/core/models/summary'; - -export interface IReceiptsOverview { - totalPayment: string; - count: number; -} - -export interface ISupplierInventorySummary { - id: number; - name: string; -} - -export interface ISupplierReceiptItemSummary { - id: number; - count: string; - unitPrice: string; - total: string; - product: { - id: string; - name: string; - sku: string; - }; -} - -export interface IReceiptInfo { - id: number; - code: string; - totalAmount: string; - paidAmount: string; - description: string; - createdAt: string; - updatedAt: string; - status: string; - supplierId: number; - inventoryId: number; - inventory: ISummary; -} diff --git a/src/app/modules/suppliers/services/index.ts b/src/app/modules/suppliers/services/index.ts deleted file mode 100644 index b4e7e7b..0000000 --- a/src/app/modules/suppliers/services/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './invoices.service'; -export * from './main.service'; diff --git a/src/app/modules/suppliers/services/invoices.service.ts b/src/app/modules/suppliers/services/invoices.service.ts deleted file mode 100644 index 55410d2..0000000 --- a/src/app/modules/suppliers/services/invoices.service.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { SUPPLIERS_API_ROUTES } from '../constants'; -import { - IInvoicePaymentRawResponse, - IInvoicePaymentResponse, - IPayRawResponse, - IPayRequestPayload, - IPayResponse, - ISupplierInvoicesRawResponse, - ISupplierInvoicesResponse, -} from '../models/invoices.io'; - -@Injectable({ providedIn: 'root' }) -export class SupplierInvoicesService { - constructor(private http: HttpClient) {} - - private apiRoutes = SUPPLIERS_API_ROUTES.invoices; - - getAll(supplierId: string): Observable> { - return this.http.get>( - this.apiRoutes.list(supplierId), - ); - } - - getSingle(supplierId: string, invoiceId: string): Observable { - return this.http.get( - this.apiRoutes.single(supplierId, invoiceId), - ); - } - - pay( - supplierId: string, - invoiceId: string, - payload: IPayRequestPayload, - ): Observable { - return this.http.post(this.apiRoutes.pay(supplierId, invoiceId), payload); - } - - getPayments( - supplierId: string, - invoiceId: string, - ): Observable> { - return this.http.get>( - this.apiRoutes.invoicePayments(supplierId, invoiceId), - ); - } -} diff --git a/src/app/modules/suppliers/services/main.service.ts b/src/app/modules/suppliers/services/main.service.ts deleted file mode 100644 index 0fbd35b..0000000 --- a/src/app/modules/suppliers/services/main.service.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; -import { getFullName } from '@/utils'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { map, Observable } from 'rxjs'; -import { SUPPLIERS_API_ROUTES } from '../constants'; -import { - ISupplierFullInfoRawResponse, - ISupplierFullInfoResponse, - ISupplierLedgerResponse, - ISupplierRawResponse, - ISupplierRequest, - ISupplierResponse, -} from '../models'; - -@Injectable({ providedIn: 'root' }) -export class SuppliersService { - constructor(private http: HttpClient) {} - - private apiRoutes = SUPPLIERS_API_ROUTES; - - getAll(): Observable> { - return this.http.get>(this.apiRoutes.list()).pipe( - map((res) => ({ - ...res, - data: res.data.map((item) => ({ - ...item, - fullname: getFullName({ firstName: item.firstName, lastName: item.lastName }), - })), - })), - ); - } - - getSingle(supplierId: string): Observable { - return this.http.get(this.apiRoutes.single(supplierId)).pipe( - map((item) => ({ - ...item, - fullname: getFullName({ firstName: item.firstName, lastName: item.lastName }), - })), - ); - } - - create(data: ISupplierRequest): Observable { - return this.http.post(this.apiRoutes.list(), data).pipe( - map((item) => ({ - ...item, - fullname: getFullName({ firstName: item.firstName, lastName: item.lastName }), - })), - ); - } - - getLedger(supplierId: string): Observable> { - return this.http.get>( - this.apiRoutes.ledger(supplierId), - ); - } -} diff --git a/src/app/modules/suppliers/store/index.ts b/src/app/modules/suppliers/store/index.ts deleted file mode 100644 index e48d1e2..0000000 --- a/src/app/modules/suppliers/store/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './invoice.store'; -export * from './main.store'; diff --git a/src/app/modules/suppliers/store/invoice.store.ts b/src/app/modules/suppliers/store/invoice.store.ts deleted file mode 100644 index af32110..0000000 --- a/src/app/modules/suppliers/store/invoice.store.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { EntityState, EntityStore } from '@/core/state'; -import { Injectable, InjectionToken } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { ISupplierInvoicesResponse } from '../models/invoices.io'; -import { SupplierInvoicesService } from '../services'; - -export interface SupplierInvoiceState extends EntityState {} -export const SUPPLIER_ID = new InjectionToken('SUPPLIER_ID'); - -@Injectable({ - providedIn: 'root', -}) -export class SupplierInvoiceStore extends EntityStore< - ISupplierInvoicesResponse, - SupplierInvoiceState -> { - private readonly _inventoryState = { - isRefreshing: false, - }; - - constructor( - private activeRoute: ActivatedRoute, - private service: SupplierInvoicesService, - private toastService: ToastService, - ) { - super({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - entities: {}, - selectedId: null, - ids: [], - }); - this.initial(); - } - - supplierId!: string; - - initial() {} - - getSingle(invoiceId: string) { - if (this.entities()[invoiceId]) { - return; - } - this.patchState({ loading: true }); - this.service.getSingle(this.supplierId, invoiceId).subscribe({ - next: (res) => { - this.patchState({ - entities: { [res.id]: res }, - loading: false, - }); - }, - error: (err) => { - this.patchState({ loading: false, error: err }); - this.toastService.error({ - text: 'خطا در دریافت اطلاعات فاکتور', - }); - }, - }); - } - - refreshSingle(supplierId: string) {} - - reset(): void { - const queryParams = this.activeRoute.snapshot.queryParams; - this.setState({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - entities: {}, - selectedId: null, - ids: [], - }); - } -} diff --git a/src/app/modules/suppliers/store/invoices.store.ts b/src/app/modules/suppliers/store/invoices.store.ts deleted file mode 100644 index 684ffc1..0000000 --- a/src/app/modules/suppliers/store/invoices.store.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { PaginatedState, PaginatedStore } from '@/core/state'; -import { Injectable, InjectionToken } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { ISupplierInvoicesResponse } from '../models/invoices.io'; -import { SupplierInvoicesService } from '../services'; - -export interface SupplierInvoicesState extends PaginatedState {} -export const SUPPLIER_ID = new InjectionToken('SUPPLIER_ID'); - -@Injectable({ - providedIn: 'root', -}) -export class SupplierInvoicesStore extends PaginatedStore< - ISupplierInvoicesResponse, - SupplierInvoicesState -> { - private readonly _inventoryState = { - isRefreshing: false, - }; - - constructor( - private activeRoute: ActivatedRoute, - private service: SupplierInvoicesService, - private toastService: ToastService, - ) { - super({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - items: [], - totalCount: 0, - currentPage: 0, - pageSize: 0, - totalPages: 0, - hasMore: false, - }); - this.initial(); - } - - supplierId!: string; - - initial() { - console.log(this.supplierId); - - if (!this.initialized()) { - this.getData(); - } - } - - getData() { - this.patchState({ loading: true }); - this.service.getAll(this.supplierId).subscribe({ - next: (res) => { - this.patchState({ - items: res.data, - totalCount: res.meta.totalRecords, - currentPage: res.meta.page, - pageSize: res.meta.perPage, - totalPages: res.meta.totalPages, - hasMore: res.meta.page < res.meta.totalPages, - initialized: true, - loading: false, - }); - }, - error: (err) => { - this.patchState({ loading: false, error: err }); - this.toastService.error({ - text: 'خطا در دریافت اطلاعات فاکتور', - }); - }, - }); - } - - refreshSingle(supplierId: string) {} - - reset(): void { - const queryParams = this.activeRoute.snapshot.queryParams; - this.setState({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - items: [], - totalCount: 0, - currentPage: 0, - pageSize: 0, - totalPages: 0, - hasMore: false, - }); - } -} diff --git a/src/app/modules/suppliers/store/main.store.ts b/src/app/modules/suppliers/store/main.store.ts deleted file mode 100644 index 232ed83..0000000 --- a/src/app/modules/suppliers/store/main.store.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { ToastService } from '@/core/services/toast.service'; -import { EntityState, EntityStore } from '@/core/state'; -import { Injectable } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { ISupplierFullInfoResponse } from '../models'; -import { SuppliersService } from '../services'; - -export interface SupplierState extends EntityState {} - -@Injectable({ - providedIn: 'root', -}) -export class SupplierStore extends EntityStore { - private readonly _inventoryState = { - isRefreshing: false, - }; - - constructor( - private activeRoute: ActivatedRoute, - private service: SuppliersService, - private toastService: ToastService, - ) { - super({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - entities: {}, - selectedId: null, - ids: [], - }); - this.initial(); - } - - initial() {} - - getSingle(supplierId: string) { - if (this.entities()[supplierId]) { - return; - } - this.patchState({ loading: true }); - this.service.getSingle(supplierId).subscribe({ - next: (res) => { - this.patchState({ - entities: { [res.id]: res }, - loading: false, - }); - }, - error: (err) => { - this.patchState({ loading: false, error: err }); - this.toastService.error({ - text: 'خطا در دریافت اطلاعات انبار', - }); - }, - }); - } - - refreshSingle(supplierId: string) {} - - reset(): void { - const queryParams = this.activeRoute.snapshot.queryParams; - this.setState({ - loading: false, - initialized: false, - error: null, - isRefreshing: false, - entities: {}, - selectedId: null, - ids: [], - }); - } -} diff --git a/src/app/modules/suppliers/views/index.ts b/src/app/modules/suppliers/views/index.ts deleted file mode 100644 index bc9dfc9..0000000 --- a/src/app/modules/suppliers/views/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './list.component'; -export * from './single.component'; diff --git a/src/app/modules/suppliers/views/invoice.component.html b/src/app/modules/suppliers/views/invoice.component.html deleted file mode 100644 index e9d779b..0000000 --- a/src/app/modules/suppliers/views/invoice.component.html +++ /dev/null @@ -1,46 +0,0 @@ -
- - - - - - - -
-
- -
-
- -
-
- - @if (invoice()?.status) { - - } - -
-
- - - -
- @if (debtAmount() > 0) { -
- - - -
- } -
- - @if (invoice() && supplier()) { - - } -
diff --git a/src/app/modules/suppliers/views/invoice.component.ts b/src/app/modules/suppliers/views/invoice.component.ts deleted file mode 100644 index f53fd84..0000000 --- a/src/app/modules/suppliers/views/invoice.component.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { CatalogPurchaseReceiptStatusTagComponent } from '@/shared/catalog'; -import { KeyValueComponent } from '@/shared/components'; -import { InnerPagesHeaderComponent } from '@/shared/components/innerPagesHeader/inner-pages-header.component'; -import { PriceMaskDirective } from '@/shared/directives'; -import { Component, computed, inject, signal } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { ButtonDirective } from 'primeng/button'; -import { SupplierInvoicePayFormComponent } from '../components/invoices/pay-form.component'; -import { InvoicePaymentsComponent } from '../components/invoices/payments.component'; -import { SupplierInvoiceStore, SupplierStore } from '../store'; - -@Component({ - selector: 'app-supplier-invoice', - templateUrl: './invoice.component.html', - imports: [ - KeyValueComponent, - InnerPagesHeaderComponent, - CatalogPurchaseReceiptStatusTagComponent, - ButtonDirective, - SupplierInvoicePayFormComponent, - InvoicePaymentsComponent, - PriceMaskDirective, - ], -}) -export class SupplierInvoiceComponent { - private route = inject(ActivatedRoute); - private supplierStore = inject(SupplierStore); - private store = inject(SupplierInvoiceStore); - - constructor() { - this.supplierStore.getSingle(this.supplierId); - this.store.supplierId = this.supplierId; - this.store.getSingle(this.invoiceId); - console.log(this.supplierId); - } - - supplierId = this.route.snapshot.params['supplierId']; - invoiceId = this.route.snapshot.params['invoiceId']; - - showPayForm = signal(false); - - supplier = computed(() => this.supplierStore.entities()[this.supplierId]); - supplierLoading = this.supplierStore.loading; - - invoice = computed(() => this.store.entities()[this.invoiceId]); - loading = this.store.loading; - - pageTitle = computed(() => { - return 'فاکتور شماره ' + this.invoice()?.code; - }); - - debtAmount = computed(() => { - const invoice = this.invoice(); - if (!invoice) { - return 0; - } - return parseFloat(invoice.totalAmount) - parseFloat(invoice.paidAmount); - }); - - openPayForm() { - this.showPayForm.set(true); - } -} diff --git a/src/app/modules/suppliers/views/invoices.component.html b/src/app/modules/suppliers/views/invoices.component.html deleted file mode 100644 index d811107..0000000 --- a/src/app/modules/suppliers/views/invoices.component.html +++ /dev/null @@ -1,18 +0,0 @@ -
- -
- @if (supplier()) { -
- -
- } -
-
-
- @for (item of topBarCardDetails; track $index) { - - } -
-
- -
diff --git a/src/app/modules/suppliers/views/invoices.component.ts b/src/app/modules/suppliers/views/invoices.component.ts deleted file mode 100644 index 70181e4..0000000 --- a/src/app/modules/suppliers/views/invoices.component.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { KeyValueComponent } from '@/shared/components'; -import { DetailsInfoCardComponent } from '@/shared/components/detailsInfoCard/details-info-card.component'; -import { InnerPagesHeaderComponent } from '@/shared/components/innerPagesHeader/inner-pages-header.component'; -import { formatWithCurrency } from '@/utils'; -import { Component, computed, inject } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { SuppliersInvoicesComponent } from '../components/invoices/invoices.component'; -import { SupplierStore } from '../store'; - -@Component({ - selector: 'app-supplier-invoices', - templateUrl: './invoices.component.html', - imports: [ - KeyValueComponent, - SuppliersInvoicesComponent, - InnerPagesHeaderComponent, - DetailsInfoCardComponent, - ], -}) -export class SupplierInvoicesComponent { - private route = inject(ActivatedRoute); - private supplierStore = inject(SupplierStore); - constructor() { - this.supplierStore.getSingle(this.supplierId); - } - - supplierId = this.route.snapshot.params['supplierId']; - invoiceId = this.route.snapshot.params['invoiceId']; - - supplier = computed(() => this.supplierStore.entities()[this.supplierId]); - - supplierLoading = this.supplierStore.loading(); - - pageTitle = computed(() => `فاکتورهای ${this.supplier()?.fullname || ''}`); - - get topBarCardDetails() { - return [ - { - icon: 'pi pi-box', - label: 'تعداد فاکتورهای صادر شده', - value: this.supplier()?.receiptsOverview.count, - }, - { - icon: 'pi pi-dollar', - label: 'مجموع کل فاکتورها', - value: formatWithCurrency(this.supplier()?.receiptsOverview.totalPayment || 0), - }, - ]; - } -} diff --git a/src/app/modules/suppliers/views/list.component.html b/src/app/modules/suppliers/views/list.component.html deleted file mode 100644 index bb4d362..0000000 --- a/src/app/modules/suppliers/views/list.component.html +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/src/app/modules/suppliers/views/list.component.ts b/src/app/modules/suppliers/views/list.component.ts deleted file mode 100644 index 06a3c59..0000000 --- a/src/app/modules/suppliers/views/list.component.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { - IColumn, - PageDataListComponent, -} from '@/shared/components/pageDataList/page-data-list.component'; -import { Component, signal } from '@angular/core'; -import { Router } from '@angular/router'; -import { SupplierFormComponent } from '../components/form.component'; -import { ISupplierResponse } from '../models'; -import { SuppliersService } from '../services/main.service'; - -@Component({ - selector: 'app-suppliers', - templateUrl: './list.component.html', - imports: [PageDataListComponent, SupplierFormComponent], -}) -export class SuppliersComponent { - constructor( - private supplierService: SuppliersService, - private router: Router, - ) { - this.getData(); - } - - columns = [ - { - field: 'name', - header: 'نام', - customDataModel(item) { - return `${item.firstName} ${item.lastName}` || '-'; - }, - }, - { field: 'mobileNumber', header: 'شماره موبایل' }, - { field: 'address', header: 'آدرس' }, - { - field: 'isActive', - header: 'وضعیت', - customDataModel(item) { - return item.isActive ? 'فعال' : 'غیرفعال'; - }, - }, - { field: 'createdAt', header: 'تاریخ ایجاد', type: 'date' }, - { field: 'updatedAt', header: 'تاریخ به‌روزرسانی', type: 'date' }, - ] as IColumn[]; - - loading = signal(false); - items = signal([]); - visibleForm = signal(false); - - refresh() { - this.getData(); - } - - getData() { - this.loading.set(true); - this.supplierService.getAll().subscribe((res) => { - this.loading.set(false); - this.items.set(res.data); - }); - } - - openAddForm() { - this.visibleForm.set(true); - } - - toDetails(supplier: ISupplierResponse) { - this.router.navigate(['/suppliers', supplier.id]); - } -} diff --git a/src/app/modules/suppliers/views/purchase.component.html b/src/app/modules/suppliers/views/purchase.component.html deleted file mode 100644 index 4e9e9ad..0000000 --- a/src/app/modules/suppliers/views/purchase.component.html +++ /dev/null @@ -1,4 +0,0 @@ -@if (loading()) { -} @else { - -} diff --git a/src/app/modules/suppliers/views/purchase.component.ts b/src/app/modules/suppliers/views/purchase.component.ts deleted file mode 100644 index 7807efe..0000000 --- a/src/app/modules/suppliers/views/purchase.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { PurchaseReceiptTemplateComponent } from '@/modules/purchases/components'; -import { Component, computed, inject } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { SupplierStore } from '../store'; - -@Component({ - selector: 'app-inventory-purchase', - templateUrl: './purchase.component.html', - imports: [PurchaseReceiptTemplateComponent], -}) -export class InventoryPurchaseComponent { - private readonly route = inject(ActivatedRoute); - private readonly store = inject(SupplierStore); - - supplierId = this.route.snapshot.paramMap.get('supplierId')!; - - supplier = computed(() => this.store.entities()[this.supplierId]); - loading = this.store.loading; - constructor() { - this.store.getSingle(this.supplierId); - } -} diff --git a/src/app/modules/suppliers/views/single.component.html b/src/app/modules/suppliers/views/single.component.html deleted file mode 100644 index b95b6ec..0000000 --- a/src/app/modules/suppliers/views/single.component.html +++ /dev/null @@ -1,38 +0,0 @@ -
-
-
-
- -

{{ data()?.fullname }}

-
-
-
- - - -
-
-
-
- -
-
- -
-
- @for (item of topBarCardDetails; track $index) { - - } -
-
- -
- -
-
diff --git a/src/app/modules/suppliers/views/single.component.ts b/src/app/modules/suppliers/views/single.component.ts deleted file mode 100644 index b9b2206..0000000 --- a/src/app/modules/suppliers/views/single.component.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { Maybe } from '@/core'; -import { KeyValueComponent } from '@/shared/components'; -import { DetailsInfoCardComponent } from '@/shared/components/detailsInfoCard/details-info-card.component'; -import { formatWithCurrency } from '@/utils'; -import { Component, inject, signal } from '@angular/core'; -import { ActivatedRoute, RouterLink } from '@angular/router'; -import { Button, ButtonDirective } from 'primeng/button'; -import { SuppliersInvoicesComponent } from '../components/invoices/invoices.component'; -import { SupplierLedgerComponent } from '../components/ledger/ledger.component'; -import { ISupplierFullInfoResponse } from '../models'; -import { SuppliersService } from '../services/main.service'; - -@Component({ - selector: 'app-supplier', - templateUrl: './single.component.html', - imports: [ - DetailsInfoCardComponent, - KeyValueComponent, - Button, - RouterLink, - ButtonDirective, - SuppliersInvoicesComponent, - SupplierLedgerComponent, - ], -}) -export class SupplierComponent { - private route = inject(ActivatedRoute); - constructor(private service: SuppliersService) { - this.getInfo(); - } - - supplierId = this.route.snapshot.params['supplierId']; - - data = signal>(null); - loading = signal>(true); - - getInfo() { - this.loading.set(true); - this.service.getSingle(this.supplierId).subscribe({ - next: (res) => { - this.loading.set(false); - this.data.set(res); - }, - error: (err) => { - this.loading.set(false); - }, - }); - } - - get topBarCardDetails() { - return [ - { - icon: 'pi pi-box', - label: 'تعداد فاکتورهای صادر شده', - value: this.data()?.receiptsOverview.count, - }, - { - icon: 'pi pi-dollar', - label: 'مجموع کل فاکتورها', - value: formatWithCurrency(this.data()?.receiptsOverview.totalPayment || 0), - }, - ]; - } -}