-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from SFTtech/milo/group-settlements
implement group settlements
- Loading branch information
Showing
31 changed files
with
410 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
abrechnung (0.11.0) stable; urgency=medium | ||
|
||
* Abrechnung release 0.11.0 | ||
|
||
-- Michael Loipführer <[email protected]> Sun, 26 Aug 2023 20:00:00 +0200 | ||
|
||
abrechnung (0.10.1) stable; urgency=medium | ||
|
||
* Abrechnung release 0.10.1 | ||
|
||
-- Michael Loipführer <[email protected]> Sun, 1 Jan 2022 18:00:00 +0100 | ||
-- Michael Loipführer <[email protected]> Sun, 1 Jan 2023 18:00:00 +0100 | ||
|
||
abrechnung (0.10.0) stable; urgency=medium | ||
|
||
* Abrechnung release 0.10.0 | ||
|
||
-- Michael Loipführer <[email protected]> Sun, 1 Jan 2022 15:00:00 +0100 | ||
-- Michael Loipführer <[email protected]> Sun, 1 Jan 2023 15:00:00 +0100 | ||
|
||
abrechnung (0.9.0) stable; urgency=medium | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ Upstream-Name: abrechnung | |
Upstream-Contact: Michael Loipführer, <[email protected]> | ||
|
||
Files: * | ||
Copyright: 2021, Jonas Jelten <[email protected]>, Michael Enßlin <[email protected]>, Michael Loipführer <[email protected]> | ||
Copyright: 2023, Jonas Jelten <[email protected]>, Michael Enßlin <[email protected]>, Michael Loipführer <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
frontend/apps/web/src/pages/accounts/SettlementPlanDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { MobilePaper } from "@/components/style/mobile"; | ||
import { selectAccountSlice, selectGroupSlice, useAppDispatch, useAppSelector } from "@/store"; | ||
import { | ||
createTransaction, | ||
selectAccountIdToAccountMap, | ||
selectGroupCurrencySymbol, | ||
selectSettlementPlan, | ||
} from "@abrechnung/redux"; | ||
import { Button, List, ListItem, ListItemSecondaryAction, ListItemText, Typography } from "@mui/material"; | ||
import * as React from "react"; | ||
import { SettlementPlanItem } from "@abrechnung/core"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
interface Props { | ||
groupId: number; | ||
} | ||
|
||
export const SettlementPlanDisplay: React.FC<Props> = ({ groupId }) => { | ||
const dispatch = useAppDispatch(); | ||
const navigate = useNavigate(); | ||
const settlementPlan = useAppSelector((state) => selectSettlementPlan({ state, groupId })); | ||
const currencySymbol = useAppSelector((state) => | ||
selectGroupCurrencySymbol({ state: selectGroupSlice(state), groupId }) | ||
); | ||
const accountMap = useAppSelector((state) => | ||
selectAccountIdToAccountMap({ state: selectAccountSlice(state), groupId }) | ||
); | ||
|
||
const onSettleClicked = (planItem: SettlementPlanItem) => { | ||
dispatch( | ||
createTransaction({ | ||
type: "transfer", | ||
groupId, | ||
data: { | ||
name: "Settlement", | ||
value: planItem.paymentAmount, | ||
creditorShares: { [planItem.creditorId]: 1 }, | ||
debitorShares: { [planItem.debitorId]: 1 }, | ||
}, | ||
}) | ||
) | ||
.unwrap() | ||
.then(({ transaction }) => { | ||
navigate(`/groups/${groupId}/transactions/${transaction.id}?no-redirect=true`); | ||
}); | ||
}; | ||
|
||
return ( | ||
<MobilePaper> | ||
<Typography variant="h5">Settle this groups balances</Typography> | ||
<List> | ||
{settlementPlan.map((planItem) => ( | ||
<ListItem key={`${planItem.creditorId}-${planItem.debitorId}`}> | ||
<ListItemText | ||
primary={ | ||
<span> | ||
{accountMap[planItem.creditorId].name} pays {accountMap[planItem.debitorId].name}{" "} | ||
{planItem.paymentAmount.toFixed(2)} | ||
{currencySymbol} | ||
</span> | ||
} | ||
/> | ||
<ListItemSecondaryAction> | ||
<Button onClick={() => onSettleClicked(planItem)}>Settle</Button> | ||
</ListItemSecondaryAction> | ||
</ListItem> | ||
))} | ||
</List> | ||
</MobilePaper> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.