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 { 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<TspProviderResponseStatus>;
}
import { ISaleInvoiceFullRawResponse } from '@/shared/components/invoices/sale-invoice-full-response.model';
export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {}
@@ -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';
@@ -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<IPaginatedResponse<IConsumerSaleInvoicesResponse>> {
getAll(
paginationQuery?: IPaginatedQuery,
): Observable<IPaginatedResponse<IConsumerSaleInvoicesResponse>> {
return this.http.get<IPaginatedResponse<IConsumerSaleInvoicesRawResponse>>(
this.apiRoutes.list(paginationQuery),
);
+1
View File
@@ -7,6 +7,7 @@ export interface IGoodRawResponse {
id: string;
code: string;
name: string;
vat: string;
};
category: ISummary;
measure_unit: ISummary;
@@ -8,10 +8,16 @@
>
@if (good) {
@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()) {
<pos-standard-payload-form
[initialValues]="standardPayload()"
[vatPercentage]="vatPercentage()"
[measureUnit]="good.measure_unit"
[editMode]="editMode()"
(onSubmit)="submit($event)"
@@ -10,7 +10,11 @@ import { PosStandardPayloadFormComponent } from './payloads/standard/form.compon
@Component({
selector: 'pos-payload-form-dialog',
templateUrl: './payload-form.component.html',
imports: [PosGoldPayloadFormComponent, SharedLightBottomsheetComponent, PosStandardPayloadFormComponent],
imports: [
PosGoldPayloadFormComponent,
SharedLightBottomsheetComponent,
PosStandardPayloadFormComponent,
],
})
export class PayloadFormDialogComponent extends AbstractDialog {
@Input({ required: true }) good!: IGoodResponse;
@@ -22,6 +26,7 @@ export class PayloadFormDialogComponent extends AbstractDialog {
totalAmount = signal<number>(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');
@@ -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<IGoldPayload>();
@Output() onChangeTotalAmount = new EventEmitter<number>();
@@ -26,6 +26,7 @@ export class PosStandardPayloadFormComponent extends AbstractForm<
IPosOrderItem<IStandardPayload>
> {
@Input({ required: true }) measureUnit!: ISummary;
@Input({ required: true }) vatPercentage!: number;
@Output() onChangeTotalAmount = new EventEmitter<number>();
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);
@@ -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';
+2 -2
View File
@@ -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,