Skip to content

Commit

Permalink
feat: groupValidStart
Browse files Browse the repository at this point in the history
Signed-off-by: Hristiyan <[email protected]>
  • Loading branch information
icoxxx committed Jan 15, 2025
1 parent 4a09a71 commit e08bcdc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('TransactionGroupsController', () => {
sequential: false,
groupItems: [],
createdAt: new Date(),
groupValidStart: new Date(),
};
});

Expand All @@ -72,6 +73,7 @@ describe('TransactionGroupsController', () => {
atomic: false,
sequential: false,
groupItems: [],
groupValidStart: new Date(),
};

transactionGroupsService.createTransactionGroup.mockResolvedValue(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ describe('TransactionGroupsService', () => {
},
},
],
groupValidStart: new Date(),
};

dataSource.manager.create.mockImplementation((entity, data) => ({ ...data }));
Expand Down
7 changes: 5 additions & 2 deletions front-end/src/renderer/stores/storeTransactionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const useTransactionGroupStore = defineStore('transactionGroup', () => {
if (modified.value) {
return;
}

groupItems.value = [];
const group = await getGroup(id);
description.value = group.description;
Expand All @@ -53,6 +54,7 @@ const useTransactionGroupStore = defineStore('transactionGroup', () => {
groupValidStart.value = new Date();
}
}

const items = await getGroupItems(id);
const drafts = await getDrafts(findArgs);
const groupItemsToAdd: GroupItem[] = [];
Expand Down Expand Up @@ -189,7 +191,7 @@ const useTransactionGroupStore = defineStore('transactionGroup', () => {
await updateGroup(
groupItems.value[0].groupId,
userId,
{ description, atomic: false },
{ description, atomic: false, groupValidStart: groupValidStart },
groupItems.value,
);
}
Expand Down Expand Up @@ -238,7 +240,8 @@ const useTransactionGroupStore = defineStore('transactionGroup', () => {

function updateTransactionValidStarts(newGroupValidStart: Date) {
groupItems.value = groupItems.value.map((item, index) => {
if (item.validStart < newGroupValidStart) {
const now = new Date();
if (item.validStart < now) {
const updatedValidStart = findUniqueValidStart(
item.payerAccountId,
newGroupValidStart.getTime() + index,
Expand Down

0 comments on commit e08bcdc

Please sign in to comment.