Refactor nested column definitions and improve license info handling
- Updated column definitions in various components to use `nestedOption` instead of `nestedPath` for better clarity and consistency. - Removed commented-out license status checks and related UI elements from the layout component. - Simplified license info interface by removing unnecessary properties. - Enhanced consumer accounts and business activities components to display additional license information. - Adjusted form components to conditionally include fields based on selected device type. - Improved the handling of discount calculations in the gold payload form component. - Added new fields for branch code in complex components and adjusted related views. - Cleaned up unused console logs in form data utility.
This commit is contained in:
@@ -34,12 +34,21 @@
|
||||
<app-amount-percentage-input
|
||||
[percentageControl]="form.controls.discount_percentage"
|
||||
[amountControl]="form.controls.discount_amount"
|
||||
[baseAmount]="baseTotalAmount()"
|
||||
[baseAmount]="baseAmountForDiscountCalculation()"
|
||||
[minAmount]="0"
|
||||
[maxAmount]="baseTotalAmount()"
|
||||
[maxAmount]="baseAmountForDiscountCalculation()"
|
||||
name="discount"
|
||||
label="تخفیف"
|
||||
/>
|
||||
>
|
||||
<ng-template #labelSuffix>
|
||||
<p-selectButton
|
||||
[options]="discountTypeItems"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
(onChange)="changeDiscountCalculation($event)"
|
||||
/>
|
||||
</ng-template>
|
||||
</app-amount-percentage-input>
|
||||
|
||||
<hr />
|
||||
<div class="flex flex-col gap-4 justify-center w-full">
|
||||
|
||||
@@ -7,6 +7,7 @@ import { formatWithCurrency } from '@/utils';
|
||||
import { Component, EventEmitter, Output, signal } from '@angular/core';
|
||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Button } from 'primeng/button';
|
||||
import { SelectButton, SelectButtonChangeEvent } from 'primeng/selectbutton';
|
||||
import { IGoldPayload, IPosOrderItem } from '../../../models';
|
||||
import { PosFormDialogAmountCardTemplateComponent } from '../form-dialog-amount-card-template.component';
|
||||
|
||||
@@ -19,6 +20,7 @@ import { PosFormDialogAmountCardTemplateComponent } from '../form-dialog-amount-
|
||||
EnumSelectComponent,
|
||||
Button,
|
||||
PosFormDialogAmountCardTemplateComponent,
|
||||
SelectButton,
|
||||
AmountPercentageInputComponent,
|
||||
],
|
||||
})
|
||||
@@ -29,9 +31,22 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
||||
@Output() onSubmitForm = new EventEmitter<IGoldPayload>();
|
||||
@Output() onChangeTotalAmount = new EventEmitter<number>();
|
||||
|
||||
readonly discountTypeItems = [
|
||||
{
|
||||
label: 'از سود',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: 'از کل',
|
||||
value: 2,
|
||||
},
|
||||
];
|
||||
|
||||
discountType = signal<number>(1);
|
||||
unitWithQuantity = signal<number>(0);
|
||||
totalAmountBeforeProfit = signal<number>(0);
|
||||
baseTotalAmount = signal<number>(0);
|
||||
baseAmountForDiscountCalculation = signal<number>(0);
|
||||
taxAmount = signal<number>(0);
|
||||
totalAmount = signal<number>(0);
|
||||
|
||||
@@ -94,7 +109,7 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
||||
|
||||
updateCalculateAmount(payload: Partial<IPosOrderItem<any>>) {
|
||||
const commissionAmount = Number(payload.payload?.commission_amount ?? '0');
|
||||
const wageAmount = Number(payload.payload?.wages ?? '0');
|
||||
const wageAmount = Number(payload.payload?.wages_amount ?? '0');
|
||||
const discountAmount = Number(payload.discount_amount ?? '0');
|
||||
const profitAmount = Number(payload.payload?.profit_amount ?? '0');
|
||||
const unitPrice = Number(payload.unit_price ?? '0');
|
||||
@@ -103,6 +118,8 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
||||
const unitWithQuantity = unitPrice * quantity;
|
||||
const totalAmountBeforeProfit = unitWithQuantity + wageAmount + commissionAmount;
|
||||
const baseTotalAmount = totalAmountBeforeProfit + profitAmount;
|
||||
const baseAmountForDiscountCalculation =
|
||||
this.discountType() === 1 ? profitAmount : baseTotalAmount;
|
||||
const taxAmount = (profitAmount + commissionAmount + wageAmount - discountAmount) * 0.1;
|
||||
const totalAmount = baseTotalAmount - discountAmount + taxAmount;
|
||||
|
||||
@@ -111,6 +128,7 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
||||
this.baseTotalAmount.set(baseTotalAmount);
|
||||
this.taxAmount.set(taxAmount);
|
||||
this.totalAmount.set(totalAmount);
|
||||
this.baseAmountForDiscountCalculation.set(baseAmountForDiscountCalculation);
|
||||
|
||||
this.onChangeTotalAmount.emit(totalAmount);
|
||||
}
|
||||
@@ -121,4 +139,10 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
||||
}
|
||||
return `(${formatWithCurrency(amount)})`;
|
||||
}
|
||||
|
||||
changeDiscountCalculation($event: SelectButtonChangeEvent) {
|
||||
this.discountType.set($event.value);
|
||||
|
||||
this.updateCalculateAmount(this.form.value as any);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user