Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-05-07 23:28:12 +03:30
parent b2a1eb8e5b
commit ce40bd8c75
54 changed files with 260 additions and 183 deletions
@@ -102,10 +102,21 @@ export class PosLayoutComponent implements AfterViewInit {
}
doPay() {
this.nativeBridgeService.pay({
amount: 1000,
id: '1',
// this.nativeBridgeService.pay({
// amount: 10_000,
// id: '1',
// });
this.nativeBridgeService.print({
title: 'salam',
items: [
{
label: 'مجموع قیمت',
value: '10_000',
},
],
});
// @ts-ignore
// window.NativeBridge.pay(12312, 'test');
}
ngOnInit() {
@@ -4,6 +4,7 @@
<field-mobile-number [control]="form.controls.mobile_number" />
<field-national-id [control]="form.controls.national_id" />
<field-economic-code [control]="form.controls.economic_code" />
<field-postal-code [control]="form.controls.postal_code" />
<app-form-footer-actions submitLabel="ثبت مشتری و ادامه" (onCancel)="close()" (onSubmit)="submit()" />
</form>
@@ -5,6 +5,7 @@ import {
LastNameComponent,
MobileNumberComponent,
NationalIdComponent,
PostalCodeComponent,
} from '@/shared/components';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { fieldControl } from '@/shared/constants';
@@ -26,6 +27,7 @@ import { PosLandingStore } from '../../../store/main.store';
NationalIdComponent,
EconomicCodeComponent,
MobileNumberComponent,
PostalCodeComponent,
],
})
export class CustomerIndividualFormComponent extends AbstractForm<
@@ -12,7 +12,7 @@
}
</div>
<div class="flex justify-between items-center">
<span>مالیات (۱۰٪)</span>
<span>ارزش افزوده</span>
<span [appPriceMask]="taxAmount"></span>
</div>
<hr />
@@ -132,9 +132,14 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
const totalAmountBeforeProfit = unitWithQuantity + wageAmount + commissionAmount;
const baseTotalAmount = totalAmountBeforeProfit + profitAmount;
const baseAmountForDiscountCalculation =
this.discountType() === 1 ? profitAmount : baseTotalAmount;
this.discountType() === 1 ? profitAmount : unitWithQuantity;
const taxAmount = (profitAmount + commissionAmount + wageAmount - discountAmount) * 0.1;
const taxAmount =
(profitAmount +
commissionAmount +
wageAmount -
(this.discountType() === 1 ? discountAmount : 0)) *
0.1;
const totalAmount = baseTotalAmount - discountAmount + taxAmount;
this.unitWithQuantity.set(unitWithQuantity);
@@ -23,7 +23,7 @@
/>
<app-input label="شناسه اقتصادی" [control]="form.controls.customer_economic_code" name="customer_economic_code" />
<div class="grid grid-cols-2 gap-2">
<!-- <div class="grid grid-cols-2 gap-2">
<uikit-datepicker label="از تاریخ فاکتور" [control]="form.controls.invoice_date_from" name="invoice_date_from" />
<uikit-datepicker label="تا تاریخ فاکتور" [control]="form.controls.invoice_date_to" name="invoice_date_to" />
</div>
@@ -31,7 +31,7 @@
<div class="grid grid-cols-2 gap-2">
<uikit-datepicker label="از تاریخ صدور" [control]="form.controls.created_at_from" name="created_at_from" />
<uikit-datepicker label="تا تاریخ صدور" [control]="form.controls.created_at_to" name="created_at_to" />
</div>
</div> -->
<div class="grid grid-cols-2 gap-2">
<app-input label="از مبلغ" [control]="form.controls.total_amount_from" name="total_amount_from" type="price" />
@@ -3,7 +3,6 @@ import { Component, computed, inject, signal } from '@angular/core';
import { Router } from '@angular/router';
import { Button, ButtonDirective } from 'primeng/button';
import { Chip } from 'primeng/chip';
import { Paginator } from 'primeng/paginator';
import { Skeleton } from 'primeng/skeleton';
import { finalize } from 'rxjs';
import { posSaleInvoicesNamedRoutes } from '../constants/routes';
@@ -27,7 +26,6 @@ import { SaleInvoiceCardComponent } from './sale-invoice-card.component';
Button,
Chip,
SaleInvoiceCardComponent,
Paginator,
],
})
export class PosSaleInvoiceListComponent {
@@ -51,7 +51,7 @@ export class SaleInvoiceCardComponent {
if (customer) {
const { legal, individual } = customer;
let text = 'الکترونیکی نوع اول - ';
let text = 'نوع اول - ';
console.log(customer);
if (legal) {
text += `حقوقی (${legal.company_name})`;
@@ -61,7 +61,7 @@ export class SaleInvoiceCardComponent {
}
return text;
}
return 'الکترونیکی نوع دوم (بدون اطلاعات خریدار)';
return 'نوع دوم (بدون اطلاعات خریدار)';
});
sendInvoice() {