diff --git a/src/app/domains/consumer/models/saleInvoice.io.ts b/src/app/domains/consumer/models/saleInvoice.io.ts index a6be113..b765f3c 100644 --- a/src/app/domains/consumer/models/saleInvoice.io.ts +++ b/src/app/domains/consumer/models/saleInvoice.io.ts @@ -1,22 +1,5 @@ import ISummary from '@/core/models/summary'; -import { TspProviderResponseStatus } from '@/shared/catalog'; -import { IEnumTranslate } from '@/shared/models/enum_translate.type'; - -export interface ISaleInvoiceFullRawResponse { - id: string; - code: string; - total_amount: string; - invoice_date: string; - consumer_account: ConsumerAccount; - pos: Pos; - payments: Payment[]; - items: Item[]; - created_at: string; - notes?: string; - customer?: Customer; - unknown_customer?: UnknownCustomer; - status: IEnumTranslate; -} +import { ISaleInvoiceFullRawResponse } from '@/shared/components/invoices/sale-invoice-full-response.model'; export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {} diff --git a/src/app/domains/consumer/modules/customers/models/saleInvoices.io.d.ts b/src/app/domains/consumer/modules/customers/models/saleInvoices.io.d.ts index 9d0b73a..3761fb6 100644 --- a/src/app/domains/consumer/modules/customers/models/saleInvoices.io.d.ts +++ b/src/app/domains/consumer/modules/customers/models/saleInvoices.io.d.ts @@ -1,5 +1,5 @@ import ISummary from '@/core/models/summary'; -import { ISaleInvoiceFullRawResponse } from '@/domains/consumer/models'; +import { ISaleInvoiceFullRawResponse } from '@/shared/components/invoices/sale-invoice-full-response.model'; import { CustomerType } from '@/shared/localEnum/constants/customerTypes'; import { CustomerIndividual, CustomerLegal } from './io'; diff --git a/src/app/domains/consumer/modules/saleInvoices/services/main.service.ts b/src/app/domains/consumer/modules/saleInvoices/services/main.service.ts index 6bf72d1..1878b84 100644 --- a/src/app/domains/consumer/modules/saleInvoices/services/main.service.ts +++ b/src/app/domains/consumer/modules/saleInvoices/services/main.service.ts @@ -1,5 +1,6 @@ import { IPaginatedQuery, IPaginatedResponse } from '@/core/models/service.model'; -import { ISaleInvoiceFullRawResponse, ISaleInvoiceFullResponse } from '@/domains/consumer/models'; +import { ISaleInvoiceFullResponse } from '@/domains/consumer/models'; +import { ISaleInvoiceFullRawResponse } from '@/shared/components/invoices/sale-invoice-full-response.model'; import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; @@ -12,7 +13,9 @@ export class ConsumerSaleInvoicesService { private apiRoutes = CONSUMER_SALE_INVOICES_API_ROUTES; - getAll(paginationQuery?: IPaginatedQuery): Observable> { + getAll( + paginationQuery?: IPaginatedQuery, + ): Observable> { return this.http.get>( this.apiRoutes.list(paginationQuery), ); diff --git a/src/app/domains/pos/models/good.io.ts b/src/app/domains/pos/models/good.io.ts index 5981c49..83c53c3 100644 --- a/src/app/domains/pos/models/good.io.ts +++ b/src/app/domains/pos/models/good.io.ts @@ -7,6 +7,7 @@ export interface IGoodRawResponse { id: string; code: string; name: string; + vat: string; }; category: ISummary; measure_unit: ISummary; diff --git a/src/app/domains/pos/modules/landing/components/payload-form.component.html b/src/app/domains/pos/modules/landing/components/payload-form.component.html index 3f6da32..5de521d 100644 --- a/src/app/domains/pos/modules/landing/components/payload-form.component.html +++ b/src/app/domains/pos/modules/landing/components/payload-form.component.html @@ -8,10 +8,16 @@ > @if (good) { @if (isGoldMode()) { - + } @else if (isStandardMode()) { (0); preparedTitle = computed(() => this.good?.name); + vatPercentage = computed(() => parseFloat(this.good.sku.vat || '0')); editMode = computed(() => Boolean(this.initialValues) && Boolean(this.orderItemId)); isGoldMode = computed(() => this.good.pricing_model === 'GOLD'); diff --git a/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts b/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts index 09577d0..9dd884c 100644 --- a/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts +++ b/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts @@ -5,7 +5,7 @@ import { InputComponent } from '@/shared/components'; import { AmountPercentageInputComponent } from '@/shared/components/amountPercentageInput/amount-percentage-input.component'; import { TGoldKarat } from '@/shared/localEnum/constants/goldKarat'; import { formatWithCurrency } from '@/utils'; -import { Component, computed, EventEmitter, Output, signal } from '@angular/core'; +import { Component, computed, EventEmitter, Input, Output, signal } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'; import { ButtonDirective } from 'primeng/button'; @@ -42,6 +42,8 @@ export class PosGoldPayloadFormComponent extends AbstractForm< // } as any, // }; + @Input({ required: true }) vatPercentage!: number; + @Output() onSubmitForm = new EventEmitter(); @Output() onChangeTotalAmount = new EventEmitter(); diff --git a/src/app/domains/pos/modules/landing/components/payloads/standard/form.component.ts b/src/app/domains/pos/modules/landing/components/payloads/standard/form.component.ts index 0c3bd2f..dabb2aa 100644 --- a/src/app/domains/pos/modules/landing/components/payloads/standard/form.component.ts +++ b/src/app/domains/pos/modules/landing/components/payloads/standard/form.component.ts @@ -26,6 +26,7 @@ export class PosStandardPayloadFormComponent extends AbstractForm< IPosOrderItem > { @Input({ required: true }) measureUnit!: ISummary; + @Input({ required: true }) vatPercentage!: number; @Output() onChangeTotalAmount = new EventEmitter(); private readonly initialForm = () => { @@ -72,7 +73,7 @@ export class PosStandardPayloadFormComponent extends AbstractForm< const baseTotalAmount = (value.unit_price ?? 0) * (value.quantity ?? 0); const discountAmount = Number(value.discount_amount ?? '0'); const baseTotalAmountWithoutTax = baseTotalAmount - discountAmount; - const taxAmount = baseTotalAmountWithoutTax * 0.1; + const taxAmount = baseTotalAmountWithoutTax * this.vatPercentage; this.baseTotalAmount.set(baseTotalAmount); this.discountAmount.set(discountAmount); diff --git a/src/app/domains/pos/modules/saleInvoices/services/main.service.ts b/src/app/domains/pos/modules/saleInvoices/services/main.service.ts index c94e8c4..00a6803 100644 --- a/src/app/domains/pos/modules/saleInvoices/services/main.service.ts +++ b/src/app/domains/pos/modules/saleInvoices/services/main.service.ts @@ -1,5 +1,6 @@ import { IPaginatedResponse } from '@/core/models/service.model'; -import { ISaleInvoiceFullRawResponse, ISaleInvoiceFullResponse } from '@/domains/consumer/models'; +import { ISaleInvoiceFullResponse } from '@/domains/consumer/models'; +import { ISaleInvoiceFullRawResponse } from '@/shared/components/invoices/sale-invoice-full-response.model'; import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; diff --git a/src/environments/environment.tis.ts b/src/environments/environment.tis.ts index 0ac90f5..8873f90 100644 --- a/src/environments/environment.tis.ts +++ b/src/environments/environment.tis.ts @@ -1,8 +1,8 @@ // TIS tenant environment configuration export const environment = { production: true, - apiBaseUrl: 'https://psp-api.shift-am.ir', - // apiBaseUrl: 'http://192.168.128.73:5002', + // apiBaseUrl: 'https://psp-api.shift-am.ir', + apiBaseUrl: 'http://192.168.128.73:5002', host: 'localhost', port: 5000, enableLogging: false,