update many things
This commit is contained in:
+5
-4
@@ -1,8 +1,9 @@
|
||||
<form [formGroup]="form" (submit)="submit()">
|
||||
<app-input [control]="form.controls.first_name" name="first_name" label="نام" />
|
||||
<app-input [control]="form.controls.last_name" name="last_name" label="نام خانوادگی" />
|
||||
<app-input [control]="form.controls.national_id" name="national_id" label="کد ملی" type="nationalId" />
|
||||
<app-input [control]="form.controls.economic_code" name="economic_code" label="کد اقتصادی" maxlength="11" />
|
||||
<field-first-name [control]="form.controls.first_name" />
|
||||
<field-last-name [control]="form.controls.last_name" />
|
||||
<field-mobile-number [control]="form.controls.mobile_number" />
|
||||
<field-national-id [control]="form.controls.national_id" />
|
||||
<field-economic-code [control]="form.controls.economic_code" />
|
||||
|
||||
<app-form-footer-actions submitLabel="ثبت مشتری و ادامه" (onCancel)="close()" (onSubmit)="submit()" />
|
||||
</form>
|
||||
|
||||
+26
-26
@@ -1,11 +1,16 @@
|
||||
import { postalCodeValidator } from '@/core/validators';
|
||||
import { nationalIdValidator } from '@/core/validators/national-id.validator';
|
||||
import { AbstractForm } from '@/shared/abstractClasses';
|
||||
import { InputComponent } from '@/shared/components';
|
||||
import {
|
||||
EconomicCodeComponent,
|
||||
FirstNameComponent,
|
||||
LastNameComponent,
|
||||
MobileNumberComponent,
|
||||
NationalIdComponent,
|
||||
} from '@/shared/components';
|
||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||
import { fieldControl } from '@/shared/constants';
|
||||
import { CustomerType } from '@/shared/localEnum/constants/customerTypes';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { Observable } from 'rxjs';
|
||||
import { IIndividualCustomer } from '../../../models/customer';
|
||||
import { PosLandingStore } from '../../../store/main.store';
|
||||
@@ -13,36 +18,31 @@ import { PosLandingStore } from '../../../store/main.store';
|
||||
@Component({
|
||||
selector: 'pos-customer-individual-form',
|
||||
templateUrl: './form.component.html',
|
||||
imports: [ReactiveFormsModule, InputComponent, FormFooterActionsComponent],
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
FormFooterActionsComponent,
|
||||
FirstNameComponent,
|
||||
LastNameComponent,
|
||||
NationalIdComponent,
|
||||
EconomicCodeComponent,
|
||||
MobileNumberComponent,
|
||||
],
|
||||
})
|
||||
export class CustomerIndividualFormComponent extends AbstractForm<
|
||||
IIndividualCustomer,
|
||||
IIndividualCustomer
|
||||
> {
|
||||
private readonly store = inject(PosLandingStore);
|
||||
costumerInfo = computed(() => this.store.customer().info?.customer_individual);
|
||||
|
||||
override showSuccessMessage = false;
|
||||
form = this.fb.group({
|
||||
first_name: [
|
||||
this.store.customer().info?.customer_individual?.first_name || '',
|
||||
[Validators.required],
|
||||
],
|
||||
last_name: [
|
||||
this.store.customer().info?.customer_individual?.last_name || '',
|
||||
[Validators.required],
|
||||
],
|
||||
national_id: [
|
||||
this.store.customer().info?.customer_individual?.national_id || '',
|
||||
[Validators.required, nationalIdValidator()],
|
||||
],
|
||||
economic_code: [
|
||||
this.store.customer().info?.customer_individual?.economic_code || '',
|
||||
[Validators.required],
|
||||
],
|
||||
postal_code: [
|
||||
this.store.customer().info?.customer_individual?.postal_code || '',
|
||||
[postalCodeValidator()],
|
||||
],
|
||||
first_name: fieldControl.first_name(this.costumerInfo()?.first_name || ''),
|
||||
last_name: fieldControl.last_name(this.costumerInfo()?.last_name || ''),
|
||||
national_id: fieldControl.national_id(this.costumerInfo()?.national_id || ''),
|
||||
postal_code: fieldControl.postal_code(this.costumerInfo()?.postal_code || ''),
|
||||
economic_code: fieldControl.economic_code(this.costumerInfo()?.economic_code || ''),
|
||||
mobile_number: fieldControl.mobile_number(this.costumerInfo()?.mobile_number || ''),
|
||||
});
|
||||
|
||||
override submitForm() {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<form [formGroup]="form" (submit)="submit()">
|
||||
<app-input [control]="form.controls.name" name="name" label="نام مشتری" />
|
||||
<app-input [control]="form.controls.national_id" name="national_id" label="شماره ملی" type="nationalId" />
|
||||
<app-input [control]="form.controls.name" name="name" label="نام" />
|
||||
<app-form-footer-actions submitLabel="ثبت بدون اطلاعات خریدار و ادامه" (onCancel)="close()" />
|
||||
</form>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<button
|
||||
pButton
|
||||
type="button"
|
||||
icon="pi pi-refresh"
|
||||
icon="pi pi-trash"
|
||||
outlined
|
||||
severity="danger"
|
||||
size="small"
|
||||
|
||||
@@ -75,6 +75,15 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
||||
this.updateCalculateAmount(value as any);
|
||||
});
|
||||
|
||||
form.controls.payload.controls.profit_amount.valueChanges.subscribe((value) => {
|
||||
// if ((form.controls.discount_amount.value || 0) > (value || 0)) {
|
||||
form.controls.discount_amount.setValue(0);
|
||||
// }
|
||||
});
|
||||
form.controls.payload.controls.profit_percentage.valueChanges.subscribe((value) => {
|
||||
form.controls.discount_amount.setValue(0);
|
||||
});
|
||||
|
||||
form.setValue({
|
||||
unit_price: 200_000_000,
|
||||
quantity: 2,
|
||||
|
||||
@@ -3,6 +3,7 @@ export interface IIndividualCustomer {
|
||||
last_name: string;
|
||||
national_id: string;
|
||||
postal_code: string;
|
||||
mobile_number: string;
|
||||
economic_code: string;
|
||||
is_favorite?: boolean;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
<p-button
|
||||
icon="pi pi-filter"
|
||||
type="button"
|
||||
size="small"
|
||||
[outlined]="!activeFilters().length"
|
||||
(click)="toggleFilterVisible()"
|
||||
></p-button>
|
||||
<button pButton icon="pi pi-refresh" type="button" outlined (click)="refresh()"></button>
|
||||
<button pButton icon="pi pi-refresh" type="button" size="small" outlined (click)="refresh()"></button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</app-inner-pages-header>
|
||||
|
||||
+26
-2
@@ -14,19 +14,43 @@
|
||||
</div>
|
||||
<hr />
|
||||
<div class="flex items-center justify-center gap-4">
|
||||
@if (["success", "failure"].includes(saleInvoice.status.value.toLowerCase())) {
|
||||
<p-button
|
||||
label="ابطال"
|
||||
type="button"
|
||||
severity="danger"
|
||||
(click)="revokeInvoice()"
|
||||
[loading]="revokingInvoiceLoading()"
|
||||
[disabled]="onAction()"
|
||||
></p-button>
|
||||
}
|
||||
@if (saleInvoice.status.value.toLowerCase() === "not_send") {
|
||||
<p-button label="ارسال فاکتور" type="button" (click)="sendInvoice()" [loading]="sendingLoading()"></p-button>
|
||||
<p-button
|
||||
label="ارسال فاکتور"
|
||||
type="button"
|
||||
(click)="sendInvoice()"
|
||||
[loading]="sendingLoading()"
|
||||
[disabled]="onAction()"
|
||||
></p-button>
|
||||
}
|
||||
@if (saleInvoice.status.value.toLowerCase() === "queued") {
|
||||
<p-button
|
||||
label="استعلام وضعیت ارسال"
|
||||
type="button"
|
||||
severity="info"
|
||||
(click)="getStatus()"
|
||||
[loading]="gettingStatusLoading()"
|
||||
[disabled]="onAction()"
|
||||
></p-button>
|
||||
}
|
||||
@if (saleInvoice.status.value.toLowerCase() === "failure") {
|
||||
<p-button label="ارسال فاکتور" type="button" (click)="resendInvoice()" [loading]="resendingLoading()"></p-button>
|
||||
<p-button
|
||||
label="ارسال مجدد"
|
||||
type="button"
|
||||
(click)="resendInvoice()"
|
||||
[loading]="resendingLoading()"
|
||||
[disabled]="onAction()"
|
||||
></p-button>
|
||||
}
|
||||
<a [routerLink]="singlePageRoute()" pButton type="button" (click)="viewDetails()" outlined>مشاهده جزییات</a>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Component, computed, EventEmitter, inject, Input, Output, signal } from
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { Button, ButtonDirective } from 'primeng/button';
|
||||
import { Card } from 'primeng/card';
|
||||
import { Tag } from 'primeng/tag';
|
||||
import { finalize } from 'rxjs';
|
||||
import { posSaleInvoicesNamedRoutes } from '../constants';
|
||||
import { IPosSaleInvoicesSummaryResponse } from '../models';
|
||||
@@ -17,7 +16,6 @@ import { PosSaleInvoicesService } from '../services/main.service';
|
||||
imports: [
|
||||
Button,
|
||||
KeyValueComponent,
|
||||
Tag,
|
||||
Card,
|
||||
RouterLink,
|
||||
ButtonDirective,
|
||||
@@ -34,6 +32,15 @@ export class SaleInvoiceCardComponent {
|
||||
sendingLoading = signal(false);
|
||||
gettingStatusLoading = signal(false);
|
||||
resendingLoading = signal(false);
|
||||
revokingInvoiceLoading = signal(false);
|
||||
|
||||
onAction = computed(
|
||||
() =>
|
||||
this.sendingLoading() ||
|
||||
this.gettingStatusLoading() ||
|
||||
this.resendingLoading() ||
|
||||
this.revokingInvoiceLoading(),
|
||||
);
|
||||
|
||||
singlePageRoute = computed(() =>
|
||||
posSaleInvoicesNamedRoutes.saleInvoice.meta.pagePath!(this.saleInvoice?.id),
|
||||
@@ -74,9 +81,6 @@ export class SaleInvoiceCardComponent {
|
||||
.getInquiry(this.saleInvoice.id)
|
||||
.pipe(finalize(() => this.gettingStatusLoading.set(false)))
|
||||
.subscribe((res) => {
|
||||
this.toastService.info({
|
||||
text: `وضعیت: ${res.status || 'نامشخص'}`,
|
||||
});
|
||||
this.refreshRequested.emit();
|
||||
});
|
||||
}
|
||||
@@ -91,5 +95,16 @@ export class SaleInvoiceCardComponent {
|
||||
this.refreshRequested.emit();
|
||||
});
|
||||
}
|
||||
|
||||
revokeInvoice() {
|
||||
this.revokingInvoiceLoading.set(true);
|
||||
this.service
|
||||
.revoke(this.saleInvoice.id)
|
||||
.pipe(finalize(() => this.revokingInvoiceLoading.set(false)))
|
||||
.subscribe(() => {
|
||||
this.toastService.success({ text: 'ابطال فاکتور با موفقیت انجام شد.' });
|
||||
this.refreshRequested.emit();
|
||||
});
|
||||
}
|
||||
viewDetails() {}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ export const POS_SALE_INVOICES_API_ROUTES = {
|
||||
retry: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/retry`,
|
||||
status: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/status`,
|
||||
getInquiry: (invoiceId: string) => `${baseUrl()}/${invoiceId}/inquiry`,
|
||||
revoke: (invoiceId: string) => `${baseUrl()}/${invoiceId}/revoke`,
|
||||
attempts: (invoiceId: string) => `${baseUrl()}/${invoiceId}/fiscal/attempts`,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import ISummary from '@/core/models/summary';
|
||||
import { TspProviderResponseStatus } from '@/shared/catalog';
|
||||
import { IEnumTranslate } from '@/shared/models/enum_translate.type';
|
||||
|
||||
export interface IPosSaleInvoicesRawResponse {
|
||||
|
||||
@@ -59,6 +59,13 @@ export class PosSaleInvoicesService {
|
||||
);
|
||||
}
|
||||
|
||||
revoke(invoiceId: string): Observable<IPosSaleInvoiceFiscalStatusResponse> {
|
||||
return this.http.post<IPosSaleInvoiceFiscalStatusResponse>(
|
||||
this.apiRoutes.fiscal.revoke(invoiceId),
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
getFiscalAttempts(invoiceId: string): Observable<IPosSaleInvoiceFiscalAttemptsResponse> {
|
||||
return this.http.get<IPosSaleInvoiceFiscalAttemptsResponse>(
|
||||
this.apiRoutes.fiscal.attempts(invoiceId),
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
<consumer-saleInvoice-shared [loading]="loading()" [invoice]="invoice()" variant="pos" />
|
||||
<div class="p-4">
|
||||
<consumer-saleInvoice-shared [loading]="loading()" [invoice]="invoice()" [backRoute]="backRoute()" variant="pos" />
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ConsumerSaleInvoiceSharedComponent } from '@/domains/consumer/component
|
||||
import pageParamsUtils from '@/utils/page-params.utils';
|
||||
import { Component, computed, inject, signal } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { posSaleInvoicesNamedRoutes } from '../constants';
|
||||
import { PosSaleInvoiceStore } from '../store/main.store';
|
||||
|
||||
@Component({
|
||||
@@ -19,6 +20,8 @@ export class PosSaleInvoiceComponent {
|
||||
readonly invoice = computed(() => this.store.entity());
|
||||
readonly loading = computed(() => this.store.loading());
|
||||
|
||||
readonly backRoute = computed(() => posSaleInvoicesNamedRoutes.saleInvoices.meta.pagePath!());
|
||||
|
||||
ngOnInit() {
|
||||
this.store.getData(this.invoiceId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user