From 12752f37d5dcfcfabb651ecabb6351b72f0baff8 Mon Sep 17 00:00:00 2001 From: ahasani194 Date: Sat, 23 May 2026 20:25:35 +0330 Subject: [PATCH] feat: add rapid invoice configuration module with form, service, and integration --- .../components/goldPrice/form.component.ts | 2 - .../rapidInvoice/form.component.html | 12 ++++ .../components/rapidInvoice/form.component.ts | 55 +++++++++++++++++++ .../components/rapidInvoice/models/index.ts | 3 + .../rapidInvoice/services/main.service.ts | 19 +++++++ .../modules/configs/views/root.component.html | 1 + .../modules/configs/views/root.component.ts | 2 + .../shop/components/payload-form.component.ts | 4 +- .../season-picker-dialog.component.html | 20 ++++--- .../season-picker-dialog.component.ts | 2 + .../constants/localStorageKeys.const.ts | 1 + 11 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 src/app/domains/pos/modules/configs/components/rapidInvoice/form.component.html create mode 100644 src/app/domains/pos/modules/configs/components/rapidInvoice/form.component.ts create mode 100644 src/app/domains/pos/modules/configs/components/rapidInvoice/models/index.ts create mode 100644 src/app/domains/pos/modules/configs/components/rapidInvoice/services/main.service.ts diff --git a/src/app/domains/pos/modules/configs/components/goldPrice/form.component.ts b/src/app/domains/pos/modules/configs/components/goldPrice/form.component.ts index 8b84b80..0b796ca 100644 --- a/src/app/domains/pos/modules/configs/components/goldPrice/form.component.ts +++ b/src/app/domains/pos/modules/configs/components/goldPrice/form.component.ts @@ -41,8 +41,6 @@ export class PosConfigGoldPriceFormComponent extends AbstractForm< this.loading.set(true); const initialValues = await this.service.get(); - console.log('initialValues.price', initialValues); - this.form.controls.price.setValue((initialValues || 0) + ''); this.loading.set(false); } diff --git a/src/app/domains/pos/modules/configs/components/rapidInvoice/form.component.html b/src/app/domains/pos/modules/configs/components/rapidInvoice/form.component.html new file mode 100644 index 0000000..3d8f896 --- /dev/null +++ b/src/app/domains/pos/modules/configs/components/rapidInvoice/form.component.html @@ -0,0 +1,12 @@ + + + در صورتی که فروش شما تک محصولی / خدماتی است، این قابلیت را فعال کنید. + +
+
+ ثبت سریع صورت‌حساب + +
+ + +
diff --git a/src/app/domains/pos/modules/configs/components/rapidInvoice/form.component.ts b/src/app/domains/pos/modules/configs/components/rapidInvoice/form.component.ts new file mode 100644 index 0000000..d05a364 --- /dev/null +++ b/src/app/domains/pos/modules/configs/components/rapidInvoice/form.component.ts @@ -0,0 +1,55 @@ +import { AbstractForm } from '@/shared/abstractClasses'; +import { AppCardComponent } from '@/shared/components'; +import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; +import { UikitLabelComponent } from '@/uikit'; +import { Component, inject, signal } from '@angular/core'; +import { ReactiveFormsModule } from '@angular/forms'; +import { Message } from 'primeng/message'; +import { ToggleSwitch } from 'primeng/toggleswitch'; +import { IPosConfigRapidInvoicePayload, IPosConfigRapidInvoiceResponse } from './models'; +import { PosConfigRapidInvoiceService } from './services/main.service'; + +@Component({ + selector: 'pos-config-rapid-invoice-form', + templateUrl: 'form.component.html', + imports: [ + ReactiveFormsModule, + FormFooterActionsComponent, + AppCardComponent, + Message, + UikitLabelComponent, + ToggleSwitch, + ], +}) +export class PosConfigRapidInvoiceFormComponent extends AbstractForm< + IPosConfigRapidInvoicePayload, + IPosConfigRapidInvoiceResponse +> { + private readonly service = inject(PosConfigRapidInvoiceService); + + loading = signal(true); + + initForm = () => { + const form = this.fb.group({ + rapidInvoice: [false], + }); + + return form; + }; + + form = this.initForm(); + + override async ngOnInit() { + this.loading.set(true); + const initialValues = await this.service.get(); + + this.form.controls.rapidInvoice.setValue(initialValues || false); + this.loading.set(false); + } + + override submitForm() { + const formValue = this.form.value.rapidInvoice as IPosConfigRapidInvoicePayload; + this.toastService.success({ text: 'تغییرات با موفقیت اعمال شد.' }); + return this.service.submit(formValue); + } +} diff --git a/src/app/domains/pos/modules/configs/components/rapidInvoice/models/index.ts b/src/app/domains/pos/modules/configs/components/rapidInvoice/models/index.ts new file mode 100644 index 0000000..ec7f8e4 --- /dev/null +++ b/src/app/domains/pos/modules/configs/components/rapidInvoice/models/index.ts @@ -0,0 +1,3 @@ +export type IPosConfigRapidInvoiceResponse = boolean; + +export type IPosConfigRapidInvoicePayload = boolean; diff --git a/src/app/domains/pos/modules/configs/components/rapidInvoice/services/main.service.ts b/src/app/domains/pos/modules/configs/components/rapidInvoice/services/main.service.ts new file mode 100644 index 0000000..dea2271 --- /dev/null +++ b/src/app/domains/pos/modules/configs/components/rapidInvoice/services/main.service.ts @@ -0,0 +1,19 @@ +import { Injectable } from '@angular/core'; +import { LOCAL_STORAGE_KEYS } from 'src/assets/constants'; +import { IPosConfigRapidInvoicePayload, IPosConfigRapidInvoiceResponse } from '../models'; + +@Injectable({ providedIn: 'root' }) +export class PosConfigRapidInvoiceService { + get(): IPosConfigRapidInvoiceResponse { + const defaultPrice = Boolean( + window.localStorage.getItem(LOCAL_STORAGE_KEYS.POS_CONFIG_RAPID_INVOICE) === 'true' + ); + + this.submit(defaultPrice); + return defaultPrice; + } + + submit(data: IPosConfigRapidInvoicePayload) { + window.localStorage.setItem(LOCAL_STORAGE_KEYS.POS_CONFIG_RAPID_INVOICE, data.toString()); + } +} diff --git a/src/app/domains/pos/modules/configs/views/root.component.html b/src/app/domains/pos/modules/configs/views/root.component.html index 5047641..34d38ea 100644 --- a/src/app/domains/pos/modules/configs/views/root.component.html +++ b/src/app/domains/pos/modules/configs/views/root.component.html @@ -2,6 +2,7 @@ @if (info()?.guild!.code.toLocaleLowerCase() === 'gold') { } + هریک از موارد زیر را که می‌خواهید در چاپ فاکتور نمایش داده‌ شوند را انتخاب کنید diff --git a/src/app/domains/pos/modules/configs/views/root.component.ts b/src/app/domains/pos/modules/configs/views/root.component.ts index b473352..b4911d1 100644 --- a/src/app/domains/pos/modules/configs/views/root.component.ts +++ b/src/app/domains/pos/modules/configs/views/root.component.ts @@ -5,6 +5,7 @@ import { Router } from '@angular/router'; import { Message } from 'primeng/message'; import { PosConfigGoldPriceFormComponent } from '../components/goldPrice/form.component'; import { PosConfigPrintFormComponent } from '../components/print/form.component'; +import { PosConfigRapidInvoiceFormComponent } from '../components/rapidInvoice/form.component'; @Component({ selector: 'pos-config-page', @@ -14,6 +15,7 @@ import { PosConfigPrintFormComponent } from '../components/print/form.component' AppCardComponent, Message, PosConfigGoldPriceFormComponent, + PosConfigRapidInvoiceFormComponent, ], }) export class PosConfigPageComponent { diff --git a/src/app/domains/pos/modules/shop/components/payload-form.component.ts b/src/app/domains/pos/modules/shop/components/payload-form.component.ts index e338500..bcba1d1 100644 --- a/src/app/domains/pos/modules/shop/components/payload-form.component.ts +++ b/src/app/domains/pos/modules/shop/components/payload-form.component.ts @@ -35,12 +35,12 @@ export class PayloadFormDialogComponent extends AbstractDialog { goldPayload = computed(() => this.isGoldMode() && this.editMode() ? (this.initialValues as IPosOrderItem) - : undefined, + : undefined ); standardPayload = computed(() => this.isStandardMode() && this.editMode() ? (this.initialValues as IPosOrderItem) - : undefined, + : undefined ); onChangeTotalAmount = (totalAmount: number) => { diff --git a/src/app/shared/components/seasonPicker/season-picker-dialog.component.html b/src/app/shared/components/seasonPicker/season-picker-dialog.component.html index 6c393cb..99b8787 100644 --- a/src/app/shared/components/seasonPicker/season-picker-dialog.component.html +++ b/src/app/shared/components/seasonPicker/season-picker-dialog.component.html @@ -1,13 +1,15 @@ - +
- - +
+ انتخاب سال + +
diff --git a/src/app/shared/components/seasonPicker/season-picker-dialog.component.ts b/src/app/shared/components/seasonPicker/season-picker-dialog.component.ts index adcd788..5a47396 100644 --- a/src/app/shared/components/seasonPicker/season-picker-dialog.component.ts +++ b/src/app/shared/components/seasonPicker/season-picker-dialog.component.ts @@ -1,4 +1,5 @@ import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog'; +import { UikitLabelComponent } from '@/uikit'; import { CommonModule } from '@angular/common'; import { Component, computed, EventEmitter, Input, Output, signal } from '@angular/core'; import { FormsModule } from '@angular/forms'; @@ -23,6 +24,7 @@ interface SeasonItem { SharedLightBottomsheetComponent, FormFooterActionsComponent, ButtonDirective, + UikitLabelComponent, ], }) export class SeasonPickerDialogComponent extends AbstractDialog { diff --git a/src/assets/constants/localStorageKeys.const.ts b/src/assets/constants/localStorageKeys.const.ts index d03eb6e..53e9007 100644 --- a/src/assets/constants/localStorageKeys.const.ts +++ b/src/assets/constants/localStorageKeys.const.ts @@ -4,6 +4,7 @@ export enum LOCAL_STORAGE_KEYS { USER_DATA = 'userData', LAST_LOGIN_TIME = 'lastLoginTime', LOGIN_ATTEMPTS = 'loginAttempts', + POS_CONFIG_RAPID_INVOICE = 'posConfigRapidInvoice', POS_CONFIG_PRINT = 'posConfigPrint', POS_CONFIG_GOLD_PRICE = 'posConfigGoldPrice', }