-
-
-
{{ product()?.name }}
+ @if (loading()) {
+
+ } @else if (product()) {
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
- @for (item of topBarCardDetails; track $index) {
-
- }
-
-
-
-
-
-
توضیحات
-
{{ product()?.description || "بدون توضیحات" }}
-
-
-
-
-
دستهبندی
-
{{ product()?.category?.name || "بدون دستهبندی" }}
-
-
-
-
برند
-
{{ product()?.brand?.name || "بدون برند" }}
-
-
-
+
+
+
+
+
+
+ @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
index 1b79e6a..2cf667d 100644
--- a/src/app/modules/products/views/single.component.ts
+++ b/src/app/modules/products/views/single.component.ts
@@ -2,12 +2,15 @@ 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 { Button, ButtonDirective } from 'primeng/button';
+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';
@@ -20,9 +23,11 @@ import { ProductsService } from '../services/main.service';
GalleriaModule,
KeyValueComponent,
Card,
- Button,
PurchaseFormComponent,
DetailsInfoCardComponent,
+ ProgressSpinner,
+ SimpleStockTextAlertComponent,
+ InnerPagesHeaderComponent,
],
})
export class ProductComponent {
@@ -79,11 +84,6 @@ export class ProductComponent {
get topBarCardDetails() {
return [
- {
- icon: 'pi pi-box',
- label: 'موجودی',
- value: this.product()?.stock || 0,
- },
{
icon: 'pi pi-dollar',
label: 'قیمت پایه',
@@ -102,7 +102,7 @@ export class ProductComponent {
{
icon: 'pi pi-clock',
label: 'تعداد فروش',
- value: '-',
+ value: this.product()?.salesCount || 0,
},
];
}
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
index 4a0597a..9ba1d18 100644
--- a/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-template.component.html
+++ b/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-template.component.html
@@ -178,4 +178,8 @@
+
+ @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
index ef567f4..312bb11 100644
--- a/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-template.component.ts
+++ b/src/app/modules/purchases/components/receiptTemplate/purchase-receipt-template.component.ts
@@ -7,6 +7,7 @@ import { SuppliersSelectComponent } from '@/modules/suppliers/components/select/
import { ISupplierResponse } from '@/modules/suppliers/models';
import { InlineEditComponent, 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';
@@ -16,7 +17,7 @@ import dayjs from 'dayjs';
import { ButtonDirective } from 'primeng/button';
import { Card } from 'primeng/card';
import { TableModule } from 'primeng/table';
-import { IPurchaseRequest } from '../../models';
+import { IPurchaseReceiptResponse, IPurchaseRequest } from '../../models';
import { PurchasesService } from '../../services/main.service';
import { PurchaseReceiptProductRowComponent } from './purchase-receipt-product-row.component';
@@ -39,6 +40,7 @@ import { PurchaseReceiptProductRowComponent } from './purchase-receipt-product-r
CommonModule,
ReactiveFormsModule,
UikitFlatpickrJalaliComponent,
+ PurchaseReceiptPaymentWrapperComponent,
],
})
export class PurchaseReceiptTemplateComponent {
@@ -142,6 +144,7 @@ export class PurchaseReceiptTemplateComponent {
}
formIsSubmitted = signal(false);
+ purchaseReceiptResponse = signal
>(null);
ngOnInit() {
this.formIsSubmitted.set(false);
@@ -203,6 +206,7 @@ export class PurchaseReceiptTemplateComponent {
// 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();
diff --git a/src/app/modules/purchases/models/io.d.ts b/src/app/modules/purchases/models/io.d.ts
index 4585168..3a0ce28 100644
--- a/src/app/modules/purchases/models/io.d.ts
+++ b/src/app/modules/purchases/models/io.d.ts
@@ -1,6 +1,6 @@
import { Maybe } from '@/core';
-export interface IPurchaseRawResponse {
+export interface IPurchaseReceiptRawResponse {
id: number;
totalAmount: number;
inventoryId: number;
@@ -12,7 +12,7 @@ export interface IPurchaseRawResponse {
deletedAt?: string;
}
-export interface IPurchaseResponse extends IPurchaseRawResponse {}
+export interface IPurchaseReceiptResponse extends IPurchaseReceiptRawResponse {}
export interface IPurchaseItemRawResponse {
id: number;
diff --git a/src/app/modules/purchases/services/main.service.ts b/src/app/modules/purchases/services/main.service.ts
index 36caf57..8922e87 100644
--- a/src/app/modules/purchases/services/main.service.ts
+++ b/src/app/modules/purchases/services/main.service.ts
@@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { PURCHASES_API_ROUTES } from '../constants';
-import { IPurchaseRawResponse, IPurchaseRequest, IPurchaseResponse } from '../models';
+import { IPurchaseReceiptRawResponse, IPurchaseReceiptResponse, IPurchaseRequest } from '../models';
@Injectable({
providedIn: 'root',
@@ -10,15 +10,15 @@ import { IPurchaseRawResponse, IPurchaseRequest, IPurchaseResponse } from '../mo
export class PurchasesService {
private http = inject(HttpClient);
- getAll(): Observable<{ data: IPurchaseRawResponse[] }> {
- return this.http.get<{ data: IPurchaseResponse[] }>(PURCHASES_API_ROUTES.getAll);
+ getAll(): Observable<{ data: IPurchaseReceiptRawResponse[] }> {
+ return this.http.get<{ data: IPurchaseReceiptResponse[] }>(PURCHASES_API_ROUTES.getAll);
}
- getSingle(id: number): Observable<{ data: IPurchaseResponse }> {
- return this.http.get<{ data: IPurchaseResponse }>(PURCHASES_API_ROUTES.getSingle(id));
+ getSingle(id: number): Observable<{ data: IPurchaseReceiptResponse }> {
+ return this.http.get<{ data: IPurchaseReceiptResponse }>(PURCHASES_API_ROUTES.getSingle(id));
}
- create(data: IPurchaseRequest): Observable<{ data: IPurchaseRawResponse }> {
- return this.http.post<{ data: IPurchaseResponse }>(PURCHASES_API_ROUTES.create, data);
+ create(data: IPurchaseRequest): Observable {
+ return this.http.post(PURCHASES_API_ROUTES.create, data);
}
}
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
new file mode 100644
index 0000000..b61133d
--- /dev/null
+++ b/src/app/modules/suppliers/components/invoices/pay-form-template.component.html
@@ -0,0 +1,13 @@
+
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
new file mode 100644
index 0000000..7be79b3
--- /dev/null
+++ b/src/app/modules/suppliers/components/invoices/pay-form-template.component.ts
@@ -0,0 +1,57 @@
+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
index f4cbce7..f3bb767 100644
--- a/src/app/modules/suppliers/components/invoices/pay-form.component.html
+++ b/src/app/modules/suppliers/components/invoices/pay-form.component.html
@@ -6,18 +6,11 @@
appendTo="body"
[closable]="true"
>
-
+
diff --git a/src/app/modules/suppliers/components/invoices/pay-form.component.ts b/src/app/modules/suppliers/components/invoices/pay-form.component.ts
index 9f2254e..3f64ec4 100644
--- a/src/app/modules/suppliers/components/invoices/pay-form.component.ts
+++ b/src/app/modules/suppliers/components/invoices/pay-form.component.ts
@@ -1,9 +1,5 @@
-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 { AbstractFormDialog } from '@/shared/components/abstract-form-dialog.component';
-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';
@@ -11,18 +7,12 @@ 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,
- InventoryBankAccountSelectComponent,
- FormFooterActionsComponent,
- InputComponent,
- PaymentMethodTypeSelectComponent,
- ],
+ imports: [Dialog, ReactiveFormsModule, SupplierInvoicePayFormTemplateComponent],
})
export class SupplierInvoicePayFormComponent extends AbstractFormDialog<
IPayResponse,
diff --git a/src/app/modules/suppliers/constants/routes/index.ts b/src/app/modules/suppliers/constants/routes/index.ts
index 474af8b..2f71b83 100644
--- a/src/app/modules/suppliers/constants/routes/index.ts
+++ b/src/app/modules/suppliers/constants/routes/index.ts
@@ -36,6 +36,15 @@ export const suppliersNamedRoutes: NamedRoutes = {
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];
diff --git a/src/app/modules/suppliers/views/invoice.component.html b/src/app/modules/suppliers/views/invoice.component.html
index ebba74a..e9d779b 100644
--- a/src/app/modules/suppliers/views/invoice.component.html
+++ b/src/app/modules/suppliers/views/invoice.component.html
@@ -20,6 +20,18 @@
}