Skip to content

Commit cc80eae

Browse files
add: tax deductible to funds (#293)
* add: tax deductible to funds * localize tax deductible * update churchapps/apphelper
1 parent 5084bc8 commit cc80eae

File tree

5 files changed

+36
-30
lines changed

5 files changed

+36
-30
lines changed

package-lock.json

Lines changed: 16 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@churchapps/apphelper": "0.2.37",
6+
"@churchapps/apphelper": "0.2.42",
77
"@mui/icons-material": "^5.14.7",
88
"@mui/material": "^5.14.7",
99
"@types/react-cropper": "^1.3.2",

public/locales/en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@
133133
"fundEdit": {
134134
"confirmMsg": "Are you sure you wish to permanently delete this batch and all donations within it?",
135135
"edit": "Edit Fund",
136-
"errBlank": "Enter a fund name"
136+
"errBlank": "Enter a fund name",
137+
"taxDeductible": "Tax Deductible",
138+
"trackDonations": "Tracks donations.",
139+
"trackNonDonations": "Tracks non-donation transactions like camp registrations, tshirts, event tickets, etc."
137140
},
138141
"funds": {
139142
"fund": "Funds",

src/donations/components/FundEdit.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React, { useState } from "react";
22
import { ApiHelper, InputBox, FundInterface, ErrorMessages, Locale } from "@churchapps/apphelper";
3-
import { TextField } from "@mui/material";
3+
import { Checkbox, FormControlLabel, TextField, Typography } from "@mui/material";
44

55
interface Props { fund: FundInterface, updatedFunction: () => void }
66
export const FundEdit: React.FC<Props> = (props) => {
7-
const [fund, setFund] = useState<FundInterface>({ id: "", name: "" });
7+
const [fund, setFund] = useState<FundInterface>({ id: "", name: "", taxDeductible: true });
88
const [errors, setErrors] = useState<string[]>([]);
99

1010
const handleCancel = () => props.updatedFunction();
@@ -31,7 +31,16 @@ export const FundEdit: React.FC<Props> = (props) => {
3131

3232
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
3333
let f = { ...fund };
34-
f.name = e.target.value;
34+
switch (e.target.name) {
35+
case "fundName":
36+
f.name = e.target.value;
37+
break;
38+
case "taxDeductible":
39+
f.taxDeductible = e.target.checked;
40+
break;
41+
default:
42+
break;
43+
}
3544
setFund(f);
3645
}
3746

@@ -41,6 +50,8 @@ export const FundEdit: React.FC<Props> = (props) => {
4150
<InputBox id="fundsBox" headerIcon="volunteer_activism" headerText={Locale.label("common.edit")} cancelFunction={handleCancel} saveFunction={handleSave} deleteFunction={(fund.id === "") ? undefined : handleDelete} help="chums/giving">
4251
<ErrorMessages errors={errors} />
4352
<TextField fullWidth name="fundName" label={Locale.label("common.name")} value={fund.name} onChange={handleChange} onKeyDown={handleKeyDown} />
53+
<FormControlLabel control={<Checkbox sx={{ marginLeft: "5px" }} checked={fund.taxDeductible} onChange={handleChange} name="taxDeductible" />} label={Locale.label("donations.fundEdit.taxDeductible")} />
54+
<Typography sx={{ fontStyle: "italic", fontSize: "12px", marginLeft: "5px" }}>{fund.taxDeductible ? Locale.label("donations.fundEdit.trackDonations") : Locale.label("donations.fundEdit.trackNonDonations")}</Typography>
4455
</InputBox>
4556

4657
);

src/donations/components/Funds.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const Funds: React.FC = () => {
1717
}
1818
const handleFundUpdated = () => { loadData(); setEditFund(null); }
1919
const getEditSection = () => {
20-
if (UserHelper.checkAccess(Permissions.givingApi.donations.edit)) return (<SmallButton onClick={() => { setEditFund({ id: "", name: "" }) }} icon="add" />);
20+
if (UserHelper.checkAccess(Permissions.givingApi.donations.edit)) return (<SmallButton onClick={() => { setEditFund({ id: "", name: "", taxDeductible: true }) }} icon="add" />);
2121
else return null;
2222
}
2323

0 commit comments

Comments
 (0)