|
- {{ index }}
+ {{ index + 1 }}
|
{{ item.userAccount?.name }}
diff --git a/src/main/webapp/app/entities/transaction/transaction.component.ts b/src/main/webapp/app/entities/transaction/transaction.component.ts
index 5d4d9dd..1bcd825 100644
--- a/src/main/webapp/app/entities/transaction/transaction.component.ts
+++ b/src/main/webapp/app/entities/transaction/transaction.component.ts
@@ -24,6 +24,7 @@ export default defineComponent({
const accountService = inject('accountService');
const isFetching = ref(false);
+ const sums: Ref = ref([]);
const clear = () => {};
// console.log(props.userAccountId);
@@ -34,6 +35,7 @@ export default defineComponent({
const res = await transactionService().retrieve();
// const res = await transactionService().retrieveForAccount(props.userAccountId);
transactions.value = res.data;
+ sums.value = sumAmountsPerColumn(transactions.value);
} catch (err) {
alertService.showHttpError(err.response);
} finally {
@@ -71,12 +73,32 @@ export default defineComponent({
}
};
+ function sumAmountsPerColumn(transactions: ITransaction[]): number[] {
+ // Jeżeli nie ma transakcji, zwracamy pustą tablicę
+ if (transactions.length === 0) return [];
+ // Liczba kolumn to liczba transactionItems w pierwszej transakcji
+ const columnCount = transactions[0].items.length;
+ // Inicjalizacja tablicy sum z zerami dla każdej kolumny
+ const sums = new Array(columnCount).fill(0);
+
+ // Iteracja przez każdą transakcję
+ for (const transaction of transactions) {
+ for (let i = 0; i < columnCount; i++) {
+ // Dodajemy amount z każdego transactionItem do odpowiedniej kolumny
+ sums[i] += transaction.items[i].amount;
+ }
+ }
+
+ return sums;
+ }
+
return {
transactions,
handleSyncList,
isFetching,
retrieveTransactions,
clear,
+ sums,
removeId,
accountService,
hasAnyAuthorityValues,
diff --git a/src/main/webapp/app/entities/transaction/transaction.vue b/src/main/webapp/app/entities/transaction/transaction.vue
index 46cb6ee..50f0740 100644
--- a/src/main/webapp/app/entities/transaction/transaction.vue
+++ b/src/main/webapp/app/entities/transaction/transaction.vue
@@ -27,26 +27,53 @@
- | ID |
- Type |
- Date |
- Comment |
+
+
+
+ |
+ |
- Event |
{{ item.userAccount?.name }}
|
|
+
+
+
+
+ |
+ Saldo |
+
+ {{ amount }}
+ |
+
+
+
+
+ | Date |
+
+
+ |
+
+
+
+
+ |
+ |
+
|
- {{ transaction.id }}
+ {{ transaction.date }} {{ transaction.type }}
+
+ {{ transaction.comment }}
|
- {{ transaction.type }} |
- {{ transaction.date }} |
- {{ transaction.comment }} |
+
+
+
{{
| |