add salesInvoice in pos of consumer domain
This commit is contained in:
-7
@@ -8,13 +8,6 @@
|
||||
>
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||
<app-input label="سریال دستگاه" [control]="form.controls.serial" name="serial" />
|
||||
<!-- <app-input label="مدل دستگاه" [control]="form.controls.model" name="model" /> -->
|
||||
<app-enum-select [control]="form.controls.pos_type" type="posType" name="pos_type" />
|
||||
@if (form.controls.pos_type.value === "PSP") {
|
||||
<catalog-device-select [control]="form.controls.device_id" />
|
||||
<catalog-provider-select [control]="form.controls.provider_id" />
|
||||
}
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
|
||||
+1
-28
@@ -34,35 +34,8 @@ export class ConsumerPosFormComponent extends AbstractFormDialog<IPosRequest, IP
|
||||
initForm = () => {
|
||||
const form = this.fb.group({
|
||||
name: [this.initialValues?.name || '', [Validators.required]],
|
||||
serial: [this.initialValues?.serial || '', [Validators.required]],
|
||||
// model: [this.initialValues?.model || '', [Validators.required]],
|
||||
pos_type: [this.initialValues?.pos_type || '', [Validators.required]],
|
||||
device_id: [this.initialValues?.device?.id || ''],
|
||||
provider_id: [this.initialValues?.provider?.id || ''],
|
||||
});
|
||||
form.controls.pos_type.valueChanges.subscribe((value) => {
|
||||
if (value === 'PSP') {
|
||||
form.addControl(
|
||||
'device_id',
|
||||
this.fb.control<string>(this.initialValues?.device?.id ?? '', {
|
||||
nonNullable: true,
|
||||
validators: [Validators.required],
|
||||
}),
|
||||
);
|
||||
form.addControl(
|
||||
'provider_id',
|
||||
this.fb.control<string>(this.initialValues?.provider?.id ?? '', {
|
||||
nonNullable: true,
|
||||
validators: [Validators.required],
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
// @ts-ignore
|
||||
form.removeControl('device_id');
|
||||
// @ts-ignore
|
||||
form.removeControl('provider_id');
|
||||
}
|
||||
});
|
||||
|
||||
return form;
|
||||
};
|
||||
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<app-page-data-list
|
||||
pageTitle="لیست فاکتورهای صادر شده"
|
||||
[columns]="columns"
|
||||
emptyPlaceholderTitle="تا به حال فاکتور فروشی توسط این پایانه ایجاد نشده است."
|
||||
[items]="items()"
|
||||
[loading]="loading()"
|
||||
>
|
||||
</app-page-data-list>
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||
import {
|
||||
IColumn,
|
||||
PageDataListComponent,
|
||||
} from '@/shared/components/pageDataList/page-data-list.component';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ISalesInvoicesResponse } from '../../models';
|
||||
import { ConsumerSalesInvoicesService } from '../../services/invoices.service';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-salesInvoices-list',
|
||||
templateUrl: './list.component.html',
|
||||
imports: [PageDataListComponent],
|
||||
})
|
||||
export class ConsumerSalesInvoicesComponent extends AbstractList<ISalesInvoicesResponse> {
|
||||
@Input({ required: true }) complexId!: string;
|
||||
@Input({ required: true }) posId!: string;
|
||||
@Input() fullHeight?: boolean;
|
||||
@Input() header: IColumn[] = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'code', header: 'کد رهگیری' },
|
||||
{ field: 'total_amount', header: 'مبلغ کل', type: 'price' },
|
||||
{
|
||||
field: 'items_count',
|
||||
header: 'تعداد کالاها',
|
||||
customDataModel(item) {
|
||||
return `${item.items.length} عدد`;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'invoice_date',
|
||||
header: 'تاریخ',
|
||||
type: 'date',
|
||||
},
|
||||
];
|
||||
|
||||
private readonly service = inject(ConsumerSalesInvoicesService);
|
||||
|
||||
override setColumns(): void {
|
||||
this.columns = this.header;
|
||||
}
|
||||
|
||||
override getDataRequest() {
|
||||
return this.service.getAll(this.complexId, this.posId);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
const baseUrl = (complexId: string, posId: string) =>
|
||||
`/api/v1/consumer/complexes/${complexId}/poses/${posId}/sales_invoices`;
|
||||
|
||||
export const POS_SALES_INVOICES_API_ROUTES = {
|
||||
list: (complexId: string, posId: string) => `${baseUrl(complexId, posId)}`,
|
||||
single: (complexId: string, posId: string, invoiceId: string) =>
|
||||
`${baseUrl(complexId, posId)}/${invoiceId}`,
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './complexes_io';
|
||||
export * from './io';
|
||||
export * from './poses_io';
|
||||
export * from './salesInvoices_io';
|
||||
|
||||
@@ -15,10 +15,4 @@ export interface IPosResponse extends IPosRawResponse {}
|
||||
|
||||
export interface IPosRequest {
|
||||
name: string;
|
||||
serial: string;
|
||||
model?: string;
|
||||
status: string;
|
||||
pos_type: string;
|
||||
device_id: string;
|
||||
provider_id: string;
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
import ISummary from '@/core/models/summary';
|
||||
import { TCustomerInfo, TPosOrderGoodPayload } from '@/domains/pos/modules/landing/models';
|
||||
import { UnitType } from '@/utils';
|
||||
|
||||
export interface ISalesInvoicesRawResponse {
|
||||
id: string;
|
||||
code: string;
|
||||
invoice_date: string;
|
||||
total_amount: string;
|
||||
items: Item[];
|
||||
payments: Payment[];
|
||||
customer?: TCustomerInfo;
|
||||
notes?: string;
|
||||
unknown_customer?: UnknownCustomer;
|
||||
}
|
||||
export interface ISalesInvoicesResponse extends ISalesInvoicesRawResponse {}
|
||||
|
||||
export interface ISalesInvoicesRequest {}
|
||||
|
||||
interface UnknownCustomer {
|
||||
name?: string;
|
||||
national_code?: string;
|
||||
}
|
||||
|
||||
interface Payment {
|
||||
amount: string;
|
||||
paid_at: string;
|
||||
payment_method: string;
|
||||
}
|
||||
|
||||
interface Item {
|
||||
unit_type: UnitType;
|
||||
discount: string;
|
||||
quantity: string;
|
||||
total_amount: string;
|
||||
unit_price: string;
|
||||
payload: TPosOrderGoodPayload;
|
||||
good: Good;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
interface Good {
|
||||
id: string;
|
||||
name: string;
|
||||
sku: string;
|
||||
barcode: null;
|
||||
local_sku: null;
|
||||
pricing_model: string;
|
||||
unit_type: string;
|
||||
category: ISummary;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { IPaginatedResponse } from '@/core/models/service.model';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { POS_SALES_INVOICES_API_ROUTES } from '../constants/apiRoutes/posSalesInvoices';
|
||||
import { ISalesInvoicesRawResponse, ISalesInvoicesResponse } from '../models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ConsumerSalesInvoicesService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
private apiRoutes = POS_SALES_INVOICES_API_ROUTES;
|
||||
|
||||
getAll(complexId: string, posId: string): Observable<IPaginatedResponse<ISalesInvoicesResponse>> {
|
||||
return this.http.get<IPaginatedResponse<ISalesInvoicesRawResponse>>(
|
||||
this.apiRoutes.list(complexId, posId),
|
||||
);
|
||||
}
|
||||
getSingle(
|
||||
complexId: string,
|
||||
posId: string,
|
||||
invoiceId: string,
|
||||
): Observable<ISalesInvoicesResponse> {
|
||||
return this.http.get<ISalesInvoicesRawResponse>(
|
||||
this.apiRoutes.single(complexId, posId, invoiceId),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,17 @@
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="عنوان" [value]="pos()?.name" />
|
||||
<app-key-value label="شماره سریال" [value]="pos()?.serial" />
|
||||
<app-key-value label="نوع پایانه" [value]="pos()?.pos_type" />
|
||||
<app-key-value label="نوع دستگاه" [value]="pos()?.device?.name" />
|
||||
<app-key-value label="مدل دستگاه" [value]="pos()?.model" />
|
||||
<app-key-value label="ارایهدهنده" [value]="pos()?.provider?.name" />
|
||||
</div>
|
||||
</div>
|
||||
</app-card-data>
|
||||
|
||||
<consumer-salesInvoices-list [complexId]="complexId()" [posId]="posId()" />
|
||||
|
||||
<consumer-pos-form
|
||||
[(visible)]="editMode"
|
||||
[editMode]="true"
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { CookieService } from 'ngx-cookie-service';
|
||||
import { Button } from 'primeng/button';
|
||||
import { ConsumerPosFormComponent } from '../../components/poses/form.component';
|
||||
import { ConsumerSalesInvoicesComponent } from '../../components/salesInvoices/list.component';
|
||||
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||
import { ConsumerComplexStore } from '../../store/complex.store';
|
||||
import { PosStore } from '../../store/pos.store';
|
||||
@@ -13,7 +14,13 @@ import { PosStore } from '../../store/pos.store';
|
||||
@Component({
|
||||
selector: 'superAdmin-user-pos',
|
||||
templateUrl: './single.component.html',
|
||||
imports: [AppCardComponent, KeyValueComponent, ConsumerPosFormComponent, Button],
|
||||
imports: [
|
||||
AppCardComponent,
|
||||
KeyValueComponent,
|
||||
ConsumerPosFormComponent,
|
||||
Button,
|
||||
ConsumerSalesInvoicesComponent,
|
||||
],
|
||||
})
|
||||
export class SuperAdminUserPosComponent {
|
||||
private readonly businessStore = inject(BusinessActivityStore);
|
||||
|
||||
@@ -9,6 +9,7 @@ export interface IGoodRawResponse {
|
||||
unit_type: UnitType;
|
||||
pricing_model: string;
|
||||
description?: string;
|
||||
is_default_guild_good: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
+6
-6
@@ -24,23 +24,23 @@ export class CustomerIndividualFormComponent extends AbstractForm<
|
||||
override showSuccessMessage = false;
|
||||
form = this.fb.group({
|
||||
first_name: [
|
||||
this.store.customer().info?.customerIndividuals?.first_name || '',
|
||||
this.store.customer().info?.customer_individual?.first_name || '',
|
||||
[Validators.required],
|
||||
],
|
||||
last_name: [
|
||||
this.store.customer().info?.customerIndividuals?.last_name || '',
|
||||
this.store.customer().info?.customer_individual?.last_name || '',
|
||||
[Validators.required],
|
||||
],
|
||||
national_id: [
|
||||
this.store.customer().info?.customerIndividuals?.national_id || '',
|
||||
this.store.customer().info?.customer_individual?.national_id || '',
|
||||
[Validators.required, nationalIdValidator()],
|
||||
],
|
||||
economic_code: [
|
||||
this.store.customer().info?.customerIndividuals?.economic_code || '',
|
||||
this.store.customer().info?.customer_individual?.economic_code || '',
|
||||
[Validators.required],
|
||||
],
|
||||
postal_code: [
|
||||
this.store.customer().info?.customerIndividuals?.postal_code || '',
|
||||
this.store.customer().info?.customer_individual?.postal_code || '',
|
||||
[postalCodeValidator()],
|
||||
],
|
||||
});
|
||||
@@ -52,7 +52,7 @@ export class CustomerIndividualFormComponent extends AbstractForm<
|
||||
customer_id: '',
|
||||
type: CustomerType.INDIVIDUAL,
|
||||
info: {
|
||||
customerIndividuals: info,
|
||||
customer_individual: info,
|
||||
},
|
||||
});
|
||||
return observer.next(info);
|
||||
|
||||
@@ -21,19 +21,19 @@ export class CustomerLegalFormComponent extends AbstractForm<ILegalCustomer, ILe
|
||||
|
||||
form = this.fb.group({
|
||||
company_name: [
|
||||
this.store.customer().info?.customerLegals?.company_name || '',
|
||||
this.store.customer().info?.customer_legal?.company_name || '',
|
||||
[Validators.required],
|
||||
],
|
||||
registration_number: [
|
||||
this.store.customer().info?.customerLegals?.registration_number || '',
|
||||
this.store.customer().info?.customer_legal?.registration_number || '',
|
||||
[Validators.required],
|
||||
],
|
||||
economic_code: [
|
||||
this.store.customer().info?.customerLegals?.economic_code || '',
|
||||
this.store.customer().info?.customer_legal?.economic_code || '',
|
||||
[Validators.required],
|
||||
],
|
||||
postal_code: [
|
||||
this.store.customer().info?.customerLegals?.postal_code || '',
|
||||
this.store.customer().info?.customer_legal?.postal_code || '',
|
||||
[postalCodeValidator()],
|
||||
],
|
||||
});
|
||||
@@ -45,7 +45,7 @@ export class CustomerLegalFormComponent extends AbstractForm<ILegalCustomer, ILe
|
||||
customer_id: '',
|
||||
type: CustomerType.LEGAL,
|
||||
info: {
|
||||
customerLegals: info,
|
||||
customer_legal: info,
|
||||
},
|
||||
});
|
||||
return observer.next(info);
|
||||
|
||||
@@ -20,10 +20,10 @@ export class CustomerUnknownFormComponent extends AbstractForm<IUnknownCustomer,
|
||||
override showSuccessMessage = false;
|
||||
form = this.fb.group({
|
||||
national_id: [
|
||||
this.store?.customer().info?.customerUnknown?.national_id || '',
|
||||
this.store?.customer().info?.customer_unknown?.national_id || '',
|
||||
[nationalIdValidator()],
|
||||
],
|
||||
name: [this.store?.customer().info?.customerUnknown?.name || ''],
|
||||
name: [this.store?.customer().info?.customer_unknown?.name || ''],
|
||||
});
|
||||
|
||||
override submitForm() {
|
||||
@@ -33,7 +33,7 @@ export class CustomerUnknownFormComponent extends AbstractForm<IUnknownCustomer,
|
||||
customer_id: '',
|
||||
type: CustomerType.UNKNOWN,
|
||||
info: {
|
||||
customerUnknown: info,
|
||||
customer_unknown: info,
|
||||
},
|
||||
});
|
||||
return observer.next(info);
|
||||
|
||||
@@ -12,11 +12,15 @@
|
||||
<div class="mt-2">
|
||||
<span class="text-lg font-bold">
|
||||
{{ good.name }}
|
||||
<!-- <small class="text-xs text-muted-color">({{ good.quantity }})</small> -->
|
||||
@if (!good.is_default_guild_good) {
|
||||
<small class="text-xs text-muted-color">*</small>
|
||||
}
|
||||
</span>
|
||||
<div class="flex items-center justify-between mt-1">
|
||||
<div class="flex items-center justify-between mt-1 w-full px-2 my-2">
|
||||
<!-- <span [appPriceMask]="good.salePrice" class="text-base font-bold"></span> -->
|
||||
<button pButton type="button" icon="pi pi-plus" size="small" (click)="addProduct(good)"></button>
|
||||
<button pButton type="button" icon="pi pi-plus" size="small" class="w-full!" (click)="addProduct(good)">
|
||||
انتخاب
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
<div class="flex flex-col gap-2">
|
||||
<span class="text-lg font-bold">
|
||||
{{ good.name }}
|
||||
@if (!good.is_default_guild_good) {
|
||||
<small class="text-xs text-muted-color">*</small>
|
||||
}
|
||||
<!-- <small class="text-xs text-muted-color">({{ good.quantity }})</small> -->
|
||||
</span>
|
||||
<span class="text-sm text-muted-color">
|
||||
@@ -22,7 +25,7 @@
|
||||
</div>
|
||||
<div class="shrink-0 flex items-center justify-between gap-3">
|
||||
<!-- <span [appPriceMask]="good.salePrice" class="text-base font-bold"></span> -->
|
||||
<button pButton type="button" icon="pi pi-plus" size="small" (click)="addGood(good)"></button>
|
||||
<button pButton type="button" icon="pi pi-plus" size="small" (click)="addGood(good)">انتخاب</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<div class="bg-surface-card w-md shrink-0 h-full overflow-hidden rounded-xl p-4 pb-0 flex flex-col">
|
||||
<div class="grow overflow-auto flex flex-col">
|
||||
<div class="flex gap-2 items-center justify-between shrink-0">
|
||||
<app-key-value label="مشتری" [value]="customerNameToShow()" />
|
||||
<button pButton outlined icon="pi pi-pencil" size="small" (click)="openCustomerDialog()"></button>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="grow flex flex-col overflow-hidden">
|
||||
<div class="flex items-center justify-between shrink-0">
|
||||
<div class="flex items-center gap-2 text-muted-color">
|
||||
<i class="pi pi-shopping-cart"></i>
|
||||
@@ -20,7 +15,7 @@
|
||||
<span class="text-lg text-muted-color">هیچ سفارشی ثبت نشده است.</span>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="flex flex-col gap-2 mt-3">
|
||||
<div class="flex flex-col gap-2 mt-3 overflow-auto">
|
||||
@for (inOrderGood of inOrderGoods(); track inOrderGood.id) {
|
||||
@if (inOrderGood.good.pricing_model === "GOLD") {
|
||||
<gold-payload-order-card [orderItem]="inOrderGood" />
|
||||
@@ -31,20 +26,25 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="flex flex-col sticky bottom-0 py-2">
|
||||
<hr />
|
||||
<div class="flex flex-col gap-4 sticky bottom-0 py-2">
|
||||
<p-card class="border border-surface-border">
|
||||
<div class="flex gap-2 items-center justify-between shrink-0">
|
||||
<app-key-value label="مشتری" [value]="customerNameToShow()" />
|
||||
<button pButton outlined icon="pi pi-pencil" size="small" (click)="openCustomerDialog()"></button>
|
||||
</div>
|
||||
</p-card>
|
||||
<pos-order-price-info-card />
|
||||
<div class="sticky bottom-0 pt-4">
|
||||
<button
|
||||
pButton
|
||||
type="button"
|
||||
label="ثبت و پرداخت"
|
||||
severity="primary"
|
||||
icon="pi pi-check"
|
||||
class="w-full"
|
||||
[attr.disabled]="inOrderGoods().length === 0 ? true : null"
|
||||
(click)="submitAndPay()"
|
||||
></button>
|
||||
</div>
|
||||
<button
|
||||
pButton
|
||||
type="button"
|
||||
label="ثبت و پرداخت"
|
||||
severity="primary"
|
||||
icon="pi pi-check"
|
||||
class="w-full"
|
||||
[attr.disabled]="inOrderGoods().length === 0 ? true : null"
|
||||
(click)="submitAndPay()"
|
||||
></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { KeyValueComponent } from '@/shared/components';
|
||||
import { Component, computed, inject, signal } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import { Card } from 'primeng/card';
|
||||
import images from 'src/assets/images';
|
||||
import { PosLandingStore } from '../../store/main.store';
|
||||
import { PosOrderCustomerDialogComponent } from '../customers/customer-dialog.component';
|
||||
@@ -24,6 +25,7 @@ import { POSOrderPriceInfoCardComponent } from './price-info-card.component';
|
||||
PosOrderCustomerDialogComponent,
|
||||
KeyValueComponent,
|
||||
PosPaymentFormDialogComponent,
|
||||
Card,
|
||||
],
|
||||
})
|
||||
export class PosOrderSectionComponent {
|
||||
@@ -44,13 +46,13 @@ export class PosOrderSectionComponent {
|
||||
|
||||
switch (type) {
|
||||
case 'UNKNOWN':
|
||||
customerNameToShow = `${info?.customerUnknown?.name || 'نامشخص'} (نوع دوم)`;
|
||||
customerNameToShow = `${info?.customer_unknown?.name || 'نامشخص'} (نوع دوم)`;
|
||||
break;
|
||||
case 'INDIVIDUAL':
|
||||
customerNameToShow = `${info?.customerIndividuals ? info?.customerIndividuals.first_name + ' ' + info?.customerIndividuals.last_name : 'نامشخص'} (نوع اول)`;
|
||||
customerNameToShow = `${info?.customer_individual ? info?.customer_individual.first_name + ' ' + info?.customer_individual.last_name : 'نامشخص'} (نوع اول)`;
|
||||
break;
|
||||
case 'LEGAL':
|
||||
customerNameToShow = `${info?.customerLegals?.company_name || 'نامشخص'} (نوع اول)`;
|
||||
customerNameToShow = `${info?.customer_legal?.company_name || 'نامشخص'} (نوع اول)`;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
submitLabel="ثبت اطلاعات پرداخت و ادامه"
|
||||
[loading]="submitOrderLoading()"
|
||||
(onCancel)="close()"
|
||||
(onSubmit)="submit()"
|
||||
/>
|
||||
</form>
|
||||
</p-dialog>
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Component, computed, inject, signal } from '@angular/core';
|
||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError, throwError } from 'rxjs';
|
||||
import { IPayment, TOrderPaymentTypes } from '../../models';
|
||||
import { PosLandingStore } from '../../store/main.store';
|
||||
|
||||
@@ -90,6 +90,8 @@ export class PosPaymentFormDialogComponent extends AbstractFormDialog<IPayment,
|
||||
}
|
||||
}
|
||||
|
||||
override showSuccessMessage = false;
|
||||
|
||||
override submitForm() {
|
||||
if (this.remainedAmount() > 0) {
|
||||
return this.toastServices.warn({
|
||||
@@ -100,16 +102,19 @@ export class PosPaymentFormDialogComponent extends AbstractFormDialog<IPayment,
|
||||
const payment = this.form.value as IPayment;
|
||||
this.store.setPayment(payment);
|
||||
|
||||
this.store.submitOrder().then((res) => {
|
||||
if (res) {
|
||||
this.store
|
||||
.submitOrder()
|
||||
.pipe(
|
||||
catchError((err) => {
|
||||
return throwError(() => err);
|
||||
}),
|
||||
)
|
||||
.subscribe(() => {
|
||||
this.close();
|
||||
this.toastServices.success({
|
||||
text: 'فاکتور شما با موفقیت ایجاد شد',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return new Observable<IPayment>((observer) => observer.next(payment));
|
||||
});
|
||||
}
|
||||
|
||||
override onSuccess(response: IPayment): void {}
|
||||
|
||||
@@ -20,9 +20,9 @@ export interface IUnknownCustomer {
|
||||
}
|
||||
|
||||
export interface ICustomer {
|
||||
customerIndividuals?: IIndividualCustomer;
|
||||
customerLegals?: ILegalCustomer;
|
||||
customerUnknown?: IUnknownCustomer;
|
||||
customer_individual?: IIndividualCustomer;
|
||||
customer_legal?: ILegalCustomer;
|
||||
customer_unknown?: IUnknownCustomer;
|
||||
}
|
||||
|
||||
export type TCustomerInfo = IIndividualCustomer | ILegalCustomer | IUnknownCustomer;
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ export interface IPosOrderRequest {
|
||||
items: IPosOrderItem[];
|
||||
notes?: string;
|
||||
customer_type?: CustomerType;
|
||||
customerId?: string;
|
||||
customer_id?: string;
|
||||
customer?: ICustomer;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { IGoodCategoryResponse, IGoodResponse } from '@/domains/pos/models/good.
|
||||
import { CustomerType } from '@/shared/localEnum/constants/customerTypes';
|
||||
import { createUUID, JALALI_DATE_FORMATS, nowJalali, parseJalali } from '@/utils';
|
||||
import { computed, inject, Injectable, signal } from '@angular/core';
|
||||
import { catchError, finalize, map, Observable, throwError } from 'rxjs';
|
||||
import { catchError, finalize, map, Observable } from 'rxjs';
|
||||
import { ICustomer, IPayment, IPosOrderRequest, IPosOrderResponse } from '../models';
|
||||
import { IPosInOrderGood, IPosOrderItem } from '../models/types';
|
||||
import { PosService } from '../services/main.service';
|
||||
@@ -208,10 +208,10 @@ export class PosLandingStore {
|
||||
this.setState({ payments });
|
||||
}
|
||||
|
||||
async submitOrder() {
|
||||
submitOrder() {
|
||||
this.setState({ submitOrderLoading: true });
|
||||
const orderPayload: IPosOrderRequest = {
|
||||
customerId: this.customer().customer_id,
|
||||
customer_id: this.customer().customer_id,
|
||||
customer_type: this.customer().type,
|
||||
customer: this.customer().info,
|
||||
items: this.inOrderGoods().map(({ good, ...rest }) => ({
|
||||
@@ -226,24 +226,30 @@ export class PosLandingStore {
|
||||
|
||||
let res: Maybe<IPosOrderResponse> = null;
|
||||
|
||||
await this.service
|
||||
.submitOrder(orderPayload)
|
||||
.pipe(
|
||||
finalize(() => {
|
||||
this.setState({ submitOrderLoading: false });
|
||||
}),
|
||||
catchError(() => {
|
||||
return throwError('');
|
||||
}),
|
||||
)
|
||||
.subscribe((_res) => {
|
||||
this.reset();
|
||||
res = _res;
|
||||
});
|
||||
return this.service.submitOrder(orderPayload).pipe(
|
||||
finalize(() => {
|
||||
this.setState({ submitOrderLoading: false });
|
||||
}),
|
||||
catchError(() => {
|
||||
return new Observable((observer) => observer.error());
|
||||
}),
|
||||
|
||||
if (res) {
|
||||
return new Observable<IPosOrderResponse>((observer) => observer.next(res!));
|
||||
}
|
||||
return new Observable((observer) => observer.error());
|
||||
map((_res) => {
|
||||
// this.setState({
|
||||
// inOrderGoods: [],
|
||||
// customerDetails: {
|
||||
// type: CustomerType.UNKNOWN,
|
||||
// },
|
||||
// invoiceDate: nowJalali(JALALI_DATE_FORMATS.NUMERIC),
|
||||
// payments: {
|
||||
// cash: 0,
|
||||
// set_off: 0,
|
||||
// terminal: 0,
|
||||
// },
|
||||
// orderNote: '',
|
||||
// });
|
||||
return _res;
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ export class POSStore {
|
||||
|
||||
submitOrder() {
|
||||
const orderPayload = {
|
||||
customerId: this.selectedCustomer()?.id,
|
||||
customer_id: this.selectedCustomer()?.id,
|
||||
items: this.inOrderProducts()?.map((item) => ({
|
||||
productId: item.productId,
|
||||
count: item.count,
|
||||
|
||||
@@ -184,8 +184,6 @@ export class InputComponent {
|
||||
}
|
||||
|
||||
onPriceInput($event: InputNumberInputEvent) {
|
||||
console.log($event);
|
||||
|
||||
this.onInput($event.originalEvent, true);
|
||||
}
|
||||
onInput($event: Event, isPriceFormat?: boolean) {
|
||||
@@ -198,7 +196,6 @@ export class InputComponent {
|
||||
|
||||
if (this.inputMode === 'numeric') {
|
||||
let newValue = parseFloat(value);
|
||||
// console.log(value, newValue);
|
||||
|
||||
const minValidator = (this.min || this.min === 0) && parseFloat(value) < this.min!;
|
||||
const maxValidator = (this.max || this.max === 0) && parseFloat(value) > this.max;
|
||||
|
||||
@@ -89,7 +89,7 @@ export class KeyValueComponent {
|
||||
}
|
||||
switch (this.type) {
|
||||
case 'simple':
|
||||
return this.value || '';
|
||||
return this.value || '-';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface IColumn<T = any> {
|
||||
width?: string;
|
||||
minWidth?: string;
|
||||
canCopy?: boolean;
|
||||
type?: 'text' | 'price' | 'boolean' | 'date' | 'nested' | 'index';
|
||||
type?: 'text' | 'price' | 'boolean' | 'date' | 'nested' | 'index' | 'id';
|
||||
nestedPath?: string;
|
||||
customDataModel?: TemplateRef<any> | ((item: T) => string | number | boolean);
|
||||
}
|
||||
@@ -139,6 +139,9 @@ export class PageDataListComponent<I> {
|
||||
}
|
||||
const data = item[String(field)];
|
||||
switch (column.type) {
|
||||
case 'id':
|
||||
if (!data) return '-';
|
||||
return `${data.slice(0, 5)}...${data.slice(data.length - 5, data.length)}`;
|
||||
case 'date':
|
||||
if (!data) return '-';
|
||||
return formatJalali(data);
|
||||
|
||||
Reference in New Issue
Block a user