-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathaccounts-list.component.html
More file actions
250 lines (249 loc) · 12.8 KB
/
accounts-list.component.html
File metadata and controls
250 lines (249 loc) · 12.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<div class="card accountListTable">
<div class="font-semibold text-xl mb-4">Accounts List</div>
<div class="mb-6 border-b border-gray-200 dark:border-gray-700 pb-6" *ngIf="accounts.length > 0 && !loading">
<div class="text-sm font-semibold text-gray-500 dark:text-gray-400 mb-4">Summary by Currency</div>
<div class="flex flex-wrap gap-4">
<div *ngFor="let currency of getUniqueCurrencies()" class="flex-1 min-w-[250px] border border-gray-200 dark:border-gray-700 rounded-lg p-4">
<div class="text-base font-bold text-gray-700 dark:text-gray-300 mb-3">{{ currency }}</div>
<div class="flex flex-col gap-2">
<div class="flex justify-between items-center">
<span class="text-sm text-gray-600 dark:text-gray-400">Total Balance:</span>
<span class="font-bold text-base text-gray-900 dark:text-gray-100">{{ formatAmount(getTotalBalanceByCurrency(currency).toString()) }}</span>
</div>
<div class="flex justify-between items-center" *ngIf="serverConfig.baseCurrency">
<span class="text-sm text-gray-600 dark:text-gray-400">Debits (Period):</span>
<span class="font-bold text-green-600 dark:text-green-400">{{ formatAmount(getTotalDebitsByCurrency(currency).toString()) }}</span>
</div>
<div class="flex justify-between items-center" *ngIf="serverConfig.baseCurrency">
<span class="text-sm text-gray-600 dark:text-gray-400">Credits (Period):</span>
<span class="font-bold text-red-600 dark:text-red-400">{{ formatAmount(getTotalCreditsByCurrency(currency).toString()) }}</span>
</div>
</div>
</div>
</div>
</div>
<p-table #dt1
dataKey="id"
[value]="accounts"
[tableStyle]="{ 'min-width': '50rem' }"
[rows]="1000"
[loading]="loading"
sortMode="multiple"
[rowHover]="true"
[showGridlines]="true"
[filters]="filters"
[multiSortMeta]="multiSortMeta"
[resizableColumns]="true" columnResizeMode="expand"
[paginator]="false"
[globalFilterFields]="['account.name', 'account.number', 'account.currency']"
(onFilter)="syncStateToUrl()"
(onSort)="syncStateToUrl()"
responsiveLayout="scroll">
<ng-template #caption>
<div class="flex justify-between items-center flex-column sm:flex-row gap-2">
<p-iconfield iconPosition="left" class="ml-auto">
<p-inputicon>
<i class="pi pi-search"></i>
</p-inputicon>
<input #filter pInputText type="text" (input)="onGlobalFilter(dt1, $event)"
placeholder="Search keyword" />
<p-button class="p-button-outlined mb-2 " icon="pi pi-filter-slash"
(click)="clear(dt1)"></p-button>
</p-iconfield>
<div class="flex gap-2">
<p-button icon="pi pi-refresh" severity="secondary"
pTooltip="Refresh table" tooltipPosition="top"
(click)="refreshTable()" />
<p-button label="Create new account" class="p-button-link"
(click)="this.router.navigate(['/accounts', 'new'], { queryParams: { returnUrl: currentReturnUrl } })" />
</div>
</div>
</ng-template>
<ng-template #header>
<tr>
<th pSortableColumn="account.name">
<p class="flex justify-between items-center text-left">
Name
<p-sortIcon field="account.name" />
</p>
</th>
<th>
<p class="text-left">
Type
</p>
</th>
<th>
<p class="text-left">
Currency
</p>
</th>
<th>
<p class="text-center">
Current Balance
</p>
</th>
<th>
<p class="text-center">
Debit/Credit
</p>
</th>
<th>
<p class="text-left">
Account number
</p>
</th>
<th>
<p class="text-left">
Tags
</p>
</th>
<th style="width: 1%; white-space: nowrap;"></th>
</tr>
<tr>
<th>
<p-columnFilter type="text" showAddButton="false" showMatchModes="false" field="account.name"
showMenu="true"
[showApplyButton]="false"
matchMode="contains"
placeholder="Filter"></p-columnFilter>
</th>
<th>
<p-columnFilter field="account.type" matchMode="equals" [showMenu]="false">
<ng-template #filter let-value let-filter="filterCallback">
<p-multiselect appendTo="body" [filter]="true" [(ngModel)]="value"
[options]="accountTypes"
field="account.type"
selectedItemsLabel="{{value?.length}} items"
maxSelectedLabels="1"
optionLabel="name" optionValue="value" (onChange)="filter($event.value)"
placeholder="Select" [showClear]="false">
</p-multiselect>
</ng-template>
</p-columnFilter>
</th>
<th>
<p-columnFilter field="account.currency" matchMode="equals" [showMenu]="false">
<ng-template #filter let-value let-filter="filterCallback">
<p-multiselect appendTo="body" [filter]="true" [(ngModel)]="value"
[options]="accountCurrencies"
field="account.currency"
maxSelectedLabels="1"
optionLabel="id" optionValue="id" (onChange)="filter($event.value)"
placeholder="Select" [showClear]="false">
</p-multiselect>
</ng-template>
</p-columnFilter>
</th>
<th>
<p-columnFilter type="numeric" showAddButton="false" showMatchModes="true"
field="account.currentBalance"
showMenu="true"
[showApplyButton]="false"
matchMode="between"
placeholder="Amount"></p-columnFilter>
</th>
<th></th>
<th>
<p-columnFilter type="text" showAddButton="false" showMatchModes="false"
field="account.accountNumber"
showMenu="true"
[showApplyButton]="false"
matchMode="contains"
placeholder="Filter"></p-columnFilter>
</th>
<th>
<p-multiselect appendTo="body" [filter]="true"
[(ngModel)]="selectedTagIds"
(onChange)="onTagFilterChange()"
[options]="tags"
maxSelectedLabels="1"
optionLabel="name" optionValue="id"
placeholder="Select" [showClear]="true"
styleClass="w-full">
</p-multiselect>
</th>
<th></th>
</tr>
</ng-template>
<ng-template #body let-accountItem>
<tr>
<td>
<a [href]="getAccountUrl(accountItem)" [routerLink]="getAccountUrl(accountItem)">
{{ accountItem.account.name }}
</a>
</td>
<td>
{{ this.accountTypesMap[accountItem.account.type].name }}
</td>
<td>
{{ accountItem.account.currency }}
</td>
<td class="text-center" style="width: 1%; white-space: nowrap;">
<div class="flex flex-col gap-1 items-center">
<div class="{{accountItem.account.currentBalance < 0 ? 'text-red-500' : 'text-green-500'}} font-semibold text-base">
<i class="pi text-xs"
[ngClass]="{'pi-arrow-down': accountItem.account.currentBalance < 0, 'pi-arrow-up': accountItem.account.currentBalance >= 0}"></i>
{{ accountItem.account.currentBalance }}
</div>
<div class="text-xs text-gray-500 dark:text-gray-400">
{{ accountItem.account.currency }}
</div>
</div>
</td>
<td class="text-center">
<div *ngIf="getAnalytics(accountItem.account.id)" class="flex flex-col gap-1 items-center">
<div class="flex items-center gap-1 text-base">
<span class="text-green-600 dark:text-green-500 font-semibold">↑ {{ formatAmount(getAnalytics(accountItem.account.id)!.totalDebitsAmount) }}</span>
<span class="text-gray-400">/</span>
<span class="text-red-600 dark:text-red-500 font-semibold">↓ {{ formatAmount(getAnalytics(accountItem.account.id)!.totalCreditsAmount) }}</span>
</div>
<div class="text-xs text-gray-500 dark:text-gray-400">
{{ serverConfig.baseCurrency }}
</div>
</div>
</td>
<td style="max-width: 10rem">
<p class="text-wrap break-all">
{{ accountItem.account.accountNumber }}
</p>
</td>
<td>
<div class="flex gap-1 flex-wrap">
@for (tagID of accountItem.account.tagIds; track tagID) {
<fancy-tag [tag]="getTag(tagID)"></fancy-tag>
}
</div>
</td>
<td>
<div class="flex gap-2">
<a [routerLink]="['/', 'accounts', 'edit', accountItem.account.id]"
[queryParams]="{ returnUrl: currentReturnUrl }">
<p-button icon="pi pi-pencil"
pTooltip="Edit account" tooltipPosition="top" placeholder="Top"
severity="secondary" [rounded]="true" />
</a>
<p-button icon="pi pi-receipt"
(onClick)="showReconcile(accountItem)"
pTooltip="Reconcile account" tooltipPosition="top" placeholder="Top"
severity="secondary" [rounded]="true" />
</div>
</td>
</tr>
</ng-template>
<ng-template #emptymessage>
<tr>
<td colspan="9">No accounts found.</td>
</tr>
</ng-template>
<ng-template #loadingbody>
<tr>
<td colspan="9">Loading accounts data. Please wait.</td>
</tr>
</ng-template>
</p-table>
@if (selectedAccount && selectedAccount.account) {
<app-reconciliation-modal (closed)="reconciliationDialogVisible = false; this.refreshTable()"
[account]="selectedAccount.account"
[visible]="reconciliationDialogVisible"></app-reconciliation-modal>
}
</div>