Files
psp_panel/src/app/modules/suppliers/store/invoice.store.ts
T
ahasani 879e29f54f feat: enhance input component to support price type and add new payment method components
- Updated InputComponent to handle 'price' type with appropriate formatting and validation.
- Introduced new API routes for purchase receipt payments.
- Created constants for purchase receipts and invoices.
- Developed SupplierInvoicePayFormComponent for processing invoice payments.
- Implemented SupplierLedgerComponent to display supplier transactions.
- Added services and stores for managing supplier invoices and payments.
- Created components for selecting payment methods and displaying payment type tags.
- Enhanced UI with new templates for invoices and payment forms.
- Added utility functions for handling payment method types and statuses.
2025-12-27 20:35:02 +03:30

79 lines
1.9 KiB
TypeScript

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<ISupplierInvoicesResponse> {}
export const SUPPLIER_ID = new InjectionToken<string>('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: [],
});
}
}