refactor: update import paths for sale invoice models; add VAT handling in payload forms

This commit is contained in:
2026-05-17 12:04:11 +03:30
parent b2a7fa7f70
commit 6f1ad20cff
10 changed files with 30 additions and 28 deletions
@@ -1,22 +1,5 @@
import ISummary from '@/core/models/summary'; import ISummary from '@/core/models/summary';
import { TspProviderResponseStatus } from '@/shared/catalog'; import { ISaleInvoiceFullRawResponse } from '@/shared/components/invoices/sale-invoice-full-response.model';
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<TspProviderResponseStatus>;
}
export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {} export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {}
@@ -1,5 +1,5 @@
import ISummary from '@/core/models/summary'; 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 { CustomerType } from '@/shared/localEnum/constants/customerTypes';
import { CustomerIndividual, CustomerLegal } from './io'; import { CustomerIndividual, CustomerLegal } from './io';
@@ -1,5 +1,6 @@
import { IPaginatedQuery, IPaginatedResponse } from '@/core/models/service.model'; 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 { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@@ -12,7 +13,9 @@ export class ConsumerSaleInvoicesService {
private apiRoutes = CONSUMER_SALE_INVOICES_API_ROUTES; private apiRoutes = CONSUMER_SALE_INVOICES_API_ROUTES;
getAll(paginationQuery?: IPaginatedQuery): Observable<IPaginatedResponse<IConsumerSaleInvoicesResponse>> { getAll(
paginationQuery?: IPaginatedQuery,
): Observable<IPaginatedResponse<IConsumerSaleInvoicesResponse>> {
return this.http.get<IPaginatedResponse<IConsumerSaleInvoicesRawResponse>>( return this.http.get<IPaginatedResponse<IConsumerSaleInvoicesRawResponse>>(
this.apiRoutes.list(paginationQuery), this.apiRoutes.list(paginationQuery),
); );
+1
View File
@@ -7,6 +7,7 @@ export interface IGoodRawResponse {
id: string; id: string;
code: string; code: string;
name: string; name: string;
vat: string;
}; };
category: ISummary; category: ISummary;
measure_unit: ISummary; measure_unit: ISummary;
@@ -8,10 +8,16 @@
> >
@if (good) { @if (good) {
@if (isGoldMode()) { @if (isGoldMode()) {
<pos-gold-payload-form [initialValues]="goldPayload()" [editMode]="editMode()" (onSubmit)="submit($event)" /> <pos-gold-payload-form
[initialValues]="goldPayload()"
[vatPercentage]="vatPercentage()"
[editMode]="editMode()"
(onSubmit)="submit($event)"
/>
} @else if (isStandardMode()) { } @else if (isStandardMode()) {
<pos-standard-payload-form <pos-standard-payload-form
[initialValues]="standardPayload()" [initialValues]="standardPayload()"
[vatPercentage]="vatPercentage()"
[measureUnit]="good.measure_unit" [measureUnit]="good.measure_unit"
[editMode]="editMode()" [editMode]="editMode()"
(onSubmit)="submit($event)" (onSubmit)="submit($event)"
@@ -10,7 +10,11 @@ import { PosStandardPayloadFormComponent } from './payloads/standard/form.compon
@Component({ @Component({
selector: 'pos-payload-form-dialog', selector: 'pos-payload-form-dialog',
templateUrl: './payload-form.component.html', templateUrl: './payload-form.component.html',
imports: [PosGoldPayloadFormComponent, SharedLightBottomsheetComponent, PosStandardPayloadFormComponent], imports: [
PosGoldPayloadFormComponent,
SharedLightBottomsheetComponent,
PosStandardPayloadFormComponent,
],
}) })
export class PayloadFormDialogComponent extends AbstractDialog { export class PayloadFormDialogComponent extends AbstractDialog {
@Input({ required: true }) good!: IGoodResponse; @Input({ required: true }) good!: IGoodResponse;
@@ -22,6 +26,7 @@ export class PayloadFormDialogComponent extends AbstractDialog {
totalAmount = signal<number>(0); totalAmount = signal<number>(0);
preparedTitle = computed(() => this.good?.name); preparedTitle = computed(() => this.good?.name);
vatPercentage = computed(() => parseFloat(this.good.sku.vat || '0'));
editMode = computed(() => Boolean(this.initialValues) && Boolean(this.orderItemId)); editMode = computed(() => Boolean(this.initialValues) && Boolean(this.orderItemId));
isGoldMode = computed(() => this.good.pricing_model === 'GOLD'); isGoldMode = computed(() => this.good.pricing_model === 'GOLD');
@@ -5,7 +5,7 @@ import { InputComponent } from '@/shared/components';
import { AmountPercentageInputComponent } from '@/shared/components/amountPercentageInput/amount-percentage-input.component'; import { AmountPercentageInputComponent } from '@/shared/components/amountPercentageInput/amount-percentage-input.component';
import { TGoldKarat } from '@/shared/localEnum/constants/goldKarat'; import { TGoldKarat } from '@/shared/localEnum/constants/goldKarat';
import { formatWithCurrency } from '@/utils'; 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 { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'; import { FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { ButtonDirective } from 'primeng/button'; import { ButtonDirective } from 'primeng/button';
@@ -42,6 +42,8 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
// } as any, // } as any,
// }; // };
@Input({ required: true }) vatPercentage!: number;
@Output() onSubmitForm = new EventEmitter<IGoldPayload>(); @Output() onSubmitForm = new EventEmitter<IGoldPayload>();
@Output() onChangeTotalAmount = new EventEmitter<number>(); @Output() onChangeTotalAmount = new EventEmitter<number>();
@@ -26,6 +26,7 @@ export class PosStandardPayloadFormComponent extends AbstractForm<
IPosOrderItem<IStandardPayload> IPosOrderItem<IStandardPayload>
> { > {
@Input({ required: true }) measureUnit!: ISummary; @Input({ required: true }) measureUnit!: ISummary;
@Input({ required: true }) vatPercentage!: number;
@Output() onChangeTotalAmount = new EventEmitter<number>(); @Output() onChangeTotalAmount = new EventEmitter<number>();
private readonly initialForm = () => { private readonly initialForm = () => {
@@ -72,7 +73,7 @@ export class PosStandardPayloadFormComponent extends AbstractForm<
const baseTotalAmount = (value.unit_price ?? 0) * (value.quantity ?? 0); const baseTotalAmount = (value.unit_price ?? 0) * (value.quantity ?? 0);
const discountAmount = Number(value.discount_amount ?? '0'); const discountAmount = Number(value.discount_amount ?? '0');
const baseTotalAmountWithoutTax = baseTotalAmount - discountAmount; const baseTotalAmountWithoutTax = baseTotalAmount - discountAmount;
const taxAmount = baseTotalAmountWithoutTax * 0.1; const taxAmount = baseTotalAmountWithoutTax * this.vatPercentage;
this.baseTotalAmount.set(baseTotalAmount); this.baseTotalAmount.set(baseTotalAmount);
this.discountAmount.set(discountAmount); this.discountAmount.set(discountAmount);
@@ -1,5 +1,6 @@
import { IPaginatedResponse } from '@/core/models/service.model'; 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 { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
+2 -2
View File
@@ -1,8 +1,8 @@
// TIS tenant environment configuration // TIS tenant environment configuration
export const environment = { export const environment = {
production: true, production: true,
apiBaseUrl: 'https://psp-api.shift-am.ir', // apiBaseUrl: 'https://psp-api.shift-am.ir',
// apiBaseUrl: 'http://192.168.128.73:5002', apiBaseUrl: 'http://192.168.128.73:5002',
host: 'localhost', host: 'localhost',
port: 5000, port: 5000,
enableLogging: false, enableLogging: false,