feat: enhance bank accounts module with transaction handling and UI updates

This commit is contained in:
2026-01-05 18:38:11 +03:30
parent 502c592f56
commit a5bcab0064
20 changed files with 499 additions and 51 deletions
@@ -0,0 +1,3 @@
export * from './tag.component';
export * from './types';
export * from './utils';
@@ -0,0 +1,3 @@
<p-tag [severity]="color">
{{ text }}
</p-tag>
@@ -0,0 +1,24 @@
import { Component, Input } from '@angular/core';
import { Tag } from 'primeng/tag';
import { BankTransactionReferenceType } from './types';
import {
getBankAccountTransactionReferenceTypeColor,
getBankAccountTransactionReferenceTypeText,
} from './utils';
@Component({
selector: 'catalog-bank-account-transaction-reference-type-tag',
templateUrl: './tag.component.html',
imports: [Tag],
})
export class CatalogBankAccountTransactionReferenceTypeTagComponent {
@Input() type!: BankTransactionReferenceType;
constructor() {}
get text() {
return getBankAccountTransactionReferenceTypeText(this.type);
}
get color() {
return getBankAccountTransactionReferenceTypeColor(this.type);
}
}
@@ -0,0 +1,11 @@
export const BankTransactionReferenceType = {
PURCHASE_PAYMENT: 'PURCHASE_PAYMENT',
PURCHASE_REFUND: 'PURCHASE_REFUND',
POS_SALE: 'POS_SALE',
POS_REFUND: 'POS_REFUND',
BANK_TRANSFER: 'BANK_TRANSFER',
MANUAL_ADJUSTMENT: 'MANUAL_ADJUSTMENT',
} as const;
export type BankTransactionReferenceType =
(typeof BankTransactionReferenceType)[keyof typeof BankTransactionReferenceType];
@@ -0,0 +1,40 @@
import { TagSeverity } from '@/core/models/tag';
import { BankTransactionReferenceType } from './types';
export const getBankAccountTransactionReferenceTypeText = (
type: BankTransactionReferenceType,
): string => {
switch (type) {
case BankTransactionReferenceType.BANK_TRANSFER:
return 'انتقال بانکی';
case BankTransactionReferenceType.MANUAL_ADJUSTMENT:
return 'تعدیل دستی';
case BankTransactionReferenceType.POS_REFUND:
return 'بازپرداخت فروشگاه';
case BankTransactionReferenceType.POS_SALE:
return 'فروش فروشگاه';
case BankTransactionReferenceType.PURCHASE_REFUND:
return 'بازپرداخت خرید';
case BankTransactionReferenceType.PURCHASE_PAYMENT:
return 'پرداخت خرید';
}
};
export const getBankAccountTransactionReferenceTypeColor = (
type: BankTransactionReferenceType,
): TagSeverity => {
switch (type) {
case BankTransactionReferenceType.BANK_TRANSFER:
return 'secondary';
case BankTransactionReferenceType.MANUAL_ADJUSTMENT:
return 'secondary';
case BankTransactionReferenceType.POS_REFUND:
return 'warn';
case BankTransactionReferenceType.POS_SALE:
return 'info';
case BankTransactionReferenceType.PURCHASE_REFUND:
return 'warn';
case BankTransactionReferenceType.PURCHASE_PAYMENT:
return 'info';
}
};
@@ -0,0 +1,3 @@
export * from './tag.component';
export * from './types';
export * from './utils';
@@ -0,0 +1,3 @@
<p-tag [severity]="color">
{{ text }}
</p-tag>
@@ -0,0 +1,21 @@
import { Component, Input } from '@angular/core';
import { Tag } from 'primeng/tag';
import { BankAccountTransactionType } from './types';
import { getBankAccountTransactionTypeColor, getBankAccountTransactionTypeText } from './utils';
@Component({
selector: 'catalog-bank-account-transaction-type-tag',
templateUrl: './tag.component.html',
imports: [Tag],
})
export class CatalogBankAccountTransactionTypeTagComponent {
@Input() type!: BankAccountTransactionType;
constructor() {}
get text() {
return getBankAccountTransactionTypeText(this.type);
}
get color() {
return getBankAccountTransactionTypeColor(this.type);
}
}
@@ -0,0 +1,7 @@
export const BankAccountTransactionType = {
DEPOSIT: 'DEPOSIT',
WITHDRAWAL: 'WITHDRAWAL',
} as const;
export type BankAccountTransactionType =
(typeof BankAccountTransactionType)[keyof typeof BankAccountTransactionType];
@@ -0,0 +1,22 @@
import { TagSeverity } from '@/core/models/tag';
import { BankAccountTransactionType } from './types';
export const getBankAccountTransactionTypeText = (type: BankAccountTransactionType): string => {
switch (type) {
case BankAccountTransactionType.DEPOSIT:
return 'واریز';
case BankAccountTransactionType.WITHDRAWAL:
return 'برداشت';
}
};
export const getBankAccountTransactionTypeColor = (
type: BankAccountTransactionType,
): TagSeverity => {
switch (type) {
case BankAccountTransactionType.DEPOSIT:
return 'success';
case BankAccountTransactionType.WITHDRAWAL:
return 'danger';
}
};